Commit 45733135 authored by Chandan Padhi's avatar Chandan Padhi Committed by Commit Bot

Add autoGainControl and noiseSuppression to MediaTrackConstraintSet

This CL also wires these constraints to Blink's internal
goog_auto_gain_control and goog_noise_suppression respectively.
This automatically provides support for these constraints in
mediaDevices.getUserMedia(), MediaStreamTrack.applyConstraints()
and MediaStreamTrack.getConstraints().

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

Bug: 823831
Change-Id: I71c84e6464533de8abfb51fb12d774849b34a91f
Reviewed-on: https://chromium-review.googlesource.com/975501Reviewed-by: default avatarGuido Urdaneta <guidou@chromium.org>
Commit-Queue: Chandan Padhi <c.padhi@samsung.com>
Cr-Commit-Position: refs/heads/master@{#545075}
parent c65098c1
......@@ -100,6 +100,8 @@ promise_test(() => {
sampleRate: { ideal: 42, min: 31, max: 54 },
sampleSize: 3,
echoCancellation: { ideal: false, exact: true },
autoGainControl: { ideal: false, exact: true },
noiseSuppression: { ideal: false, exact: true },
latency: 0.22,
channelCount: 2,
deviceId: { ideal: ["foo", "fooz"] },
......@@ -174,11 +176,21 @@ constraintSyntaxTestWithChange(
constraintSyntaxTest('Both Ideal and Exact string',
{ facingMode: { ideal: "user6", exact: "left6" }});
constraintSyntaxTest('Simple boolean', { echoCancellation: true });
constraintSyntaxTest('Ideal boolean', { echoCancellation: { ideal: true }});
constraintSyntaxTestWithChange('Exact unwrapped boolean',
constraintSyntaxTest('echoCancellation with simple boolean value', { echoCancellation: true });
constraintSyntaxTest('echoCancellation with ideal boolean value', { echoCancellation: { ideal: true }});
constraintSyntaxTestWithChange('echoCancellation with exact unwrapped boolean value',
{ echoCancellation: { exact: true } }, { echoCancellation: true });
constraintSyntaxTest('autoGainControl with simple boolean value', { autoGainControl: true });
constraintSyntaxTest('autoGainControl with ideal boolean value', { autoGainControl: { ideal: true }});
constraintSyntaxTestWithChange('autoGainControl with exact unwrapped boolean value',
{ autoGainControl: { exact: true } }, { autoGainControl: true });
constraintSyntaxTest('noiseSuppression with simple boolean value', { noiseSuppression: true });
constraintSyntaxTest('noiseSuppression with ideal boolean value', { noiseSuppression: { ideal: true }});
constraintSyntaxTestWithChange('noiseSuppression with exact unwrapped boolean value',
{ noiseSuppression: { exact: true } }, { noiseSuppression: true });
</script>
</body>
</html>
......@@ -9,12 +9,16 @@
// If a constraint is specified, it should come back in getConstraints().
promise_test(function() {
return navigator.mediaDevices.getUserMedia({audio: { echoCancellation: { exact: true}}})
return navigator.mediaDevices.getUserMedia({audio: { echoCancellation: { exact: true}, autoGainControl: { exact: true }, noiseSuppression: { exact: true }}})
.then(function(s) {
constraints = s.getAudioTracks()[0].getConstraints();
assert_equals(Object.keys(constraints).length, 1);
assert_equals(Object.keys(constraints).length, 3);
assert_true(constraints.hasOwnProperty('echoCancellation'));
assert_true(constraints.echoCancellation.exact);
assert_true(constraints.hasOwnProperty('autoGainControl'));
assert_true(constraints.autoGainControl.exact);
assert_true(constraints.hasOwnProperty('noiseSuppression'));
assert_true(constraints.noiseSuppression.exact);
});
}, 'A set constraint is returned on getConstraints');
......@@ -68,6 +72,8 @@ promise_test(function() {
sampleRate: { ideal: 42 },
sampleSize: { ideal: 3 },
echoCancellation: { ideal: false },
autoGainControl: { ideal: false },
noiseSuppression: { ideal: false },
latency: { ideal: 0.22 },
channelCount: { ideal: 2 },
deviceId: { ideal: ["foo", "fooz"] },
......@@ -131,11 +137,21 @@ constraintSyntaxTestWithChange('Single Bracketed string unwrapped',
{ 'facingMode': ["user5"]}, { facingMode: "user5" });
constraintSyntaxTest('Both Ideal and Exact string', { facingMode: { ideal: "user6", exact: "left6" }});
constraintSyntaxTest('Simple boolean', { echoCancellation: true });
constraintSyntaxTest('Ideal boolean', { echoCancellation: { ideal: true }});
constraintSyntaxTestWithChange('Exact unwrapped boolean',
constraintSyntaxTest('echoCancellation with simple boolean value', { echoCancellation: true });
constraintSyntaxTest('echoCancellation with ideal boolean value', { echoCancellation: { ideal: true }});
constraintSyntaxTestWithChange('echoCancellation with exact unwrapped boolean value',
{ echoCancellation: { exact: true } }, { echoCancellation: true });
constraintSyntaxTest('autoGainControl with simple boolean value', { autoGainControl: true });
constraintSyntaxTest('autoGainControl with ideal boolean value', { autoGainControl: { ideal: true }});
constraintSyntaxTestWithChange('autoGainControl with exact unwrapped boolean value',
{ autoGainControl: { exact: true } }, { autoGainControl: true });
constraintSyntaxTest('noiseSuppression with simple boolean value', { noiseSuppression: true });
constraintSyntaxTest('noiseSuppression with ideal boolean value', { noiseSuppression: { ideal: true }});
constraintSyntaxTestWithChange('noiseSuppression with exact unwrapped boolean value',
{ noiseSuppression: { exact: true } }, { noiseSuppression: true });
</script>
</body>
</html>
......@@ -91,12 +91,26 @@ check_constraints_pass(
{height: 47});
check_constraints_pass(
'Constraint with boolean value should be parsed',
'echoCancellation constraint with boolean value should be parsed',
{'echoCancellation': {exact: true}});
check_constraints_pass(
'Constraint with boolean naked value should be parsed',
'echoCancellation constraint with boolean naked value should be parsed',
{'echoCancellation': true});
check_constraints_pass(
'autoGainControl constraint with boolean value should be parsed',
{'autoGainControl': {exact: true}});
check_constraints_pass(
'autoGainControl constraint with boolean naked value should be parsed',
{'autoGainControl': true});
check_constraints_pass(
'noiseSuppression constraint with boolean value should be parsed',
{'noiseSuppression': {exact: true}});
check_constraints_pass(
'noiseSuppression constraint with boolean naked value should be parsed',
{'noiseSuppression': true});
check_constraints_pass(
'Constraint with string value should work on exact with array',
{'facingMode': {ideal: ['user']}});
......
......@@ -677,6 +677,14 @@ void CopyConstraintSet(const MediaTrackConstraintSet& constraints_in,
CopyBooleanConstraint(constraints_in.echoCancellation(), naked_treatment,
constraint_buffer.echo_cancellation);
}
if (constraints_in.hasAutoGainControl()) {
CopyBooleanConstraint(constraints_in.autoGainControl(), naked_treatment,
constraint_buffer.goog_auto_gain_control);
}
if (constraints_in.hasNoiseSuppression()) {
CopyBooleanConstraint(constraints_in.noiseSuppression(), naked_treatment,
constraint_buffer.goog_noise_suppression);
}
if (constraints_in.hasLatency()) {
CopyDoubleConstraint(constraints_in.latency(), naked_treatment,
constraint_buffer.latency);
......@@ -931,6 +939,14 @@ void ConvertConstraintSet(const WebMediaTrackConstraintSet& input,
output.setEchoCancellation(
ConvertBoolean(input.echo_cancellation, naked_treatment));
}
if (!input.goog_auto_gain_control.IsEmpty()) {
output.setAutoGainControl(
ConvertBoolean(input.goog_auto_gain_control, naked_treatment));
}
if (!input.goog_noise_suppression.IsEmpty()) {
output.setNoiseSuppression(
ConvertBoolean(input.goog_noise_suppression, naked_treatment));
}
if (!input.latency.IsEmpty())
output.setLatency(ConvertDouble(input.latency, naked_treatment));
if (!input.channel_count.IsEmpty())
......
......@@ -20,6 +20,8 @@ dictionary MediaTrackConstraintSet {
ConstrainLong sampleRate;
ConstrainLong sampleSize;
ConstrainBoolean echoCancellation;
ConstrainBoolean autoGainControl;
ConstrainBoolean noiseSuppression;
ConstrainDouble latency;
ConstrainLong channelCount;
ConstrainDOMString deviceId;
......
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