| 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/videoprocessor.h" | |
| 34 #include "talk/media/base/videorenderer.h" | 33 #include "talk/media/base/videorenderer.h" |
| 35 #include "webrtc/base/checks.h" | 34 #include "webrtc/base/checks.h" |
| 36 #include "webrtc/base/logging.h" | 35 #include "webrtc/base/logging.h" |
| 37 | 36 |
| 38 namespace cricket { | 37 namespace cricket { |
| 39 | 38 |
| 40 // CaptureManager helper class. | 39 // CaptureManager helper class. |
| 41 class VideoCapturerState { | 40 class VideoCapturerState { |
| 42 public: | 41 public: |
| 43 static const VideoFormatPod kDefaultCaptureFormat; | 42 static const VideoFormatPod kDefaultCaptureFormat; |
| (...skipping 263 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 307 if (!video_capturer || !video_renderer) { | 306 if (!video_capturer || !video_renderer) { |
| 308 return false; | 307 return false; |
| 309 } | 308 } |
| 310 CaptureRenderAdapter* adapter = GetAdapter(video_capturer); | 309 CaptureRenderAdapter* adapter = GetAdapter(video_capturer); |
| 311 if (!adapter) { | 310 if (!adapter) { |
| 312 return false; | 311 return false; |
| 313 } | 312 } |
| 314 return adapter->RemoveRenderer(video_renderer); | 313 return adapter->RemoveRenderer(video_renderer); |
| 315 } | 314 } |
| 316 | 315 |
| 317 bool CaptureManager::AddVideoProcessor(VideoCapturer* video_capturer, | |
| 318 VideoProcessor* video_processor) { | |
| 319 DCHECK(thread_checker_.CalledOnValidThread()); | |
| 320 if (!video_capturer || !video_processor) { | |
| 321 return false; | |
| 322 } | |
| 323 if (!IsCapturerRegistered(video_capturer)) { | |
| 324 return false; | |
| 325 } | |
| 326 video_capturer->AddVideoProcessor(video_processor); | |
| 327 return true; | |
| 328 } | |
| 329 | |
| 330 bool CaptureManager::RemoveVideoProcessor(VideoCapturer* video_capturer, | |
| 331 VideoProcessor* video_processor) { | |
| 332 DCHECK(thread_checker_.CalledOnValidThread()); | |
| 333 if (!video_capturer || !video_processor) { | |
| 334 return false; | |
| 335 } | |
| 336 if (!IsCapturerRegistered(video_capturer)) { | |
| 337 return false; | |
| 338 } | |
| 339 return video_capturer->RemoveVideoProcessor(video_processor); | |
| 340 } | |
| 341 | |
| 342 bool CaptureManager::IsCapturerRegistered(VideoCapturer* video_capturer) const { | 316 bool CaptureManager::IsCapturerRegistered(VideoCapturer* video_capturer) const { |
| 343 DCHECK(thread_checker_.CalledOnValidThread()); | 317 DCHECK(thread_checker_.CalledOnValidThread()); |
| 344 return GetCaptureState(video_capturer) != NULL; | 318 return GetCaptureState(video_capturer) != NULL; |
| 345 } | 319 } |
| 346 | 320 |
| 347 bool CaptureManager::RegisterVideoCapturer(VideoCapturer* video_capturer) { | 321 bool CaptureManager::RegisterVideoCapturer(VideoCapturer* video_capturer) { |
| 348 DCHECK(thread_checker_.CalledOnValidThread()); | 322 DCHECK(thread_checker_.CalledOnValidThread()); |
| 349 VideoCapturerState* capture_state = | 323 VideoCapturerState* capture_state = |
| 350 VideoCapturerState::Create(video_capturer); | 324 VideoCapturerState::Create(video_capturer); |
| 351 if (!capture_state) { | 325 if (!capture_state) { |
| (...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 422 VideoCapturer* video_capturer) const { | 396 VideoCapturer* video_capturer) const { |
| 423 DCHECK(thread_checker_.CalledOnValidThread()); | 397 DCHECK(thread_checker_.CalledOnValidThread()); |
| 424 VideoCapturerState* capture_state = GetCaptureState(video_capturer); | 398 VideoCapturerState* capture_state = GetCaptureState(video_capturer); |
| 425 if (!capture_state) { | 399 if (!capture_state) { |
| 426 return NULL; | 400 return NULL; |
| 427 } | 401 } |
| 428 return capture_state->adapter(); | 402 return capture_state->adapter(); |
| 429 } | 403 } |
| 430 | 404 |
| 431 } // namespace cricket | 405 } // namespace cricket |
| OLD | NEW |