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