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" src="webrtc_test_audio.js"></script> | 4 <script type="text/javascript" src="webrtc_test_audio.js"></script> |
5 <script type="text/javascript"> | 5 <script type="text/javascript"> |
6 $ = function(id) { | 6 $ = function(id) { |
7 return document.getElementById(id); | 7 return document.getElementById(id); |
8 }; | 8 }; |
9 | 9 |
10 var gFirstConnection = null; | 10 var gFirstConnection = null; |
(...skipping 282 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
293 remoteVideoTrack = remoteStream.getVideoTracks()[0]; | 293 remoteVideoTrack = remoteStream.getVideoTracks()[0]; |
294 remoteVideoTrack.enabled = enabled; | 294 remoteVideoTrack.enabled = enabled; |
295 } | 295 } |
296 | 296 |
297 function enableRemoteAudio(peerConnection, enabled) { | 297 function enableRemoteAudio(peerConnection, enabled) { |
298 remoteStream = peerConnection.getRemoteStreams()[0]; | 298 remoteStream = peerConnection.getRemoteStreams()[0]; |
299 remoteAudioTrack = remoteStream.getAudioTracks()[0]; | 299 remoteAudioTrack = remoteStream.getAudioTracks()[0]; |
300 remoteAudioTrack.enabled = enabled; | 300 remoteAudioTrack.enabled = enabled; |
301 } | 301 } |
302 | 302 |
303 function callAndEnsureAudioIsPlaying(beLenient) { | 303 function callAndEnsureAudioIsPlaying(beLenient, constraints) { |
304 createConnections(null); | 304 createConnections(null); |
305 navigator.webkitGetUserMedia({audio: true, video: true}, | 305 navigator.webkitGetUserMedia(constraints, |
306 addStreamToBothConnectionsAndNegotiate, printGetUserMediaError); | 306 addStreamToBothConnectionsAndNegotiate, printGetUserMediaError); |
307 | 307 |
308 // Wait until we have gathered samples and can conclude if audio is playing. | 308 // Wait until we have gathered samples and can conclude if audio is playing. |
309 addExpectedEvent(); | 309 addExpectedEvent(); |
310 var onCallEstablished = function() { | 310 var onCallEstablished = function() { |
311 // Gather 50 samples per second for 2 seconds. | 311 // Gather 50 samples per second for 2 seconds. |
312 gatherAudioLevelSamples(gSecondConnection, 100, 50, function(samples) { | 312 gatherAudioLevelSamples(gSecondConnection, 100, 50, function(samples) { |
313 verifyAudioIsPlaying(samples, beLenient); | 313 verifyAudioIsPlaying(samples, beLenient); |
314 eventOccured(); | 314 eventOccured(); |
315 }); | 315 }); |
316 | |
317 // (Also, ensure video muting doesn't affect audio). | |
318 enableRemoteVideo(gSecondConnection, false); | |
319 }; | 316 }; |
320 | 317 |
321 detectVideoPlaying('remote-view-2', onCallEstablished); | 318 waitForConnectionToStabilize(gFirstConnection, onCallEstablished); |
322 } | 319 } |
323 | 320 |
324 function callAndEnsureAudioTrackMutingWorks(beLenient) { | 321 function callAndEnsureAudioTrackMutingWorks(beLenient) { |
325 callAndEnsureAudioIsPlaying(beLenient); | 322 callAndEnsureAudioIsPlaying(beLenient, {audio: true, video: true}); |
326 setAllEventsOccuredHandler(function() { | 323 setAllEventsOccuredHandler(function() { |
327 // Call is up, now mute the track and check everything goes silent (give | 324 // Call is up, now mute the track and check everything goes silent (give |
328 // it a small delay though, we don't expect it to happen instantly). | 325 // it a small delay though, we don't expect it to happen instantly). |
329 enableRemoteAudio(gSecondConnection, false); | 326 enableRemoteAudio(gSecondConnection, false); |
330 | 327 |
331 setTimeout(function() { | 328 setTimeout(function() { |
332 gatherAudioLevelSamples(gSecondConnection, 100, 50, function(samples) { | 329 gatherAudioLevelSamples(gSecondConnection, 100, 50, function(samples) { |
333 verifyIsSilent(samples); | 330 verifyIsSilent(samples); |
334 reportTestSuccess(); | 331 reportTestSuccess(); |
335 }); | 332 }); |
336 }, 500); | 333 }, 500); |
337 }); | 334 }); |
338 } | 335 } |
339 | 336 |
340 function callAndEnsureAudioTrackUnmutingWorks(beLenient) { | 337 function callAndEnsureAudioTrackUnmutingWorks(beLenient) { |
341 callAndEnsureAudioIsPlaying(beLenient); | 338 callAndEnsureAudioIsPlaying(beLenient, {audio: true, video: true}); |
342 setAllEventsOccuredHandler(function() { | 339 setAllEventsOccuredHandler(function() { |
343 // Mute, wait a while, unmute, verify audio gets back up. | 340 // Mute, wait a while, unmute, verify audio gets back up. |
| 341 // (Also, ensure video muting doesn't affect audio). |
344 enableRemoteAudio(gSecondConnection, false); | 342 enableRemoteAudio(gSecondConnection, false); |
| 343 enableRemoteVideo(gSecondConnection, false); |
345 | 344 |
346 setTimeout(function() { | 345 setTimeout(function() { |
347 enableRemoteAudio(gSecondConnection, true); | 346 enableRemoteAudio(gSecondConnection, true); |
348 }, 500); | 347 }, 500); |
349 | 348 |
350 setTimeout(function() { | 349 setTimeout(function() { |
351 // Sample for four seconds here; it can take a bit of time for audio to | 350 // Sample for four seconds here; it can take a bit of time for audio to |
352 // get back up after the unmute. | 351 // get back up after the unmute. |
353 gatherAudioLevelSamples(gSecondConnection, 200, 50, function(samples) { | 352 gatherAudioLevelSamples(gSecondConnection, 200, 50, function(samples) { |
354 verifyAudioIsPlaying(samples, beLenient); | 353 verifyAudioIsPlaying(samples, beLenient); |
(...skipping 504 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
859 <td><canvas width="320" height="240" id="remote-view-2-canvas" | 858 <td><canvas width="320" height="240" id="remote-view-2-canvas" |
860 style="display:none"></canvas></td> | 859 style="display:none"></canvas></td> |
861 <td><canvas width="320" height="240" id="remote-view-3-canvas" | 860 <td><canvas width="320" height="240" id="remote-view-3-canvas" |
862 style="display:none"></canvas></td> | 861 style="display:none"></canvas></td> |
863 <td><canvas width="320" height="240" id="remote-view-4-canvas" | 862 <td><canvas width="320" height="240" id="remote-view-4-canvas" |
864 style="display:none"></canvas></td> | 863 style="display:none"></canvas></td> |
865 </tr> | 864 </tr> |
866 </table> | 865 </table> |
867 </body> | 866 </body> |
868 </html> | 867 </html> |
OLD | NEW |