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

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: philipj@opera.com 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]. It checks a few numerical bitrate
7 // TODO(mcasas): test also the expected allocated values once [2] is closed. 8 // allocations, asserting that individual bit rates are honored or clamped as
9 // expected, and how the overall bitsPerSecond is divided into video and audio
10 // bitrates.
8 // [1] https://rawgit.com/w3c/mediacapture-record/master/MediaRecorder.html#Medi aRecorderOptions 11 // [1] https://rawgit.com/w3c/mediacapture-record/master/MediaRecorder.html#Medi aRecorderOptions
9 // [2] https://github.com/w3c/mediacapture-record/issues/43
10 12
11 13 function makeExpectedBitrateAsyncTest(options, testName, expectedBps) {
12 function makeAsyncTest(options, message) { 14 async_test(function(test) {
13 return async_test(function(test) { 15 const constraints = {video: true, audio: true};
14 const constraints = {video: true, audio: false};
15 16
16 const gotStream = test.step_func(function(stream) { 17 const gotStream = test.step_func(function(stream) {
17 assert_throws("NotSupportedError", 18 var recorder = new MediaRecorder(stream, options);
18 function() { 19 assert_equals(recorder.videoBitsPerSecond, expectedBps.video);
19 var recorder = new MediaRecorder(stream, options); 20 assert_equals(recorder.audioBitsPerSecond, expectedBps.audio);
20 }, 21
21 "recorder rejects too large bit rates");
22 test.done(); 22 test.done();
23 }); 23 });
24 24
25 const onError = this.step_func(function() { 25 const onError = test.unreached_func('Error creating MediaStream.');
26 assert_unreached('Error creating MediaStream.'); 26 navigator.webkitGetUserMedia(constraints, gotStream, onError);
27 }); 27 }, testName);
28
29 try {
30 navigator.webkitGetUserMedia(constraints, gotStream, onError);
31 }
32 catch (e) {
33 assert_unreached('Exception launching getUserMedia(): ' + e);
34 }
35 }, message);
36 }; 28 };
37 29
38 makeAsyncTest({audioBitsPerSecond:4294967294}, 'Audio bitrate too large'); 30 const kTooSmallBps = 1000;
39 makeAsyncTest({videoBitsPerSecond:4294967294}, 'Video bitrate too large'); 31 const kTooLargeBps = 1000000000;
40 makeAsyncTest({bitsPerSecond:4294967294}, 'Overall bitrate too large'); 32
33 const kOkVideoBps = 500000;
34 const kMinVideoBps = 100000;
35 makeExpectedBitrateAsyncTest({ videoBitsPerSecond : kOkVideoBps },
36 'Video bitrate OK',
37 { video : kOkVideoBps, audio : 0 });
38 makeExpectedBitrateAsyncTest({ videoBitsPerSecond : kTooSmallBps },
39 'Video bitrate clamped to minimum',
40 { video : kMinVideoBps, audio : 0 });
41
42 const kOkAudioBps = 10000;
43 const kMinAudioBps = 6000; // https://www.opus-codec.org/
44 const kMaxAudioBps = 128000;
45 makeExpectedBitrateAsyncTest({ audioBitsPerSecond : kOkAudioBps },
46 'Audio bitrate OK',
47 { audio : kOkAudioBps, video : 0 });
48 makeExpectedBitrateAsyncTest({ audioBitsPerSecond : kTooSmallBps },
49 'Audio bitrate clamped to minimum',
50 { audio : kMinAudioBps, video : 0 });
51 makeExpectedBitrateAsyncTest({ audioBitsPerSecond : kTooLargeBps },
52 'Audio bitrate clamped to maximum',
53 { audio : kMaxAudioBps , video : 0});
54 makeExpectedBitrateAsyncTest({ videoBitsPerSecond : kOkVideoBps, audioBitsPerSec ond : kOkAudioBps },
55 'Video and audio bitrates OK',
56 { video : kOkVideoBps, audio : kOkAudioBps });
57
58 const kOkOverallBps = 120000;
59 makeExpectedBitrateAsyncTest({ bitsPerSecond : kOkOverallBps },
60 'Overall bitrate OK (divided 90/10 video/audio)',
61 { video : kOkOverallBps * 0.9, audio : kOkOverallBp s * 0.1 });
62 makeExpectedBitrateAsyncTest({ videoBitsPerSecond : kOkVideoBps, bitsPerSecond : kOkOverallBps },
63 'Overall bitrate OK, w/ explicit video bitrate igno red',
64 { video : kOkOverallBps * 0.9, audio : kOkOverallB ps * 0.1 });
65 makeExpectedBitrateAsyncTest({ audioBitsPerSecond : kOkAudioBps, bitsPerSecond : kOkOverallBps },
66 'Overall bitrate OK, w/ explicit audio bitrate ign ored',
67 { video : kOkOverallBps * 0.9, audio : kOkOverallB ps * 0.1 });
68
69 makeExpectedBitrateAsyncTest({ bitsPerSecond : 10E6 },
70 'Overall bitrate leads to audio clamped to its maxi mum',
71 { video : 10E6 - kMaxAudioBps, audio : kMaxAudioBps });
72 makeExpectedBitrateAsyncTest({ bitsPerSecond : (kMinVideoBps - 1E3) },
73 'Overall bitrate leads to video clamped to its mini mum',
74 { video : kMinVideoBps, audio : (kMinVideoBps - 1E3 ) * 0.1 });
75 makeExpectedBitrateAsyncTest({ bitsPerSecond : kTooSmallBps },
76 'Overall bitrate leads to both audio and video clam ped to min',
77 { video : kMinVideoBps, audio : kMinAudioBps });
78
41 79
42 </script> 80 </script>
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698