| <html> |
| <head> |
| <script type="text/javascript" src="webrtc_test_utilities.js"></script> |
| <script type="text/javascript"> |
| $ = function(id) { |
| return document.getElementById(id); |
| }; |
| |
| const WIDTH = 320; |
| var CONSTRAINTS = { video: { width: { exact : WIDTH } } }; |
| var hasReceivedTrackEndedEvent = false; |
| |
| function startVideoCaptureAndVerifySize() { |
| console.log('Calling getUserMediaAndWaitForVideoRendering.'); |
| navigator.mediaDevices.getUserMedia(CONSTRAINTS) |
| .then(gotStreamCallback) |
| .catch(failedCallback); |
| } |
| |
| function failedCallback(error) { |
| failTest('GetUserMedia call failed with code ' + error.code); |
| } |
| |
| function gotStreamCallback(stream) { |
| var localView = $('local-view'); |
| localView.src = URL.createObjectURL(stream); |
| |
| var videoTracks = stream.getVideoTracks(); |
| if (videoTracks.length == 0) { |
| failTest('Did not receive any video tracks'); |
| } |
| var videoTrack = videoTracks[0]; |
| videoTrack.onended = function() { |
| hasReceivedTrackEndedEvent = true; |
| }; |
| |
| detectVideoPlaying('local-view').then(() => { |
| if (localView.videoWidth == WIDTH) { |
| reportTestSuccess(); |
| } else { |
| failTest('Video has unexpected width.'); |
| } |
| }); |
| } |
| |
| function waitForVideoToTurnBlack() { |
| detectBlackVideo('local-view').then(() => { |
| reportTestSuccess(); |
| }); |
| } |
| |
| function verifyHasReceivedTrackEndedEvent() { |
| if (hasReceivedTrackEndedEvent) { |
| reportTestSuccess(); |
| } else { |
| failTest('Did not receive ended event from track.'); |
| } |
| } |
| |
| </script> |
| </head> |
| <body> |
| <table border="0"> |
| <tr> |
| <td><video id="local-view" width="96" height="96" autoplay |
| style="display:none"></video></td> |
| <!-- The canvas is used to detect when video starts and stops. --> |
| <td><canvas id="local-view-canvas" width="96" height="96" |
| style="display:none"></canvas></td> |
| </tr> |
| </table> |
| </body> |
| </html> |