| 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_device_enumeration_event_handler.h" | 5 #include "content/renderer/pepper/pepper_device_enumeration_event_handler.h" |
| 6 | 6 |
| 7 #include "base/logging.h" | 7 #include "base/logging.h" |
| 8 #include "ppapi/shared_impl/ppb_device_ref_shared.h" | 8 #include "ppapi/shared_impl/ppb_device_ref_shared.h" |
| 9 | 9 |
| 10 namespace content { |
| 11 |
| 10 namespace { | 12 namespace { |
| 11 | 13 |
| 12 ppapi::DeviceRefData FromStreamDeviceInfo( | 14 ppapi::DeviceRefData FromStreamDeviceInfo( |
| 13 const media_stream::StreamDeviceInfo& info) { | 15 const media_stream::StreamDeviceInfo& info) { |
| 14 ppapi::DeviceRefData data; | 16 ppapi::DeviceRefData data; |
| 15 data.id = info.device_id; | 17 data.id = info.device_id; |
| 16 data.name = info.name; | 18 data.name = info.name; |
| 17 data.type = PepperDeviceEnumerationEventHandler::FromMediaStreamType( | 19 data.type = PepperDeviceEnumerationEventHandler::FromMediaStreamType( |
| 18 info.stream_type); | 20 info.stream_type); |
| 19 return data; | 21 return data; |
| (...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 85 void PepperDeviceEnumerationEventHandler::OnDeviceOpenFailed(int request_id) { | 87 void PepperDeviceEnumerationEventHandler::OnDeviceOpenFailed(int request_id) { |
| 86 NotifyDeviceOpened(request_id, false, ""); | 88 NotifyDeviceOpened(request_id, false, ""); |
| 87 } | 89 } |
| 88 | 90 |
| 89 // static | 91 // static |
| 90 media_stream::MediaStreamType | 92 media_stream::MediaStreamType |
| 91 PepperDeviceEnumerationEventHandler::FromPepperDeviceType( | 93 PepperDeviceEnumerationEventHandler::FromPepperDeviceType( |
| 92 PP_DeviceType_Dev type) { | 94 PP_DeviceType_Dev type) { |
| 93 switch (type) { | 95 switch (type) { |
| 94 case PP_DEVICETYPE_DEV_INVALID: | 96 case PP_DEVICETYPE_DEV_INVALID: |
| 95 return content::MEDIA_STREAM_DEVICE_TYPE_NO_SERVICE; | 97 return MEDIA_STREAM_DEVICE_TYPE_NO_SERVICE; |
| 96 case PP_DEVICETYPE_DEV_AUDIOCAPTURE: | 98 case PP_DEVICETYPE_DEV_AUDIOCAPTURE: |
| 97 return content::MEDIA_STREAM_DEVICE_TYPE_AUDIO_CAPTURE; | 99 return MEDIA_STREAM_DEVICE_TYPE_AUDIO_CAPTURE; |
| 98 case PP_DEVICETYPE_DEV_VIDEOCAPTURE: | 100 case PP_DEVICETYPE_DEV_VIDEOCAPTURE: |
| 99 return content::MEDIA_STREAM_DEVICE_TYPE_VIDEO_CAPTURE; | 101 return MEDIA_STREAM_DEVICE_TYPE_VIDEO_CAPTURE; |
| 100 default: | 102 default: |
| 101 NOTREACHED(); | 103 NOTREACHED(); |
| 102 return content::MEDIA_STREAM_DEVICE_TYPE_NO_SERVICE; | 104 return MEDIA_STREAM_DEVICE_TYPE_NO_SERVICE; |
| 103 } | 105 } |
| 104 } | 106 } |
| 105 | 107 |
| 106 // static | 108 // static |
| 107 PP_DeviceType_Dev PepperDeviceEnumerationEventHandler::FromMediaStreamType( | 109 PP_DeviceType_Dev PepperDeviceEnumerationEventHandler::FromMediaStreamType( |
| 108 media_stream::MediaStreamType type) { | 110 media_stream::MediaStreamType type) { |
| 109 switch (type) { | 111 switch (type) { |
| 110 case content::MEDIA_STREAM_DEVICE_TYPE_NO_SERVICE: | 112 case MEDIA_STREAM_DEVICE_TYPE_NO_SERVICE: |
| 111 return PP_DEVICETYPE_DEV_INVALID; | 113 return PP_DEVICETYPE_DEV_INVALID; |
| 112 case content::MEDIA_STREAM_DEVICE_TYPE_AUDIO_CAPTURE: | 114 case MEDIA_STREAM_DEVICE_TYPE_AUDIO_CAPTURE: |
| 113 return PP_DEVICETYPE_DEV_AUDIOCAPTURE; | 115 return PP_DEVICETYPE_DEV_AUDIOCAPTURE; |
| 114 case content::MEDIA_STREAM_DEVICE_TYPE_VIDEO_CAPTURE: | 116 case MEDIA_STREAM_DEVICE_TYPE_VIDEO_CAPTURE: |
| 115 return PP_DEVICETYPE_DEV_VIDEOCAPTURE; | 117 return PP_DEVICETYPE_DEV_VIDEOCAPTURE; |
| 116 default: | 118 default: |
| 117 NOTREACHED(); | 119 NOTREACHED(); |
| 118 return PP_DEVICETYPE_DEV_INVALID; | 120 return PP_DEVICETYPE_DEV_INVALID; |
| 119 } | 121 } |
| 120 } | 122 } |
| 121 | 123 |
| 122 void PepperDeviceEnumerationEventHandler::NotifyDevicesEnumerated( | 124 void PepperDeviceEnumerationEventHandler::NotifyDevicesEnumerated( |
| 123 int request_id, | 125 int request_id, |
| 124 bool succeeded, | 126 bool succeeded, |
| (...skipping 27 matching lines...) Expand all Loading... |
| 152 if (iter == open_callbacks_.end()) { | 154 if (iter == open_callbacks_.end()) { |
| 153 NOTREACHED(); | 155 NOTREACHED(); |
| 154 return; | 156 return; |
| 155 } | 157 } |
| 156 | 158 |
| 157 PepperPluginDelegateImpl::OpenDeviceCallback callback = iter->second; | 159 PepperPluginDelegateImpl::OpenDeviceCallback callback = iter->second; |
| 158 open_callbacks_.erase(iter); | 160 open_callbacks_.erase(iter); |
| 159 | 161 |
| 160 callback.Run(request_id, succeeded, label); | 162 callback.Run(request_id, succeeded, label); |
| 161 } | 163 } |
| 164 |
| 165 } // namespace content |
| OLD | NEW |