Chromium Code Reviews| 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 139 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 150 | 150 |
| 151 // This test that a MediaStream can be cloned and that the clone can | 151 // This test that a MediaStream can be cloned and that the clone can |
| 152 // be rendered. | 152 // be rendered. |
| 153 function getUserMediaAndClone() { | 153 function getUserMediaAndClone() { |
| 154 console.log('Calling getUserMediaAndClone.'); | 154 console.log('Calling getUserMediaAndClone.'); |
| 155 navigator.webkitGetUserMedia({video: true, audio: true}, | 155 navigator.webkitGetUserMedia({video: true, audio: true}, |
| 156 createAndRenderClone, failedCallback); | 156 createAndRenderClone, failedCallback); |
| 157 } | 157 } |
| 158 | 158 |
| 159 // Creates two MediaStream and renders them locally. When the video of both | 159 // Creates two MediaStream and renders them locally. When the video of both |
| 160 // streams are detected to be rolling, we stop the local stream. Since both | 160 // streams are detected to be rolling, we stop the local video tracks. |
| 161 // streams have the same source, both video streams should stop. If they do, | |
| 162 // the test succeeds. | |
| 163 function twoGetUserMediaAndStop(constraints) { | 161 function twoGetUserMediaAndStop(constraints) { |
| 164 console.log('Calling Two GetUserMedia'); | 162 console.log('Calling Two GetUserMedia'); |
| 165 navigator.webkitGetUserMedia( | 163 navigator.webkitGetUserMedia( |
| 166 constraints, | 164 constraints, |
| 167 function(stream) { | 165 function(stream) { |
| 168 displayAndDetectVideo(stream, requestSecondGetUserMedia); | 166 displayAndDetectVideo(stream, requestSecondGetUserMedia); |
| 169 }, | 167 }, |
| 170 failedCallback); | 168 failedCallback); |
| 171 var requestSecondGetUserMedia = function() { | 169 var requestSecondGetUserMedia = function() { |
| 172 navigator.webkitGetUserMedia( | 170 navigator.webkitGetUserMedia( |
| 173 constraints, | 171 constraints, |
| 174 function(stream) { | 172 function(stream) { |
| 175 displayIntoVideoElement(stream, | 173 displayIntoVideoElement(stream, |
| 176 stopStreamAndVerifyAllLocalViewsDontPlayVideo, 'local-view-2'); | 174 stopBothVideoTracksAndVerify(stream), |
|
phoglund_chromium
2014/04/08 12:04:21
This is wrong; you're supposed to pass in a callba
perkj_chrome
2014/04/09 15:31:32
Good catch
| |
| 175 'local-view-2'); | |
| 177 }, | 176 }, |
| 178 failedCallback); | 177 failedCallback); |
| 179 }; | 178 }; |
| 180 | 179 |
| 181 var stopStreamAndVerifyAllLocalViewsDontPlayVideo = function() { | 180 var stopBothVideoTracksAndVerify = function(stream) { |
| 182 gLocalStream.getVideoTracks()[0].stop(); | |
| 183 | |
| 184 // Since local-view and local-view-2 are playing the video from the same | |
| 185 // source, both of them should stop. | |
| 186 waitForVideoToStop('local-view'); | |
| 187 waitForVideoToStop('local-view-2'); | 181 waitForVideoToStop('local-view-2'); |
|
phoglund_chromium
2014/04/08 12:04:21
Hm. This is confusing, move the wait-for-video-to-
perkj_chrome
2014/04/09 15:31:32
Done.
| |
| 182 stream.getVideoTracks()[0].stop(); | |
| 183 // Make sure the original track is still playing and then stop it. | |
|
phoglund_chromium
2014/04/08 12:04:21
So both tracks are no longer stopped by stopping t
perkj_chrome
2014/04/09 15:31:32
Right- stop is per track.
phoglund_chromium
2014/04/09 15:51:31
Ok, so you're stopping video track 0 on #183, then
perkj_chrome
2014/04/10 11:25:08
Done.
| |
| 184 displayAndDetectVideo(gLocalStream, stopVideoTrack); | |
| 188 }; | 185 }; |
| 189 } | 186 } |
| 190 | 187 |
| 191 function failedCallback(error) { | 188 function failedCallback(error) { |
| 192 failTest('GetUserMedia call failed with code ' + error.code); | 189 failTest('GetUserMedia call failed with code ' + error.code); |
| 193 } | 190 } |
| 194 | 191 |
| 195 function plugStreamIntoVideoElement(stream, videoElement) { | 192 function plugStreamIntoVideoElement(stream, videoElement) { |
| 196 gLocalStream = stream; | 193 gLocalStream = stream; |
| 197 var localStreamUrl = URL.createObjectURL(stream); | 194 var localStreamUrl = URL.createObjectURL(stream); |
| (...skipping 188 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 386 <tr> | 383 <tr> |
| 387 <td><video width="320" height="240" id="local-view-2" | 384 <td><video width="320" height="240" id="local-view-2" |
| 388 autoplay="autoplay"></video></td> | 385 autoplay="autoplay"></video></td> |
| 389 <!-- Canvases are named after their corresponding video elements. --> | 386 <!-- Canvases are named after their corresponding video elements. --> |
| 390 <td><canvas width="320" height="240" id="local-view-2-canvas" | 387 <td><canvas width="320" height="240" id="local-view-2-canvas" |
| 391 style="display:none"></canvas></td> | 388 style="display:none"></canvas></td> |
| 392 </tr> | 389 </tr> |
| 393 </table> | 390 </table> |
| 394 </body> | 391 </body> |
| 395 </html> | 392 </html> |
| OLD | NEW |