| 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 575 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 586 | 586 |
| 587 std::unique_ptr<media::VideoCaptureDevice> | 587 std::unique_ptr<media::VideoCaptureDevice> |
| 588 VideoCaptureManager::DoStartTabCaptureOnDeviceThread( | 588 VideoCaptureManager::DoStartTabCaptureOnDeviceThread( |
| 589 const std::string& id, | 589 const std::string& id, |
| 590 const media::VideoCaptureParams& params, | 590 const media::VideoCaptureParams& params, |
| 591 std::unique_ptr<VideoCaptureDevice::Client> device_client) { | 591 std::unique_ptr<VideoCaptureDevice::Client> device_client) { |
| 592 SCOPED_UMA_HISTOGRAM_TIMER("Media.VideoCaptureManager.StartDeviceTime"); | 592 SCOPED_UMA_HISTOGRAM_TIMER("Media.VideoCaptureManager.StartDeviceTime"); |
| 593 DCHECK(IsOnDeviceThread()); | 593 DCHECK(IsOnDeviceThread()); |
| 594 | 594 |
| 595 std::unique_ptr<VideoCaptureDevice> video_capture_device; | 595 std::unique_ptr<VideoCaptureDevice> video_capture_device; |
| 596 video_capture_device.reset(WebContentsVideoCaptureDevice::Create(id)); | 596 video_capture_device = WebContentsVideoCaptureDevice::Create(id); |
| 597 | 597 |
| 598 if (!video_capture_device) { | 598 if (!video_capture_device) { |
| 599 device_client->OnError(FROM_HERE, "Could not create capture device"); | 599 device_client->OnError(FROM_HERE, "Could not create capture device"); |
| 600 return nullptr; | 600 return nullptr; |
| 601 } | 601 } |
| 602 | 602 |
| 603 video_capture_device->AllocateAndStart(params, std::move(device_client)); | 603 video_capture_device->AllocateAndStart(params, std::move(device_client)); |
| 604 return video_capture_device; | 604 return video_capture_device; |
| 605 } | 605 } |
| 606 | 606 |
| 607 std::unique_ptr<media::VideoCaptureDevice> | 607 std::unique_ptr<media::VideoCaptureDevice> |
| 608 VideoCaptureManager::DoStartDesktopCaptureOnDeviceThread( | 608 VideoCaptureManager::DoStartDesktopCaptureOnDeviceThread( |
| 609 const std::string& id, | 609 const std::string& id, |
| 610 const media::VideoCaptureParams& params, | 610 const media::VideoCaptureParams& params, |
| 611 std::unique_ptr<VideoCaptureDevice::Client> device_client) { | 611 std::unique_ptr<VideoCaptureDevice::Client> device_client) { |
| 612 SCOPED_UMA_HISTOGRAM_TIMER("Media.VideoCaptureManager.StartDeviceTime"); | 612 SCOPED_UMA_HISTOGRAM_TIMER("Media.VideoCaptureManager.StartDeviceTime"); |
| 613 DCHECK(IsOnDeviceThread()); | 613 DCHECK(IsOnDeviceThread()); |
| 614 | 614 |
| 615 std::unique_ptr<VideoCaptureDevice> video_capture_device; | 615 std::unique_ptr<VideoCaptureDevice> video_capture_device; |
| 616 #if defined(ENABLE_SCREEN_CAPTURE) | 616 #if defined(ENABLE_SCREEN_CAPTURE) |
| 617 DesktopMediaID desktop_id = DesktopMediaID::Parse(id); | 617 DesktopMediaID desktop_id = DesktopMediaID::Parse(id); |
| 618 if (desktop_id.is_null()) { | 618 if (desktop_id.is_null()) { |
| 619 device_client->OnError(FROM_HERE, "Desktop media ID is null"); | 619 device_client->OnError(FROM_HERE, "Desktop media ID is null"); |
| 620 return nullptr; | 620 return nullptr; |
| 621 } | 621 } |
| 622 | 622 |
| 623 if (desktop_id.type == DesktopMediaID::TYPE_WEB_CONTENTS) { | 623 if (desktop_id.type == DesktopMediaID::TYPE_WEB_CONTENTS) { |
| 624 video_capture_device.reset(WebContentsVideoCaptureDevice::Create(id)); | 624 video_capture_device = WebContentsVideoCaptureDevice::Create(id); |
| 625 IncrementDesktopCaptureCounter(TAB_VIDEO_CAPTURER_CREATED); | 625 IncrementDesktopCaptureCounter(TAB_VIDEO_CAPTURER_CREATED); |
| 626 if (desktop_id.audio_share) { | 626 if (desktop_id.audio_share) { |
| 627 IncrementDesktopCaptureCounter(TAB_VIDEO_CAPTURER_CREATED_WITH_AUDIO); | 627 IncrementDesktopCaptureCounter(TAB_VIDEO_CAPTURER_CREATED_WITH_AUDIO); |
| 628 } else { | 628 } else { |
| 629 IncrementDesktopCaptureCounter(TAB_VIDEO_CAPTURER_CREATED_WITHOUT_AUDIO); | 629 IncrementDesktopCaptureCounter(TAB_VIDEO_CAPTURER_CREATED_WITHOUT_AUDIO); |
| 630 } | 630 } |
| 631 } else { | 631 } else { |
| 632 #if defined(OS_ANDROID) | 632 #if defined(OS_ANDROID) |
| 633 video_capture_device = base::MakeUnique<ScreenCaptureDeviceAndroid>(); | 633 video_capture_device = base::MakeUnique<ScreenCaptureDeviceAndroid>(); |
| 634 #else | 634 #else |
| (...skipping 650 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1285 if (!device_in_queue) { | 1285 if (!device_in_queue) { |
| 1286 // Session ID is only valid for Screen capture. So we can fake it to | 1286 // Session ID is only valid for Screen capture. So we can fake it to |
| 1287 // resume video capture devices here. | 1287 // resume video capture devices here. |
| 1288 QueueStartDevice(kFakeSessionId, entry.get(), entry->parameters); | 1288 QueueStartDevice(kFakeSessionId, entry.get(), entry->parameters); |
| 1289 } | 1289 } |
| 1290 } | 1290 } |
| 1291 } | 1291 } |
| 1292 #endif // defined(OS_ANDROID) | 1292 #endif // defined(OS_ANDROID) |
| 1293 | 1293 |
| 1294 } // namespace content | 1294 } // namespace content |
| OLD | NEW |