| 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/renderer/pepper/pepper_media_device_manager.h" | 5 #include "content/renderer/pepper/pepper_media_device_manager.h" |
| 6 | 6 |
| 7 #include "base/location.h" | 7 #include "base/location.h" |
| 8 #include "base/logging.h" | 8 #include "base/logging.h" |
| 9 #include "base/single_thread_task_runner.h" | 9 #include "base/single_thread_task_runner.h" |
| 10 #include "base/threading/thread_task_runner_handle.h" | 10 #include "base/threading/thread_task_runner_handle.h" |
| 11 #include "content/renderer/media/media_devices_event_dispatcher.h" | 11 #include "content/renderer/media/media_devices_event_dispatcher.h" |
| 12 #include "content/renderer/media/media_stream_dispatcher.h" | 12 #include "content/renderer/media/media_stream_dispatcher.h" |
| 13 #include "content/renderer/render_frame_impl.h" | 13 #include "content/renderer/render_frame_impl.h" |
| 14 #include "media/media_features.h" | 14 #include "media/media_features.h" |
| 15 #include "ppapi/shared_impl/ppb_device_ref_shared.h" | 15 #include "ppapi/shared_impl/ppb_device_ref_shared.h" |
| 16 #include "services/service_manager/public/cpp/interface_provider.h" | 16 #include "services/service_manager/public/cpp/interface_provider.h" |
| 17 | 17 |
| 18 namespace content { | 18 namespace content { |
| 19 | 19 |
| 20 namespace { | 20 namespace { |
| 21 | 21 |
| 22 PP_DeviceType_Dev FromMediaDeviceType(MediaDeviceType type) { | 22 PP_DeviceType_Dev FromMediaDeviceType(MediaDeviceType type) { |
| 23 switch (type) { | 23 switch (type) { |
| 24 case MEDIA_DEVICE_TYPE_AUDIO_INPUT: | 24 case MEDIA_DEVICE_TYPE_AUDIO_INPUT: |
| 25 return PP_DEVICETYPE_DEV_AUDIOCAPTURE; | 25 return PP_DEVICETYPE_DEV_AUDIOCAPTURE; |
| 26 case MEDIA_DEVICE_TYPE_VIDEO_INPUT: | 26 case MEDIA_DEVICE_TYPE_VIDEO_INPUT: |
| 27 return PP_DEVICETYPE_DEV_VIDEOCAPTURE; | 27 return PP_DEVICETYPE_DEV_VIDEOCAPTURE; |
| 28 case MEDIA_DEVICE_TYPE_AUDIO_OUTPUT: |
| 29 return PP_DEVICETYPE_DEV_AUDIOOUTPUT; |
| 28 default: | 30 default: |
| 29 NOTREACHED(); | 31 NOTREACHED(); |
| 30 return PP_DEVICETYPE_DEV_INVALID; | 32 return PP_DEVICETYPE_DEV_INVALID; |
| 31 } | 33 } |
| 32 } | 34 } |
| 33 | 35 |
| 34 MediaDeviceType ToMediaDeviceType(PP_DeviceType_Dev type) { | 36 MediaDeviceType ToMediaDeviceType(PP_DeviceType_Dev type) { |
| 35 switch (type) { | 37 switch (type) { |
| 36 case PP_DEVICETYPE_DEV_AUDIOCAPTURE: | 38 case PP_DEVICETYPE_DEV_AUDIOCAPTURE: |
| 37 return MEDIA_DEVICE_TYPE_AUDIO_INPUT; | 39 return MEDIA_DEVICE_TYPE_AUDIO_INPUT; |
| 38 case PP_DEVICETYPE_DEV_VIDEOCAPTURE: | 40 case PP_DEVICETYPE_DEV_VIDEOCAPTURE: |
| 39 return MEDIA_DEVICE_TYPE_VIDEO_INPUT; | 41 return MEDIA_DEVICE_TYPE_VIDEO_INPUT; |
| 42 case PP_DEVICETYPE_DEV_AUDIOOUTPUT: |
| 43 return MEDIA_DEVICE_TYPE_AUDIO_OUTPUT; |
| 40 default: | 44 default: |
| 41 NOTREACHED(); | 45 NOTREACHED(); |
| 42 return MEDIA_DEVICE_TYPE_AUDIO_OUTPUT; | 46 return MEDIA_DEVICE_TYPE_AUDIO_OUTPUT; |
| 43 } | 47 } |
| 44 } | 48 } |
| 45 | 49 |
| 46 ppapi::DeviceRefData FromMediaDeviceInfo(MediaDeviceType type, | 50 ppapi::DeviceRefData FromMediaDeviceInfo(MediaDeviceType type, |
| 47 const MediaDeviceInfo& info) { | 51 const MediaDeviceInfo& info) { |
| 48 ppapi::DeviceRefData data; | 52 ppapi::DeviceRefData data; |
| 49 data.id = info.device_id; | 53 data.id = info.device_id; |
| (...skipping 25 matching lines...) Expand all Loading... |
| 75 DCHECK(open_callbacks_.empty()); | 79 DCHECK(open_callbacks_.empty()); |
| 76 } | 80 } |
| 77 | 81 |
| 78 void PepperMediaDeviceManager::EnumerateDevices( | 82 void PepperMediaDeviceManager::EnumerateDevices( |
| 79 PP_DeviceType_Dev type, | 83 PP_DeviceType_Dev type, |
| 80 const GURL& document_url, | 84 const GURL& document_url, |
| 81 const DevicesCallback& callback) { | 85 const DevicesCallback& callback) { |
| 82 #if BUILDFLAG(ENABLE_WEBRTC) | 86 #if BUILDFLAG(ENABLE_WEBRTC) |
| 83 bool request_audio_input = type == PP_DEVICETYPE_DEV_AUDIOCAPTURE; | 87 bool request_audio_input = type == PP_DEVICETYPE_DEV_AUDIOCAPTURE; |
| 84 bool request_video_input = type == PP_DEVICETYPE_DEV_VIDEOCAPTURE; | 88 bool request_video_input = type == PP_DEVICETYPE_DEV_VIDEOCAPTURE; |
| 85 CHECK(request_audio_input || request_video_input); | 89 bool request_audio_output = type == PP_DEVICETYPE_DEV_AUDIOOUTPUT; |
| 90 CHECK(request_audio_input || request_video_input || request_audio_output); |
| 86 GetMediaDevicesDispatcher()->EnumerateDevices( | 91 GetMediaDevicesDispatcher()->EnumerateDevices( |
| 87 request_audio_input, request_video_input, false /* audio_output */, | 92 request_audio_input, request_video_input, request_audio_output, |
| 88 url::Origin(document_url.GetOrigin()), | 93 url::Origin(document_url.GetOrigin()), |
| 89 base::Bind(&PepperMediaDeviceManager::DevicesEnumerated, AsWeakPtr(), | 94 base::Bind(&PepperMediaDeviceManager::DevicesEnumerated, AsWeakPtr(), |
| 90 callback, ToMediaDeviceType(type))); | 95 callback, ToMediaDeviceType(type))); |
| 91 #else | 96 #else |
| 92 base::ThreadTaskRunnerHandle::Get()->PostTask( | 97 base::ThreadTaskRunnerHandle::Get()->PostTask( |
| 93 FROM_HERE, base::Bind(&PepperMediaDeviceManager::DevicesEnumerated, | 98 FROM_HERE, base::Bind(&PepperMediaDeviceManager::DevicesEnumerated, |
| 94 AsWeakPtr(), callback, ToMediaDeviceType(type), | 99 AsWeakPtr(), callback, ToMediaDeviceType(type), |
| 95 std::vector<MediaDeviceInfoArray>())); | 100 std::vector<MediaDeviceInfoArray>())); |
| 96 #endif | 101 #endif |
| 97 } | 102 } |
| (...skipping 169 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 267 } | 272 } |
| 268 | 273 |
| 269 return media_devices_dispatcher_; | 274 return media_devices_dispatcher_; |
| 270 } | 275 } |
| 271 | 276 |
| 272 void PepperMediaDeviceManager::OnDestruct() { | 277 void PepperMediaDeviceManager::OnDestruct() { |
| 273 delete this; | 278 delete this; |
| 274 } | 279 } |
| 275 | 280 |
| 276 } // namespace content | 281 } // namespace content |
| OLD | NEW |