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_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 14 matching lines...) Expand all Loading... | |
25 #include "content/browser/media/capture/web_contents_video_capture_device.h" | 25 #include "content/browser/media/capture/web_contents_video_capture_device.h" |
26 #include "content/browser/media/media_internals.h" | 26 #include "content/browser/media/media_internals.h" |
27 #include "content/browser/renderer_host/media/video_capture_controller.h" | 27 #include "content/browser/renderer_host/media/video_capture_controller.h" |
28 #include "content/browser/renderer_host/media/video_capture_controller_event_han dler.h" | 28 #include "content/browser/renderer_host/media/video_capture_controller_event_han dler.h" |
29 #include "content/public/browser/browser_thread.h" | 29 #include "content/public/browser/browser_thread.h" |
30 #include "content/public/browser/desktop_media_id.h" | 30 #include "content/public/browser/desktop_media_id.h" |
31 #include "content/public/common/media_stream_request.h" | 31 #include "content/public/common/media_stream_request.h" |
32 #include "media/base/bind_to_current_loop.h" | 32 #include "media/base/bind_to_current_loop.h" |
33 #include "media/base/media_switches.h" | 33 #include "media/base/media_switches.h" |
34 #include "media/capture/video/video_capture_device.h" | 34 #include "media/capture/video/video_capture_device.h" |
35 #include "media/capture/video/video_capture_device_client.h" | |
35 #include "media/capture/video/video_capture_device_factory.h" | 36 #include "media/capture/video/video_capture_device_factory.h" |
36 | 37 |
37 #if defined(ENABLE_SCREEN_CAPTURE) && !defined(OS_ANDROID) | 38 #if defined(ENABLE_SCREEN_CAPTURE) && !defined(OS_ANDROID) |
38 #include "content/browser/media/capture/desktop_capture_device.h" | 39 #include "content/browser/media/capture/desktop_capture_device.h" |
39 #if defined(USE_AURA) | 40 #if defined(USE_AURA) |
40 #include "content/browser/media/capture/desktop_capture_device_aura.h" | 41 #include "content/browser/media/capture/desktop_capture_device_aura.h" |
41 #endif | 42 #endif |
42 #endif | 43 #endif |
43 | 44 |
44 #if defined(ENABLE_SCREEN_CAPTURE) && defined(OS_ANDROID) | 45 #if defined(ENABLE_SCREEN_CAPTURE) && defined(OS_ANDROID) |
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
123 | 124 |
124 // Counter used for identifying a DeviceRequest to start a capture device. | 125 // Counter used for identifying a DeviceRequest to start a capture device. |
125 static int g_device_start_id = 0; | 126 static int g_device_start_id = 0; |
126 | 127 |
127 const media::VideoCaptureSessionId kFakeSessionId = -1; | 128 const media::VideoCaptureSessionId kFakeSessionId = -1; |
128 | 129 |
129 } // namespace | 130 } // namespace |
130 | 131 |
131 namespace content { | 132 namespace content { |
132 | 133 |
133 // This class owns a pair VideoCaptureDevice - VideoCaptureController. | 134 // Instances of this struct go through 3 different phases during their lifetime. |
134 // VideoCaptureManager owns all such pairs and is responsible for deleting the | 135 // Phase 1: When first created (in GetOrCreateDeviceEntry()), this consists of a |
miu
2016/12/01 05:25:18
s/consists of a only a controller/consists of only
chfremer
2016/12/02 01:28:28
Done.
| |
135 // instances when they are not used any longer. | 136 // only a controller. Clients can already connect to the controller, but there |
137 // is no device present. | |
138 // Phase 2: When a request to "start" the entry comes in (via | |
139 // HandleQueuedStartRequest()), a VideoCaptureDevice::Client is created | |
140 // via video_capture_controller()->NewDeviceClient() and is used to schedule the | |
141 // creation and start of a VideoCaptureDevice on the Device Thread. | |
142 // Phase 3: As soon as the creation of the VideoCaptureDevice is complete, it | |
143 // is connected to the VideoCaptureDevice::Client as the ConsumerLoadObserver. | |
136 class VideoCaptureManager::DeviceEntry { | 144 class VideoCaptureManager::DeviceEntry { |
137 public: | 145 public: |
138 DeviceEntry(MediaStreamType stream_type, | 146 DeviceEntry(MediaStreamType stream_type, |
139 const std::string& id, | 147 const std::string& id, |
140 std::unique_ptr<VideoCaptureController> controller, | 148 std::unique_ptr<VideoCaptureController> controller, |
141 const media::VideoCaptureParams& params); | 149 const media::VideoCaptureParams& params); |
142 ~DeviceEntry(); | 150 ~DeviceEntry(); |
143 | 151 |
144 const int serial_id; | 152 const int serial_id; |
145 const MediaStreamType stream_type; | 153 const MediaStreamType stream_type; |
(...skipping 265 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
411 DVLOG(3) << "DoStopDevice, aborting start request for device " | 419 DVLOG(3) << "DoStopDevice, aborting start request for device " |
412 << entry->id << " serial_id = " << entry->serial_id; | 420 << entry->id << " serial_id = " << entry->serial_id; |
413 return; | 421 return; |
414 } | 422 } |
415 } | 423 } |
416 | 424 |
417 DVLOG(3) << "DoStopDevice. Send stop request for device = " << entry->id | 425 DVLOG(3) << "DoStopDevice. Send stop request for device = " << entry->id |
418 << " serial_id = " << entry->serial_id << "."; | 426 << " serial_id = " << entry->serial_id << "."; |
419 entry->video_capture_controller()->OnLog( | 427 entry->video_capture_controller()->OnLog( |
420 base::StringPrintf("Stopping device: id: %s", entry->id.c_str())); | 428 base::StringPrintf("Stopping device: id: %s", entry->id.c_str())); |
429 entry->video_capture_controller()->SetFrameReceiverObserver(nullptr); | |
421 | 430 |
422 if (entry->video_capture_device()) { | 431 if (entry->video_capture_device()) { |
423 // |entry->video_capture_device| can be null if creating the device fails. | 432 // |entry->video_capture_device| can be null if creating the device fails. |
424 device_task_runner_->PostTask( | 433 device_task_runner_->PostTask( |
425 FROM_HERE, | 434 FROM_HERE, |
426 base::Bind(&VideoCaptureManager::DoStopDeviceOnDeviceThread, this, | 435 base::Bind(&VideoCaptureManager::DoStopDeviceOnDeviceThread, this, |
427 base::Passed(entry->ReleaseVideoCaptureDevice()))); | 436 base::Passed(entry->ReleaseVideoCaptureDevice()))); |
428 } | 437 } |
429 } | 438 } |
430 | 439 |
(...skipping 16 matching lines...) Expand all Loading... | |
447 if (NeedToInitializeCaptureDeviceApi(entry->stream_type)) { | 456 if (NeedToInitializeCaptureDeviceApi(entry->stream_type)) { |
448 InitializeCaptureDeviceApiOnUIThread( | 457 InitializeCaptureDeviceApiOnUIThread( |
449 base::Bind(&VideoCaptureManager::HandleQueuedStartRequest, this)); | 458 base::Bind(&VideoCaptureManager::HandleQueuedStartRequest, this)); |
450 return; | 459 return; |
451 } | 460 } |
452 #endif | 461 #endif |
453 | 462 |
454 DVLOG(3) << "HandleQueuedStartRequest, Post start to device thread, device = " | 463 DVLOG(3) << "HandleQueuedStartRequest, Post start to device thread, device = " |
455 << entry->id << " start id = " << entry->serial_id; | 464 << entry->id << " start id = " << entry->serial_id; |
456 | 465 |
466 std::unique_ptr<media::VideoCaptureDeviceClient> device_client = | |
467 entry->video_capture_controller()->NewDeviceClient(); | |
468 media::VideoCaptureDeviceClient* device_client_ptr = device_client.get(); | |
469 | |
457 base::Callback<std::unique_ptr<VideoCaptureDevice>(void)> | 470 base::Callback<std::unique_ptr<VideoCaptureDevice>(void)> |
458 start_capture_function; | 471 start_capture_function; |
459 | 472 |
460 switch (entry->stream_type) { | 473 switch (entry->stream_type) { |
461 case MEDIA_DEVICE_VIDEO_CAPTURE: { | 474 case MEDIA_DEVICE_VIDEO_CAPTURE: { |
462 // We look up the device id from the renderer in our local enumeration | 475 // We look up the device id from the renderer in our local enumeration |
463 // since the renderer does not have all the information that might be | 476 // since the renderer does not have all the information that might be |
464 // held in the browser-side VideoCaptureDevice::Name structure. | 477 // held in the browser-side VideoCaptureDevice::Name structure. |
465 const DeviceInfo* found = GetDeviceInfoById(entry->id); | 478 const DeviceInfo* found = GetDeviceInfoById(entry->id); |
466 if (found) { | 479 if (found) { |
467 entry->video_capture_controller()->OnLog( | 480 entry->video_capture_controller()->OnLog( |
468 base::StringPrintf("Starting device: id: %s, name: %s, api: %s", | 481 base::StringPrintf("Starting device: id: %s, name: %s, api: %s", |
469 found->descriptor.device_id.c_str(), | 482 found->descriptor.device_id.c_str(), |
470 found->descriptor.GetNameAndModel().c_str(), | 483 found->descriptor.GetNameAndModel().c_str(), |
471 found->descriptor.GetCaptureApiTypeString())); | 484 found->descriptor.GetCaptureApiTypeString())); |
472 | 485 |
473 start_capture_function = base::Bind( | 486 start_capture_function = |
474 &VideoCaptureManager::DoStartDeviceCaptureOnDeviceThread, this, | 487 base::Bind(&VideoCaptureManager::DoStartDeviceCaptureOnDeviceThread, |
475 found->descriptor, request->params(), | 488 this, found->descriptor, request->params(), |
476 base::Passed(entry->video_capture_controller()->NewDeviceClient())); | 489 base::Passed(std::move(device_client))); |
477 } else { | 490 } else { |
478 // Errors from DoStartDeviceCaptureOnDeviceThread go via | 491 // Errors from DoStartDeviceCaptureOnDeviceThread go via |
479 // VideoCaptureDeviceClient::OnError, which needs some thread | 492 // VideoCaptureDeviceClient::OnError, which needs some thread |
480 // dancing to get errors processed on the IO thread. But since | 493 // dancing to get errors processed on the IO thread. But since |
481 // we're on that thread, we call VideoCaptureController | 494 // we're on that thread, we call VideoCaptureController |
482 // methods directly. | 495 // methods directly. |
483 const std::string log_message = base::StringPrintf( | 496 const std::string log_message = base::StringPrintf( |
484 "Error on %s:%d: device %s unknown. Maybe recently disconnected?", | 497 "Error on %s:%d: device %s unknown. Maybe recently disconnected?", |
485 __FILE__, __LINE__, entry->id.c_str()); | 498 __FILE__, __LINE__, entry->id.c_str()); |
486 DLOG(ERROR) << log_message; | 499 DLOG(ERROR) << log_message; |
487 entry->video_capture_controller()->OnLog(log_message); | 500 entry->video_capture_controller()->OnLog(log_message); |
488 entry->video_capture_controller()->OnError(); | 501 entry->video_capture_controller()->OnError(); |
489 // Drop the failed start request. | 502 // Drop the failed start request. |
490 device_start_queue_.pop_front(); | 503 device_start_queue_.pop_front(); |
491 | 504 |
492 return; | 505 return; |
493 } | 506 } |
494 break; | 507 break; |
495 } | 508 } |
496 case MEDIA_TAB_VIDEO_CAPTURE: | 509 case MEDIA_TAB_VIDEO_CAPTURE: |
497 start_capture_function = base::Bind( | 510 start_capture_function = |
498 &VideoCaptureManager::DoStartTabCaptureOnDeviceThread, this, | 511 base::Bind(&VideoCaptureManager::DoStartTabCaptureOnDeviceThread, |
499 entry->id, request->params(), | 512 this, entry->id, request->params(), |
500 base::Passed(entry->video_capture_controller()->NewDeviceClient())); | 513 base::Passed(std::move(device_client))); |
501 break; | 514 break; |
502 | 515 |
503 case MEDIA_DESKTOP_VIDEO_CAPTURE: | 516 case MEDIA_DESKTOP_VIDEO_CAPTURE: |
504 start_capture_function = base::Bind( | 517 start_capture_function = |
505 &VideoCaptureManager::DoStartDesktopCaptureOnDeviceThread, this, | 518 base::Bind(&VideoCaptureManager::DoStartDesktopCaptureOnDeviceThread, |
506 entry->id, request->params(), | 519 this, entry->id, request->params(), |
507 base::Passed(entry->video_capture_controller()->NewDeviceClient())); | 520 base::Passed(std::move(device_client))); |
508 break; | 521 break; |
509 | 522 |
510 default: { | 523 default: { |
511 NOTIMPLEMENTED(); | 524 NOTIMPLEMENTED(); |
512 return; | 525 return; |
513 } | 526 } |
514 } | 527 } |
515 base::PostTaskAndReplyWithResult( | 528 base::PostTaskAndReplyWithResult( |
516 device_task_runner_.get(), FROM_HERE, start_capture_function, | 529 device_task_runner_.get(), FROM_HERE, start_capture_function, |
517 base::Bind(&VideoCaptureManager::OnDeviceStarted, this, | 530 base::Bind(&VideoCaptureManager::OnDeviceStarted, this, |
518 request->serial_id())); | 531 request->serial_id(), device_client_ptr)); |
miu
2016/12/01 05:25:17
Is this safe (passing the raw pointer)? Could, in
chfremer
2016/12/02 01:28:28
Yes, but that fact that you had to raise the quest
| |
519 } | 532 } |
520 | 533 |
521 void VideoCaptureManager::OnDeviceStarted( | 534 void VideoCaptureManager::OnDeviceStarted( |
522 int serial_id, | 535 int serial_id, |
536 media::VideoCaptureDeviceClient* device_client_ptr, | |
523 std::unique_ptr<VideoCaptureDevice> device) { | 537 std::unique_ptr<VideoCaptureDevice> device) { |
524 DVLOG(3) << __func__; | 538 DVLOG(3) << __func__; |
525 DCHECK_CURRENTLY_ON(BrowserThread::IO); | 539 DCHECK_CURRENTLY_ON(BrowserThread::IO); |
526 DCHECK_EQ(serial_id, device_start_queue_.begin()->serial_id()); | 540 DCHECK_EQ(serial_id, device_start_queue_.begin()->serial_id()); |
541 // |device| can be null if creation failed in | |
542 // DoStartDeviceCaptureOnDeviceThread. | |
527 if (device_start_queue_.front().abort_start()) { | 543 if (device_start_queue_.front().abort_start()) { |
528 // |device| can be null if creation failed in | |
529 // DoStartDeviceCaptureOnDeviceThread. | |
530 // The device is no longer wanted. Stop the device again. | 544 // The device is no longer wanted. Stop the device again. |
531 DVLOG(3) << "OnDeviceStarted but start request have been aborted."; | 545 DVLOG(3) << "OnDeviceStarted but start request have been aborted."; |
532 media::VideoCaptureDevice* device_ptr = device.get(); | 546 media::VideoCaptureDevice* device_ptr = device.get(); |
533 base::Closure closure = | 547 base::Closure closure = |
534 base::Bind(&VideoCaptureManager::DoStopDeviceOnDeviceThread, this, | 548 base::Bind(&VideoCaptureManager::DoStopDeviceOnDeviceThread, this, |
535 base::Passed(&device)); | 549 base::Passed(&device)); |
536 if (device_ptr && !device_task_runner_->PostTask(FROM_HERE, closure)) { | 550 if (device_ptr && !device_task_runner_->PostTask(FROM_HERE, closure)) { |
537 // PostTask failed. The device must be stopped anyway. | 551 // PostTask failed. The device must be stopped anyway. |
538 device_ptr->StopAndDeAllocate(); | 552 device_ptr->StopAndDeAllocate(); |
539 } | 553 } |
540 } else { | 554 } else { |
541 DeviceEntry* const entry = GetDeviceEntryBySerialId(serial_id); | 555 DeviceEntry* const entry = GetDeviceEntryBySerialId(serial_id); |
542 DCHECK(entry); | 556 DCHECK(entry); |
543 DCHECK(!entry->video_capture_device()); | 557 DCHECK(!entry->video_capture_device()); |
558 if (device) { | |
559 entry->video_capture_controller()->SetFrameReceiverObserver( | |
560 device_client_ptr); | |
561 } | |
544 entry->SetVideoCaptureDevice(std::move(device)); | 562 entry->SetVideoCaptureDevice(std::move(device)); |
545 | 563 |
546 if (entry->stream_type == MEDIA_DESKTOP_VIDEO_CAPTURE) { | 564 if (entry->stream_type == MEDIA_DESKTOP_VIDEO_CAPTURE) { |
547 const media::VideoCaptureSessionId session_id = | 565 const media::VideoCaptureSessionId session_id = |
548 device_start_queue_.front().session_id(); | 566 device_start_queue_.front().session_id(); |
549 DCHECK(session_id != kFakeSessionId); | 567 DCHECK(session_id != kFakeSessionId); |
550 MaybePostDesktopCaptureWindowId(session_id); | 568 MaybePostDesktopCaptureWindowId(session_id); |
551 } | 569 } |
552 | 570 |
553 auto it = photo_request_queue_.begin(); | 571 auto it = photo_request_queue_.begin(); |
554 while (it != photo_request_queue_.end()) { | 572 while (it != photo_request_queue_.end()) { |
555 auto request = it++; | 573 auto request = it++; |
556 DeviceEntry* maybe_entry = GetDeviceEntryBySessionId(request->first); | 574 DeviceEntry* maybe_entry = GetDeviceEntryBySessionId(request->first); |
557 if (maybe_entry && maybe_entry->video_capture_device()) { | 575 if (maybe_entry && maybe_entry->video_capture_device()) { |
558 request->second.Run(maybe_entry->video_capture_device()); | 576 request->second.Run(maybe_entry->video_capture_device()); |
559 photo_request_queue_.erase(request); | 577 photo_request_queue_.erase(request); |
560 } | 578 } |
561 } | 579 } |
562 } | 580 } |
563 | 581 |
564 device_start_queue_.pop_front(); | 582 device_start_queue_.pop_front(); |
565 HandleQueuedStartRequest(); | 583 HandleQueuedStartRequest(); |
566 } | 584 } |
567 | 585 |
568 std::unique_ptr<media::VideoCaptureDevice> | 586 std::unique_ptr<media::VideoCaptureDevice> |
569 VideoCaptureManager::DoStartDeviceCaptureOnDeviceThread( | 587 VideoCaptureManager::DoStartDeviceCaptureOnDeviceThread( |
570 const VideoCaptureDeviceDescriptor& descriptor, | 588 const VideoCaptureDeviceDescriptor& descriptor, |
571 const media::VideoCaptureParams& params, | 589 const media::VideoCaptureParams& params, |
572 std::unique_ptr<VideoCaptureDevice::Client> device_client) { | 590 std::unique_ptr<media::VideoCaptureDeviceClient> device_client) { |
573 SCOPED_UMA_HISTOGRAM_TIMER("Media.VideoCaptureManager.StartDeviceTime"); | 591 SCOPED_UMA_HISTOGRAM_TIMER("Media.VideoCaptureManager.StartDeviceTime"); |
574 DCHECK(IsOnDeviceThread()); | 592 DCHECK(IsOnDeviceThread()); |
575 | 593 |
576 std::unique_ptr<VideoCaptureDevice> video_capture_device; | 594 std::unique_ptr<VideoCaptureDevice> video_capture_device; |
577 video_capture_device = | 595 video_capture_device = |
578 video_capture_device_factory_->CreateDevice(descriptor); | 596 video_capture_device_factory_->CreateDevice(descriptor); |
579 | 597 |
580 if (!video_capture_device) { | 598 if (!video_capture_device) { |
581 device_client->OnError(FROM_HERE, "Could not create capture device"); | 599 device_client->OnError(FROM_HERE, "Could not create capture device"); |
582 return nullptr; | 600 return nullptr; |
583 } | 601 } |
584 | 602 |
603 device_client->SetConsumerLoadObserver(video_capture_device.get()); | |
585 video_capture_device->AllocateAndStart(params, std::move(device_client)); | 604 video_capture_device->AllocateAndStart(params, std::move(device_client)); |
586 return video_capture_device; | 605 return video_capture_device; |
587 } | 606 } |
588 | 607 |
589 std::unique_ptr<media::VideoCaptureDevice> | 608 std::unique_ptr<media::VideoCaptureDevice> |
590 VideoCaptureManager::DoStartTabCaptureOnDeviceThread( | 609 VideoCaptureManager::DoStartTabCaptureOnDeviceThread( |
591 const std::string& id, | 610 const std::string& id, |
592 const media::VideoCaptureParams& params, | 611 const media::VideoCaptureParams& params, |
593 std::unique_ptr<VideoCaptureDevice::Client> device_client) { | 612 std::unique_ptr<media::VideoCaptureDeviceClient> device_client) { |
594 SCOPED_UMA_HISTOGRAM_TIMER("Media.VideoCaptureManager.StartDeviceTime"); | 613 SCOPED_UMA_HISTOGRAM_TIMER("Media.VideoCaptureManager.StartDeviceTime"); |
595 DCHECK(IsOnDeviceThread()); | 614 DCHECK(IsOnDeviceThread()); |
596 | 615 |
597 std::unique_ptr<VideoCaptureDevice> video_capture_device; | 616 std::unique_ptr<VideoCaptureDevice> video_capture_device; |
598 video_capture_device = WebContentsVideoCaptureDevice::Create(id); | 617 video_capture_device = WebContentsVideoCaptureDevice::Create(id); |
599 | 618 |
600 if (!video_capture_device) { | 619 if (!video_capture_device) { |
601 device_client->OnError(FROM_HERE, "Could not create capture device"); | 620 device_client->OnError(FROM_HERE, "Could not create capture device"); |
602 return nullptr; | 621 return nullptr; |
603 } | 622 } |
604 | 623 |
624 device_client->SetConsumerLoadObserver(video_capture_device.get()); | |
miu
2016/12/01 05:25:17
OOC, should we call SetConsumerLoadObserver(nullpt
chfremer
2016/12/02 01:28:28
Again, this is no longer needed with the other sim
| |
605 video_capture_device->AllocateAndStart(params, std::move(device_client)); | 625 video_capture_device->AllocateAndStart(params, std::move(device_client)); |
606 return video_capture_device; | 626 return video_capture_device; |
607 } | 627 } |
608 | 628 |
609 std::unique_ptr<media::VideoCaptureDevice> | 629 std::unique_ptr<media::VideoCaptureDevice> |
610 VideoCaptureManager::DoStartDesktopCaptureOnDeviceThread( | 630 VideoCaptureManager::DoStartDesktopCaptureOnDeviceThread( |
611 const std::string& id, | 631 const std::string& id, |
612 const media::VideoCaptureParams& params, | 632 const media::VideoCaptureParams& params, |
613 std::unique_ptr<VideoCaptureDevice::Client> device_client) { | 633 std::unique_ptr<media::VideoCaptureDeviceClient> device_client) { |
614 SCOPED_UMA_HISTOGRAM_TIMER("Media.VideoCaptureManager.StartDeviceTime"); | 634 SCOPED_UMA_HISTOGRAM_TIMER("Media.VideoCaptureManager.StartDeviceTime"); |
615 DCHECK(IsOnDeviceThread()); | 635 DCHECK(IsOnDeviceThread()); |
616 | 636 |
617 std::unique_ptr<VideoCaptureDevice> video_capture_device; | 637 std::unique_ptr<VideoCaptureDevice> video_capture_device; |
618 #if defined(ENABLE_SCREEN_CAPTURE) | 638 #if defined(ENABLE_SCREEN_CAPTURE) |
619 DesktopMediaID desktop_id = DesktopMediaID::Parse(id); | 639 DesktopMediaID desktop_id = DesktopMediaID::Parse(id); |
620 if (desktop_id.is_null()) { | 640 if (desktop_id.is_null()) { |
621 device_client->OnError(FROM_HERE, "Desktop media ID is null"); | 641 device_client->OnError(FROM_HERE, "Desktop media ID is null"); |
622 return nullptr; | 642 return nullptr; |
623 } | 643 } |
(...skipping 17 matching lines...) Expand all Loading... | |
641 video_capture_device = DesktopCaptureDevice::Create(desktop_id); | 661 video_capture_device = DesktopCaptureDevice::Create(desktop_id); |
642 #endif // defined (OS_ANDROID) | 662 #endif // defined (OS_ANDROID) |
643 } | 663 } |
644 #endif // defined(ENABLE_SCREEN_CAPTURE) | 664 #endif // defined(ENABLE_SCREEN_CAPTURE) |
645 | 665 |
646 if (!video_capture_device) { | 666 if (!video_capture_device) { |
647 device_client->OnError(FROM_HERE, "Could not create capture device"); | 667 device_client->OnError(FROM_HERE, "Could not create capture device"); |
648 return nullptr; | 668 return nullptr; |
649 } | 669 } |
650 | 670 |
671 device_client->SetConsumerLoadObserver(video_capture_device.get()); | |
651 video_capture_device->AllocateAndStart(params, std::move(device_client)); | 672 video_capture_device->AllocateAndStart(params, std::move(device_client)); |
652 return video_capture_device; | 673 return video_capture_device; |
653 } | 674 } |
654 | 675 |
655 void VideoCaptureManager::StartCaptureForClient( | 676 void VideoCaptureManager::StartCaptureForClient( |
656 media::VideoCaptureSessionId session_id, | 677 media::VideoCaptureSessionId session_id, |
657 const media::VideoCaptureParams& params, | 678 const media::VideoCaptureParams& params, |
658 VideoCaptureControllerID client_id, | 679 VideoCaptureControllerID client_id, |
659 VideoCaptureControllerEventHandler* client_handler, | 680 VideoCaptureControllerEventHandler* client_handler, |
660 const DoneCB& done_cb) { | 681 const DoneCB& done_cb) { |
(...skipping 625 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1286 if (!device_in_queue) { | 1307 if (!device_in_queue) { |
1287 // Session ID is only valid for Screen capture. So we can fake it to | 1308 // Session ID is only valid for Screen capture. So we can fake it to |
1288 // resume video capture devices here. | 1309 // resume video capture devices here. |
1289 QueueStartDevice(kFakeSessionId, entry.get(), entry->parameters); | 1310 QueueStartDevice(kFakeSessionId, entry.get(), entry->parameters); |
1290 } | 1311 } |
1291 } | 1312 } |
1292 } | 1313 } |
1293 #endif // defined(OS_ANDROID) | 1314 #endif // defined(OS_ANDROID) |
1294 | 1315 |
1295 } // namespace content | 1316 } // namespace content |
OLD | NEW |