michael@0: /* This Source Code Form is subject to the terms of the Mozilla Public michael@0: * License, v. 2.0. If a copy of the MPL was not distributed with this file, michael@0: * You can obtain one at http://mozilla.org/MPL/2.0/. */ michael@0: michael@0: #ifndef DOM_CAMERA_CAMERAPREVIEWMEDIASTREAM_H michael@0: #define DOM_CAMERA_CAMERAPREVIEWMEDIASTREAM_H michael@0: michael@0: #include "VideoFrameContainer.h" michael@0: #include "MediaStreamGraph.h" michael@0: #include "mozilla/Mutex.h" michael@0: michael@0: namespace mozilla { michael@0: michael@0: class CameraPreviewFrameCallback { michael@0: public: michael@0: virtual void OnNewFrame(const gfxIntSize& aIntrinsicSize, layers::Image* aImage) = 0; michael@0: }; michael@0: michael@0: /** michael@0: * This is a stream for camere preview. michael@0: * michael@0: * XXX It is a temporary fix of SourceMediaStream. michael@0: * A camera preview requests no delay and no buffering stream. michael@0: * But the SourceMediaStream do not support it. michael@0: */ michael@0: class CameraPreviewMediaStream : public MediaStream michael@0: { michael@0: typedef mozilla::layers::Image Image; michael@0: michael@0: public: michael@0: CameraPreviewMediaStream(DOMMediaStream* aWrapper); michael@0: michael@0: virtual void AddAudioOutput(void* aKey) MOZ_OVERRIDE; michael@0: virtual void SetAudioOutputVolume(void* aKey, float aVolume) MOZ_OVERRIDE; michael@0: virtual void RemoveAudioOutput(void* aKey) MOZ_OVERRIDE; michael@0: virtual void AddVideoOutput(VideoFrameContainer* aContainer) MOZ_OVERRIDE; michael@0: virtual void RemoveVideoOutput(VideoFrameContainer* aContainer) MOZ_OVERRIDE; michael@0: virtual void ChangeExplicitBlockerCount(int32_t aDelta) MOZ_OVERRIDE; michael@0: virtual void AddListener(MediaStreamListener* aListener) MOZ_OVERRIDE; michael@0: virtual void RemoveListener(MediaStreamListener* aListener) MOZ_OVERRIDE; michael@0: virtual void Destroy(); michael@0: michael@0: // Call these on any thread. michael@0: void SetCurrentFrame(const gfxIntSize& aIntrinsicSize, Image* aImage); michael@0: void ClearCurrentFrame(); michael@0: michael@0: void SetFrameCallback(CameraPreviewFrameCallback* aCallback) { michael@0: mFrameCallback = aCallback; michael@0: } michael@0: michael@0: protected: michael@0: // mMutex protects all the class' fields. michael@0: // This class is not registered to MediaStreamGraph. michael@0: // It needs to protect all the fields. michael@0: Mutex mMutex; michael@0: CameraPreviewFrameCallback* mFrameCallback; michael@0: }; michael@0: michael@0: } michael@0: michael@0: #endif // DOM_CAMERA_CAMERAPREVIEWMEDIASTREAM_H