OLD | NEW |
---|---|
1 <html> | 1 <html> |
2 <head> | 2 <head> |
3 <script type="text/javascript" src="webrtc_test_utilities.js"></script> | 3 <script type="text/javascript" src="webrtc_test_utilities.js"></script> |
4 <script type="text/javascript"> | 4 <script type="text/javascript"> |
5 $ = function(id) { | 5 $ = function(id) { |
6 return document.getElementById(id); | 6 return document.getElementById(id); |
7 }; | 7 }; |
8 | 8 |
9 var gLocalStream = null; | 9 var gLocalStream = null; |
10 | 10 |
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
57 constraints, displayDetectAndAnalyzeVideo, failedCallback); | 57 constraints, displayDetectAndAnalyzeVideo, failedCallback); |
58 } | 58 } |
59 | 59 |
60 // This test that a MediaStream can be cloned and that the clone can | 60 // This test that a MediaStream can be cloned and that the clone can |
61 // be rendered. | 61 // be rendered. |
62 function getUserMediaAndClone() { | 62 function getUserMediaAndClone() { |
63 navigator.webkitGetUserMedia({video: true, audio: true}, | 63 navigator.webkitGetUserMedia({video: true, audio: true}, |
64 createAndRenderClone, failedCallback); | 64 createAndRenderClone, failedCallback); |
65 } | 65 } |
66 | 66 |
67 // Creates two MediaStream and renders them locally. When the video of both | |
68 // streams are detected to be rolling, the test succeeds. | |
phoglund_chromium
2014/01/16 08:22:07
... we stop the local stream. Since both streams h
no longer working on chromium
2014/01/16 13:08:56
Fixed the comment, but actually it is because both
| |
69 function twoGetUserMediaAndStop(constraints) { | |
70 document.title = 'Calling Two GetUserMedia'; | |
71 navigator.webkitGetUserMedia( | |
72 constraints, | |
73 function(stream) { | |
74 displayAndDetectVideo(stream, requestSecondGetUserMedia); | |
75 }, | |
76 failedCallback); | |
77 var requestSecondGetUserMedia = function() { | |
78 navigator.webkitGetUserMedia( | |
79 constraints, | |
80 function(stream) { | |
81 displayIntoVideoElement(stream, | |
82 stopStreamAndVerifyAllLocalViewsDontPlayVideo, 'local-view-2'); | |
83 }, | |
84 failedCallback); | |
85 }; | |
86 | |
87 var stopStreamAndVerifyAllLocalViewsDontPlayVideo = function() { | |
88 gLocalStream.getVideoTracks()[0].stop(); | |
89 | |
90 // Since local-view and local-view-2 are playing the video from the same | |
91 // source, both of them should stop. | |
92 waitForVideoToStop('local-view'); | |
93 waitForVideoToStop('local-view-2'); | |
94 }; | |
95 } | |
96 | |
67 function failedCallback(error) { | 97 function failedCallback(error) { |
68 document.title = 'GetUserMedia call failed with code ' + error.code; | 98 document.title = 'GetUserMedia call failed with code ' + error.code; |
69 sendValueToTest(document.title); | 99 sendValueToTest(document.title); |
70 } | 100 } |
71 | 101 |
72 function plugStreamIntoLocalView(stream) { | 102 function plugStreamIntoVideoElement(stream, videoElement) { |
73 gLocalStream = stream; | 103 gLocalStream = stream; |
74 var localStreamUrl = URL.createObjectURL(stream); | 104 var localStreamUrl = URL.createObjectURL(stream); |
75 $('local-view').src = localStreamUrl; | 105 $(videoElement).src = localStreamUrl; |
106 } | |
107 | |
108 function displayIntoVideoElement(stream, callback, videoElement) { | |
109 plugStreamIntoVideoElement(stream, videoElement); | |
110 document.title = 'Waiting for video...'; | |
111 detectVideoPlaying(videoElement, callback); | |
76 } | 112 } |
77 | 113 |
78 function displayAndDetectVideo(stream, callback) { | 114 function displayAndDetectVideo(stream, callback) { |
79 plugStreamIntoLocalView(stream); | 115 displayIntoVideoElement(stream, callback, 'local-view'); |
80 document.title = 'Waiting for video...'; | |
81 detectVideoPlaying('local-view', callback); | |
82 } | 116 } |
83 | 117 |
84 function displayDetectAndAnalyzeVideo(stream) { | 118 function displayDetectAndAnalyzeVideo(stream) { |
85 plugStreamIntoLocalView(stream); | 119 plugStreamIntoVideoElement(stream, 'local-view'); |
86 analyzeVideo(); | 120 analyzeVideo(); |
87 } | 121 } |
88 | 122 |
89 function createAndRenderClone(stream) { | 123 function createAndRenderClone(stream) { |
90 gLocalStream = stream; | 124 gLocalStream = stream; |
91 // TODO(perkj): --use-fake-device-for-media-stream do not currently | 125 // TODO(perkj): --use-fake-device-for-media-stream do not currently |
92 // work with audio devices and not all bots has a microphone. | 126 // work with audio devices and not all bots has a microphone. |
93 new_stream = new webkitMediaStream(); | 127 new_stream = new webkitMediaStream(); |
94 new_stream.addTrack(stream.getVideoTracks()[0]); | 128 new_stream.addTrack(stream.getVideoTracks()[0]); |
95 expectEquals(new_stream.getVideoTracks().length, 1); | 129 expectEquals(new_stream.getVideoTracks().length, 1); |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
127 </script> | 161 </script> |
128 </head> | 162 </head> |
129 <body> | 163 <body> |
130 <table border="0"> | 164 <table border="0"> |
131 <tr> | 165 <tr> |
132 <td>Local Preview</td> | 166 <td>Local Preview</td> |
133 </tr> | 167 </tr> |
134 <tr> | 168 <tr> |
135 <td><video width="320" height="240" id="local-view" | 169 <td><video width="320" height="240" id="local-view" |
136 autoplay="autoplay"></video></td> | 170 autoplay="autoplay"></video></td> |
171 <td><canvas width="320" height="240" id="local-view-canvas" | |
172 style="display:none"></canvas></td> | |
173 </tr> | |
174 <tr> | |
175 <td>Local Preview 2</td> | |
176 </tr> | |
177 <tr> | |
178 <td><video width="320" height="240" id="local-view-2" | |
179 autoplay="autoplay"></video></td> | |
137 <!-- Canvases are named after their corresponding video elements. --> | 180 <!-- Canvases are named after their corresponding video elements. --> |
138 <td><canvas width="320" height="240" id="local-view-canvas" | 181 <td><canvas width="320" height="240" id="local-view-2-canvas" |
139 style="display:none"></canvas></td> | 182 style="display:none"></canvas></td> |
140 </tr> | 183 </tr> |
141 </table> | 184 </table> |
142 </body> | 185 </body> |
143 </html> | 186 </html> |
OLD | NEW |