| 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 |
| (...skipping 268 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 279 new rtc::RefCountedObject<VideoCapturerTrackSource>(worker_thread, | 279 new rtc::RefCountedObject<VideoCapturerTrackSource>(worker_thread, |
| 280 capturer, remote)); | 280 capturer, remote)); |
| 281 source->Initialize(nullptr); | 281 source->Initialize(nullptr); |
| 282 return source; | 282 return source; |
| 283 } | 283 } |
| 284 | 284 |
| 285 VideoCapturerTrackSource::VideoCapturerTrackSource( | 285 VideoCapturerTrackSource::VideoCapturerTrackSource( |
| 286 rtc::Thread* worker_thread, | 286 rtc::Thread* worker_thread, |
| 287 cricket::VideoCapturer* capturer, | 287 cricket::VideoCapturer* capturer, |
| 288 bool remote) | 288 bool remote) |
| 289 : VideoTrackSource(capturer, worker_thread, remote), | 289 : VideoTrackSource(capturer, remote), |
| 290 signaling_thread_(rtc::Thread::Current()), | 290 signaling_thread_(rtc::Thread::Current()), |
| 291 worker_thread_(worker_thread), |
| 291 video_capturer_(capturer), | 292 video_capturer_(capturer), |
| 292 started_(false) { | 293 started_(false) { |
| 293 video_capturer_->SignalStateChange.connect( | 294 video_capturer_->SignalStateChange.connect( |
| 294 this, &VideoCapturerTrackSource::OnStateChange); | 295 this, &VideoCapturerTrackSource::OnStateChange); |
| 295 } | 296 } |
| 296 | 297 |
| 297 VideoCapturerTrackSource::~VideoCapturerTrackSource() { | 298 VideoCapturerTrackSource::~VideoCapturerTrackSource() { |
| 298 video_capturer_->SignalStateChange.disconnect(this); | 299 video_capturer_->SignalStateChange.disconnect(this); |
| 299 Stop(); | 300 Stop(); |
| 300 } | 301 } |
| (...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 343 if (!ExtractOption(constraints, MediaConstraintsInterface::kNoiseReduction, | 344 if (!ExtractOption(constraints, MediaConstraintsInterface::kNoiseReduction, |
| 344 &needs_denoising_)) { | 345 &needs_denoising_)) { |
| 345 LOG(LS_WARNING) << "Invalid mandatory value for" | 346 LOG(LS_WARNING) << "Invalid mandatory value for" |
| 346 << MediaConstraintsInterface::kNoiseReduction; | 347 << MediaConstraintsInterface::kNoiseReduction; |
| 347 SetState(kEnded); | 348 SetState(kEnded); |
| 348 return; | 349 return; |
| 349 } | 350 } |
| 350 | 351 |
| 351 format_ = GetBestCaptureFormat(formats); | 352 format_ = GetBestCaptureFormat(formats); |
| 352 // Start the camera with our best guess. | 353 // Start the camera with our best guess. |
| 353 if (!worker_thread()->Invoke<bool>( | 354 if (!worker_thread_->Invoke<bool>( |
| 354 rtc::Bind(&cricket::VideoCapturer::StartCapturing, | 355 rtc::Bind(&cricket::VideoCapturer::StartCapturing, |
| 355 video_capturer_.get(), format_))) { | 356 video_capturer_.get(), format_))) { |
| 356 SetState(kEnded); | 357 SetState(kEnded); |
| 357 return; | 358 return; |
| 358 } | 359 } |
| 359 started_ = true; | 360 started_ = true; |
| 360 // Initialize hasn't succeeded until a successful state change has occurred. | 361 // Initialize hasn't succeeded until a successful state change has occurred. |
| 361 } | 362 } |
| 362 | 363 |
| 363 bool VideoCapturerTrackSource::GetStats(Stats* stats) { | 364 bool VideoCapturerTrackSource::GetStats(Stats* stats) { |
| 364 return video_capturer_->GetInputSize(&stats->input_width, | 365 return video_capturer_->GetInputSize(&stats->input_width, |
| 365 &stats->input_height); | 366 &stats->input_height); |
| 366 } | 367 } |
| 367 | 368 |
| 368 void VideoCapturerTrackSource::Stop() { | 369 void VideoCapturerTrackSource::Stop() { |
| 369 if (!started_) { | 370 if (!started_) { |
| 370 return; | 371 return; |
| 371 } | 372 } |
| 372 started_ = false; | 373 started_ = false; |
| 373 worker_thread()->Invoke<void>( | 374 worker_thread_->Invoke<void>( |
| 374 rtc::Bind(&cricket::VideoCapturer::Stop, video_capturer_.get())); | 375 rtc::Bind(&cricket::VideoCapturer::Stop, video_capturer_.get())); |
| 375 } | 376 } |
| 376 | 377 |
| 377 void VideoCapturerTrackSource::Restart() { | 378 void VideoCapturerTrackSource::Restart() { |
| 378 if (started_) { | 379 if (started_) { |
| 379 return; | 380 return; |
| 380 } | 381 } |
| 381 if (!worker_thread()->Invoke<bool>( | 382 if (!worker_thread_->Invoke<bool>( |
| 382 rtc::Bind(&cricket::VideoCapturer::StartCapturing, | 383 rtc::Bind(&cricket::VideoCapturer::StartCapturing, |
| 383 video_capturer_.get(), format_))) { | 384 video_capturer_.get(), format_))) { |
| 384 SetState(kEnded); | 385 SetState(kEnded); |
| 385 return; | 386 return; |
| 386 } | 387 } |
| 387 started_ = true; | 388 started_ = true; |
| 388 } | 389 } |
| 389 | 390 |
| 390 // OnStateChange listens to the cricket::VideoCapturer::SignalStateChange. | 391 // OnStateChange listens to the cricket::VideoCapturer::SignalStateChange. |
| 391 void VideoCapturerTrackSource::OnStateChange( | 392 void VideoCapturerTrackSource::OnStateChange( |
| 392 cricket::VideoCapturer* capturer, | 393 cricket::VideoCapturer* capturer, |
| 393 cricket::CaptureState capture_state) { | 394 cricket::CaptureState capture_state) { |
| 394 if (rtc::Thread::Current() != signaling_thread_) { | 395 if (rtc::Thread::Current() != signaling_thread_) { |
| 395 invoker_.AsyncInvoke<void>( | 396 invoker_.AsyncInvoke<void>( |
| 396 signaling_thread_, rtc::Bind(&VideoCapturerTrackSource::OnStateChange, | 397 signaling_thread_, rtc::Bind(&VideoCapturerTrackSource::OnStateChange, |
| 397 this, capturer, capture_state)); | 398 this, capturer, capture_state)); |
| 398 return; | 399 return; |
| 399 } | 400 } |
| 400 | 401 |
| 401 if (capturer == video_capturer_.get()) { | 402 if (capturer == video_capturer_.get()) { |
| 402 SetState(GetReadyState(capture_state)); | 403 SetState(GetReadyState(capture_state)); |
| 403 } | 404 } |
| 404 } | 405 } |
| 405 | 406 |
| 406 } // namespace webrtc | 407 } // namespace webrtc |
| OLD | NEW |