Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(71)

Unified Diff: third_party/WebKit/LayoutTests/fast/mediarecorder/MediaRecorder-bitrates.html

Issue 1652373004: MediaRecorder: add and wire read {video,audio}BitsPerSecond props (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
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..c8af84f14857440226b65c04ca6dff2a298c0cf8 100644
--- a/third_party/WebKit/LayoutTests/fast/mediarecorder/MediaRecorder-bitrates.html
+++ b/third_party/WebKit/LayoutTests/fast/mediarecorder/MediaRecorder-bitrates.html
@@ -2,14 +2,16 @@
<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]. The first bunch checks that an
whywhat 2016/02/02 22:19:54 nit: s/bunch/bunch of tests/
mcasas 2016/02/03 02:49:58 Done.
+// off-the-limit bitrate causes an exception thrown. The following bunch checks
whywhat 2016/02/02 22:19:54 nit: s/bunch/tests
mcasas 2016/02/03 02:49:58 Done.
+// a few numerical bitrate allocations, asserting that individual bit rates are
+// honored or clamped as expeected, and how the overall bitsPerSecond is divided
whywhat 2016/02/02 22:19:54 nit: s/expeected/expected
mcasas 2016/02/03 02:49:58 Done.
+// 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) {
+function makeTooLargeBitrateAsyncTest(options, message) {
return async_test(function(test) {
const constraints = {video: true, audio: false};
@@ -35,8 +37,89 @@ function makeAsyncTest(options, message) {
}, message);
};
-makeAsyncTest({audioBitsPerSecond:4294967294}, 'Audio bitrate too large');
-makeAsyncTest({videoBitsPerSecond:4294967294}, 'Video bitrate too large');
-makeAsyncTest({bitsPerSecond:4294967294}, 'Overall bitrate too large');
+makeTooLargeBitrateAsyncTest({audioBitsPerSecond:4294967294}, 'Audio bitrate too large');
+makeTooLargeBitrateAsyncTest({videoBitsPerSecond:4294967294}, 'Video bitrate too large');
+makeTooLargeBitrateAsyncTest({bitsPerSecond:4294967294}, 'Overall bitrate too large');
+
+
+function makeExpectedBitrateAsyncTest(options, message, expectedVideoBps, expectedAudioBps) {
+ return async_test(function(test) {
+ const constraints = {video: true, audio: true};
+
+ const gotStream = test.step_func(function(stream) {
+ var recorder;
+ try {
+ recorder = new MediaRecorder(stream, options);
+ } catch (e) {
+ assert_unreached('Exception while creating MediaRecorder: ' + e);
+ }
+ assert_equals(recorder.videoBitsPerSecond, expectedVideoBps);
+ assert_equals(recorder.audioBitsPerSecond, expectedAudioBps);
+
+ test.done();
+ });
+
+ const onError = this.step_func(function() {
+ assert_unreached('Error creating MediaStream.');
+ });
+
+ try {
+ navigator.webkitGetUserMedia(constraints, gotStream, onError);
+ }
+ catch (e) {
+ assert_unreached('Exception launching getUserMedia(): ' + e);
+ }
+ }, message);
+};
+
+const kTooSmallBps = 1E3;
Peter Beverloo 2016/02/02 22:43:51 This is an odd way to note these numbers (especial
mcasas 2016/02/03 02:49:58 Done.
+const kTooLargeBps = 1E9;
+
+const kOkVideoBps = 500E3;
+const kMinVideoBps = 100E3;
+makeExpectedBitrateAsyncTest({ videoBitsPerSecond : kOkVideoBps },
+ 'Video bitrate OK',
+ kOkVideoBps, 0);
+makeExpectedBitrateAsyncTest({ videoBitsPerSecond : kTooSmallBps },
+ 'Video bitrate clamped to minimum',
+ kMinVideoBps, 0);
+
+const kOkAudioBps = 10E3;
+const kMinAudioBps = 6E3; // https://www.opus-codec.org/
+const kMaxAudioBps = 128E3;
+makeExpectedBitrateAsyncTest({ audioBitsPerSecond : kOkAudioBps },
+ 'Audio bitrate OK',
+ 0, kOkAudioBps);
+makeExpectedBitrateAsyncTest({ audioBitsPerSecond : kTooSmallBps },
+ 'Audio bitrate clamped to minimum',
+ 0, kMinAudioBps);
+makeExpectedBitrateAsyncTest({ audioBitsPerSecond : kTooLargeBps },
+ 'Audio bitrate clamped to maximum',
+ 0, kMaxAudioBps);
+makeExpectedBitrateAsyncTest({ videoBitsPerSecond : kOkVideoBps, audioBitsPerSecond : kOkAudioBps },
+ 'Video and audio bitrates OK',
+ kOkVideoBps, kOkAudioBps);
+
+const kOkOverallBps = 120E3;
+makeExpectedBitrateAsyncTest({ bitsPerSecond : kOkOverallBps },
+ 'Overall bitrate OK (divided 90/10 video/audio)',
+ kOkOverallBps * 0.9, kOkOverallBps * 0.1);
+makeExpectedBitrateAsyncTest({ videoBitsPerSecond : kOkVideoBps, bitsPerSecond : kOkOverallBps },
+ 'Overall bitrate OK, w/ explicit video bitrate ignored',
+ kOkOverallBps * 0.9, kOkOverallBps * 0.1);
+makeExpectedBitrateAsyncTest({ audioBitsPerSecond : kOkAudioBps, bitsPerSecond : kOkOverallBps },
+ 'Overall bitrate OK, w/ explicit audio bitrate ignored',
+ kOkOverallBps * 0.9, kOkOverallBps * 0.1);
+
+makeExpectedBitrateAsyncTest({ bitsPerSecond : 10E6 },
+ 'Overall bitrate leads to audio clamped to its maximum',
+ 10E6 - kMaxAudioBps, kMaxAudioBps);
+makeExpectedBitrateAsyncTest({ bitsPerSecond : (kMinVideoBps - 1E3) },
+ 'Overall bitrate leads to video clamped to its minimum',
+ kMinVideoBps, (kMinVideoBps - 1E3) * 0.1);
+makeExpectedBitrateAsyncTest({ bitsPerSecond : kTooSmallBps },
+ 'Overall bitrate leads to both audio and video clamped to min',
+ kMinVideoBps, kMinAudioBps);
+
</script>

Powered by Google App Engine
This is Rietveld 408576698