dom/camera/CameraPreviewMediaStream.h

Tue, 06 Jan 2015 21:39:09 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Tue, 06 Jan 2015 21:39:09 +0100
branch
TOR_BUG_9701
changeset 8
97036ab72558
permissions
-rw-r--r--

Conditionally force memory storage according to privacy.thirdparty.isolate;
This solves Tor bug #9701, complying with disk avoidance documented in
https://www.torproject.org/projects/torbrowser/design/#disk-avoidance.

     1 /* This Source Code Form is subject to the terms of the Mozilla Public
     2  * License, v. 2.0. If a copy of the MPL was not distributed with this file,
     3  * You can obtain one at http://mozilla.org/MPL/2.0/. */
     5 #ifndef DOM_CAMERA_CAMERAPREVIEWMEDIASTREAM_H
     6 #define DOM_CAMERA_CAMERAPREVIEWMEDIASTREAM_H
     8 #include "VideoFrameContainer.h"
     9 #include "MediaStreamGraph.h"
    10 #include "mozilla/Mutex.h"
    12 namespace mozilla {
    14 class CameraPreviewFrameCallback {
    15 public:
    16   virtual void OnNewFrame(const gfxIntSize& aIntrinsicSize, layers::Image* aImage) = 0;
    17 };
    19 /**
    20  * This is a stream for camere preview.
    21  *
    22  * XXX It is a temporary fix of SourceMediaStream.
    23  * A camera preview requests no delay and no buffering stream.
    24  * But the SourceMediaStream do not support it.
    25  */
    26 class CameraPreviewMediaStream : public MediaStream
    27 {
    28   typedef mozilla::layers::Image Image;
    30 public:
    31   CameraPreviewMediaStream(DOMMediaStream* aWrapper);
    33   virtual void AddAudioOutput(void* aKey) MOZ_OVERRIDE;
    34   virtual void SetAudioOutputVolume(void* aKey, float aVolume) MOZ_OVERRIDE;
    35   virtual void RemoveAudioOutput(void* aKey) MOZ_OVERRIDE;
    36   virtual void AddVideoOutput(VideoFrameContainer* aContainer) MOZ_OVERRIDE;
    37   virtual void RemoveVideoOutput(VideoFrameContainer* aContainer) MOZ_OVERRIDE;
    38   virtual void ChangeExplicitBlockerCount(int32_t aDelta) MOZ_OVERRIDE;
    39   virtual void AddListener(MediaStreamListener* aListener) MOZ_OVERRIDE;
    40   virtual void RemoveListener(MediaStreamListener* aListener) MOZ_OVERRIDE;
    41   virtual void Destroy();
    43   // Call these on any thread.
    44   void SetCurrentFrame(const gfxIntSize& aIntrinsicSize, Image* aImage);
    45   void ClearCurrentFrame();
    47   void SetFrameCallback(CameraPreviewFrameCallback* aCallback) {
    48     mFrameCallback = aCallback;
    49   }
    51 protected:
    52   // mMutex protects all the class' fields.
    53   // This class is not registered to MediaStreamGraph.
    54   // It needs to protect all the fields.
    55   Mutex mMutex;
    56   CameraPreviewFrameCallback* mFrameCallback;
    57 };
    59 }
    61 #endif // DOM_CAMERA_CAMERAPREVIEWMEDIASTREAM_H

mercurial