Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(292)

Side by Side Diff: webrtc/api/videotrackrenderers.h

Issue 1684423002: Make VideoTrack and VideoTrackRenderers implement rtc::VideoSourceInterface. (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@master
Patch Set: Created 4 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 #include "webrtc/media/base/videobroadcaster.h"
20 21
21 namespace webrtc { 22 namespace webrtc {
22 23
23 // Class used for rendering cricket::VideoFrames to multiple renderers of type 24 // Class used for rendering cricket::VideoFrames to multiple renderers of type
24 // VideoRendererInterface. 25 // VideoRendererInterface.
25 // Each VideoTrack owns a VideoTrackRenderers instance. 26 // Each VideoTrack owns a VideoTrackRenderers instance.
26 // The class is thread safe. Rendering to the added VideoRendererInterfaces is 27 // The class is thread safe. Rendering to the added VideoRendererInterfaces is
27 // done on the same thread as the cricket::VideoRenderer. 28 // done on the same thread as the cricket::VideoRenderer.
28 class VideoTrackRenderers : public cricket::VideoRenderer { 29 class VideoTrackRenderers
30 : public cricket::VideoRenderer,
31 public rtc::VideoSourceInterface<cricket::VideoFrame> {
29 public: 32 public:
30 VideoTrackRenderers(); 33 VideoTrackRenderers();
31 ~VideoTrackRenderers(); 34 ~VideoTrackRenderers();
32 35
33 // Implements cricket::VideoRenderer. If the track is disabled, 36 // Implements cricket::VideoRenderer. If the track is disabled,
34 // incoming frames are replaced by black frames. 37 // incoming frames are replaced by black frames.
35 virtual bool RenderFrame(const cricket::VideoFrame* frame); 38 virtual bool RenderFrame(const cricket::VideoFrame* frame);
36 39
37 void AddRenderer(VideoRendererInterface* renderer); 40 void AddOrUpdateSink(VideoSinkInterface<cricket::VideoFrame>* sink,
38 void RemoveRenderer(VideoRendererInterface* renderer); 41 const rtc::VideoSinkWants& wants) override;
42 void RemoveSink(VideoSinkInterface<cricket::VideoFrame>* sink) override;
39 void SetEnabled(bool enable); 43 void SetEnabled(bool enable);
40 44
41 private: 45 private:
42 // Pass the frame on to to each registered renderer. Requires
43 // critical_section_ already locked.
44 void RenderFrameToRenderers(const cricket::VideoFrame* frame);
45
46 bool enabled_; 46 bool enabled_;
47 std::set<VideoRendererInterface*> renderers_; 47 rtc::VideoBroadcaster broadcaster_;
48
49 rtc::CriticalSection critical_section_; // Protects the above variables 48 rtc::CriticalSection critical_section_; // Protects the above variables
50 }; 49 };
51 50
52 } // namespace webrtc 51 } // namespace webrtc
53 52
54 #endif // WEBRTC_API_VIDEOTRACKRENDERERS_H_ 53 #endif // WEBRTC_API_VIDEOTRACKRENDERERS_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698