1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/dom/camera/CameraPreviewMediaStream.h Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,61 @@ 1.4 +/* This Source Code Form is subject to the terms of the Mozilla Public 1.5 + * License, v. 2.0. If a copy of the MPL was not distributed with this file, 1.6 + * You can obtain one at http://mozilla.org/MPL/2.0/. */ 1.7 + 1.8 +#ifndef DOM_CAMERA_CAMERAPREVIEWMEDIASTREAM_H 1.9 +#define DOM_CAMERA_CAMERAPREVIEWMEDIASTREAM_H 1.10 + 1.11 +#include "VideoFrameContainer.h" 1.12 +#include "MediaStreamGraph.h" 1.13 +#include "mozilla/Mutex.h" 1.14 + 1.15 +namespace mozilla { 1.16 + 1.17 +class CameraPreviewFrameCallback { 1.18 +public: 1.19 + virtual void OnNewFrame(const gfxIntSize& aIntrinsicSize, layers::Image* aImage) = 0; 1.20 +}; 1.21 + 1.22 +/** 1.23 + * This is a stream for camere preview. 1.24 + * 1.25 + * XXX It is a temporary fix of SourceMediaStream. 1.26 + * A camera preview requests no delay and no buffering stream. 1.27 + * But the SourceMediaStream do not support it. 1.28 + */ 1.29 +class CameraPreviewMediaStream : public MediaStream 1.30 +{ 1.31 + typedef mozilla::layers::Image Image; 1.32 + 1.33 +public: 1.34 + CameraPreviewMediaStream(DOMMediaStream* aWrapper); 1.35 + 1.36 + virtual void AddAudioOutput(void* aKey) MOZ_OVERRIDE; 1.37 + virtual void SetAudioOutputVolume(void* aKey, float aVolume) MOZ_OVERRIDE; 1.38 + virtual void RemoveAudioOutput(void* aKey) MOZ_OVERRIDE; 1.39 + virtual void AddVideoOutput(VideoFrameContainer* aContainer) MOZ_OVERRIDE; 1.40 + virtual void RemoveVideoOutput(VideoFrameContainer* aContainer) MOZ_OVERRIDE; 1.41 + virtual void ChangeExplicitBlockerCount(int32_t aDelta) MOZ_OVERRIDE; 1.42 + virtual void AddListener(MediaStreamListener* aListener) MOZ_OVERRIDE; 1.43 + virtual void RemoveListener(MediaStreamListener* aListener) MOZ_OVERRIDE; 1.44 + virtual void Destroy(); 1.45 + 1.46 + // Call these on any thread. 1.47 + void SetCurrentFrame(const gfxIntSize& aIntrinsicSize, Image* aImage); 1.48 + void ClearCurrentFrame(); 1.49 + 1.50 + void SetFrameCallback(CameraPreviewFrameCallback* aCallback) { 1.51 + mFrameCallback = aCallback; 1.52 + } 1.53 + 1.54 +protected: 1.55 + // mMutex protects all the class' fields. 1.56 + // This class is not registered to MediaStreamGraph. 1.57 + // It needs to protect all the fields. 1.58 + Mutex mMutex; 1.59 + CameraPreviewFrameCallback* mFrameCallback; 1.60 +}; 1.61 + 1.62 +} 1.63 + 1.64 +#endif // DOM_CAMERA_CAMERAPREVIEWMEDIASTREAM_H