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

Side by Side Diff: content/test/data/media/mediarecorder_test.html

Issue 2639693003: MediaRecorder: add timecode validation in content_browsertests (Closed)
Patch Set: Created 3 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 unified diff | Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 <!DOCTYPE html> 1 <!DOCTYPE html>
2 <html> 2 <html>
3 <head> 3 <head>
4 <title>MediaStream Recoder Browser Test (w/ MediaSource)</title> 4 <title>MediaStream Recoder Browser Test (w/ MediaSource)</title>
5 </head> 5 </head>
6 <body> 6 <body>
7 <div> Record Real-Time video content browser test.</div> 7 <div> Record Real-Time video content browser test.</div>
8 <video id="video" autoplay></video> 8 <video id="video" autoplay></video>
9 <video id="remoteVideo" autoplay></video> 9 <video id="remoteVideo" autoplay></video>
10 </body> 10 </body>
(...skipping 153 matching lines...) Expand 10 before | Expand all | Expand 10 after
164 reportTestSuccess(); 164 reportTestSuccess();
165 }); 165 });
166 } 166 }
167 167
168 // Tests that when MediaRecorder's start(0) function is called, some data is 168 // Tests that when MediaRecorder's start(0) function is called, some data is
169 // made available by media recorder via dataavailable events, containing non 169 // made available by media recorder via dataavailable events, containing non
170 // empty blob data. 170 // empty blob data.
171 function testStartAndDataAvailable(mimeType) { 171 function testStartAndDataAvailable(mimeType) {
172 var videoSize = 0; 172 var videoSize = 0;
173 var emptyBlobs = 0; 173 var emptyBlobs = 0;
174 var timeStamps = []; 174 var lastTimecode = NaN;
175 navigator.mediaDevices.getUserMedia(DEFAULT_CONSTRAINTS) 175 navigator.mediaDevices.getUserMedia(DEFAULT_CONSTRAINTS)
176 .then(function(stream) { 176 .then(function(stream) {
177 return createAndStartMediaRecorder(stream, mimeType); 177 return createAndStartMediaRecorder(stream, mimeType);
178 }) 178 })
179 .then(function(recorder) { 179 .then(function(recorder) {
180 // Save history of Blobs received via dataavailable. 180 // Save history of Blobs received via dataavailable.
181 recorder.ondataavailable = function(event) { 181 recorder.ondataavailable = function(event) {
182 timeStamps.push(event.timeStamp);
183 if (event.data.size > 0) 182 if (event.data.size > 0)
184 videoSize += event.data.size; 183 videoSize += event.data.size;
185 else 184 else
186 emptyBlobs += 1; 185 emptyBlobs += 1;
186
187 if (!isNaN(lastTimecode))
188 assertTrue(event.timecode > lastTimecode, 'timecodes');
189 lastTimecode = event.timecode;
187 }; 190 };
188 }) 191 })
189 .then(function() { 192 .then(function() {
190 return waitFor('Make sure the recording has data', 193 return waitFor('Make sure the recording has data',
191 function() { 194 function() {
192 return videoSize > 0; 195 return videoSize > 0;
193 }); 196 });
194 }) 197 })
195 .then(function() { 198 .then(function() {
196 assertTrue(emptyBlobs == 0, 'Recording has ' + emptyBlobs + 199 assertTrue(emptyBlobs == 0, 'Recording has ' + emptyBlobs +
197 ' empty blobs, there should be no such empty blobs.'); 200 ' empty blobs, there should be no such empty blobs.');
198 }) 201 })
199 .catch(function(err) { 202 .catch(function(err) {
200 return failTest(err.toString()); 203 return failTest(err.toString());
201 }) 204 })
202 .then(function() { 205 .then(function() {
203 reportTestSuccess(); 206 reportTestSuccess();
204 }); 207 });
205 } 208 }
206 209
207 // Tests that when MediaRecorder's start(timeSlice) is called, some data 210 // Tests that when MediaRecorder's start(timeSlice) is called, some data
208 // available events are fired containing non empty blob data. 211 // available events are fired containing non empty blob data.
209 function testStartWithTimeSlice(mimeType) { 212 function testStartWithTimeSlice(mimeType) {
210 var videoSize = 0; 213 var videoSize = 0;
211 var emptyBlobs = 0; 214 var emptyBlobs = 0;
212 var timeStamps = []; 215 var timeStamps = [];
216 var lastTimecode = NaN;
213 navigator.mediaDevices.getUserMedia(DEFAULT_CONSTRAINTS) 217 navigator.mediaDevices.getUserMedia(DEFAULT_CONSTRAINTS)
214 .then(function(stream) { 218 .then(function(stream) {
215 return createAndStartMediaRecorder(stream, mimeType, 219 return createAndStartMediaRecorder(stream, mimeType,
216 DEFAULT_TIME_SLICE); 220 DEFAULT_TIME_SLICE);
217 }) 221 })
218 .then(function(recorder) { 222 .then(function(recorder) {
219 recorder.ondataavailable = function(event) { 223 recorder.ondataavailable = function(event) {
220 timeStamps.push(event.timeStamp); 224 timeStamps.push(event.timeStamp);
221 if (event.data.size > 0) 225 if (event.data.size > 0)
222 videoSize += event.data.size; 226 videoSize += event.data.size;
223 else 227 else
224 emptyBlobs += 1; 228 emptyBlobs += 1;
229
230 if (!isNaN(lastTimecode))
231 assertTrue(event.timecode > lastTimecode, 'timecodes');
232 lastTimecode = event.timecode;
225 }; 233 };
226 }) 234 })
227 .then(function() { 235 .then(function() {
228 return waitFor('Making sure the recording has data', 236 return waitFor('Making sure the recording has data',
229 function() { 237 function() {
230 return videoSize > 0 && timeStamps.length > 10; 238 return videoSize > 0 && timeStamps.length > 10;
231 }); 239 });
232 }) 240 })
233 .then(function() { 241 .then(function() {
234 assertTrue(emptyBlobs == 0, 'Recording has ' + emptyBlobs + 242 assertTrue(emptyBlobs == 0, 'Recording has ' + emptyBlobs +
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
282 .then(function(recorder) { 290 .then(function(recorder) {
283 assertThrows(function() {recorder.resume()}, 'Calling resume() in' + 291 assertThrows(function() {recorder.resume()}, 'Calling resume() in' +
284 ' inactive state should cause a DOM error'); 292 ' inactive state should cause a DOM error');
285 }); 293 });
286 } 294 }
287 295
288 // Tests that MediaRecorder sends data blobs when resume() is called. 296 // Tests that MediaRecorder sends data blobs when resume() is called.
289 function testResumeAndDataAvailable(mimeType) { 297 function testResumeAndDataAvailable(mimeType) {
290 var videoSize = 0; 298 var videoSize = 0;
291 var emptyBlobs = 0; 299 var emptyBlobs = 0;
300 var lastTimecode = NaN;
292 navigator.mediaDevices.getUserMedia(DEFAULT_CONSTRAINTS) 301 navigator.mediaDevices.getUserMedia(DEFAULT_CONSTRAINTS)
293 .then(function(stream) { 302 .then(function(stream) {
294 return createAndStartMediaRecorder(stream, mimeType); 303 return createAndStartMediaRecorder(stream, mimeType);
295 }) 304 })
296 .then(function(recorder) { 305 .then(function(recorder) {
297 recorder.pause(); 306 recorder.pause();
298 recorder.ondataavailable = function(event) { 307 recorder.ondataavailable = function(event) {
299 if (event.data.size > 0) { 308 if (event.data.size > 0) {
300 videoSize += event.data.size; 309 videoSize += event.data.size;
301 } else { 310 } else {
302 console.log('This dataavailable event is empty', event); 311 console.log('This dataavailable event is empty', event);
303 emptyBlobs += 1; 312 emptyBlobs += 1;
304 } 313 }
314
315 if (!isNaN(lastTimecode))
316 assertTrue(event.timecode > lastTimecode, 'timecodes');
317 lastTimecode = event.timecode;
305 }; 318 };
306 recorder.resume(); 319 recorder.resume();
307 }) 320 })
308 .then(function() { 321 .then(function() {
309 return waitFor('Make sure the recording has data after resuming', 322 return waitFor('Make sure the recording has data after resuming',
310 function() { 323 function() {
311 return videoSize > 0; 324 return videoSize > 0;
312 }); 325 });
313 }) 326 })
314 .then(function() { 327 .then(function() {
(...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after
407 .then(function(recorder) { 420 .then(function(recorder) {
408 assertThrows(function() {recorder.pause()}, 'Calling pause() in' + 421 assertThrows(function() {recorder.pause()}, 'Calling pause() in' +
409 ' inactive state should cause a DOM error'); 422 ' inactive state should cause a DOM error');
410 }); 423 });
411 } 424 }
412 425
413 // Tests that a remote peer connection stream can be successfully recorded. 426 // Tests that a remote peer connection stream can be successfully recorded.
414 function testRecordRemotePeerConnection(mimeType) { 427 function testRecordRemotePeerConnection(mimeType) {
415 var videoSize = 0; 428 var videoSize = 0;
416 var timeStamps = []; 429 var timeStamps = [];
430 var lastTimecode = NaN;
417 navigator.mediaDevices.getUserMedia(DEFAULT_CONSTRAINTS) 431 navigator.mediaDevices.getUserMedia(DEFAULT_CONSTRAINTS)
418 .then(function(localStream) { 432 .then(function(localStream) {
419 return setupPeerConnection(localStream); 433 return setupPeerConnection(localStream);
420 }) 434 })
421 .then(function(remoteStream) { 435 .then(function(remoteStream) {
422 return createMediaRecorder(remoteStream, mimeType); 436 return createMediaRecorder(remoteStream, mimeType);
423 }) 437 })
424 .then(function(recorder) { 438 .then(function(recorder) {
425 recorder.ondataavailable = function(event) { 439 recorder.ondataavailable = function(event) {
426 timeStamps.push(event.timeStamp); 440 timeStamps.push(event.timeStamp);
427 videoSize += event.data.size; 441 videoSize += event.data.size;
442
443 if (!isNaN(lastTimecode))
444 assertTrue(event.timecode > lastTimecode, 'timecodes');
445 lastTimecode = event.timecode;
428 }; 446 };
429 recorder.start(0); 447 recorder.start(0);
430 }) 448 })
431 .then(function() { 449 .then(function() {
432 return waitFor('Making sure the recording has data', 450 return waitFor('Making sure the recording has data',
433 function() { 451 function() {
434 return videoSize > 0 && timeStamps.length > 100; 452 return videoSize > 0 && timeStamps.length > 100;
435 }); 453 });
436 }) 454 })
437 .catch(function(err) { 455 .catch(function(err) {
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
485 // Tests that MediaRecorder can record a 2 Channel audio stream. 503 // Tests that MediaRecorder can record a 2 Channel audio stream.
486 function testTwoChannelAudio() { 504 function testTwoChannelAudio() {
487 var audioSize = 0; 505 var audioSize = 0;
488 var context = new OfflineAudioContext(2, NUM_SAMPLES, SAMPLING_RATE); 506 var context = new OfflineAudioContext(2, NUM_SAMPLES, SAMPLING_RATE);
489 var oscillator = context.createOscillator(); 507 var oscillator = context.createOscillator();
490 oscillator.type = 'sine'; 508 oscillator.type = 'sine';
491 oscillator.frequency.value = FREQUENCY; 509 oscillator.frequency.value = FREQUENCY;
492 var dest = context.createMediaStreamDestination(); 510 var dest = context.createMediaStreamDestination();
493 dest.channelCount = 2; 511 dest.channelCount = 2;
494 oscillator.connect(dest); 512 oscillator.connect(dest);
513 var lastTimecode = NaN;
495 createMediaRecorder(dest.stream, DEFAULT_RECORDER_MIME_TYPE) 514 createMediaRecorder(dest.stream, DEFAULT_RECORDER_MIME_TYPE)
496 .then(function(recorder) { 515 .then(function(recorder) {
497 recorder.ondataavailable = function(event) { 516 recorder.ondataavailable = function(event) {
498 audioSize += event.data.size; 517 audioSize += event.data.size;
518 if (!isNaN(lastTimecode))
519 assertTrue(event.timecode > lastTimecode, 'timecodes');
520 lastTimecode = event.timecode;
499 }; 521 };
500 recorder.start(0); 522 recorder.start(0);
501 oscillator.start(); 523 oscillator.start();
502 context.startRendering(); 524 context.startRendering();
503 }) 525 })
504 .then(function() { 526 .then(function() {
505 return waitFor('Make sure the recording has data', 527 return waitFor('Make sure the recording has data',
506 function() { 528 function() {
507 return audioSize > 0; 529 return audioSize > 0;
508 }); 530 });
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after
589 return failTest(err.toString()); 611 return failTest(err.toString());
590 }) 612 })
591 .then(function() { 613 .then(function() {
592 reportTestSuccess(); 614 reportTestSuccess();
593 }); 615 });
594 } 616 }
595 617
596 </script> 618 </script>
597 </body> 619 </body>
598 </html> 620 </html>
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698