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

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: 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 checks that an
whywhat 2016/02/02 22:19:54 nit: s/bunch/bunch of tests/
mcasas 2016/02/03 02:49:58 Done.
7 // TODO(mcasas): test also the expected allocated values once [2] is closed. 8 // 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.
9 // a few numerical bitrate allocations, asserting that individual bit rates are
10 // 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.
11 // 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",
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) {
46 return async_test(function(test) {
47 const constraints = {video: true, audio: true};
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) ;
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() {
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);
71 }
72 }, message);
73 };
74
75 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.
76 const kTooLargeBps = 1E9;
77
78 const kOkVideoBps = 500E3;
79 const kMinVideoBps = 100E3;
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 = 10E3;
88 const kMinAudioBps = 6E3; // https://www.opus-codec.org/
89 const kMaxAudioBps = 128E3;
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 = 120E3;
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