| 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/media/user_media_client_impl.h" | 5 #include "content/renderer/media/user_media_client_impl.h" |
| 6 | 6 |
| 7 #include <stddef.h> | 7 #include <stddef.h> |
| 8 | 8 |
| 9 #include <utility> | 9 #include <utility> |
| 10 #include <vector> | 10 #include <vector> |
| (...skipping 460 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 471 // as the group id for input and output audio devices. If an input device | 471 // as the group id for input and output audio devices. If an input device |
| 472 // doesn't have an associated output device, we use the input device's own id. | 472 // doesn't have an associated output device, we use the input device's own id. |
| 473 // We don't support group id for video devices, that's left empty. | 473 // We don't support group id for video devices, that's left empty. |
| 474 blink::WebVector<blink::WebMediaDeviceInfo> | 474 blink::WebVector<blink::WebMediaDeviceInfo> |
| 475 devices(request->audio_input_devices.size() + | 475 devices(request->audio_input_devices.size() + |
| 476 request->video_input_devices.size() + | 476 request->video_input_devices.size() + |
| 477 request->audio_output_devices.size()); | 477 request->audio_output_devices.size()); |
| 478 for (size_t i = 0; i < request->audio_input_devices.size(); ++i) { | 478 for (size_t i = 0; i < request->audio_input_devices.size(); ++i) { |
| 479 const MediaStreamDevice& device = request->audio_input_devices[i].device; | 479 const MediaStreamDevice& device = request->audio_input_devices[i].device; |
| 480 DCHECK_EQ(device.type, MEDIA_DEVICE_AUDIO_CAPTURE); | 480 DCHECK_EQ(device.type, MEDIA_DEVICE_AUDIO_CAPTURE); |
| 481 |
| 482 // We add an arbitrary character to the device ID in order to avoid the same |
| 483 // group ID for the input and output devices that share the same ID but are |
| 484 // not in the same physical device. This may happen with the default and |
| 485 // communication devices. |
| 481 std::string group_id = base::UintToString(base::Hash( | 486 std::string group_id = base::UintToString(base::Hash( |
| 482 !device.matched_output_device_id.empty() ? | 487 device.matched_output_device_id.empty() ? |
| 483 device.matched_output_device_id : | 488 device.id + "i" : |
| 484 device.id)); | 489 device.matched_output_device_id)); |
| 485 devices[i].initialize( | 490 devices[i].initialize( |
| 486 blink::WebString::fromUTF8(device.id), | 491 blink::WebString::fromUTF8(device.id), |
| 487 blink::WebMediaDeviceInfo::MediaDeviceKindAudioInput, | 492 blink::WebMediaDeviceInfo::MediaDeviceKindAudioInput, |
| 488 blink::WebString::fromUTF8(device.name), | 493 blink::WebString::fromUTF8(device.name), |
| 489 blink::WebString::fromUTF8(group_id)); | 494 blink::WebString::fromUTF8(group_id)); |
| 490 } | 495 } |
| 491 size_t offset = request->audio_input_devices.size(); | 496 size_t offset = request->audio_input_devices.size(); |
| 492 for (size_t i = 0; i < request->video_input_devices.size(); ++i) { | 497 for (size_t i = 0; i < request->video_input_devices.size(); ++i) { |
| 493 const MediaStreamDevice& device = request->video_input_devices[i].device; | 498 const MediaStreamDevice& device = request->video_input_devices[i].device; |
| 494 DCHECK_EQ(device.type, MEDIA_DEVICE_VIDEO_CAPTURE); | 499 DCHECK_EQ(device.type, MEDIA_DEVICE_VIDEO_CAPTURE); |
| (...skipping 699 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1194 | 1199 |
| 1195 bool UserMediaClientImpl::UserMediaRequestInfo::HasPendingSources() const { | 1200 bool UserMediaClientImpl::UserMediaRequestInfo::HasPendingSources() const { |
| 1196 return !sources_waiting_for_callback_.empty(); | 1201 return !sources_waiting_for_callback_.empty(); |
| 1197 } | 1202 } |
| 1198 | 1203 |
| 1199 void UserMediaClientImpl::OnDestruct() { | 1204 void UserMediaClientImpl::OnDestruct() { |
| 1200 delete this; | 1205 delete this; |
| 1201 } | 1206 } |
| 1202 | 1207 |
| 1203 } // namespace content | 1208 } // namespace content |
| OLD | NEW |