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 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; |
|
phoglund_chromium
2014/10/09 12:20:07
Unless of course you see a problem with doing the
| |
| 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 detectVideoInLocalView1(stream, maybeStopBothVideoTracksAndVerify); |
| 181 }, | 176 }, |
| 182 failedCallback); | 177 failedCallback); |
| 183 var requestSecondGetUserMedia = function() { | 178 navigator.webkitGetUserMedia( |
| 184 navigator.webkitGetUserMedia( | 179 constraints, |
| 185 constraints, | 180 function(stream) { |
| 186 function(stream) { | 181 stream2 = stream; |
| 187 stream2 = stream; | 182 attachMediaStream(stream, 'local-view-2'); |
| 188 attachMediaStream(stream, 'local-view-2'); | 183 detectVideoPlaying('local-view-2', maybeStopBothVideoTracksAndVerify); |
| 189 detectVideoPlaying('local-view-2', stopBothVideoTracksAndVerify); | 184 }, |
| 190 }, | 185 failedCallback); |
| 191 failedCallback); | |
| 192 }; | |
| 193 | 186 |
| 194 var stopBothVideoTracksAndVerify = function() { | 187 var maybeStopBothVideoTracksAndVerify = function() { |
| 195 // Stop track 2, ensure that stops track 2 but not track 1, then stop | 188 if (stream1 == null || stream2 == null) |
| 196 // track 1. | 189 return; |
| 190 | |
| 191 // Stop track 2, ensure track 2 stops but not track 1, then stop track 1. | |
| 197 stream2.getVideoTracks()[0].stop(); | 192 stream2.getVideoTracks()[0].stop(); |
| 198 waitForVideoToStop('local-view-1'); | 193 waitForVideoToStop('local-view-1'); |
| 199 waitForVideoToStop('local-view-2'); | 194 waitForVideoToStop('local-view-2'); |
| 200 detectVideoInLocalView1(stream1, function() { | 195 detectVideoInLocalView1(stream1, function() { |
| 201 stream1.getVideoTracks()[0].stop(); | 196 stream1.getVideoTracks()[0].stop(); |
| 202 }); | 197 }); |
| 203 }; | 198 }; |
| 204 } | 199 } |
| 205 | 200 |
| 206 function twoGetUserMedia(constraints1, | 201 // Makes to getUserMedia calls in parallel and detects the aspect ratio for |
| 207 constraints2) { | 202 // both. The two aspect ratios are returned to the test separated by a dash, |
| 208 // TODO(phoglund): see TODO on twoGetUserMediaAndStop. | 203 // like for instance w=640:h=480-w=640:h=480. |
| 209 var result=""; | 204 function twoGetUserMedia(constraints1, constraints2) { |
| 205 var aspectRatio1 = null; | |
| 206 var aspectRatio2 = null; | |
| 210 navigator.webkitGetUserMedia( | 207 navigator.webkitGetUserMedia( |
| 211 constraints1, | 208 constraints1, |
| 212 function(stream) { | 209 function(stream) { |
| 213 displayDetectAndAnalyzeVideoInElement( | 210 displayDetectAndAnalyzeVideoInElement( |
| 214 stream, | 211 stream, |
| 215 function(aspectRatio) { | 212 function(aspectRatio) { |
| 216 result = aspectRatio; | 213 aspectRatio1 = aspectRatio; |
| 217 requestSecondGetUserMedia(); | 214 maybeFinishTest(); |
| 218 }, | 215 }, |
| 219 'local-view-1'); | 216 'local-view-1'); |
| 220 }, | 217 }, |
| 221 failedCallback); | 218 failedCallback); |
| 222 var requestSecondGetUserMedia = function() { | 219 navigator.webkitGetUserMedia( |
| 223 navigator.webkitGetUserMedia( | 220 constraints2, |
| 224 constraints2, | 221 function(stream) { |
| 225 function(stream) { | 222 displayDetectAndAnalyzeVideoInElement( |
| 226 displayDetectAndAnalyzeVideoInElement( | 223 stream, |
| 227 stream, | 224 function(aspectRatio) { |
| 228 function(aspectRatio) { | 225 aspectRatio2 = aspectRatio; |
| 229 result = result + '-' + aspectRatio; | 226 maybeFinishTest(); |
| 230 sendValueToTest(result); | 227 }, |
| 231 }, | 228 'local-view-2'); |
| 232 'local-view-2'); | 229 }, |
| 233 }, | 230 failedCallback); |
| 234 failedCallback); | 231 |
| 232 var maybeFinishTest = function() { | |
| 233 if (aspectRatio1 == null || aspectRatio2 == null) | |
| 234 return; | |
| 235 sendValueToTest(aspectRatio1 + '-' + aspectRatio2); | |
| 235 } | 236 } |
| 236 } | 237 } |
| 237 | 238 |
| 238 // Calls GetUserMedia twice and verify that the frame rate is as expected for | 239 // Calls GetUserMedia twice and verify that the frame rate is as expected for |
| 239 // both streams. | 240 // both streams. |
| 240 function twoGetUserMediaAndVerifyFrameRate(constraints1, | 241 function twoGetUserMediaAndVerifyFrameRate(constraints1, |
| 241 constraints2, | 242 constraints2, |
| 242 expected_frame_rate1, | 243 expected_frame_rate1, |
| 243 expected_frame_rate2) { | 244 expected_frame_rate2) { |
| 244 // TODO(phoglund): see TODO on twoGetUserMediaAndStop. | |
| 245 addExpectedEvent(); | 245 addExpectedEvent(); |
| 246 addExpectedEvent(); | 246 addExpectedEvent(); |
| 247 var validateFrameRateCallback = function (success) { | 247 var validateFrameRateCallback = function (result) { |
| 248 if (!success) | 248 if (result != 'OK') |
| 249 failTest("Failed to validate frameRate."); | 249 failTest(result); |
|
phoglund_chromium
2014/10/09 12:20:07
I've been annoyed by this rather bare error messag
| |
| 250 eventOccured(); | 250 eventOccured(); |
| 251 }; | 251 }; |
| 252 | 252 |
| 253 navigator.webkitGetUserMedia( | 253 navigator.webkitGetUserMedia( |
| 254 constraints1, | 254 constraints1, |
| 255 function(stream) { | 255 function(stream) { |
| 256 requestSecondGetUserMedia(); | |
| 257 attachMediaStream(stream, 'local-view-1'); | 256 attachMediaStream(stream, 'local-view-1'); |
| 258 detectVideoPlaying('local-view-1', | 257 detectVideoPlaying('local-view-1', |
| 259 function() { | 258 function() { |
| 260 validateFrameRate('local-view-1', expected_frame_rate1, | 259 validateFrameRate('local-view-1', expected_frame_rate1, |
| 261 validateFrameRateCallback); | 260 validateFrameRateCallback); |
| 262 }); | 261 }); |
| 263 }, | 262 }, |
| 264 failedCallback); | 263 failedCallback); |
| 265 var requestSecondGetUserMedia = function() { | 264 navigator.webkitGetUserMedia( |
| 266 navigator.webkitGetUserMedia( | 265 constraints2, |
| 267 constraints2, | 266 function(stream) { |
| 268 function(stream) { | 267 attachMediaStream(stream, 'local-view-2'); |
| 269 attachMediaStream(stream, 'local-view-2'); | 268 detectVideoPlaying('local-view-2', |
| 270 detectVideoPlaying('local-view-2', | 269 function() { |
| 271 function() { | 270 validateFrameRate('local-view-2', expected_frame_rate2, |
| 272 validateFrameRate('local-view-2', expected_frame_rate2, | 271 validateFrameRateCallback); |
| 273 validateFrameRateCallback); | 272 }); |
| 274 }); | 273 }, |
| 275 }, | 274 failedCallback); |
| 276 failedCallback); | |
| 277 } | |
| 278 } | 275 } |
| 279 | 276 |
| 280 function failedCallback(error) { | 277 function failedCallback(error) { |
| 281 failTest('GetUserMedia call failed with code ' + error.code); | 278 failTest('GetUserMedia call failed with code ' + error.code); |
| 282 } | 279 } |
| 283 | 280 |
| 284 function attachMediaStream(stream, videoElement) { | 281 function attachMediaStream(stream, videoElement) { |
| 285 var localStreamUrl = URL.createObjectURL(stream); | 282 var localStreamUrl = URL.createObjectURL(stream); |
| 286 $(videoElement).src = localStreamUrl; | 283 $(videoElement).src = localStreamUrl; |
| 287 } | 284 } |
| (...skipping 176 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 464 </tr> | 461 </tr> |
| 465 <tr> | 462 <tr> |
| 466 <td><video id="local-view-2" width="320" height="240" autoplay | 463 <td><video id="local-view-2" width="320" height="240" autoplay |
| 467 style="display:none"></video></td> | 464 style="display:none"></video></td> |
| 468 <td><canvas id="local-view-2-canvas" width="320" height="240" | 465 <td><canvas id="local-view-2-canvas" width="320" height="240" |
| 469 style="display:none"></canvas></td> | 466 style="display:none"></canvas></td> |
| 470 </tr> | 467 </tr> |
| 471 </table> | 468 </table> |
| 472 </body> | 469 </body> |
| 473 </html> | 470 </html> |
| OLD | NEW |