OLD | NEW |
---|---|
1 <html> | 1 <html> |
phoglund_chromium
2013/04/11 11:16:48
Rename this file to something like basic_getuserme
perkj_chrome
2013/04/11 11:50:48
Done.
| |
2 <head> | 2 <head> |
3 <script type="text/javascript" src="webrtc_test_utilities.js"></script> | |
3 <script type="text/javascript"> | 4 <script type="text/javascript"> |
5 $ = function(id) { | |
6 return document.getElementById(id); | |
7 }; | |
8 | |
9 var gLocalStream = null; | |
10 | |
phoglund_chromium
2013/04/11 11:16:48
I'd prefer if this is done through some accessor.
perkj_chrome
2013/04/11 11:50:48
Done.
| |
11 gAllEventsOccured = function() { | |
12 gLocalStream.stop(); | |
13 document.title = 'OK'; | |
14 } | |
15 | |
16 // This test that a MediaStream can be created and a local preview | |
17 // rendered. | |
4 function getUserMedia(constraints) { | 18 function getUserMedia(constraints) { |
5 navigator.webkitGetUserMedia(constraints, okCallback, failedCallback); | 19 navigator.webkitGetUserMedia(constraints, displayAndWaitForVideo, |
20 failedCallback); | |
6 } | 21 } |
7 | 22 |
23 // This test that a MediaStream can be cloned and that the clone can | |
24 // be rendered. | |
25 function getUserMediaAndClone() { | |
26 navigator.webkitGetUserMedia({video: true, audio: true}, | |
27 createAndRenderClone, failedCallback); | |
28 } | |
29 | |
8 function failedCallback(error) { | 30 function failedCallback(error) { |
9 document.title = 'GetUserMedia call failed with code ' + error.code; | 31 document.title = 'GetUserMedia call failed with code ' + error.code; |
10 } | 32 } |
11 | 33 |
12 function okCallback(stream) { | 34 function displayAndWaitForVideo(stream) { |
13 stream.stop(); | 35 gLocalStream = stream; |
14 document.title = 'OK'; | 36 var localStreamUrl = webkitURL.createObjectURL(stream); |
37 $('local-view').src = localStreamUrl; | |
38 waitForVideo('local-view'); | |
15 } | 39 } |
16 </script> | 40 |
41 function createAndRenderClone(stream) { | |
42 gLocalStream = stream; | |
43 | |
44 var new_stream = new webkitMediaStream(stream.getAudioTracks()); | |
45 expectEquals(new_stream.getAudioTracks().length, 1); | |
46 new_stream.addTrack(stream.getVideoTracks()[0]); | |
47 expectEquals(new_stream.getVideoTracks().length, 1); | |
48 new_stream.removeTrack(new_stream.getAudioTracks()[0]); | |
49 expectEquals(new_stream.getAudioTracks().length, 0); | |
50 | |
51 var newStreamUrl = webkitURL.createObjectURL(new_stream); | |
52 $('local-view').src = newStreamUrl; | |
53 waitForVideo('local-view'); | |
54 } | |
55 | |
56 </script> | |
17 </head> | 57 </head> |
58 <body> | |
59 <table border="0"> | |
60 <tr> | |
61 <td>Local Preview</td> | |
62 </tr> | |
63 <tr> | |
64 <td><video width="320" height="240" id="local-view" | |
65 autoplay="autoplay"></video></td> | |
66 <!-- Canvases are named after their corresponding video elements. --> | |
67 <td><canvas width="320" height="240" id="local-view-canvas" | |
68 style="display:none"></canvas></td> | |
69 </tr> | |
70 </table> | |
71 </body> | |
18 </html> | 72 </html> |
OLD | NEW |