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 // This file contains interfaces for MediaStream, MediaTrack and MediaSource. | 11 // This file contains interfaces for MediaStream, MediaTrack and MediaSource. |
12 // These interfaces are used for implementing MediaStream and MediaTrack as | 12 // These interfaces are used for implementing MediaStream and MediaTrack as |
13 // defined in http://dev.w3.org/2011/webrtc/editor/webrtc.html#stream-api. These | 13 // defined in http://dev.w3.org/2011/webrtc/editor/webrtc.html#stream-api. These |
14 // interfaces must be used only with PeerConnection. PeerConnectionManager | 14 // interfaces must be used only with PeerConnection. PeerConnectionManager |
15 // interface provides the factory methods to create MediaStream and MediaTracks. | 15 // interface provides the factory methods to create MediaStream and MediaTracks. |
16 | 16 |
17 #ifndef WEBRTC_API_MEDIASTREAMINTERFACE_H_ | 17 #ifndef WEBRTC_API_MEDIASTREAMINTERFACE_H_ |
18 #define WEBRTC_API_MEDIASTREAMINTERFACE_H_ | 18 #define WEBRTC_API_MEDIASTREAMINTERFACE_H_ |
19 | 19 |
20 #include <string> | 20 #include <string> |
21 #include <vector> | 21 #include <vector> |
22 | 22 |
23 #include "webrtc/base/basictypes.h" | 23 #include "webrtc/base/basictypes.h" |
24 #include "webrtc/base/refcount.h" | 24 #include "webrtc/base/refcount.h" |
25 #include "webrtc/base/scoped_ref_ptr.h" | 25 #include "webrtc/base/scoped_ref_ptr.h" |
26 #include "webrtc/media/base/videosinkinterface.h" | 26 #include "webrtc/media/base/videosinkinterface.h" |
| 27 #include "webrtc/media/base/videosourceinterface.h" |
27 | 28 |
28 namespace cricket { | 29 namespace cricket { |
29 | 30 |
30 class AudioRenderer; | 31 class AudioRenderer; |
31 class VideoCapturer; | 32 class VideoCapturer; |
32 class VideoRenderer; | 33 class VideoRenderer; |
33 class VideoFrame; | 34 class VideoFrame; |
34 | 35 |
35 } // namespace cricket | 36 } // namespace cricket |
36 | 37 |
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
114 | 115 |
115 protected: | 116 protected: |
116 // The destructor is protected to prevent deletion via the interface. | 117 // The destructor is protected to prevent deletion via the interface. |
117 // This is so that we allow reference counted classes, where the destructor | 118 // This is so that we allow reference counted classes, where the destructor |
118 // should never be public, to implement the interface. | 119 // should never be public, to implement the interface. |
119 virtual ~VideoRendererInterface() {} | 120 virtual ~VideoRendererInterface() {} |
120 }; | 121 }; |
121 | 122 |
122 class VideoSourceInterface; | 123 class VideoSourceInterface; |
123 | 124 |
124 class VideoTrackInterface : public MediaStreamTrackInterface { | 125 class VideoTrackInterface |
| 126 : public MediaStreamTrackInterface, |
| 127 public rtc::VideoSourceInterface<cricket::VideoFrame> { |
125 public: | 128 public: |
126 // Register a renderer that will render all frames received on this track. | 129 // Make an unqualified VideoSourceInterface resolve to |
127 virtual void AddRenderer(VideoRendererInterface* renderer) = 0; | 130 // webrtc::VideoSourceInterface, not our base class |
128 // Deregister a renderer. | 131 // rtc::VideoSourceInterface<cricket::VideoFrame>. |
129 virtual void RemoveRenderer(VideoRendererInterface* renderer) = 0; | 132 using VideoSourceInterface = webrtc::VideoSourceInterface; |
| 133 |
| 134 // AddRenderer and RemoveRenderer are for backwards compatibility |
| 135 // only. They are obsoleted by the methods of |
| 136 // rtc::VideoSourceInterface. |
| 137 virtual void AddRenderer(VideoRendererInterface* renderer) { |
| 138 AddOrUpdateSink(renderer, rtc::VideoSinkWants()); |
| 139 } |
| 140 virtual void RemoveRenderer(VideoRendererInterface* renderer) { |
| 141 RemoveSink(renderer); |
| 142 } |
| 143 |
| 144 // Register a video sink for this track. |
| 145 void AddOrUpdateSink(rtc::VideoSinkInterface<cricket::VideoFrame>* sink, |
| 146 const rtc::VideoSinkWants& wants) override{}; |
| 147 void RemoveSink( |
| 148 rtc::VideoSinkInterface<cricket::VideoFrame>* sink) override{}; |
130 | 149 |
131 virtual VideoSourceInterface* GetSource() const = 0; | 150 virtual VideoSourceInterface* GetSource() const = 0; |
132 | 151 |
133 // Return the track input sink. I.e., frames sent to this sink are | 152 // Return the track input sink. I.e., frames sent to this sink are |
134 // propagated to all renderers registered with the track. The | 153 // propagated to all renderers registered with the track. The |
135 // returned sink must not change between calls. Currently, this | 154 // returned sink must not change between calls. Currently, this |
136 // method is used for remote tracks (VideoRtpReceiver); further | 155 // method is used for remote tracks (VideoRtpReceiver); further |
137 // refactoring is planned for this path, it's unclear if this method | 156 // refactoring is planned for this path, it's unclear if this method |
138 // belongs here long term. | 157 // belongs here long term. |
139 | 158 |
(...skipping 130 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
270 virtual bool RemoveTrack(AudioTrackInterface* track) = 0; | 289 virtual bool RemoveTrack(AudioTrackInterface* track) = 0; |
271 virtual bool RemoveTrack(VideoTrackInterface* track) = 0; | 290 virtual bool RemoveTrack(VideoTrackInterface* track) = 0; |
272 | 291 |
273 protected: | 292 protected: |
274 virtual ~MediaStreamInterface() {} | 293 virtual ~MediaStreamInterface() {} |
275 }; | 294 }; |
276 | 295 |
277 } // namespace webrtc | 296 } // namespace webrtc |
278 | 297 |
279 #endif // WEBRTC_API_MEDIASTREAMINTERFACE_H_ | 298 #endif // WEBRTC_API_MEDIASTREAMINTERFACE_H_ |
OLD | NEW |