Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(879)

Unified Diff: content/browser/renderer_host/media/in_process_buildable_video_capture_device.cc

Issue 2769543002: [Mojo Video Capture] Introduce abstraction VideoCaptureSystem (Closed)
Patch Set: Incorporated suggestions from PatchSet 5 Created 3 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: content/browser/renderer_host/media/in_process_buildable_video_capture_device.cc
diff --git a/content/browser/renderer_host/media/in_process_buildable_video_capture_device.cc b/content/browser/renderer_host/media/in_process_buildable_video_capture_device.cc
index 271d80b2445e13a10805bb8eb33d047b7cb81977..c9fd848ef4fc76b91142a2c608e2e6a682b8d66c 100644
--- a/content/browser/renderer_host/media/in_process_buildable_video_capture_device.cc
+++ b/content/browser/renderer_host/media/in_process_buildable_video_capture_device.cc
@@ -84,9 +84,9 @@ namespace content {
InProcessBuildableVideoCaptureDevice::InProcessBuildableVideoCaptureDevice(
scoped_refptr<base::SingleThreadTaskRunner> device_task_runner,
- media::VideoCaptureDeviceFactory* device_factory)
+ media::VideoCaptureSystem* video_capture_system)
: device_task_runner_(std::move(device_task_runner)),
- device_factory_(device_factory) {}
+ video_capture_system_(video_capture_system) {}
InProcessBuildableVideoCaptureDevice::~InProcessBuildableVideoCaptureDevice() {
DCHECK_CURRENTLY_ON(BrowserThread::IO);
@@ -109,45 +109,24 @@ void InProcessBuildableVideoCaptureDevice::CreateAndStartDeviceAsync(
CreateDeviceClient(max_buffers, controller->GetWeakPtrForIOThread());
base::Closure start_capture_closure;
+ // Use of Unretained() is safe, because |done_cb| guarantees that
+ // |this| stays alive.
+ ReceiveDeviceCallback after_start_capture_callback = media::BindToCurrentLoop(
+ base::Bind(&InProcessBuildableVideoCaptureDevice::OnDeviceStarted,
+ base::Unretained(this), controller, callbacks,
+ base::Passed(&done_cb)));
+
switch (controller->stream_type()) {
case MEDIA_DEVICE_VIDEO_CAPTURE: {
- const media::VideoCaptureDeviceDescriptor* descriptor =
- callbacks->LookupDeviceDescriptor(controller->device_id());
- if (!descriptor) {
- callbacks->OnDeviceStartFailed(controller);
- base::ResetAndReturn(&done_cb).Run();
- return;
- }
- controller->OnLog(base::StringPrintf(
- "Starting device: id: %s, name: %s, api: %s",
- descriptor->device_id.c_str(), descriptor->GetNameAndModel().c_str(),
- descriptor->GetCaptureApiTypeString()));
-
- callbacks->WillStartDevice(descriptor->facing);
-
- // Use of Unretained() is safe, because |done_cb| guarantees that |this|
- // stays alive.
- ReceiveDeviceCallback after_start_capture_callback =
- media::BindToCurrentLoop(
- base::Bind(&InProcessBuildableVideoCaptureDevice::OnDeviceStarted,
- base::Unretained(this), controller, callbacks,
- base::Passed(&done_cb)));
start_capture_closure =
base::Bind(&InProcessBuildableVideoCaptureDevice::
DoStartDeviceCaptureOnDeviceThread,
- base::Unretained(this), *descriptor, params,
+ base::Unretained(this), controller->device_id(), params,
base::Passed(std::move(device_client)),
std::move(after_start_capture_callback));
break;
}
- case MEDIA_TAB_VIDEO_CAPTURE: {
- // Use of Unretained() is safe, because |done_cb| guarantees that |this|
- // stays alive.
- ReceiveDeviceCallback after_start_capture_callback =
- media::BindToCurrentLoop(
- base::Bind(&InProcessBuildableVideoCaptureDevice::OnDeviceStarted,
- base::Unretained(this), controller, callbacks,
- base::Passed(&done_cb)));
+ case MEDIA_TAB_VIDEO_CAPTURE:
start_capture_closure =
base::Bind(&InProcessBuildableVideoCaptureDevice::
DoStartTabCaptureOnDeviceThread,
@@ -155,15 +134,8 @@ void InProcessBuildableVideoCaptureDevice::CreateAndStartDeviceAsync(
base::Passed(std::move(device_client)),
std::move(after_start_capture_callback));
break;
- }
- case MEDIA_DESKTOP_VIDEO_CAPTURE: {
- // Use of Unretained() is safe, because |done_cb| guarantees that |this|
- // stays alive.
- ReceiveDeviceCallback after_start_capture_callback =
- media::BindToCurrentLoop(
- base::Bind(&InProcessBuildableVideoCaptureDevice::OnDeviceStarted,
- base::Unretained(this), controller, callbacks,
- base::Passed(&done_cb)));
+
+ case MEDIA_DESKTOP_VIDEO_CAPTURE:
start_capture_closure =
base::Bind(&InProcessBuildableVideoCaptureDevice::
DoStartDesktopCaptureOnDeviceThread,
@@ -171,7 +143,7 @@ void InProcessBuildableVideoCaptureDevice::CreateAndStartDeviceAsync(
base::Passed(std::move(device_client)),
std::move(after_start_capture_callback));
break;
- }
+
default: {
NOTIMPLEMENTED();
return;
@@ -338,7 +310,7 @@ void InProcessBuildableVideoCaptureDevice::OnDeviceStarted(
device.get(), device_task_runner_));
device_ = std::move(device);
state_ = State::DEVICE_STARTED;
- callbacks->DidStartDevice(controller);
+ callbacks->OnDeviceStarted(controller);
base::ResetAndReturn(&done_cb).Run();
return;
case State::DEVICE_START_ABORTING:
@@ -363,7 +335,7 @@ void InProcessBuildableVideoCaptureDevice::OnDeviceStarted(
}
void InProcessBuildableVideoCaptureDevice::DoStartDeviceCaptureOnDeviceThread(
- const media::VideoCaptureDeviceDescriptor& descriptor,
+ const std::string& device_id,
const media::VideoCaptureParams& params,
std::unique_ptr<media::VideoCaptureDeviceClient> device_client,
ReceiveDeviceCallback result_callback) {
@@ -371,7 +343,7 @@ void InProcessBuildableVideoCaptureDevice::DoStartDeviceCaptureOnDeviceThread(
DCHECK(device_task_runner_->BelongsToCurrentThread());
std::unique_ptr<media::VideoCaptureDevice> video_capture_device =
- device_factory_->CreateDevice(descriptor);
+ video_capture_system_->CreateDevice(device_id);
if (!video_capture_device) {
result_callback.Run(nullptr);

Powered by Google App Engine
This is Rietveld 408576698