Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(226)

Unified Diff: content/renderer/media/user_media_client_impl.cc

Issue 2296393004: Revert of Add groupid for media devices. Group audio devices. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: content/renderer/media/user_media_client_impl.cc
diff --git a/content/renderer/media/user_media_client_impl.cc b/content/renderer/media/user_media_client_impl.cc
index 10122a048a4468a368fd10747996b159811a8868..bda19f7a6c3e87554a2b1f3cea2f253b38287e39 100644
--- a/content/renderer/media/user_media_client_impl.cc
+++ b/content/renderer/media/user_media_client_impl.cc
@@ -467,6 +467,10 @@
void UserMediaClientImpl::FinalizeEnumerateDevices(
MediaDevicesRequestInfo* request) {
+ // All devices are ready for copying. We use a hashed audio output device id
+ // as the group id for input and output audio devices. If an input device
+ // doesn't have an associated output device, we use the input device's own id.
+ // We don't support group id for video devices, that's left empty.
blink::WebVector<blink::WebMediaDeviceInfo>
devices(request->audio_input_devices.size() +
request->video_input_devices.size() +
@@ -475,10 +479,19 @@
const MediaStreamDevice& device = request->audio_input_devices[i].device;
DCHECK_EQ(device.type, MEDIA_DEVICE_AUDIO_CAPTURE);
- devices[i].initialize(blink::WebString::fromUTF8(device.id),
- blink::WebMediaDeviceInfo::MediaDeviceKindAudioInput,
- blink::WebString::fromUTF8(device.name),
- blink::WebString::fromUTF8(device.group_id));
+ // We add an arbitrary character to the device ID in order to avoid the same
+ // group ID for the input and output devices that share the same ID but are
+ // not in the same physical device. This may happen with the default and
+ // communication devices.
+ std::string group_id = base::UintToString(base::Hash(
+ device.matched_output_device_id.empty() ?
+ device.id + "i" :
+ device.matched_output_device_id));
+ devices[i].initialize(
+ blink::WebString::fromUTF8(device.id),
+ blink::WebMediaDeviceInfo::MediaDeviceKindAudioInput,
+ blink::WebString::fromUTF8(device.name),
+ blink::WebString::fromUTF8(group_id));
}
size_t offset = request->audio_input_devices.size();
for (size_t i = 0; i < request->video_input_devices.size(); ++i) {
@@ -498,7 +511,7 @@
blink::WebString::fromUTF8(device.id),
blink::WebMediaDeviceInfo::MediaDeviceKindAudioOutput,
blink::WebString::fromUTF8(device.name),
- blink::WebString::fromUTF8(device.group_id));
+ blink::WebString::fromUTF8(base::UintToString(base::Hash(device.id))));
}
EnumerateDevicesSucceded(&request->media_devices_request, devices);

Powered by Google App Engine
This is Rietveld 408576698