| 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 // TODO(perkj): Remove this file once Chrome builds doesnt depend on it. |
| 15 | |
| 16 #include "webrtc/api/mediastreaminterface.h" | |
| 17 #include "webrtc/base/criticalsection.h" | |
| 18 #include "webrtc/base/scoped_ptr.h" | |
| 19 #include "webrtc/media/base/videorenderer.h" | |
| 20 | |
| 21 namespace webrtc { | |
| 22 | |
| 23 // Class used for rendering cricket::VideoFrames to multiple renderers of type | |
| 24 // VideoRendererInterface. | |
| 25 // Each VideoTrack owns a VideoTrackRenderers instance. | |
| 26 // The class is thread safe. Rendering to the added VideoRendererInterfaces is | |
| 27 // done on the same thread as the cricket::VideoRenderer. | |
| 28 class VideoTrackRenderers | |
| 29 : public cricket::VideoRenderer, | |
| 30 public rtc::VideoSourceInterface<cricket::VideoFrame> { | |
| 31 public: | |
| 32 VideoTrackRenderers(); | |
| 33 ~VideoTrackRenderers(); | |
| 34 | |
| 35 // Implements cricket::VideoRenderer. If the track is disabled, | |
| 36 // incoming frames are replaced by black frames. | |
| 37 virtual bool RenderFrame(const cricket::VideoFrame* frame); | |
| 38 | |
| 39 void AddOrUpdateSink(VideoSinkInterface<cricket::VideoFrame>* sink, | |
| 40 const rtc::VideoSinkWants& wants) override; | |
| 41 void RemoveSink(VideoSinkInterface<cricket::VideoFrame>* sink) override; | |
| 42 void SetEnabled(bool enable); | |
| 43 | |
| 44 private: | |
| 45 // Pass the frame on to to each registered renderer. Requires | |
| 46 // critical_section_ already locked. | |
| 47 void RenderFrameToSinks(const cricket::VideoFrame& frame); | |
| 48 | |
| 49 bool enabled_; | |
| 50 std::vector<VideoSinkInterface<cricket::VideoFrame>*> sinks_; | |
| 51 rtc::CriticalSection critical_section_; // Protects the above variables | |
| 52 }; | |
| 53 | |
| 54 } // namespace webrtc | |
| 55 | 15 |
| 56 #endif // WEBRTC_API_VIDEOTRACKRENDERERS_H_ | 16 #endif // WEBRTC_API_VIDEOTRACKRENDERERS_H_ |
| OLD | NEW |