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 171 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
182 | 182 |
183 var stopBothVideoTracksAndVerify = function(streamPlayingInLocalView2) { | 183 var stopBothVideoTracksAndVerify = function(streamPlayingInLocalView2) { |
184 streamPlayingInLocalView2.getVideoTracks()[0].stop(); | 184 streamPlayingInLocalView2.getVideoTracks()[0].stop(); |
185 waitForVideoToStop('local-view-2'); | 185 waitForVideoToStop('local-view-2'); |
186 // Make sure the video track in gLocalStream is still playing in | 186 // Make sure the video track in gLocalStream is still playing in |
187 // 'local-view1' and then stop it. | 187 // 'local-view1' and then stop it. |
188 displayAndDetectVideo(gLocalStream, stopVideoTrack); | 188 displayAndDetectVideo(gLocalStream, stopVideoTrack); |
189 }; | 189 }; |
190 } | 190 } |
191 | 191 |
| 192 function twoGetUserMedia(constraints1, constraints2) { |
| 193 console.log('Calling Two GetUserMedia'); |
| 194 var result=""; |
| 195 navigator.webkitGetUserMedia( |
| 196 constraints1, |
| 197 function(stream) { |
| 198 displayDetectAndAnalyzeVideoInElement( |
| 199 stream, |
| 200 function(aspectRatio) { |
| 201 result = aspectRatio; |
| 202 requestSecondGetUserMedia(); |
| 203 }, |
| 204 'local-view'); |
| 205 }, |
| 206 failedCallback); |
| 207 var requestSecondGetUserMedia = function() { |
| 208 navigator.webkitGetUserMedia( |
| 209 constraints2, |
| 210 function(stream) { |
| 211 displayDetectAndAnalyzeVideoInElement( |
| 212 stream, |
| 213 function(aspectRatio) { |
| 214 result = result + '-' + aspectRatio; |
| 215 sendValueToTest(result); |
| 216 }, |
| 217 'local-view-2'); |
| 218 }, |
| 219 failedCallback); |
| 220 } |
| 221 } |
| 222 |
192 function failedCallback(error) { | 223 function failedCallback(error) { |
193 failTest('GetUserMedia call failed with code ' + error.code); | 224 failTest('GetUserMedia call failed with code ' + error.code); |
194 } | 225 } |
195 | 226 |
196 function plugStreamIntoVideoElement(stream, videoElement) { | 227 function plugStreamIntoVideoElement(stream, videoElement) { |
197 gLocalStream = stream; | 228 gLocalStream = stream; |
198 var localStreamUrl = URL.createObjectURL(stream); | 229 var localStreamUrl = URL.createObjectURL(stream); |
199 $(videoElement).src = localStreamUrl; | 230 $(videoElement).src = localStreamUrl; |
200 } | 231 } |
201 | 232 |
202 function displayIntoVideoElement(stream, callback, videoElement) { | 233 function displayIntoVideoElement(stream, callback, videoElement) { |
203 plugStreamIntoVideoElement(stream, videoElement); | 234 plugStreamIntoVideoElement(stream, videoElement); |
204 detectVideoPlaying(videoElement, callback); | 235 detectVideoPlaying(videoElement, callback); |
205 } | 236 } |
206 | 237 |
207 function displayAndDetectVideo(stream, callback) { | 238 function displayAndDetectVideo(stream, callback) { |
208 displayIntoVideoElement(stream, callback, 'local-view'); | 239 displayIntoVideoElement(stream, callback, 'local-view'); |
209 } | 240 } |
210 | 241 |
211 function displayDetectAndAnalyzeVideo(stream) { | 242 function displayDetectAndAnalyzeVideo(stream) { |
212 plugStreamIntoVideoElement(stream, 'local-view'); | 243 displayDetectAndAnalyzeVideoInElement(stream, |
213 analyzeVideo(); | 244 function(aspectRatio) { |
| 245 sendValueToTest(aspectRatio); |
| 246 }, |
| 247 'local-view'); |
| 248 } |
| 249 |
| 250 function displayDetectAndAnalyzeVideoInElement( |
| 251 stream, callback, videoElement) { |
| 252 plugStreamIntoVideoElement(stream, videoElement); |
| 253 detectAspectRatio(callback, videoElement); |
214 } | 254 } |
215 | 255 |
216 function createAndRenderClone(stream) { | 256 function createAndRenderClone(stream) { |
217 gLocalStream = stream; | 257 gLocalStream = stream; |
218 // TODO(perkj): --use-fake-device-for-media-stream do not currently | 258 // TODO(perkj): --use-fake-device-for-media-stream do not currently |
219 // work with audio devices and not all bots has a microphone. | 259 // work with audio devices and not all bots has a microphone. |
220 new_stream = new webkitMediaStream(); | 260 new_stream = new webkitMediaStream(); |
221 new_stream.addTrack(stream.getVideoTracks()[0]); | 261 new_stream.addTrack(stream.getVideoTracks()[0]); |
222 assertEquals(new_stream.getVideoTracks().length, 1); | 262 assertEquals(new_stream.getVideoTracks().length, 1); |
223 if (stream.getAudioTracks().length > 0) { | 263 if (stream.getAudioTracks().length > 0) { |
(...skipping 10 matching lines...) Expand all Loading... |
234 | 274 |
235 function stopVideoTrack() { | 275 function stopVideoTrack() { |
236 gLocalStream.getVideoTracks()[0].stop(); | 276 gLocalStream.getVideoTracks()[0].stop(); |
237 waitForVideoToStop('local-view'); | 277 waitForVideoToStop('local-view'); |
238 } | 278 } |
239 | 279 |
240 function waitAndStopVideoTrack(waitTimeInSeconds) { | 280 function waitAndStopVideoTrack(waitTimeInSeconds) { |
241 setTimeout(stopVideoTrack, waitTimeInSeconds * 1000); | 281 setTimeout(stopVideoTrack, waitTimeInSeconds * 1000); |
242 } | 282 } |
243 | 283 |
244 function analyzeVideo() { | |
245 detectAspectRatio(function(aspectRatio) { | |
246 sendValueToTest(aspectRatio); | |
247 }); | |
248 } | |
249 | |
250 // This test make sure multiple video renderers can be created for the same | 284 // This test make sure multiple video renderers can be created for the same |
251 // local video track and make sure a renderer can still render if other | 285 // local video track and make sure a renderer can still render if other |
252 // renderers are paused. See http://crbug/352619. | 286 // renderers are paused. See http://crbug/352619. |
253 function createMultipleVideoRenderersAndPause(stream) { | 287 function createMultipleVideoRenderersAndPause(stream) { |
254 function createDetectableRenderer(stream, id) { | 288 function createDetectableRenderer(stream, id) { |
255 var video = document.createElement('video'); | 289 var video = document.createElement('video'); |
256 document.body.appendChild(video); | 290 document.body.appendChild(video); |
257 var localStreamUrl = URL.createObjectURL(stream); | 291 var localStreamUrl = URL.createObjectURL(stream); |
258 video.id = id; | 292 video.id = id; |
259 video.src = localStreamUrl; | 293 video.src = localStreamUrl; |
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
297 // This function tries to calculate the aspect ratio shown by the fake capture | 331 // This function tries to calculate the aspect ratio shown by the fake capture |
298 // device in the video tag. For this, we count the amount of light green | 332 // device in the video tag. For this, we count the amount of light green |
299 // pixels along |aperture| pixels on the positive X and Y axis starting from | 333 // pixels along |aperture| pixels on the positive X and Y axis starting from |
300 // the center of the image. In this very center there should be a time-varying | 334 // the center of the image. In this very center there should be a time-varying |
301 // pacman; the algorithm counts for a couple of iterations and keeps the | 335 // pacman; the algorithm counts for a couple of iterations and keeps the |
302 // maximum amount of light green pixels on both directions. From this data | 336 // maximum amount of light green pixels on both directions. From this data |
303 // the aspect ratio is calculated and the test fails if the number of green | 337 // the aspect ratio is calculated and the test fails if the number of green |
304 // pixels are not the same along the X and Y axis. | 338 // pixels are not the same along the X and Y axis. |
305 // The result of the analysis is sent back to the test as a string on the | 339 // The result of the analysis is sent back to the test as a string on the |
306 // format "w=xxx:h=yyy". | 340 // format "w=xxx:h=yyy". |
307 function detectAspectRatio(callback) { | 341 function detectAspectRatio(callback, videoElementName) { |
308 var videoElement = $('local-view'); | 342 var videoElement = $(videoElementName); |
309 var canvas = $('local-view-canvas'); | 343 var canvas = $(videoElementName + '-canvas'); |
310 | 344 |
311 var maxLightGreenPixelsX = 0; | 345 var maxLightGreenPixelsX = 0; |
312 var maxLightGreenPixelsY = 0; | 346 var maxLightGreenPixelsY = 0; |
313 | 347 |
314 var iterations = 0; | 348 var iterations = 0; |
315 var maxIterations = 10; | 349 var maxIterations = 10; |
316 | 350 |
317 var detectorFunction = function() { | 351 var detectorFunction = function() { |
318 var width = videoElement.videoWidth; | 352 var width = videoElement.videoWidth; |
319 var height = videoElement.videoHeight; | 353 var height = videoElement.videoHeight; |
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
387 <tr> | 421 <tr> |
388 <td><video width="320" height="240" id="local-view-2" | 422 <td><video width="320" height="240" id="local-view-2" |
389 autoplay="autoplay"></video></td> | 423 autoplay="autoplay"></video></td> |
390 <!-- Canvases are named after their corresponding video elements. --> | 424 <!-- Canvases are named after their corresponding video elements. --> |
391 <td><canvas width="320" height="240" id="local-view-2-canvas" | 425 <td><canvas width="320" height="240" id="local-view-2-canvas" |
392 style="display:none"></canvas></td> | 426 style="display:none"></canvas></td> |
393 </tr> | 427 </tr> |
394 </table> | 428 </table> |
395 </body> | 429 </body> |
396 </html> | 430 </html> |
OLD | NEW |