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

Side by Side 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: reviewers@ comments Created 4 years, 10 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 unified diff | Download patch
OLDNEW
1 <!DOCTYPE html> 1 <!DOCTYPE html>
2 <script src=../../resources/testharness.js></script> 2 <script src=../../resources/testharness.js></script>
3 <script src=../../resources/testharnessreport.js></script> 3 <script src=../../resources/testharnessreport.js></script>
4 <script> 4 <script>
5
5 // This test verifies that MediaRecorder can be created or not with different 6 // This test verifies that MediaRecorder can be created or not with different
6 // bitrates for video, audio and for both [1]. 7 // bitrates for video, audio and for both [1]. The first bunch of tests checks
7 // TODO(mcasas): test also the expected allocated values once [2] is closed. 8 // that an off-the-limit bitrate causes an exception thrown. The following bunch
9 // of tests checks a few numerical bitrate allocations, asserting that
10 // individual bit rates are honored or clamped as expected, and how the overall
11 // bitsPerSecond is divided into video and audio bitrates.
8 // [1] https://rawgit.com/w3c/mediacapture-record/master/MediaRecorder.html#Medi aRecorderOptions 12 // [1] https://rawgit.com/w3c/mediacapture-record/master/MediaRecorder.html#Medi aRecorderOptions
9 // [2] https://github.com/w3c/mediacapture-record/issues/43
10 13
11 14 function makeTooLargeBitrateAsyncTest(options, message) {
12 function makeAsyncTest(options, message) {
13 return async_test(function(test) { 15 return async_test(function(test) {
14 const constraints = {video: true, audio: false}; 16 const constraints = {video: true, audio: false};
15 17
16 const gotStream = test.step_func(function(stream) { 18 const gotStream = test.step_func(function(stream) {
17 assert_throws("NotSupportedError", 19 assert_throws("NotSupportedError",
philipj_slow 2016/02/03 03:31:04 The spec doesn't allow for NotSupportedError to be
mcasas 2016/02/03 23:50:26 Hmm that makes sense. I propose not throwing, ASSE
philipj_slow 2016/02/04 03:03:10 Clamping sounds good, yep.
18 function() { 20 function() {
19 var recorder = new MediaRecorder(stream, options); 21 var recorder = new MediaRecorder(stream, options);
20 }, 22 },
21 "recorder rejects too large bit rates"); 23 "recorder rejects too large bit rates");
22 test.done(); 24 test.done();
23 }); 25 });
24 26
25 const onError = this.step_func(function() { 27 const onError = this.step_func(function() {
26 assert_unreached('Error creating MediaStream.'); 28 assert_unreached('Error creating MediaStream.');
27 }); 29 });
28 30
29 try { 31 try {
30 navigator.webkitGetUserMedia(constraints, gotStream, onError); 32 navigator.webkitGetUserMedia(constraints, gotStream, onError);
31 } 33 }
32 catch (e) { 34 catch (e) {
33 assert_unreached('Exception launching getUserMedia(): ' + e); 35 assert_unreached('Exception launching getUserMedia(): ' + e);
34 } 36 }
35 }, message); 37 }, message);
36 }; 38 };
37 39
38 makeAsyncTest({audioBitsPerSecond:4294967294}, 'Audio bitrate too large'); 40 makeTooLargeBitrateAsyncTest({audioBitsPerSecond:4294967294}, 'Audio bitrate too large');
39 makeAsyncTest({videoBitsPerSecond:4294967294}, 'Video bitrate too large'); 41 makeTooLargeBitrateAsyncTest({videoBitsPerSecond:4294967294}, 'Video bitrate too large');
40 makeAsyncTest({bitsPerSecond:4294967294}, 'Overall bitrate too large'); 42 makeTooLargeBitrateAsyncTest({bitsPerSecond:4294967294}, 'Overall bitrate too la rge');
43
44
45 function makeExpectedBitrateAsyncTest(options, message, expectedVideoBps, expect edAudioBps) {
philipj_slow 2016/02/03 03:31:04 s/message/name/ or testName (in existing test too)
philipj_slow 2016/02/03 03:31:05 How about making expected a dictionary too, so tha
mcasas 2016/02/03 23:50:26 Done.
mcasas 2016/02/03 23:50:27 Done.
46 return async_test(function(test) {
philipj_slow 2016/02/03 03:31:05 No reason to return the test, it'll run anyway.
mcasas 2016/02/03 23:50:26 Done.
47 const constraints = {video: true, audio: true};
philipj_slow 2016/02/03 03:31:04 No tests for when either audio or video are not wa
48
49 const gotStream = test.step_func(function(stream) {
50 var recorder;
51 try {
52 recorder = new MediaRecorder(stream, options);
53 } catch (e) {
54 assert_unreached('Exception while creating MediaRecorder: ' + e) ;
philipj_slow 2016/02/03 03:31:05 Don't really need this, any exception thrown will
mcasas 2016/02/03 23:50:26 Done.
55 }
56 assert_equals(recorder.videoBitsPerSecond, expectedVideoBps);
57 assert_equals(recorder.audioBitsPerSecond, expectedAudioBps);
58
59 test.done();
60 });
61
62 const onError = this.step_func(function() {
philipj_slow 2016/02/03 03:31:04 can be simplified to test.unreached_func('Error cr
mcasas 2016/02/03 23:50:26 Nice! Done.
63 assert_unreached('Error creating MediaStream.');
64 });
65
66 try {
67 navigator.webkitGetUserMedia(constraints, gotStream, onError);
68 }
69 catch (e) {
70 assert_unreached('Exception launching getUserMedia(): ' + e);
philipj_slow 2016/02/03 03:31:04 Dito, can drop try catch
mcasas 2016/02/03 23:50:26 More succint, done. Took the chance and cleaned u
71 }
72 }, message);
73 };
74
75 const kTooSmallBps = 1000;
76 const kTooLargeBps = 1000000000;
77
78 const kOkVideoBps = 500000;
79 const kMinVideoBps = 100000;
80 makeExpectedBitrateAsyncTest({ videoBitsPerSecond : kOkVideoBps },
81 'Video bitrate OK',
82 kOkVideoBps, 0);
83 makeExpectedBitrateAsyncTest({ videoBitsPerSecond : kTooSmallBps },
84 'Video bitrate clamped to minimum',
85 kMinVideoBps, 0);
86
87 const kOkAudioBps = 10000;
88 const kMinAudioBps = 6000; // https://www.opus-codec.org/
89 const kMaxAudioBps = 128000;
90 makeExpectedBitrateAsyncTest({ audioBitsPerSecond : kOkAudioBps },
91 'Audio bitrate OK',
92 0, kOkAudioBps);
93 makeExpectedBitrateAsyncTest({ audioBitsPerSecond : kTooSmallBps },
94 'Audio bitrate clamped to minimum',
95 0, kMinAudioBps);
96 makeExpectedBitrateAsyncTest({ audioBitsPerSecond : kTooLargeBps },
97 'Audio bitrate clamped to maximum',
98 0, kMaxAudioBps);
99 makeExpectedBitrateAsyncTest({ videoBitsPerSecond : kOkVideoBps, audioBitsPerSec ond : kOkAudioBps },
100 'Video and audio bitrates OK',
101 kOkVideoBps, kOkAudioBps);
102
103 const kOkOverallBps = 120000;
104 makeExpectedBitrateAsyncTest({ bitsPerSecond : kOkOverallBps },
105 'Overall bitrate OK (divided 90/10 video/audio)',
106 kOkOverallBps * 0.9, kOkOverallBps * 0.1);
107 makeExpectedBitrateAsyncTest({ videoBitsPerSecond : kOkVideoBps, bitsPerSecond : kOkOverallBps },
108 'Overall bitrate OK, w/ explicit video bitrate igno red',
109 kOkOverallBps * 0.9, kOkOverallBps * 0.1);
110 makeExpectedBitrateAsyncTest({ audioBitsPerSecond : kOkAudioBps, bitsPerSecond : kOkOverallBps },
111 'Overall bitrate OK, w/ explicit audio bitrate ign ored',
112 kOkOverallBps * 0.9, kOkOverallBps * 0.1);
113
114 makeExpectedBitrateAsyncTest({ bitsPerSecond : 10E6 },
115 'Overall bitrate leads to audio clamped to its maxi mum',
116 10E6 - kMaxAudioBps, kMaxAudioBps);
117 makeExpectedBitrateAsyncTest({ bitsPerSecond : (kMinVideoBps - 1E3) },
118 'Overall bitrate leads to video clamped to its mini mum',
119 kMinVideoBps, (kMinVideoBps - 1E3) * 0.1);
120 makeExpectedBitrateAsyncTest({ bitsPerSecond : kTooSmallBps },
121 'Overall bitrate leads to both audio and video clam ped to min',
122 kMinVideoBps, kMinAudioBps);
123
41 124
42 </script> 125 </script>
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698