Commit 41c3ad10 authored by Guido Urdaneta's avatar Guido Urdaneta Committed by Commit Bot

Support the groupId property in MediaStreamTrack.getSettings()

Bug: 834281
Change-Id: I5ef11a3343e5b534bee6e088a36fb3365bd218e8
Reviewed-on: https://chromium-review.googlesource.com/1019323
Commit-Queue: Guido Urdaneta <guidou@chromium.org>
Reviewed-by: default avatarPhilip Jägenstedt <foolip@chromium.org>
Reviewed-by: default avatarHarald Alvestrand <hta@chromium.org>
Cr-Commit-Position: refs/heads/master@{#555759}
parent ae817e6c
...@@ -7,6 +7,7 @@ ...@@ -7,6 +7,7 @@
#include <stddef.h> #include <stddef.h>
#include <algorithm> #include <algorithm>
#include <map>
#include <utility> #include <utility>
#include "base/location.h" #include "base/location.h"
...@@ -1158,6 +1159,8 @@ blink::WebMediaStreamSource UserMediaProcessor::FindOrInitializeSourceObject( ...@@ -1158,6 +1159,8 @@ blink::WebMediaStreamSource UserMediaProcessor::FindOrInitializeSourceObject(
source.Initialize(blink::WebString::FromUTF8(device.id), type, source.Initialize(blink::WebString::FromUTF8(device.id), type,
blink::WebString::FromUTF8(device.name), blink::WebString::FromUTF8(device.name),
false /* remote */); false /* remote */);
if (device.group_id)
source.SetGroupId(blink::WebString::FromUTF8(*device.group_id));
DVLOG(1) << "Initialize source object :" DVLOG(1) << "Initialize source object :"
<< "id = " << source.Id().Utf8() << "id = " << source.Id().Utf8()
......
...@@ -57,4 +57,22 @@ ...@@ -57,4 +57,22 @@
}); });
}); });
}, 'A device can be opened twice with different resolutions'); }, 'A device can be opened twice with different resolutions');
promise_test(t => {
return navigator.mediaDevices.enumerateDevices().then(async devices => {
for (var device of devices) {
if (device.kind == "audiooutput")
continue;
var device_id_constraint = {deviceId: {exact: device.deviceId}};
var constraints = device.kind == "audioinput"
? {audio: device_id_constraint}
: {video: device_id_constraint};
var stream = await navigator.mediaDevices.getUserMedia(constraints);
assert_equals(stream.getTracks()[0].getSettings().groupId,
device.groupId);
assert_true(device.groupId.length > 0);
}
});
}, 'groupId is correctly reported by getSettings() for all devices');
</script> </script>
...@@ -116,6 +116,9 @@ class WebMediaStreamSource { ...@@ -116,6 +116,9 @@ class WebMediaStreamSource {
BLINK_PLATFORM_EXPORT WebString GetName() const; BLINK_PLATFORM_EXPORT WebString GetName() const;
BLINK_PLATFORM_EXPORT bool Remote() const; BLINK_PLATFORM_EXPORT bool Remote() const;
BLINK_PLATFORM_EXPORT void SetGroupId(const WebString& group_id);
BLINK_PLATFORM_EXPORT WebString GroupId() const;
BLINK_PLATFORM_EXPORT void SetReadyState(ReadyState); BLINK_PLATFORM_EXPORT void SetReadyState(ReadyState);
BLINK_PLATFORM_EXPORT ReadyState GetReadyState() const; BLINK_PLATFORM_EXPORT ReadyState GetReadyState() const;
......
...@@ -62,6 +62,7 @@ class WebMediaStreamTrack { ...@@ -62,6 +62,7 @@ class WebMediaStreamTrack {
long height = -1; long height = -1;
double aspect_ratio = -1.0; double aspect_ratio = -1.0;
WebString device_id; WebString device_id;
WebString group_id;
FacingMode facing_mode = FacingMode::kNone; FacingMode facing_mode = FacingMode::kNone;
base::Optional<bool> echo_cancellation; base::Optional<bool> echo_cancellation;
base::Optional<bool> auto_gain_control; base::Optional<bool> auto_gain_control;
......
...@@ -435,6 +435,8 @@ void MediaStreamTrack::getSettings(MediaTrackSettings& settings) { ...@@ -435,6 +435,8 @@ void MediaStreamTrack::getSettings(MediaTrackSettings& settings) {
settings.setFocalLengthY(platform_settings.focal_length_y); settings.setFocalLengthY(platform_settings.focal_length_y);
} }
settings.setDeviceId(platform_settings.device_id); settings.setDeviceId(platform_settings.device_id);
if (!platform_settings.group_id.IsNull())
settings.setGroupId(platform_settings.group_id);
if (platform_settings.HasFacingMode()) { if (platform_settings.HasFacingMode()) {
switch (platform_settings.facing_mode) { switch (platform_settings.facing_mode) {
case WebMediaStreamTrack::FacingMode::kUser: case WebMediaStreamTrack::FacingMode::kUser:
......
...@@ -21,8 +21,7 @@ dictionary MediaTrackSettings { ...@@ -21,8 +21,7 @@ dictionary MediaTrackSettings {
// double latency; // double latency;
// long channelCount; // long channelCount;
DOMString deviceId; DOMString deviceId;
// groupId is not implemented. DOMString groupId;
// DOMString groupId;
// Media Capture Depth Stream Extensions // Media Capture Depth Stream Extensions
// https://w3c.github.io/mediacapture-depth/#mediatracksettings-dictionary // https://w3c.github.io/mediacapture-depth/#mediatracksettings-dictionary
// TODO(aleksandar.stojiljkovic): videoKind, depthNear, depthFar, // TODO(aleksandar.stojiljkovic): videoKind, depthNear, depthFar,
......
...@@ -127,6 +127,16 @@ bool WebMediaStreamSource::Remote() const { ...@@ -127,6 +127,16 @@ bool WebMediaStreamSource::Remote() const {
return private_.Get()->Remote(); return private_.Get()->Remote();
} }
void WebMediaStreamSource::SetGroupId(const blink::WebString& group_id) {
DCHECK(!private_.IsNull());
private_->SetGroupId(group_id);
}
WebString WebMediaStreamSource::GroupId() const {
DCHECK(!private_.IsNull());
return private_->GroupId();
}
void WebMediaStreamSource::SetReadyState(ReadyState state) { void WebMediaStreamSource::SetReadyState(ReadyState state) {
DCHECK(!private_.IsNull()); DCHECK(!private_.IsNull());
private_->SetReadyState(static_cast<MediaStreamSource::ReadyState>(state)); private_->SetReadyState(static_cast<MediaStreamSource::ReadyState>(state));
......
...@@ -56,6 +56,10 @@ MediaStreamSource::MediaStreamSource(const String& id, ...@@ -56,6 +56,10 @@ MediaStreamSource::MediaStreamSource(const String& id,
ready_state_(ready_state), ready_state_(ready_state),
requires_consumer_(requires_consumer) {} requires_consumer_(requires_consumer) {}
void MediaStreamSource::SetGroupId(const String& group_id) {
group_id_ = group_id;
}
void MediaStreamSource::SetReadyState(ReadyState ready_state) { void MediaStreamSource::SetReadyState(ReadyState ready_state) {
if (ready_state_ != kReadyStateEnded && ready_state_ != ready_state) { if (ready_state_ != kReadyStateEnded && ready_state_ != ready_state) {
ready_state_ = ready_state; ready_state_ = ready_state;
...@@ -117,6 +121,7 @@ bool MediaStreamSource::RemoveAudioConsumer( ...@@ -117,6 +121,7 @@ bool MediaStreamSource::RemoveAudioConsumer(
void MediaStreamSource::GetSettings(WebMediaStreamTrack::Settings& settings) { void MediaStreamSource::GetSettings(WebMediaStreamTrack::Settings& settings) {
settings.device_id = Id(); settings.device_id = Id();
settings.group_id = GroupId();
if (echo_cancellation_) if (echo_cancellation_)
settings.echo_cancellation = *echo_cancellation_; settings.echo_cancellation = *echo_cancellation_;
......
...@@ -84,6 +84,9 @@ class PLATFORM_EXPORT MediaStreamSource final ...@@ -84,6 +84,9 @@ class PLATFORM_EXPORT MediaStreamSource final
const String& GetName() const { return name_; } const String& GetName() const { return name_; }
bool Remote() const { return remote_; } bool Remote() const { return remote_; }
void SetGroupId(const String& group_id);
const String& GroupId() { return group_id_; }
void SetReadyState(ReadyState); void SetReadyState(ReadyState);
ReadyState GetReadyState() const { return ready_state_; } ReadyState GetReadyState() const { return ready_state_; }
...@@ -138,6 +141,7 @@ class PLATFORM_EXPORT MediaStreamSource final ...@@ -138,6 +141,7 @@ class PLATFORM_EXPORT MediaStreamSource final
String id_; String id_;
StreamType type_; StreamType type_;
String name_; String name_;
String group_id_;
bool remote_; bool remote_;
ReadyState ready_state_; ReadyState ready_state_;
bool requires_consumer_; bool requires_consumer_;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment