dom/camera/CameraPreviewMediaStream.h

branch
TOR_BUG_9701
changeset 9
a63d609f5ebe
equal deleted inserted replaced
-1:000000000000 0:d76278bb2383
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/. */
4
5 #ifndef DOM_CAMERA_CAMERAPREVIEWMEDIASTREAM_H
6 #define DOM_CAMERA_CAMERAPREVIEWMEDIASTREAM_H
7
8 #include "VideoFrameContainer.h"
9 #include "MediaStreamGraph.h"
10 #include "mozilla/Mutex.h"
11
12 namespace mozilla {
13
14 class CameraPreviewFrameCallback {
15 public:
16 virtual void OnNewFrame(const gfxIntSize& aIntrinsicSize, layers::Image* aImage) = 0;
17 };
18
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;
29
30 public:
31 CameraPreviewMediaStream(DOMMediaStream* aWrapper);
32
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();
42
43 // Call these on any thread.
44 void SetCurrentFrame(const gfxIntSize& aIntrinsicSize, Image* aImage);
45 void ClearCurrentFrame();
46
47 void SetFrameCallback(CameraPreviewFrameCallback* aCallback) {
48 mFrameCallback = aCallback;
49 }
50
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 };
58
59 }
60
61 #endif // DOM_CAMERA_CAMERAPREVIEWMEDIASTREAM_H

mercurial