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

Side by Side Diff: content/browser/renderer_host/media/video_capture_manager.cc

Issue 2308533003: Break tight coupling of VideoCaptureDeviceClient to renderer_host (Closed)
Patch Set: miu's comments Created 4 years, 3 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 unified diff | Download patch
« no previous file with comments | « content/browser/renderer_host/media/video_capture_gpu_jpeg_decoder.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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_manager.h" 5 #include "content/browser/renderer_host/media/video_capture_manager.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <set> 8 #include <set>
9 #include <utility> 9 #include <utility>
10 10
(...skipping 394 matching lines...) Expand 10 before | Expand all | Expand 10 after
405 if (request->serial_id() == entry->serial_id) { 405 if (request->serial_id() == entry->serial_id) {
406 request->set_abort_start(); 406 request->set_abort_start();
407 DVLOG(3) << "DoStopDevice, aborting start request for device " 407 DVLOG(3) << "DoStopDevice, aborting start request for device "
408 << entry->id << " serial_id = " << entry->serial_id; 408 << entry->id << " serial_id = " << entry->serial_id;
409 return; 409 return;
410 } 410 }
411 } 411 }
412 412
413 DVLOG(3) << "DoStopDevice. Send stop request for device = " << entry->id 413 DVLOG(3) << "DoStopDevice. Send stop request for device = " << entry->id
414 << " serial_id = " << entry->serial_id << "."; 414 << " serial_id = " << entry->serial_id << ".";
415 entry->video_capture_controller()->DoLogOnIOThread( 415 entry->video_capture_controller()->OnLog(
416 base::StringPrintf("Stopping device: id: %s", entry->id.c_str())); 416 base::StringPrintf("Stopping device: id: %s", entry->id.c_str()));
417 417
418 if (entry->video_capture_device()) { 418 if (entry->video_capture_device()) {
419 // |entry->video_capture_device| can be null if creating the device fails. 419 // |entry->video_capture_device| can be null if creating the device fails.
420 device_task_runner_->PostTask( 420 device_task_runner_->PostTask(
421 FROM_HERE, 421 FROM_HERE,
422 base::Bind(&VideoCaptureManager::DoStopDeviceOnDeviceThread, this, 422 base::Bind(&VideoCaptureManager::DoStopDeviceOnDeviceThread, this,
423 base::Passed(entry->ReleaseVideoCaptureDevice()))); 423 base::Passed(entry->ReleaseVideoCaptureDevice())));
424 } 424 }
425 } 425 }
(...skipping 27 matching lines...) Expand all
453 base::Callback<std::unique_ptr<VideoCaptureDevice>(void)> 453 base::Callback<std::unique_ptr<VideoCaptureDevice>(void)>
454 start_capture_function; 454 start_capture_function;
455 455
456 switch (entry->stream_type) { 456 switch (entry->stream_type) {
457 case MEDIA_DEVICE_VIDEO_CAPTURE: { 457 case MEDIA_DEVICE_VIDEO_CAPTURE: {
458 // We look up the device id from the renderer in our local enumeration 458 // We look up the device id from the renderer in our local enumeration
459 // since the renderer does not have all the information that might be 459 // since the renderer does not have all the information that might be
460 // held in the browser-side VideoCaptureDevice::Name structure. 460 // held in the browser-side VideoCaptureDevice::Name structure.
461 const DeviceInfo* found = GetDeviceInfoById(entry->id); 461 const DeviceInfo* found = GetDeviceInfoById(entry->id);
462 if (found) { 462 if (found) {
463 entry->video_capture_controller()->DoLogOnIOThread( 463 entry->video_capture_controller()->OnLog(
464 base::StringPrintf("Starting device: id: %s, name: %s, api: %s", 464 base::StringPrintf("Starting device: id: %s, name: %s, api: %s",
465 found->descriptor.device_id.c_str(), 465 found->descriptor.device_id.c_str(),
466 found->descriptor.GetNameAndModel().c_str(), 466 found->descriptor.GetNameAndModel().c_str(),
467 found->descriptor.GetCaptureApiTypeString())); 467 found->descriptor.GetCaptureApiTypeString()));
468 468
469 start_capture_function = base::Bind( 469 start_capture_function = base::Bind(
470 &VideoCaptureManager::DoStartDeviceCaptureOnDeviceThread, this, 470 &VideoCaptureManager::DoStartDeviceCaptureOnDeviceThread, this,
471 found->descriptor, request->params(), 471 found->descriptor, request->params(),
472 base::Passed(entry->video_capture_controller()->NewDeviceClient())); 472 base::Passed(entry->video_capture_controller()->NewDeviceClient()));
473 } else { 473 } else {
474 // Errors from DoStartDeviceCaptureOnDeviceThread go via 474 // Errors from DoStartDeviceCaptureOnDeviceThread go via
475 // VideoCaptureDeviceClient::OnError, which needs some thread 475 // VideoCaptureDeviceClient::OnError, which needs some thread
476 // dancing to get errors processed on the IO thread. But since 476 // dancing to get errors processed on the IO thread. But since
477 // we're on that thread, we call VideoCaptureController 477 // we're on that thread, we call VideoCaptureController
478 // methods directly. 478 // methods directly.
479 const std::string log_message = base::StringPrintf( 479 const std::string log_message = base::StringPrintf(
480 "Error on %s:%d: device %s unknown. Maybe recently disconnected?", 480 "Error on %s:%d: device %s unknown. Maybe recently disconnected?",
481 __FILE__, __LINE__, entry->id.c_str()); 481 __FILE__, __LINE__, entry->id.c_str());
482 DLOG(ERROR) << log_message; 482 DLOG(ERROR) << log_message;
483 entry->video_capture_controller()->DoLogOnIOThread(log_message); 483 entry->video_capture_controller()->OnLog(log_message);
484 entry->video_capture_controller()->DoErrorOnIOThread(); 484 entry->video_capture_controller()->OnError();
485 // Drop the failed start request. 485 // Drop the failed start request.
486 device_start_queue_.pop_front(); 486 device_start_queue_.pop_front();
487 487
488 return; 488 return;
489 } 489 }
490 break; 490 break;
491 } 491 }
492 case MEDIA_TAB_VIDEO_CAPTURE: 492 case MEDIA_TAB_VIDEO_CAPTURE:
493 start_capture_function = base::Bind( 493 start_capture_function = base::Bind(
494 &VideoCaptureManager::DoStartTabCaptureOnDeviceThread, this, 494 &VideoCaptureManager::DoStartTabCaptureOnDeviceThread, this,
(...skipping 767 matching lines...) Expand 10 before | Expand all | Expand 10 after
1262 if (!device_in_queue) { 1262 if (!device_in_queue) {
1263 // Session ID is only valid for Screen capture. So we can fake it to 1263 // Session ID is only valid for Screen capture. So we can fake it to
1264 // resume video capture devices here. 1264 // resume video capture devices here.
1265 QueueStartDevice(kFakeSessionId, entry.get(), entry->parameters); 1265 QueueStartDevice(kFakeSessionId, entry.get(), entry->parameters);
1266 } 1266 }
1267 } 1267 }
1268 } 1268 }
1269 #endif // defined(OS_ANDROID) 1269 #endif // defined(OS_ANDROID)
1270 1270
1271 } // namespace content 1271 } // namespace content
OLDNEW
« no previous file with comments | « content/browser/renderer_host/media/video_capture_gpu_jpeg_decoder.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698