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/mediachannel.h" |
26 #include "webrtc/media/base/videosinkinterface.h" | 27 #include "webrtc/media/base/videosinkinterface.h" |
27 #include "webrtc/media/base/videosourceinterface.h" | 28 #include "webrtc/media/base/videosourceinterface.h" |
28 | 29 |
29 namespace cricket { | 30 namespace cricket { |
30 | 31 |
31 class AudioRenderer; | 32 class AudioRenderer; |
32 class VideoCapturer; | 33 class VideoCapturer; |
33 class VideoRenderer; | 34 class VideoRenderer; |
34 class VideoFrame; | 35 class VideoFrame; |
35 | 36 |
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
113 RenderFrame(&frame); | 114 RenderFrame(&frame); |
114 } | 115 } |
115 | 116 |
116 protected: | 117 protected: |
117 // The destructor is protected to prevent deletion via the interface. | 118 // The destructor is protected to prevent deletion via the interface. |
118 // This is so that we allow reference counted classes, where the destructor | 119 // This is so that we allow reference counted classes, where the destructor |
119 // should never be public, to implement the interface. | 120 // should never be public, to implement the interface. |
120 virtual ~VideoRendererInterface() {} | 121 virtual ~VideoRendererInterface() {} |
121 }; | 122 }; |
122 | 123 |
123 class VideoSourceInterface; | 124 // VideoTrackSourceInterface is a reference counted source used for VideoTracks. |
| 125 // The same source can be used in multiple VideoTracks. |
| 126 class VideoTrackSourceInterface |
| 127 : public MediaSourceInterface, |
| 128 public rtc::VideoSourceInterface<cricket::VideoFrame> { |
| 129 public: |
| 130 // Get access to the source implementation of cricket::VideoCapturer. |
| 131 // This can be used for receiving frames and state notifications. |
| 132 // But it should not be used for starting or stopping capturing. |
| 133 // TODO(perkj): We are currently trying to replace all internal use of |
| 134 // cricket::VideoCapturer with rtc::VideoSourceInterface. Once that |
| 135 // refactoring is done, |
| 136 // remove this method. |
| 137 virtual cricket::VideoCapturer* GetVideoCapturer() = 0; |
| 138 |
| 139 virtual void Stop() = 0; |
| 140 virtual void Restart() = 0; |
| 141 |
| 142 virtual const cricket::VideoOptions* options() const = 0; |
| 143 |
| 144 protected: |
| 145 virtual ~VideoTrackSourceInterface() {} |
| 146 }; |
124 | 147 |
125 class VideoTrackInterface | 148 class VideoTrackInterface |
126 : public MediaStreamTrackInterface, | 149 : public MediaStreamTrackInterface, |
127 public rtc::VideoSourceInterface<cricket::VideoFrame> { | 150 public rtc::VideoSourceInterface<cricket::VideoFrame> { |
128 public: | 151 public: |
129 // Make an unqualified VideoSourceInterface resolve to | |
130 // webrtc::VideoSourceInterface, not our base class | |
131 // rtc::VideoSourceInterface<cricket::VideoFrame>. | |
132 using VideoSourceInterface = webrtc::VideoSourceInterface; | |
133 | |
134 // AddRenderer and RemoveRenderer are for backwards compatibility | 152 // AddRenderer and RemoveRenderer are for backwards compatibility |
135 // only. They are obsoleted by the methods of | 153 // only. They are obsoleted by the methods of |
136 // rtc::VideoSourceInterface. | 154 // rtc::VideoSourceInterface. |
137 virtual void AddRenderer(VideoRendererInterface* renderer) { | 155 virtual void AddRenderer(VideoRendererInterface* renderer) { |
138 AddOrUpdateSink(renderer, rtc::VideoSinkWants()); | 156 AddOrUpdateSink(renderer, rtc::VideoSinkWants()); |
139 } | 157 } |
140 virtual void RemoveRenderer(VideoRendererInterface* renderer) { | 158 virtual void RemoveRenderer(VideoRendererInterface* renderer) { |
141 RemoveSink(renderer); | 159 RemoveSink(renderer); |
142 } | 160 } |
143 | 161 |
144 // Register a video sink for this track. | 162 // Register a video sink for this track. |
145 void AddOrUpdateSink(rtc::VideoSinkInterface<cricket::VideoFrame>* sink, | 163 void AddOrUpdateSink(rtc::VideoSinkInterface<cricket::VideoFrame>* sink, |
146 const rtc::VideoSinkWants& wants) override{}; | 164 const rtc::VideoSinkWants& wants) override{}; |
147 void RemoveSink( | 165 void RemoveSink( |
148 rtc::VideoSinkInterface<cricket::VideoFrame>* sink) override{}; | 166 rtc::VideoSinkInterface<cricket::VideoFrame>* sink) override{}; |
149 | 167 |
150 virtual VideoSourceInterface* GetSource() const = 0; | 168 virtual VideoTrackSourceInterface* GetSource() const = 0; |
151 | 169 |
152 // Return the track input sink. I.e., frames sent to this sink are | 170 // Return the track input sink. I.e., frames sent to this sink are |
153 // propagated to all renderers registered with the track. The | 171 // propagated to all renderers registered with the track. The |
154 // returned sink must not change between calls. Currently, this | 172 // returned sink must not change between calls. Currently, this |
155 // method is used for remote tracks (VideoRtpReceiver); further | 173 // method is used for remote tracks (VideoRtpReceiver); further |
156 // refactoring is planned for this path, it's unclear if this method | 174 // refactoring is planned for this path, it's unclear if this method |
157 // belongs here long term. | 175 // belongs here long term. |
158 | 176 |
159 // We do this instead of simply implementing the | 177 // We do this instead of simply implementing the |
160 // VideoSourceInterface directly, because if we did the latter, we'd | 178 // VideoSourceInterface directly, because if we did the latter, we'd |
(...skipping 128 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
289 virtual bool RemoveTrack(AudioTrackInterface* track) = 0; | 307 virtual bool RemoveTrack(AudioTrackInterface* track) = 0; |
290 virtual bool RemoveTrack(VideoTrackInterface* track) = 0; | 308 virtual bool RemoveTrack(VideoTrackInterface* track) = 0; |
291 | 309 |
292 protected: | 310 protected: |
293 virtual ~MediaStreamInterface() {} | 311 virtual ~MediaStreamInterface() {} |
294 }; | 312 }; |
295 | 313 |
296 } // namespace webrtc | 314 } // namespace webrtc |
297 | 315 |
298 #endif // WEBRTC_API_MEDIASTREAMINTERFACE_H_ | 316 #endif // WEBRTC_API_MEDIASTREAMINTERFACE_H_ |
OLD | NEW |