OLD | NEW |
1 /* | 1 /* |
2 * libjingle | 2 * libjingle |
3 * Copyright 2012 Google Inc. | 3 * Copyright 2012 Google Inc. |
4 * | 4 * |
5 * Redistribution and use in source and binary forms, with or without | 5 * Redistribution and use in source and binary forms, with or without |
6 * modification, are permitted provided that the following conditions are met: | 6 * modification, are permitted provided that the following conditions are met: |
7 * | 7 * |
8 * 1. Redistributions of source code must retain the above copyright notice, | 8 * 1. Redistributions of source code must retain the above copyright notice, |
9 * this list of conditions and the following disclaimer. | 9 * this list of conditions and the following disclaimer. |
10 * 2. Redistributions in binary form must reproduce the above copyright notice, | 10 * 2. Redistributions in binary form must reproduce the above copyright notice, |
(...skipping 12 matching lines...) Expand all Loading... |
23 * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR | 23 * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR |
24 * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF | 24 * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF |
25 * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 25 * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
26 */ | 26 */ |
27 | 27 |
28 #include "talk/media/base/capturemanager.h" | 28 #include "talk/media/base/capturemanager.h" |
29 | 29 |
30 #include <algorithm> | 30 #include <algorithm> |
31 | 31 |
32 #include "talk/media/base/videocapturer.h" | 32 #include "talk/media/base/videocapturer.h" |
| 33 #include "talk/media/base/videorenderer.h" |
33 #include "webrtc/base/checks.h" | 34 #include "webrtc/base/checks.h" |
34 #include "webrtc/base/logging.h" | 35 #include "webrtc/base/logging.h" |
35 | 36 |
36 namespace cricket { | 37 namespace cricket { |
37 | 38 |
38 // CaptureManager helper class. | 39 // CaptureManager helper class. |
39 class VideoCapturerState { | 40 class VideoCapturerState { |
40 public: | 41 public: |
41 static const VideoFormatPod kDefaultCaptureFormat; | 42 static const VideoFormatPod kDefaultCaptureFormat; |
42 | 43 |
(...skipping 236 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
279 // TODO(ryanpetrie): Support restart requests. Should this | 280 // TODO(ryanpetrie): Support restart requests. Should this |
280 // to-be-implemented logic be used for {Start,Stop}VideoCapture as well? | 281 // to-be-implemented logic be used for {Start,Stop}VideoCapture as well? |
281 break; | 282 break; |
282 default: | 283 default: |
283 LOG(LS_ERROR) << "Unknown/unimplemented RestartOption"; | 284 LOG(LS_ERROR) << "Unknown/unimplemented RestartOption"; |
284 break; | 285 break; |
285 } | 286 } |
286 return true; | 287 return true; |
287 } | 288 } |
288 | 289 |
289 void CaptureManager::AddVideoSink(VideoCapturer* video_capturer, | 290 bool CaptureManager::AddVideoRenderer(VideoCapturer* video_capturer, |
290 rtc::VideoSinkInterface<VideoFrame>* sink) { | 291 VideoRenderer* video_renderer) { |
291 RTC_DCHECK(thread_checker_.CalledOnValidThread()); | 292 RTC_DCHECK(thread_checker_.CalledOnValidThread()); |
292 // TODO(nisse): Do we really need to tolerate NULL inputs? | 293 if (!video_capturer || !video_renderer) { |
293 if (!video_capturer || !sink) { | 294 return false; |
294 return; | |
295 } | 295 } |
296 CaptureRenderAdapter* adapter = GetAdapter(video_capturer); | 296 CaptureRenderAdapter* adapter = GetAdapter(video_capturer); |
297 if (!adapter) { | 297 if (!adapter) { |
298 return; | 298 return false; |
299 } | 299 } |
300 adapter->AddSink(sink); | 300 adapter->AddRenderer(video_renderer); |
| 301 return true; |
301 } | 302 } |
302 | 303 |
303 void CaptureManager::RemoveVideoSink( | 304 bool CaptureManager::RemoveVideoRenderer(VideoCapturer* video_capturer, |
304 VideoCapturer* video_capturer, | 305 VideoRenderer* video_renderer) { |
305 rtc::VideoSinkInterface<VideoFrame>* sink) { | |
306 RTC_DCHECK(thread_checker_.CalledOnValidThread()); | 306 RTC_DCHECK(thread_checker_.CalledOnValidThread()); |
307 if (!video_capturer || !sink) { | 307 if (!video_capturer || !video_renderer) { |
308 return; | 308 return false; |
309 } | 309 } |
310 CaptureRenderAdapter* adapter = GetAdapter(video_capturer); | 310 CaptureRenderAdapter* adapter = GetAdapter(video_capturer); |
311 if (!adapter) { | 311 if (!adapter) { |
312 return; | 312 return false; |
313 } | 313 } |
314 adapter->RemoveSink(sink); | 314 adapter->RemoveRenderer(video_renderer); |
| 315 return true; |
315 } | 316 } |
316 | 317 |
317 bool CaptureManager::IsCapturerRegistered(VideoCapturer* video_capturer) const { | 318 bool CaptureManager::IsCapturerRegistered(VideoCapturer* video_capturer) const { |
318 RTC_DCHECK(thread_checker_.CalledOnValidThread()); | 319 RTC_DCHECK(thread_checker_.CalledOnValidThread()); |
319 return GetCaptureState(video_capturer) != NULL; | 320 return GetCaptureState(video_capturer) != NULL; |
320 } | 321 } |
321 | 322 |
322 bool CaptureManager::RegisterVideoCapturer(VideoCapturer* video_capturer) { | 323 bool CaptureManager::RegisterVideoCapturer(VideoCapturer* video_capturer) { |
323 RTC_DCHECK(thread_checker_.CalledOnValidThread()); | 324 RTC_DCHECK(thread_checker_.CalledOnValidThread()); |
324 VideoCapturerState* capture_state = | 325 VideoCapturerState* capture_state = |
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
397 VideoCapturer* video_capturer) const { | 398 VideoCapturer* video_capturer) const { |
398 RTC_DCHECK(thread_checker_.CalledOnValidThread()); | 399 RTC_DCHECK(thread_checker_.CalledOnValidThread()); |
399 VideoCapturerState* capture_state = GetCaptureState(video_capturer); | 400 VideoCapturerState* capture_state = GetCaptureState(video_capturer); |
400 if (!capture_state) { | 401 if (!capture_state) { |
401 return NULL; | 402 return NULL; |
402 } | 403 } |
403 return capture_state->adapter(); | 404 return capture_state->adapter(); |
404 } | 405 } |
405 | 406 |
406 } // namespace cricket | 407 } // namespace cricket |
OLD | NEW |