OLD | NEW |
---|---|
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 520 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
531 }) | 531 }) |
532 .catch(function(err) { | 532 .catch(function(err) { |
533 return failTest(err.toString()); | 533 return failTest(err.toString()); |
534 }) | 534 }) |
535 .then(function() { | 535 .then(function() { |
536 console.log('audioSize', audioSize); | 536 console.log('audioSize', audioSize); |
537 reportTestSuccess(); | 537 reportTestSuccess(); |
538 }); | 538 }); |
539 } | 539 } |
540 | 540 |
541 | |
542 // Tests that MediaRecorder can handle a mid-stream resize of the video input | |
543 function testResizeVideoInput(mimeType) { | |
544 const ON_DATA_AVAILABLE_THRESHOLD = 10; | |
545 const NUMBER_OF_EVENTS_TO_RECORD = 5; | |
546 | |
547 var canvas = document.createElement('canvas'); | |
548 canvas.width = canvas.height = 64; | |
549 var stream = canvas.captureStream(); | |
550 assertTrue(stream, 'Error creating MediaStream'); | |
551 assertEquals(1, stream.getVideoTracks().length); | |
552 assertEquals(0, stream.getAudioTracks().length); | |
553 var recordedEvents = 0; | |
554 | |
555 function drawOnCanvas(canvas) { | |
556 var ctx = canvas.getContext('2d'); | |
557 ctx.fillStyle = 'green'; | |
558 ctx.fillRect(0, 0, canvas.width, canvas.height); | |
559 requestAnimationFrame( function() { drawOnCanvas(canvas); }); | |
560 } | |
561 | |
562 createMediaRecorder(stream, mimeType) | |
563 .then(function(recorder) { | |
564 recorder.ondataavailable = function(event) { | |
565 if (event.data.size > ON_DATA_AVAILABLE_THRESHOLD) | |
566 ++recordedEvents; | |
567 }; | |
568 recorder.start(0); | |
569 drawOnCanvas(canvas); | |
mcasas
2017/03/16 23:15:47
Could we use stream.requestFrame() instead of
pai
emircan
2017/03/16 23:33:55
requestFrame() makes sure that the next drawn item
| |
570 }) | |
571 .then(function() { | |
572 return waitFor('Make sure the recording has data', | |
573 function() { | |
574 return recordedEvents > NUMBER_OF_EVENTS_TO_RECORD; | |
575 }); | |
576 }) | |
577 .then(function() { | |
578 canvas.width = canvas.height = 48; | |
579 recordedEvents = 0; | |
580 }) | |
581 .then(function() { | |
582 return waitFor('Make sure the recording has data', | |
583 function() { | |
584 return recordedEvents > NUMBER_OF_EVENTS_TO_RECORD; | |
585 }); | |
586 }) | |
587 .catch(function(err) { | |
588 return failTest(err.toString()); | |
589 }) | |
590 .then(function() { | |
591 reportTestSuccess(); | |
592 }); | |
593 } | |
594 | |
541 // Tests that MediaRecorder's requestData() throws an exception if |state| is | 595 // Tests that MediaRecorder's requestData() throws an exception if |state| is |
542 // 'inactive'. | 596 // 'inactive'. |
543 function testIllegalRequestDataThrowsDOMError() { | 597 function testIllegalRequestDataThrowsDOMError() { |
544 navigator.mediaDevices.getUserMedia(DEFAULT_CONSTRAINTS) | 598 navigator.mediaDevices.getUserMedia(DEFAULT_CONSTRAINTS) |
545 .then(function(stream) { | 599 .then(function(stream) { |
546 return createMediaRecorder(stream, DEFAULT_RECORDER_MIME_TYPE); | 600 return createMediaRecorder(stream, DEFAULT_RECORDER_MIME_TYPE); |
547 }) | 601 }) |
548 .then(function(recorder) { | 602 .then(function(recorder) { |
549 assertThrows(function() {recorder.requestData()}, | 603 assertThrows(function() {recorder.requestData()}, |
550 'Calling requestdata() in inactive state should throw a DOM ' + | 604 'Calling requestdata() in inactive state should throw a DOM ' + |
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
611 return failTest(err.toString()); | 665 return failTest(err.toString()); |
612 }) | 666 }) |
613 .then(function() { | 667 .then(function() { |
614 reportTestSuccess(); | 668 reportTestSuccess(); |
615 }); | 669 }); |
616 } | 670 } |
617 | 671 |
618 </script> | 672 </script> |
619 </body> | 673 </body> |
620 </html> | 674 </html> |
OLD | NEW |