OLD | NEW |
(Empty) | |
| 1 /* |
| 2 * Copyright 2012 The WebRTC project authors. All Rights Reserved. |
| 3 * |
| 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 |
| 6 * tree. An additional intellectual property rights grant can be found |
| 7 * in the file PATENTS. All contributing project authors may |
| 8 * be found in the AUTHORS file in the root of the source tree. |
| 9 */ |
| 10 |
| 11 #ifndef WEBRTC_API_VIDEOTRACKRENDERERS_H_ |
| 12 #define WEBRTC_API_VIDEOTRACKRENDERERS_H_ |
| 13 |
| 14 #include <set> |
| 15 |
| 16 #include "talk/media/base/videorenderer.h" |
| 17 #include "webrtc/api/mediastreaminterface.h" |
| 18 #include "webrtc/base/criticalsection.h" |
| 19 #include "webrtc/base/scoped_ptr.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 : public cricket::VideoRenderer { |
| 29 public: |
| 30 VideoTrackRenderers(); |
| 31 ~VideoTrackRenderers(); |
| 32 |
| 33 // Implements cricket::VideoRenderer. If the track is disabled, |
| 34 // incoming frames are replaced by black frames. |
| 35 virtual bool RenderFrame(const cricket::VideoFrame* frame); |
| 36 |
| 37 void AddRenderer(VideoRendererInterface* renderer); |
| 38 void RemoveRenderer(VideoRendererInterface* renderer); |
| 39 void SetEnabled(bool enable); |
| 40 |
| 41 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_; |
| 47 std::set<VideoRendererInterface*> renderers_; |
| 48 |
| 49 rtc::CriticalSection critical_section_; // Protects the above variables |
| 50 }; |
| 51 |
| 52 } // namespace webrtc |
| 53 |
| 54 #endif // WEBRTC_API_VIDEOTRACKRENDERERS_H_ |
OLD | NEW |