OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2012 The WebRTC project authors. All Rights Reserved. | 2 * Copyright 2012 The WebRTC project authors. All Rights Reserved. |
3 * | 3 * |
4 * Use of this source code is governed by a BSD-style license | 4 * Use of this source code is governed by a BSD-style license |
5 * that can be found in the LICENSE file in the root of the source | 5 * that can be found in the LICENSE file in the root of the source |
6 * tree. An additional intellectual property rights grant can be found | 6 * tree. An additional intellectual property rights grant can be found |
7 * in the file PATENTS. All contributing project authors may | 7 * in the file PATENTS. All contributing project authors may |
8 * be found in the AUTHORS file in the root of the source tree. | 8 * be found in the AUTHORS file in the root of the source tree. |
9 */ | 9 */ |
10 | 10 |
11 #ifndef WEBRTC_API_VIDEOTRACKRENDERERS_H_ | 11 #ifndef WEBRTC_API_VIDEOTRACKRENDERERS_H_ |
12 #define WEBRTC_API_VIDEOTRACKRENDERERS_H_ | 12 #define WEBRTC_API_VIDEOTRACKRENDERERS_H_ |
13 | 13 |
14 #include <set> | 14 #include <set> |
15 | 15 |
16 #include "webrtc/api/mediastreaminterface.h" | 16 #include "webrtc/api/mediastreaminterface.h" |
17 #include "webrtc/base/criticalsection.h" | 17 #include "webrtc/base/criticalsection.h" |
18 #include "webrtc/base/scoped_ptr.h" | 18 #include "webrtc/base/scoped_ptr.h" |
19 #include "webrtc/media/base/videorenderer.h" | 19 #include "webrtc/media/base/videorenderer.h" |
20 | 20 |
21 namespace webrtc { | 21 namespace webrtc { |
22 | 22 |
23 // Class used for rendering cricket::VideoFrames to multiple renderers of type | 23 // Class used for rendering cricket::VideoFrames to multiple renderers of type |
24 // VideoRendererInterface. | 24 // VideoRendererInterface. |
25 // Each VideoTrack owns a VideoTrackRenderers instance. | 25 // Each VideoTrack owns a VideoTrackRenderers instance. |
26 // The class is thread safe. Rendering to the added VideoRendererInterfaces is | 26 // The class is thread safe. Rendering to the added VideoRendererInterfaces is |
27 // done on the same thread as the cricket::VideoRenderer. | 27 // done on the same thread as the cricket::VideoRenderer. |
28 class VideoTrackRenderers : public cricket::VideoRenderer { | 28 class VideoTrackRenderers |
| 29 : public cricket::VideoRenderer, |
| 30 public rtc::VideoSourceInterface<cricket::VideoFrame> { |
29 public: | 31 public: |
30 VideoTrackRenderers(); | 32 VideoTrackRenderers(); |
31 ~VideoTrackRenderers(); | 33 ~VideoTrackRenderers(); |
32 | 34 |
33 // Implements cricket::VideoRenderer. If the track is disabled, | 35 // Implements cricket::VideoRenderer. If the track is disabled, |
34 // incoming frames are replaced by black frames. | 36 // incoming frames are replaced by black frames. |
35 virtual bool RenderFrame(const cricket::VideoFrame* frame); | 37 virtual bool RenderFrame(const cricket::VideoFrame* frame); |
36 | 38 |
37 void AddRenderer(VideoRendererInterface* renderer); | 39 void AddOrUpdateSink(VideoSinkInterface<cricket::VideoFrame>* sink, |
38 void RemoveRenderer(VideoRendererInterface* renderer); | 40 const rtc::VideoSinkWants& wants) override; |
| 41 void RemoveSink(VideoSinkInterface<cricket::VideoFrame>* sink) override; |
39 void SetEnabled(bool enable); | 42 void SetEnabled(bool enable); |
40 | 43 |
41 private: | 44 private: |
42 // Pass the frame on to to each registered renderer. Requires | 45 // Pass the frame on to to each registered renderer. Requires |
43 // critical_section_ already locked. | 46 // critical_section_ already locked. |
44 void RenderFrameToRenderers(const cricket::VideoFrame* frame); | 47 void RenderFrameToSinks(const cricket::VideoFrame& frame); |
45 | 48 |
46 bool enabled_; | 49 bool enabled_; |
47 std::set<VideoRendererInterface*> renderers_; | 50 std::vector<VideoSinkInterface<cricket::VideoFrame>*> sinks_; |
48 | |
49 rtc::CriticalSection critical_section_; // Protects the above variables | 51 rtc::CriticalSection critical_section_; // Protects the above variables |
50 }; | 52 }; |
51 | 53 |
52 } // namespace webrtc | 54 } // namespace webrtc |
53 | 55 |
54 #endif // WEBRTC_API_VIDEOTRACKRENDERERS_H_ | 56 #endif // WEBRTC_API_VIDEOTRACKRENDERERS_H_ |
OLD | NEW |