Commit 75c6c086 authored by Guido Urdaneta's avatar Guido Urdaneta Committed by Commit Bot

Wire the resizeMode property to the constraints parsing mechanism.

This CL adds resizeMode support for MediaStreamTrack.getConstraints()
and marks resizeMode as a supported constrainable property.

Support for getUserMedia(), applyConstraints() and getCapabilities()
will be added in follow-up CLs in this series.

Intent to Ship:
https://groups.google.com/a/chromium.org/forum/#!topic/blink-dev/V2srjdzRCXE

Bug: 854980
Change-Id: Ia23b8119768ab67ab498f0f8e2267aeb388f9fc3
Reviewed-on: https://chromium-review.googlesource.com/c/1309749Reviewed-by: default avatarHenrik Boström <hbos@chromium.org>
Reviewed-by: default avatarPhilip Jägenstedt <foolip@chromium.org>
Commit-Queue: Guido Urdaneta <guidou@chromium.org>
Cr-Commit-Position: refs/heads/master@{#606856}
parent 386114b5
<!doctype html>
<html>
<head>
<title>Test navigator.mediaDevices.getSupportedConstraints()</title>
<link rel="help" href="https://w3c.github.io/mediacapture-main/#enumerating-devices">
<meta name='assert' content='Test the getSupportedConstraints() method.'/>
</head>
<body>
<h1 class="instructions">Description</h1>
<p class="instructions">This test checks for the presence of the
<code>navigator.mediaDevices.getSupportedConstraints()</code> method.</p>
<div id='log'></div>
<script src=/resources/testharness.js></script>
<script src=/resources/testharnessreport.js></script>
<script>
"use strict";
test(() => {
assert_inherits(navigator.mediaDevices, "getSupportedConstraints");
assert_equals(typeof navigator.mediaDevices.getSupportedConstraints, "function");
}, "navigator.mediaDevices.getSupportedConstraints exists");
{
const properties = [
"width",
"height",
"aspectRatio",
"frameRate",
"facingMode",
"resizeMode",
"volume",
"sampleRate",
"sampleSize",
"echoCancellation",
"autoGainControl",
"noiseSuppression",
"latency",
"channelCount",
"deviceId",
"groupId"];
properties.forEach(property => {
test(()=>{
const supportedConstraints = navigator.mediaDevices.getSupportedConstraints();
assert_true(supportedConstraints[property]);
}, property + " is supported");
});
}
</script>
</body>
</html>
......@@ -12,6 +12,7 @@ test(function() {
assert_true(supported_constraints.aspectRatio);
assert_true(supported_constraints.frameRate);
assert_true(supported_constraints.facingMode);
assert_true(supported_constraints.resizeMode);
assert_true(supported_constraints.volume);
assert_true(supported_constraints.sampleRate);
assert_true(supported_constraints.sampleSize);
......
......@@ -129,13 +129,21 @@ constraintSyntaxTest('Min/max double', { aspectRatio: { min: 1.5, max: 2.0 }});
constraintSyntaxTestWithChange('Exact unwrapped double',
{ aspectRatio: { exact: 1.5 } }, { aspectRatio: 1.5 });
constraintSyntaxTest('Simple String', { facingMode: "user1" });
constraintSyntaxTest('Ideal String', { facingMode: { ideal: "user2" }});
constraintSyntaxTest('Multiple String in Brackets', { facingMode: { ideal: ["user3", "left3"]}});
constraintSyntaxTest('Multiple Bracketed Naked String', { facingMode: ["user4", "left4"] });
constraintSyntaxTestWithChange('Single Bracketed string unwrapped',
constraintSyntaxTest('Simple facingMode string', { facingMode: "user1" });
constraintSyntaxTest('Ideal facingMode string', { facingMode: { ideal: "user2" }});
constraintSyntaxTest('Multiple facingMode string in brackets', { facingMode: { ideal: ["user3", "left3"]}});
constraintSyntaxTest('Multiple bracketed naked facingMode string', { facingMode: ["user4", "left4"] });
constraintSyntaxTestWithChange('Single bracketed facingMode string unwrapped',
{ 'facingMode': ["user5"]}, { facingMode: "user5" });
constraintSyntaxTest('Both Ideal and Exact string', { facingMode: { ideal: "user6", exact: "left6" }});
constraintSyntaxTest('Both ideal and exact facingMode string', { facingMode: { ideal: "user6", exact: "left6" }});
constraintSyntaxTest('Simple resizeMode string', { resizeMode: "none1" });
constraintSyntaxTest('Ideal resizeMode string', { resizeMode: { ideal: "none2" }});
constraintSyntaxTest('Multiple resizeMode string in brackets', { resizeMode: { ideal: ["none3", "crop3"]}});
constraintSyntaxTest('Multiple bracketed naked resizeMode string', { resizeMode: ["none4", "crop4"] });
constraintSyntaxTestWithChange('Single bracketed resizeMode string unwrapped',
{ 'resizeMode': ["none5"]}, { resizeMode: "none5" });
constraintSyntaxTest('Both ideal and exact resizeMode string', { resizeMode: { ideal: "none6", exact: "crop6" }});
constraintSyntaxTest('echoCancellation with simple boolean value', { echoCancellation: true });
constraintSyntaxTest('echoCancellation with ideal boolean value', { echoCancellation: { ideal: true }});
......
......@@ -230,6 +230,7 @@ struct WebMediaTrackConstraintSet {
DoubleConstraint aspect_ratio;
DoubleConstraint frame_rate;
StringConstraint facing_mode;
StringConstraint resize_mode;
DoubleConstraint volume;
LongConstraint sample_rate;
LongConstraint sample_size;
......
......@@ -645,6 +645,10 @@ void CopyConstraintSet(const MediaTrackConstraintSet* constraints_in,
CopyStringConstraint(constraints_in->facingMode(), naked_treatment,
constraint_buffer.facing_mode);
}
if (constraints_in->hasResizeMode()) {
CopyStringConstraint(constraints_in->resizeMode(), naked_treatment,
constraint_buffer.resize_mode);
}
if (constraints_in->hasVolume()) {
CopyDoubleConstraint(constraints_in->volume(), naked_treatment,
constraint_buffer.volume);
......@@ -919,6 +923,8 @@ void ConvertConstraintSet(const WebMediaTrackConstraintSet& input,
output->setFrameRate(ConvertDouble(input.frame_rate, naked_treatment));
if (!input.facing_mode.IsEmpty())
output->setFacingMode(ConvertString(input.facing_mode, naked_treatment));
if (!input.resize_mode.IsEmpty())
output->setResizeMode(ConvertString(input.resize_mode, naked_treatment));
if (!input.volume.IsEmpty())
output->setVolume(ConvertDouble(input.volume, naked_treatment));
if (!input.sample_rate.IsEmpty())
......
......@@ -87,7 +87,8 @@ bool ConstraintSetHasNonImageCapture(
constraint_set->hasChannelCount() || constraint_set->hasDepthFar() ||
constraint_set->hasDepthNear() || constraint_set->hasDeviceId() ||
constraint_set->hasEchoCancellation() ||
constraint_set->hasFacingMode() || constraint_set->hasFocalLengthX() ||
constraint_set->hasFacingMode() || constraint_set->hasResizeMode() ||
constraint_set->hasFocalLengthX() ||
constraint_set->hasFocalLengthY() || constraint_set->hasFrameRate() ||
constraint_set->hasGroupId() || constraint_set->hasHeight() ||
constraint_set->hasLatency() || constraint_set->hasSampleRate() ||
......
......@@ -16,6 +16,7 @@ dictionary MediaTrackConstraintSet {
ConstrainDouble aspectRatio;
ConstrainDouble frameRate;
ConstrainDOMString facingMode;
ConstrainDOMString resizeMode;
ConstrainDouble volume;
ConstrainLong sampleRate;
ConstrainLong sampleSize;
......
......@@ -13,6 +13,7 @@ dictionary MediaTrackSupportedConstraints {
boolean aspectRatio = true;
boolean frameRate = true;
boolean facingMode = true;
boolean resizeMode = true;
boolean volume = true;
boolean sampleRate = true;
boolean sampleSize = true;
......
......@@ -340,6 +340,7 @@ WebMediaTrackConstraintSet::WebMediaTrackConstraintSet()
aspect_ratio("aspectRatio"),
frame_rate("frameRate"),
facing_mode("facingMode"),
resize_mode("resizeMode"),
volume("volume"),
sample_rate("sampleRate"),
sample_size("sampleSize"),
......@@ -401,6 +402,7 @@ std::vector<const BaseConstraint*> WebMediaTrackConstraintSet::AllConstraints()
&aspect_ratio,
&frame_rate,
&facing_mode,
&resize_mode,
&volume,
&sample_rate,
&sample_size,
......
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