| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "content/browser/renderer_host/media/video_capture_controller.h" | 5 #include "content/browser/renderer_host/media/video_capture_controller.h" |
| 6 | 6 |
| 7 #include <stddef.h> | 7 #include <stddef.h> |
| 8 #include <stdint.h> | 8 #include <stdint.h> |
| 9 | 9 |
| 10 #include <map> | 10 #include <map> |
| (...skipping 480 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 491 } | 491 } |
| 492 | 492 |
| 493 void VideoCaptureController::OnDeviceLaunched( | 493 void VideoCaptureController::OnDeviceLaunched( |
| 494 std::unique_ptr<LaunchedVideoCaptureDevice> device) { | 494 std::unique_ptr<LaunchedVideoCaptureDevice> device) { |
| 495 DCHECK_CURRENTLY_ON(BrowserThread::IO); | 495 DCHECK_CURRENTLY_ON(BrowserThread::IO); |
| 496 launched_device_ = std::move(device); | 496 launched_device_ = std::move(device); |
| 497 for (auto& entry : buffer_contexts_) | 497 for (auto& entry : buffer_contexts_) |
| 498 entry.set_consumer_feedback_observer(launched_device_.get()); | 498 entry.set_consumer_feedback_observer(launched_device_.get()); |
| 499 if (device_launch_observer_) { | 499 if (device_launch_observer_) { |
| 500 device_launch_observer_->OnDeviceLaunched(this); | 500 device_launch_observer_->OnDeviceLaunched(this); |
| 501 device_launch_observer_ = nullptr; | |
| 502 } | 501 } |
| 503 } | 502 } |
| 504 | 503 |
| 505 void VideoCaptureController::OnDeviceLaunchFailed() { | 504 void VideoCaptureController::OnDeviceLaunchFailed() { |
| 506 DCHECK_CURRENTLY_ON(BrowserThread::IO); | 505 DCHECK_CURRENTLY_ON(BrowserThread::IO); |
| 507 if (device_launch_observer_) { | 506 if (device_launch_observer_) { |
| 508 device_launch_observer_->OnDeviceLaunchFailed(this); | 507 device_launch_observer_->OnDeviceLaunchFailed(this); |
| 509 device_launch_observer_ = nullptr; | 508 device_launch_observer_ = nullptr; |
| 510 } | 509 } |
| 511 } | 510 } |
| 512 | 511 |
| 513 void VideoCaptureController::OnDeviceLaunchAborted() { | 512 void VideoCaptureController::OnDeviceLaunchAborted() { |
| 514 DCHECK_CURRENTLY_ON(BrowserThread::IO); | 513 DCHECK_CURRENTLY_ON(BrowserThread::IO); |
| 515 if (device_launch_observer_) { | 514 if (device_launch_observer_) { |
| 516 device_launch_observer_->OnDeviceLaunchAborted(); | 515 device_launch_observer_->OnDeviceLaunchAborted(); |
| 517 device_launch_observer_ = nullptr; | 516 device_launch_observer_ = nullptr; |
| 518 } | 517 } |
| 519 } | 518 } |
| 520 | 519 |
| 520 void VideoCaptureController::OnDeviceConnectionLost() { |
| 521 DCHECK_CURRENTLY_ON(BrowserThread::IO); |
| 522 if (device_launch_observer_) { |
| 523 device_launch_observer_->OnDeviceConnectionLost(this); |
| 524 device_launch_observer_ = nullptr; |
| 525 } |
| 526 } |
| 527 |
| 521 void VideoCaptureController::CreateAndStartDeviceAsync( | 528 void VideoCaptureController::CreateAndStartDeviceAsync( |
| 522 const media::VideoCaptureParams& params, | 529 const media::VideoCaptureParams& params, |
| 523 VideoCaptureDeviceLaunchObserver* observer, | 530 VideoCaptureDeviceLaunchObserver* observer, |
| 524 base::OnceClosure done_cb) { | 531 base::OnceClosure done_cb) { |
| 525 DCHECK_CURRENTLY_ON(BrowserThread::IO); | 532 DCHECK_CURRENTLY_ON(BrowserThread::IO); |
| 526 device_launch_observer_ = observer; | 533 device_launch_observer_ = observer; |
| 527 device_launcher_->LaunchDeviceAsync(device_id_, stream_type_, params, | 534 device_launcher_->LaunchDeviceAsync( |
| 528 GetWeakPtrForIOThread(), this, | 535 device_id_, stream_type_, params, GetWeakPtrForIOThread(), |
| 529 std::move(done_cb)); | 536 base::Bind(&VideoCaptureController::OnDeviceConnectionLost, |
| 537 GetWeakPtrForIOThread()), |
| 538 this, std::move(done_cb)); |
| 530 } | 539 } |
| 531 | 540 |
| 532 void VideoCaptureController::ReleaseDeviceAsync(base::OnceClosure done_cb) { | 541 void VideoCaptureController::ReleaseDeviceAsync(base::OnceClosure done_cb) { |
| 533 DCHECK_CURRENTLY_ON(BrowserThread::IO); | 542 DCHECK_CURRENTLY_ON(BrowserThread::IO); |
| 534 if (!launched_device_) { | 543 if (!launched_device_) { |
| 535 device_launcher_->AbortLaunch(); | 544 device_launcher_->AbortLaunch(); |
| 536 return; | 545 return; |
| 537 } | 546 } |
| 538 launched_device_.reset(); | 547 launched_device_.reset(); |
| 539 } | 548 } |
| (...skipping 128 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 668 EventHandlerAction action) { | 677 EventHandlerAction action) { |
| 669 DCHECK_CURRENTLY_ON(BrowserThread::IO); | 678 DCHECK_CURRENTLY_ON(BrowserThread::IO); |
| 670 for (const auto& client : controller_clients_) { | 679 for (const auto& client : controller_clients_) { |
| 671 if (client->session_closed) | 680 if (client->session_closed) |
| 672 continue; | 681 continue; |
| 673 action.Run(client->event_handler, client->controller_id); | 682 action.Run(client->event_handler, client->controller_id); |
| 674 } | 683 } |
| 675 } | 684 } |
| 676 | 685 |
| 677 } // namespace content | 686 } // namespace content |
| OLD | NEW |