Skip to content

Commit

Permalink
Introduce InputDeviceInfo interface
Browse files Browse the repository at this point in the history
InputDeviceInfo extends MediaDeviceInfo and represents audio and video input
devices. These objects are the result of calling MediaDevices.enumerateDevices().
This interface gives access to the capabilities of the input device it represents
via getCapabilities() method which will be implemented in asubsequent CL.

Intent to implement and ship:
https://groups.google.com/a/chromium.org/forum/#!topic/blink-dev/h4sCuIqb_78

Bug: 817769
Change-Id: Ic9a016a05e622ee02b86d567f64c3ed84f0926c3
Reviewed-on: https://chromium-review.googlesource.com/942961
Commit-Queue: Guido Urdaneta <guidou@chromium.org>
Reviewed-by: Guido Urdaneta <guidou@chromium.org>
Reviewed-by: Philip Jägenstedt <foolip@chromium.org>
Cr-Commit-Position: refs/heads/master@{#541772}
  • Loading branch information
chandanpadhi authored and chromium-wpt-export-bot committed Mar 8, 2018
1 parent c36f238 commit aaea1a4
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 12 deletions.
1 change: 1 addition & 0 deletions interfaces/mediacapture-main.idl
Expand Up @@ -167,6 +167,7 @@ enum MediaDeviceKind {
"videoinput"
};

[Exposed=Window]
interface InputDeviceInfo : MediaDeviceInfo {
MediaTrackCapabilities getCapabilities();
};
Expand Down
13 changes: 9 additions & 4 deletions mediacapture-streams/MediaDevices-IDL-enumerateDevices.html
Expand Up @@ -34,15 +34,20 @@ <h1 class="instructions">Description</h1>
return navigator.mediaDevices.enumerateDevices()
.then(function(list) {
if( list.length > 0 ) {
window._mediaInfo = list[0];
MDI_idl.add_objects({MediaDeviceInfo: ["_mediaInfo"]});
var kind = list[0].kind;
if (kind == "audioinput" ||
kind == "videoinput") {
MDI_idl.add_objects({InputDeviceInfo: [list[0]]});
} else if (kind == "audiooutput" ) {
MDI_idl.add_objects({MediaDeviceInfo: [list[0]]});
}
}

for(const media of list) {
if( media.kind == "audioinput" ||
if (media.kind == "audioinput" ||
media.kind == "videoinput") {
// TODO -- Check InputDeviceInfo IDL, getCapabilities()
} else if ( media.kind == "audiooutput" ) {
} else if (media.kind == "audiooutput" ) {
// TODO -- pass
} else {
assert_unreached("media.kind should be one of 'audioinput', 'videoinput', or 'audiooutput'.")
Expand Down
14 changes: 6 additions & 8 deletions mediacapture-streams/MediaDevices-enumerateDevices.https.html
Expand Up @@ -20,20 +20,18 @@ <h1 class="instructions">Description</h1>
assert_true(undefined !== navigator.mediaDevices.enumerateDevices, "navigator.mediaDevices.enumerateDevices exists");
var p = navigator.mediaDevices.enumerateDevices()
p.then(function(list){
for(let mediainfo of list){
// TODO check the type of mediainfo
for (let mediainfo of list) {
assert_true(undefined !== mediainfo.deviceId, "mediaInfo's deviceId should exist.");
assert_true(undefined !== mediainfo.kind, "mediaInfo's kind should exist.");
assert_true(undefined !== mediainfo.label, "mediaInfo's label should exist.");
assert_true(undefined !== mediainfo.groupId, "mediaInfo's groupId should exist.");
// TODO the values of some of those fields should be empty string by default if no permission has been requested.
if( mediainfo.kind == "audioinput" ||
if ( mediainfo.kind == "audioinput" ||
mediainfo.kind == "videoinput") {
// NOTE ALEX: looks like nobody has implemented that. How can I make it a separate test,
// ... to have better granularity?
// assert_true(undefined !== mediainfo.getCapabilities(), "MediaDeviceInfo.getCapabilities() exists.");
// var cap = mediainfo.getcapabilities();
} else if ( mediainfo.kind !== "audiooutput" ) {
assert_true(mediainfo instanceof InputDeviceInfo);
} else if ( mediainfo.kind == "audiooutput" ) {
assert_true(mediainfo instanceof MediaDeviceInfo);
} else {
assert_unreached("mediainfo.kind should be one of 'audioinput', 'videoinput', or 'audiooutput'.")
}
}
Expand Down

0 comments on commit aaea1a4

Please sign in to comment.