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 22 matching lines...) Expand all Loading... | |
33 #include "content/public/browser/desktop_media_id.h" | 33 #include "content/public/browser/desktop_media_id.h" |
34 #include "content/public/common/media_stream_request.h" | 34 #include "content/public/common/media_stream_request.h" |
35 #include "media/base/bind_to_current_loop.h" | 35 #include "media/base/bind_to_current_loop.h" |
36 #include "media/base/media_switches.h" | 36 #include "media/base/media_switches.h" |
37 #include "media/capture/video/video_capture_buffer_pool_impl.h" | 37 #include "media/capture/video/video_capture_buffer_pool_impl.h" |
38 #include "media/capture/video/video_capture_buffer_tracker_factory_impl.h" | 38 #include "media/capture/video/video_capture_buffer_tracker_factory_impl.h" |
39 #include "media/capture/video/video_capture_device.h" | 39 #include "media/capture/video/video_capture_device.h" |
40 #include "media/capture/video/video_capture_device_client.h" | 40 #include "media/capture/video/video_capture_device_client.h" |
41 #include "media/capture/video/video_capture_device_factory.h" | 41 #include "media/capture/video/video_capture_device_factory.h" |
42 | 42 |
43 #if defined(ENABLE_SCREEN_CAPTURE) && !defined(OS_ANDROID) | 43 #if BUILDFLAG(ENABLE_WEBRTC) && !defined(OS_ANDROID) |
miu
2017/01/10 23:27:49
Both (per prior e-mail on this CR):
#if defined
byungchul
2017/01/10 23:48:33
Done.
| |
44 #include "content/browser/media/capture/desktop_capture_device.h" | 44 #include "content/browser/media/capture/desktop_capture_device.h" |
45 #if defined(USE_AURA) | 45 #endif |
46 | |
47 #if defined(ENABLE_SCREEN_CAPTURE) && !defined(OS_ANDROID) && defined(USE_AURA) | |
miu
2017/01/10 23:27:50
!defined(OS_ANDROID) is not needed (since AURA is
| |
46 #include "content/browser/media/capture/desktop_capture_device_aura.h" | 48 #include "content/browser/media/capture/desktop_capture_device_aura.h" |
47 #endif | 49 #endif |
48 #endif | |
49 | 50 |
50 #if defined(ENABLE_SCREEN_CAPTURE) && defined(OS_ANDROID) | 51 #if defined(ENABLE_SCREEN_CAPTURE) && defined(OS_ANDROID) |
51 #include "content/browser/media/capture/screen_capture_device_android.h" | 52 #include "content/browser/media/capture/screen_capture_device_android.h" |
52 #endif | 53 #endif |
53 | 54 |
54 namespace { | 55 namespace { |
55 | 56 |
56 class VideoFrameConsumerFeedbackObserverOnTaskRunner | 57 class VideoFrameConsumerFeedbackObserverOnTaskRunner |
57 : public media::VideoFrameConsumerFeedbackObserver { | 58 : public media::VideoFrameConsumerFeedbackObserver { |
58 public: | 59 public: |
(...skipping 617 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
676 | 677 |
677 std::unique_ptr<media::VideoCaptureDevice> | 678 std::unique_ptr<media::VideoCaptureDevice> |
678 VideoCaptureManager::DoStartDesktopCaptureOnDeviceThread( | 679 VideoCaptureManager::DoStartDesktopCaptureOnDeviceThread( |
679 const std::string& id, | 680 const std::string& id, |
680 const media::VideoCaptureParams& params, | 681 const media::VideoCaptureParams& params, |
681 std::unique_ptr<VideoCaptureDevice::Client> device_client) { | 682 std::unique_ptr<VideoCaptureDevice::Client> device_client) { |
682 SCOPED_UMA_HISTOGRAM_TIMER("Media.VideoCaptureManager.StartDeviceTime"); | 683 SCOPED_UMA_HISTOGRAM_TIMER("Media.VideoCaptureManager.StartDeviceTime"); |
683 DCHECK(IsOnDeviceThread()); | 684 DCHECK(IsOnDeviceThread()); |
684 | 685 |
685 std::unique_ptr<VideoCaptureDevice> video_capture_device; | 686 std::unique_ptr<VideoCaptureDevice> video_capture_device; |
686 #if defined(ENABLE_SCREEN_CAPTURE) | |
687 DesktopMediaID desktop_id = DesktopMediaID::Parse(id); | 687 DesktopMediaID desktop_id = DesktopMediaID::Parse(id); |
688 if (desktop_id.is_null()) { | 688 if (desktop_id.is_null()) { |
689 device_client->OnError(FROM_HERE, "Desktop media ID is null"); | 689 device_client->OnError(FROM_HERE, "Desktop media ID is null"); |
690 return nullptr; | 690 return nullptr; |
691 } | 691 } |
692 | 692 |
693 #if defined(ENABLE_SCREEN_CAPTURE) | |
miu
2017/01/10 23:27:49
Let's move this back up to where it was, given pre
byungchul
2017/01/10 23:48:33
Done.
| |
693 if (desktop_id.type == DesktopMediaID::TYPE_WEB_CONTENTS) { | 694 if (desktop_id.type == DesktopMediaID::TYPE_WEB_CONTENTS) { |
694 #if defined(OS_LINUX) || defined(OS_MACOSX) || defined(OS_WIN) | 695 #if defined(OS_LINUX) || defined(OS_MACOSX) || defined(OS_WIN) |
695 video_capture_device = WebContentsVideoCaptureDevice::Create(id); | 696 video_capture_device = WebContentsVideoCaptureDevice::Create(id); |
696 IncrementDesktopCaptureCounter(TAB_VIDEO_CAPTURER_CREATED); | 697 IncrementDesktopCaptureCounter(TAB_VIDEO_CAPTURER_CREATED); |
697 if (desktop_id.audio_share) { | 698 if (desktop_id.audio_share) { |
698 IncrementDesktopCaptureCounter(TAB_VIDEO_CAPTURER_CREATED_WITH_AUDIO); | 699 IncrementDesktopCaptureCounter(TAB_VIDEO_CAPTURER_CREATED_WITH_AUDIO); |
699 } else { | 700 } else { |
700 IncrementDesktopCaptureCounter(TAB_VIDEO_CAPTURER_CREATED_WITHOUT_AUDIO); | 701 IncrementDesktopCaptureCounter(TAB_VIDEO_CAPTURER_CREATED_WITHOUT_AUDIO); |
701 } | 702 } |
702 #endif | 703 #endif |
703 } else { | 704 } else { |
704 #if defined(OS_ANDROID) | 705 #if defined(OS_ANDROID) |
705 video_capture_device = base::MakeUnique<ScreenCaptureDeviceAndroid>(); | 706 video_capture_device = base::MakeUnique<ScreenCaptureDeviceAndroid>(); |
706 #else | 707 #else |
707 #if defined(USE_AURA) | 708 #if defined(USE_AURA) |
708 video_capture_device = DesktopCaptureDeviceAura::Create(desktop_id); | 709 video_capture_device = DesktopCaptureDeviceAura::Create(desktop_id); |
709 #endif // defined(USE_AURA) | 710 #endif // defined(USE_AURA) |
710 if (!video_capture_device) | |
711 video_capture_device = DesktopCaptureDevice::Create(desktop_id); | |
712 #endif // defined (OS_ANDROID) | 711 #endif // defined (OS_ANDROID) |
713 } | 712 } |
714 #endif // defined(ENABLE_SCREEN_CAPTURE) | 713 #endif // defined(ENABLE_SCREEN_CAPTURE) |
715 | 714 |
715 #if BUILDFLAG(ENABLE_WEBRTC) && !defined(OS_ANDROID) | |
miu
2017/01/10 23:27:49
...and move this up so that it is within the ENABL
byungchul
2017/01/10 23:48:33
Done.
| |
716 if (!video_capture_device) | |
717 video_capture_device = DesktopCaptureDevice::Create(desktop_id); | |
718 #endif // BUILDFLAG(ENABLE_WEBRTC) | |
719 | |
716 if (!video_capture_device) { | 720 if (!video_capture_device) { |
717 device_client->OnError(FROM_HERE, "Could not create capture device"); | 721 device_client->OnError(FROM_HERE, "Could not create capture device"); |
718 return nullptr; | 722 return nullptr; |
719 } | 723 } |
720 | 724 |
721 video_capture_device->AllocateAndStart(params, std::move(device_client)); | 725 video_capture_device->AllocateAndStart(params, std::move(device_client)); |
722 return video_capture_device; | 726 return video_capture_device; |
723 } | 727 } |
724 | 728 |
725 void VideoCaptureManager::StartCaptureForClient( | 729 void VideoCaptureManager::StartCaptureForClient( |
(...skipping 494 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1220 | 1224 |
1221 devices_.emplace_back( | 1225 devices_.emplace_back( |
1222 new DeviceEntry(device_info.type, device_info.id, params)); | 1226 new DeviceEntry(device_info.type, device_info.id, params)); |
1223 return devices_.back().get(); | 1227 return devices_.back().get(); |
1224 } | 1228 } |
1225 | 1229 |
1226 void VideoCaptureManager::SetDesktopCaptureWindowIdOnDeviceThread( | 1230 void VideoCaptureManager::SetDesktopCaptureWindowIdOnDeviceThread( |
1227 media::VideoCaptureDevice* device, | 1231 media::VideoCaptureDevice* device, |
1228 gfx::NativeViewId window_id) { | 1232 gfx::NativeViewId window_id) { |
1229 DCHECK(IsOnDeviceThread()); | 1233 DCHECK(IsOnDeviceThread()); |
1230 #if defined(ENABLE_SCREEN_CAPTURE) && !defined(OS_ANDROID) | 1234 #if BUILDFLAG(ENABLE_WEBRTC) && !defined(OS_ANDROID) |
1231 DesktopCaptureDevice* desktop_device = | 1235 DesktopCaptureDevice* desktop_device = |
1232 static_cast<DesktopCaptureDevice*>(device); | 1236 static_cast<DesktopCaptureDevice*>(device); |
1233 desktop_device->SetNotificationWindowId(window_id); | 1237 desktop_device->SetNotificationWindowId(window_id); |
1234 VLOG(2) << "Screen capture notification window passed on device thread."; | 1238 VLOG(2) << "Screen capture notification window passed on device thread."; |
1235 #endif | 1239 #endif |
1236 } | 1240 } |
1237 | 1241 |
1238 void VideoCaptureManager::DoGetPhotoCapabilities( | 1242 void VideoCaptureManager::DoGetPhotoCapabilities( |
1239 VideoCaptureDevice::GetPhotoCapabilitiesCallback callback, | 1243 VideoCaptureDevice::GetPhotoCapabilitiesCallback callback, |
1240 VideoCaptureDevice* device) { | 1244 VideoCaptureDevice* device) { |
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1321 if (!device_in_queue) { | 1325 if (!device_in_queue) { |
1322 // Session ID is only valid for Screen capture. So we can fake it to | 1326 // Session ID is only valid for Screen capture. So we can fake it to |
1323 // resume video capture devices here. | 1327 // resume video capture devices here. |
1324 QueueStartDevice(kFakeSessionId, entry.get(), entry->parameters); | 1328 QueueStartDevice(kFakeSessionId, entry.get(), entry->parameters); |
1325 } | 1329 } |
1326 } | 1330 } |
1327 } | 1331 } |
1328 #endif // defined(OS_ANDROID) | 1332 #endif // defined(OS_ANDROID) |
1329 | 1333 |
1330 } // namespace content | 1334 } // namespace content |
OLD | NEW |