Index: content/browser/renderer_host/media/video_capture_controller.cc |
diff --git a/content/browser/renderer_host/media/video_capture_controller.cc b/content/browser/renderer_host/media/video_capture_controller.cc |
index 22578ac132b94239d72b7126b8f6338d2a1f8343..c291a144674681c899d516bdfe6f1b2720699c9f 100644 |
--- a/content/browser/renderer_host/media/video_capture_controller.cc |
+++ b/content/browser/renderer_host/media/video_capture_controller.cc |
@@ -167,13 +167,13 @@ VideoCaptureController::VideoCaptureController( |
const std::string& device_id, |
MediaStreamType stream_type, |
const media::VideoCaptureParams& params, |
- std::unique_ptr<BuildableVideoCaptureDevice> buildable_device) |
+ std::unique_ptr<VideoCaptureDeviceLauncher> device_launcher) |
: serial_id_(g_device_start_id++), |
device_id_(device_id), |
stream_type_(stream_type), |
parameters_(params), |
- buildable_device_(std::move(buildable_device)), |
- consumer_feedback_observer_(nullptr), |
+ device_launcher_(std::move(device_launcher)), |
+ device_launch_observer_(nullptr), |
state_(VIDEO_CAPTURE_STATE_STARTING), |
has_received_frames_(false), |
weak_ptr_factory_(this) { |
@@ -187,16 +187,6 @@ VideoCaptureController::GetWeakPtrForIOThread() { |
return weak_ptr_factory_.GetWeakPtr(); |
} |
-void VideoCaptureController::SetConsumerFeedbackObserver( |
- std::unique_ptr<media::VideoFrameConsumerFeedbackObserver> |
- consumer_feedback_observer) { |
- DCHECK_CURRENTLY_ON(BrowserThread::IO); |
- consumer_feedback_observer_ = std::move(consumer_feedback_observer); |
- // Update existing BufferContext entries. |
- for (auto& entry : buffer_contexts_) |
- entry.set_consumer_feedback_observer(consumer_feedback_observer_.get()); |
-} |
- |
void VideoCaptureController::AddClient( |
VideoCaptureControllerID id, |
VideoCaptureControllerEventHandler* event_handler, |
@@ -385,7 +375,7 @@ void VideoCaptureController::OnNewBufferHandle( |
DCHECK(FindUnretiredBufferContextFromBufferId(buffer_id) == |
buffer_contexts_.end()); |
buffer_contexts_.emplace_back( |
- next_buffer_context_id_++, buffer_id, consumer_feedback_observer_.get(), |
+ next_buffer_context_id_++, buffer_id, launched_device_.get(), |
handle_provider->GetHandleForInterProcessTransit()); |
} |
@@ -497,55 +487,106 @@ void VideoCaptureController::OnStartedUsingGpuDecode() { |
PerformForClientsWithOpenSession(base::Bind(&CallOnStartedUsingGpuDecode)); |
} |
+void VideoCaptureController::OnDeviceLaunched( |
+ std::unique_ptr<LaunchedVideoCaptureDevice> device) { |
+ DCHECK_CURRENTLY_ON(BrowserThread::IO); |
+ launched_device_ = std::move(device); |
+ for (auto& entry : buffer_contexts_) |
+ entry.set_consumer_feedback_observer(launched_device_.get()); |
+ if (device_launch_observer_) { |
+ device_launch_observer_->OnDeviceLaunched(this); |
+ device_launch_observer_ = nullptr; |
+ } |
+} |
+ |
+void VideoCaptureController::OnDeviceLaunchFailed() { |
+ DCHECK_CURRENTLY_ON(BrowserThread::IO); |
+ if (device_launch_observer_) { |
+ device_launch_observer_->OnDeviceLaunchFailed(this); |
+ device_launch_observer_ = nullptr; |
+ } |
+} |
+ |
+void VideoCaptureController::OnDeviceLaunchAborted() { |
+ DCHECK_CURRENTLY_ON(BrowserThread::IO); |
+ if (device_launch_observer_) { |
+ device_launch_observer_->OnDeviceLaunchAborted(); |
+ device_launch_observer_ = nullptr; |
+ } |
+} |
+ |
void VideoCaptureController::CreateAndStartDeviceAsync( |
const media::VideoCaptureParams& params, |
- BuildableVideoCaptureDevice::Callbacks* callbacks, |
+ VideoCaptureDeviceLaunchObserver* observer, |
base::OnceClosure done_cb) { |
- buildable_device_->CreateAndStartDeviceAsync(this, params, callbacks, |
- std::move(done_cb)); |
+ DCHECK_CURRENTLY_ON(BrowserThread::IO); |
+ device_launch_observer_ = observer; |
+ device_launcher_->LaunchDeviceAsync(device_id_, stream_type_, params, |
+ GetWeakPtrForIOThread(), this, |
+ std::move(done_cb)); |
} |
void VideoCaptureController::ReleaseDeviceAsync(base::OnceClosure done_cb) { |
- buildable_device_->ReleaseDeviceAsync(this, std::move(done_cb)); |
+ DCHECK_CURRENTLY_ON(BrowserThread::IO); |
+ if (!launched_device_) { |
+ device_launcher_->AbortLaunch(); |
+ return; |
+ } |
+ launched_device_.reset(); |
} |
bool VideoCaptureController::IsDeviceAlive() const { |
- return buildable_device_->IsDeviceAlive(); |
+ DCHECK_CURRENTLY_ON(BrowserThread::IO); |
+ return launched_device_ != nullptr; |
} |
void VideoCaptureController::GetPhotoCapabilities( |
media::VideoCaptureDevice::GetPhotoCapabilitiesCallback callback) const { |
- buildable_device_->GetPhotoCapabilities(std::move(callback)); |
+ DCHECK_CURRENTLY_ON(BrowserThread::IO); |
+ DCHECK(launched_device_); |
+ launched_device_->GetPhotoCapabilities(std::move(callback)); |
} |
void VideoCaptureController::SetPhotoOptions( |
media::mojom::PhotoSettingsPtr settings, |
media::VideoCaptureDevice::SetPhotoOptionsCallback callback) { |
- buildable_device_->SetPhotoOptions(std::move(settings), std::move(callback)); |
+ DCHECK_CURRENTLY_ON(BrowserThread::IO); |
+ DCHECK(launched_device_); |
+ launched_device_->SetPhotoOptions(std::move(settings), std::move(callback)); |
} |
void VideoCaptureController::TakePhoto( |
media::VideoCaptureDevice::TakePhotoCallback callback) { |
- buildable_device_->TakePhoto(std::move(callback)); |
+ DCHECK_CURRENTLY_ON(BrowserThread::IO); |
+ DCHECK(launched_device_); |
+ launched_device_->TakePhoto(std::move(callback)); |
} |
void VideoCaptureController::MaybeSuspend() { |
- buildable_device_->MaybeSuspendDevice(); |
+ DCHECK_CURRENTLY_ON(BrowserThread::IO); |
+ DCHECK(launched_device_); |
+ launched_device_->MaybeSuspendDevice(); |
} |
void VideoCaptureController::Resume() { |
- buildable_device_->ResumeDevice(); |
+ DCHECK_CURRENTLY_ON(BrowserThread::IO); |
+ DCHECK(launched_device_); |
+ launched_device_->ResumeDevice(); |
} |
void VideoCaptureController::RequestRefreshFrame() { |
- buildable_device_->RequestRefreshFrame(); |
+ DCHECK_CURRENTLY_ON(BrowserThread::IO); |
+ DCHECK(launched_device_); |
+ launched_device_->RequestRefreshFrame(); |
} |
void VideoCaptureController::SetDesktopCaptureWindowIdAsync( |
gfx::NativeViewId window_id, |
base::OnceClosure done_cb) { |
- buildable_device_->SetDesktopCaptureWindowIdAsync(window_id, |
- std::move(done_cb)); |
+ DCHECK_CURRENTLY_ON(BrowserThread::IO); |
+ DCHECK(launched_device_); |
+ launched_device_->SetDesktopCaptureWindowIdAsync(window_id, |
+ std::move(done_cb)); |
} |
VideoCaptureController::ControllerClient* VideoCaptureController::FindClient( |