| Index: third_party/WebKit/LayoutTests/fast/mediarecorder/MediaRecorder-bitrates.html
|
| diff --git a/third_party/WebKit/LayoutTests/fast/mediarecorder/MediaRecorder-bitrates.html b/third_party/WebKit/LayoutTests/fast/mediarecorder/MediaRecorder-bitrates.html
|
| index 4fe68e375be9d5fe3a7f937ec0e86e6ac6bbc3ae..4b758abd671a9880593df14dc81df6330aa9a252 100644
|
| --- a/third_party/WebKit/LayoutTests/fast/mediarecorder/MediaRecorder-bitrates.html
|
| +++ b/third_party/WebKit/LayoutTests/fast/mediarecorder/MediaRecorder-bitrates.html
|
| @@ -2,41 +2,79 @@
|
| <script src=../../resources/testharness.js></script>
|
| <script src=../../resources/testharnessreport.js></script>
|
| <script>
|
| +
|
| // This test verifies that MediaRecorder can be created or not with different
|
| -// bitrates for video, audio and for both [1].
|
| -// TODO(mcasas): test also the expected allocated values once [2] is closed.
|
| +// bitrates for video, audio and for both [1]. It checks a few numerical bitrate
|
| +// allocations, asserting that individual bit rates are honored or clamped as
|
| +// expected, and how the overall bitsPerSecond is divided into video and audio
|
| +// bitrates.
|
| // [1] https://rawgit.com/w3c/mediacapture-record/master/MediaRecorder.html#MediaRecorderOptions
|
| -// [2] https://github.com/w3c/mediacapture-record/issues/43
|
| -
|
|
|
| -function makeAsyncTest(options, message) {
|
| - return async_test(function(test) {
|
| - const constraints = {video: true, audio: false};
|
| +function makeExpectedBitrateAsyncTest(options, testName, expectedBps) {
|
| + async_test(function(test) {
|
| + const constraints = {video: true, audio: true};
|
|
|
| const gotStream = test.step_func(function(stream) {
|
| - assert_throws("NotSupportedError",
|
| - function() {
|
| - var recorder = new MediaRecorder(stream, options);
|
| - },
|
| - "recorder rejects too large bit rates");
|
| - test.done();
|
| - });
|
| + var recorder = new MediaRecorder(stream, options);
|
| + assert_equals(recorder.videoBitsPerSecond, expectedBps.video, 'video');
|
| + assert_equals(recorder.audioBitsPerSecond, expectedBps.audio, 'audio');
|
|
|
| - const onError = this.step_func(function() {
|
| - assert_unreached('Error creating MediaStream.');
|
| + test.done();
|
| });
|
|
|
| - try {
|
| - navigator.webkitGetUserMedia(constraints, gotStream, onError);
|
| - }
|
| - catch (e) {
|
| - assert_unreached('Exception launching getUserMedia(): ' + e);
|
| - }
|
| - }, message);
|
| + const onError = test.unreached_func('Error creating MediaStream.');
|
| + navigator.webkitGetUserMedia(constraints, gotStream, onError);
|
| + }, testName);
|
| };
|
|
|
| -makeAsyncTest({audioBitsPerSecond:4294967294}, 'Audio bitrate too large');
|
| -makeAsyncTest({videoBitsPerSecond:4294967294}, 'Video bitrate too large');
|
| -makeAsyncTest({bitsPerSecond:4294967294}, 'Overall bitrate too large');
|
| +const kTooSmallBps = 1000;
|
| +const kTooLargeBps = 1000000000;
|
| +
|
| +const kOkVideoBps = 500000;
|
| +const kMinVideoBps = 100000;
|
| +makeExpectedBitrateAsyncTest({ videoBitsPerSecond : kOkVideoBps },
|
| + 'Video bitrate OK',
|
| + { video : kOkVideoBps, audio : 0 });
|
| +makeExpectedBitrateAsyncTest({ videoBitsPerSecond : kTooSmallBps },
|
| + 'Video bitrate clamped to minimum',
|
| + { video : kMinVideoBps, audio : 0 });
|
| +
|
| +const kOkAudioBps = 10000;
|
| +const kMinAudioBps = 6000; // https://www.opus-codec.org/
|
| +const kMaxAudioBps = 128000;
|
| +makeExpectedBitrateAsyncTest({ audioBitsPerSecond : kOkAudioBps },
|
| + 'Audio bitrate OK',
|
| + { audio : kOkAudioBps, video : 0 });
|
| +makeExpectedBitrateAsyncTest({ audioBitsPerSecond : kTooSmallBps },
|
| + 'Audio bitrate clamped to minimum',
|
| + { audio : kMinAudioBps, video : 0 });
|
| +makeExpectedBitrateAsyncTest({ audioBitsPerSecond : kTooLargeBps },
|
| + 'Audio bitrate clamped to maximum',
|
| + { audio : kMaxAudioBps , video : 0});
|
| +makeExpectedBitrateAsyncTest({ videoBitsPerSecond : kOkVideoBps, audioBitsPerSecond : kOkAudioBps },
|
| + 'Video and audio bitrates OK',
|
| + { video : kOkVideoBps, audio : kOkAudioBps });
|
| +
|
| +const kOkOverallBps = 120000;
|
| +makeExpectedBitrateAsyncTest({ bitsPerSecond : kOkOverallBps },
|
| + 'Overall bitrate OK (divided 90/10 video/audio)',
|
| + { video : kOkOverallBps * 0.9, audio : kOkOverallBps * 0.1 });
|
| +makeExpectedBitrateAsyncTest({ videoBitsPerSecond : kOkVideoBps, bitsPerSecond : kOkOverallBps },
|
| + 'Overall bitrate OK, w/ explicit video bitrate ignored',
|
| + { video : kOkOverallBps * 0.9, audio : kOkOverallBps * 0.1 });
|
| +makeExpectedBitrateAsyncTest({ audioBitsPerSecond : kOkAudioBps, bitsPerSecond : kOkOverallBps },
|
| + 'Overall bitrate OK, w/ explicit audio bitrate ignored',
|
| + { video : kOkOverallBps * 0.9, audio : kOkOverallBps * 0.1 });
|
| +
|
| +makeExpectedBitrateAsyncTest({ bitsPerSecond : 10E6 },
|
| + 'Overall bitrate leads to audio clamped to its maximum',
|
| + { video : 10E6 - kMaxAudioBps, audio : kMaxAudioBps });
|
| +makeExpectedBitrateAsyncTest({ bitsPerSecond : (kMinVideoBps - 1E3) },
|
| + 'Overall bitrate leads to video clamped to its minimum',
|
| + { video : kMinVideoBps, audio : (kMinVideoBps - 1E3) * 0.1 });
|
| +makeExpectedBitrateAsyncTest({ bitsPerSecond : kTooSmallBps },
|
| + 'Overall bitrate leads to both audio and video clamped to min',
|
| + { video : kMinVideoBps, audio : kMinAudioBps });
|
| +
|
|
|
| </script>
|
|
|