| 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 setAllEventsOccuredHandler(function() { | 9 setAllEventsOccuredHandler(function() { |
| 10 reportTestSuccess(); | 10 reportTestSuccess(); |
| (...skipping 145 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 156 // This test that a MediaStream can be cloned and that the clone can | 156 // This test that a MediaStream can be cloned and that the clone can |
| 157 // be rendered. | 157 // be rendered. |
| 158 function getUserMediaAndClone() { | 158 function getUserMediaAndClone() { |
| 159 console.log('Calling getUserMediaAndClone.'); | 159 console.log('Calling getUserMediaAndClone.'); |
| 160 navigator.webkitGetUserMedia({video: true, audio: true}, | 160 navigator.webkitGetUserMedia({video: true, audio: true}, |
| 161 createAndRenderClone, failedCallback); | 161 createAndRenderClone, failedCallback); |
| 162 } | 162 } |
| 163 | 163 |
| 164 // Creates two MediaStream and renders them locally. When the video of both | 164 // Creates two MediaStream and renders them locally. When the video of both |
| 165 // streams are detected to be rolling, we stop the local video tracks one at | 165 // streams are detected to be rolling, we stop the local video tracks one at |
| 166 // the time. | 166 // the time. In particular, we verify that stopping one track does not stop |
| 167 // the other. |
| 167 function twoGetUserMediaAndStop(constraints) { | 168 function twoGetUserMediaAndStop(constraints) { |
| 168 // TODO(phoglund): make gUM requests in parallel; this test is too slow | |
| 169 // and flakes on slow bots (http://crbug.com/417756). The current cycle of | |
| 170 // detect - gum - detect - gum - stop - detect - stop - detect contains too | |
| 171 // many detection phases. On bots with GPU emulation this looks to be really | |
| 172 // slow, so I was thinking we could at least get video up for both streams | |
| 173 // simultaneously and thereby run the first two detects in parallel. | |
| 174 var stream1 = null; | 169 var stream1 = null; |
| 175 var stream2 = null; | 170 var stream2 = null; |
| 176 navigator.webkitGetUserMedia( | 171 navigator.webkitGetUserMedia( |
| 177 constraints, | 172 constraints, |
| 178 function(stream) { | 173 function(stream) { |
| 179 stream1 = stream; | 174 stream1 = stream; |
| 180 detectVideoInLocalView1(stream, requestSecondGetUserMedia); | 175 attachMediaStream(stream, 'local-view-1'); |
| 176 requestSecondGetUserMedia(); |
| 181 }, | 177 }, |
| 182 failedCallback); | 178 failedCallback); |
| 183 var requestSecondGetUserMedia = function() { | 179 var requestSecondGetUserMedia = function() { |
| 184 navigator.webkitGetUserMedia( | 180 navigator.webkitGetUserMedia( |
| 185 constraints, | 181 constraints, |
| 186 function(stream) { | 182 function(stream) { |
| 187 stream2 = stream; | 183 stream2 = stream; |
| 188 attachMediaStream(stream, 'local-view-2'); | 184 attachMediaStream(stream, 'local-view-2'); |
| 189 detectVideoPlaying('local-view-2', stopBothVideoTracksAndVerify); | 185 stopBothVideoTracksAndVerify(); |
| 190 }, | 186 }, |
| 191 failedCallback); | 187 failedCallback); |
| 192 }; | 188 }; |
| 193 | 189 |
| 194 var stopBothVideoTracksAndVerify = function() { | 190 var stopBothVideoTracksAndVerify = function() { |
| 195 // Stop track 2, ensure that stops track 2 but not track 1, then stop | 191 // Stop track 2, ensure track 2 stops but not track 1, then stop track 1. |
| 196 // track 1. | |
| 197 stream2.getVideoTracks()[0].stop(); | 192 stream2.getVideoTracks()[0].stop(); |
| 198 waitForVideoToStop('local-view-1'); | 193 detectVideoStopped('local-view-2', function() { |
| 199 waitForVideoToStop('local-view-2'); | 194 detectVideoInLocalView1(stream1, function() { |
| 200 detectVideoInLocalView1(stream1, function() { | 195 stream1.getVideoTracks()[0].stop(); |
| 201 stream1.getVideoTracks()[0].stop(); | 196 waitForVideoToStop('local-view-1'); |
| 197 }); |
| 202 }); | 198 }); |
| 203 }; | 199 }; |
| 204 } | 200 } |
| 205 | 201 |
| 206 function twoGetUserMedia(constraints1, | 202 function twoGetUserMedia(constraints1, constraints2) { |
| 207 constraints2) { | |
| 208 // TODO(phoglund): see TODO on twoGetUserMediaAndStop. | |
| 209 var result=""; | 203 var result=""; |
| 210 navigator.webkitGetUserMedia( | 204 navigator.webkitGetUserMedia( |
| 211 constraints1, | 205 constraints1, |
| 212 function(stream) { | 206 function(stream) { |
| 213 displayDetectAndAnalyzeVideoInElement( | 207 displayDetectAndAnalyzeVideoInElement( |
| 214 stream, | 208 stream, |
| 215 function(aspectRatio) { | 209 function(aspectRatio) { |
| 216 result = aspectRatio; | 210 result = aspectRatio; |
| 217 requestSecondGetUserMedia(); | 211 requestSecondGetUserMedia(); |
| 218 }, | 212 }, |
| 219 'local-view-1'); | 213 'local-view-1'); |
| 220 }, | 214 }, |
| 221 failedCallback); | 215 failedCallback); |
| 222 var requestSecondGetUserMedia = function() { | 216 var requestSecondGetUserMedia = function() { |
| 223 navigator.webkitGetUserMedia( | 217 navigator.webkitGetUserMedia( |
| 224 constraints2, | 218 constraints2, |
| 225 function(stream) { | 219 function(stream) { |
| 226 displayDetectAndAnalyzeVideoInElement( | 220 displayDetectAndAnalyzeVideoInElement( |
| 227 stream, | 221 stream, |
| 228 function(aspectRatio) { | 222 function(aspectRatio) { |
| 229 result = result + '-' + aspectRatio; | 223 result = result + '-' + aspectRatio; |
| 230 sendValueToTest(result); | 224 sendValueToTest(result); |
| 231 }, | 225 }, |
| 232 'local-view-2'); | 226 'local-view-2'); |
| 233 }, | 227 }, |
| 234 failedCallback); | 228 failedCallback); |
| 235 } | 229 } |
| 236 } | 230 } |
| 237 | 231 |
| 238 // Calls GetUserMedia twice and verify that the frame rate is as expected for | 232 // Calls GetUserMedia twice and verify that the frame rate is as expected for |
| 239 // both streams. | 233 // both streams. |
| 240 function twoGetUserMediaAndVerifyFrameRate(constraints1, | 234 function twoGetUserMediaAndVerifyFrameRate(constraints1, |
| 241 constraints2, | 235 constraints2, |
| 242 expected_frame_rate1, | 236 expected_frame_rate1, |
| 243 expected_frame_rate2) { | 237 expected_frame_rate2) { |
| 244 // TODO(phoglund): see TODO on twoGetUserMediaAndStop. | |
| 245 addExpectedEvent(); | 238 addExpectedEvent(); |
| 246 addExpectedEvent(); | 239 addExpectedEvent(); |
| 247 var validateFrameRateCallback = function (success) { | 240 var validateFrameRateCallback = function (success) { |
| 248 if (!success) | 241 if (!success) |
| 249 failTest("Failed to validate frameRate."); | 242 failTest("Failed to validate frameRate."); |
| 250 eventOccured(); | 243 eventOccured(); |
| 251 }; | 244 }; |
| 252 | 245 |
| 253 navigator.webkitGetUserMedia( | 246 navigator.webkitGetUserMedia( |
| 254 constraints1, | 247 constraints1, |
| 255 function(stream) { | 248 function(stream) { |
| 256 requestSecondGetUserMedia(); | 249 requestSecondGetUserMedia(); |
| 257 attachMediaStream(stream, 'local-view-1'); | 250 attachMediaStream(stream, 'local-view-1'); |
| 258 detectVideoPlaying('local-view-1', | 251 detectVideoPlaying( |
| 252 'local-view-1', |
| 259 function() { | 253 function() { |
| 260 validateFrameRate('local-view-1', expected_frame_rate1, | 254 validateFrameRate('local-view-1', expected_frame_rate1, |
| 261 validateFrameRateCallback); | 255 validateFrameRateCallback); |
| 262 }); | 256 }); |
| 263 }, | 257 }, |
| 264 failedCallback); | 258 failedCallback); |
| 265 var requestSecondGetUserMedia = function() { | 259 var requestSecondGetUserMedia = function() { |
| 266 navigator.webkitGetUserMedia( | 260 navigator.webkitGetUserMedia( |
| 267 constraints2, | 261 constraints2, |
| 268 function(stream) { | 262 function(stream) { |
| 269 attachMediaStream(stream, 'local-view-2'); | 263 attachMediaStream(stream, 'local-view-2'); |
| 270 detectVideoPlaying('local-view-2', | 264 detectVideoPlaying( |
| 265 'local-view-2', |
| 271 function() { | 266 function() { |
| 272 validateFrameRate('local-view-2', expected_frame_rate2, | 267 validateFrameRate('local-view-2', expected_frame_rate2, |
| 273 validateFrameRateCallback); | 268 validateFrameRateCallback); |
| 274 }); | 269 }); |
| 275 }, | 270 }, |
| 276 failedCallback); | 271 failedCallback); |
| 277 } | 272 } |
| 278 } | 273 } |
| 279 | 274 |
| 280 function failedCallback(error) { | 275 function failedCallback(error) { |
| 281 failTest('GetUserMedia call failed with code ' + error.code); | 276 failTest('GetUserMedia call failed with code ' + error.code); |
| 282 } | 277 } |
| 283 | 278 |
| (...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 386 // pixels are not the same along the X and Y axis. | 381 // pixels are not the same along the X and Y axis. |
| 387 // The result of the analysis is sent back to the test as a string on the | 382 // The result of the analysis is sent back to the test as a string on the |
| 388 // format "w=xxx:h=yyy". | 383 // format "w=xxx:h=yyy". |
| 389 function detectAspectRatio(callback, videoElementName) { | 384 function detectAspectRatio(callback, videoElementName) { |
| 390 var videoElement = $(videoElementName); | 385 var videoElement = $(videoElementName); |
| 391 var canvas = $(videoElementName + '-canvas'); | 386 var canvas = $(videoElementName + '-canvas'); |
| 392 | 387 |
| 393 var maxLightGreenPixelsX = 0; | 388 var maxLightGreenPixelsX = 0; |
| 394 var maxLightGreenPixelsY = 0; | 389 var maxLightGreenPixelsY = 0; |
| 395 | 390 |
| 391 // TODO(phoglund): don't iterate 10 times - too slow on Windows. |
| 396 var iterations = 0; | 392 var iterations = 0; |
| 397 var maxIterations = 10; | 393 var maxIterations = 10; |
| 398 | 394 |
| 399 var detectorFunction = function() { | 395 var detectorFunction = function() { |
| 400 var width = videoElement.videoWidth; | 396 var width = videoElement.videoWidth; |
| 401 var height = videoElement.videoHeight; | 397 var height = videoElement.videoHeight; |
| 402 if (width == 0 || height == 0) | 398 if (width == 0 || height == 0) |
| 403 return; | 399 return; |
| 404 | 400 |
| 405 canvas.width = width; | 401 canvas.width = width; |
| (...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 464 </tr> | 460 </tr> |
| 465 <tr> | 461 <tr> |
| 466 <td><video id="local-view-2" width="320" height="240" autoplay | 462 <td><video id="local-view-2" width="320" height="240" autoplay |
| 467 style="display:none"></video></td> | 463 style="display:none"></video></td> |
| 468 <td><canvas id="local-view-2-canvas" width="320" height="240" | 464 <td><canvas id="local-view-2-canvas" width="320" height="240" |
| 469 style="display:none"></canvas></td> | 465 style="display:none"></canvas></td> |
| 470 </tr> | 466 </tr> |
| 471 </table> | 467 </table> |
| 472 </body> | 468 </body> |
| 473 </html> | 469 </html> |
| OLD | NEW |