| 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 334 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 345 &needs_denoising_)) { | 345 &needs_denoising_)) { |
| 346 LOG(LS_WARNING) << "Invalid mandatory value for" | 346 LOG(LS_WARNING) << "Invalid mandatory value for" |
| 347 << MediaConstraintsInterface::kNoiseReduction; | 347 << MediaConstraintsInterface::kNoiseReduction; |
| 348 SetState(kEnded); | 348 SetState(kEnded); |
| 349 return; | 349 return; |
| 350 } | 350 } |
| 351 | 351 |
| 352 format_ = GetBestCaptureFormat(formats); | 352 format_ = GetBestCaptureFormat(formats); |
| 353 // Start the camera with our best guess. | 353 // Start the camera with our best guess. |
| 354 if (!worker_thread_->Invoke<bool>( | 354 if (!worker_thread_->Invoke<bool>( |
| 355 rtc::Bind(&cricket::VideoCapturer::StartCapturing, | 355 RTC_FROM_HERE, rtc::Bind(&cricket::VideoCapturer::StartCapturing, |
| 356 video_capturer_.get(), format_))) { | 356 video_capturer_.get(), format_))) { |
| 357 SetState(kEnded); | 357 SetState(kEnded); |
| 358 return; | 358 return; |
| 359 } | 359 } |
| 360 started_ = true; | 360 started_ = true; |
| 361 // Initialize hasn't succeeded until a successful state change has occurred. | 361 // Initialize hasn't succeeded until a successful state change has occurred. |
| 362 } | 362 } |
| 363 | 363 |
| 364 bool VideoCapturerTrackSource::GetStats(Stats* stats) { | 364 bool VideoCapturerTrackSource::GetStats(Stats* stats) { |
| 365 return video_capturer_->GetInputSize(&stats->input_width, | 365 return video_capturer_->GetInputSize(&stats->input_width, |
| 366 &stats->input_height); | 366 &stats->input_height); |
| 367 } | 367 } |
| 368 | 368 |
| 369 void VideoCapturerTrackSource::Stop() { | 369 void VideoCapturerTrackSource::Stop() { |
| 370 if (!started_) { | 370 if (!started_) { |
| 371 return; | 371 return; |
| 372 } | 372 } |
| 373 started_ = false; | 373 started_ = false; |
| 374 worker_thread_->Invoke<void>( | 374 worker_thread_->Invoke<void>( |
| 375 RTC_FROM_HERE, |
| 375 rtc::Bind(&cricket::VideoCapturer::Stop, video_capturer_.get())); | 376 rtc::Bind(&cricket::VideoCapturer::Stop, video_capturer_.get())); |
| 376 } | 377 } |
| 377 | 378 |
| 378 void VideoCapturerTrackSource::Restart() { | 379 void VideoCapturerTrackSource::Restart() { |
| 379 if (started_) { | 380 if (started_) { |
| 380 return; | 381 return; |
| 381 } | 382 } |
| 382 if (!worker_thread_->Invoke<bool>( | 383 if (!worker_thread_->Invoke<bool>( |
| 383 rtc::Bind(&cricket::VideoCapturer::StartCapturing, | 384 RTC_FROM_HERE, rtc::Bind(&cricket::VideoCapturer::StartCapturing, |
| 384 video_capturer_.get(), format_))) { | 385 video_capturer_.get(), format_))) { |
| 385 SetState(kEnded); | 386 SetState(kEnded); |
| 386 return; | 387 return; |
| 387 } | 388 } |
| 388 started_ = true; | 389 started_ = true; |
| 389 } | 390 } |
| 390 | 391 |
| 391 // OnStateChange listens to the cricket::VideoCapturer::SignalStateChange. | 392 // OnStateChange listens to the cricket::VideoCapturer::SignalStateChange. |
| 392 void VideoCapturerTrackSource::OnStateChange( | 393 void VideoCapturerTrackSource::OnStateChange( |
| 393 cricket::VideoCapturer* capturer, | 394 cricket::VideoCapturer* capturer, |
| 394 cricket::CaptureState capture_state) { | 395 cricket::CaptureState capture_state) { |
| 395 if (rtc::Thread::Current() != signaling_thread_) { | 396 if (rtc::Thread::Current() != signaling_thread_) { |
| 396 invoker_.AsyncInvoke<void>( | 397 invoker_.AsyncInvoke<void>( |
| 397 signaling_thread_, rtc::Bind(&VideoCapturerTrackSource::OnStateChange, | 398 RTC_FROM_HERE, signaling_thread_, |
| 398 this, capturer, capture_state)); | 399 rtc::Bind(&VideoCapturerTrackSource::OnStateChange, this, capturer, |
| 400 capture_state)); |
| 399 return; | 401 return; |
| 400 } | 402 } |
| 401 | 403 |
| 402 if (capturer == video_capturer_.get()) { | 404 if (capturer == video_capturer_.get()) { |
| 403 SetState(GetReadyState(capture_state)); | 405 SetState(GetReadyState(capture_state)); |
| 404 } | 406 } |
| 405 } | 407 } |
| 406 | 408 |
| 407 } // namespace webrtc | 409 } // namespace webrtc |
| OLD | NEW |