| 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 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 65 waitForVideo('remote-view-2'); | 65 waitForVideo('remote-view-2'); |
| 66 } | 66 } |
| 67 | 67 |
| 68 // First calls without streams on any connections, and then adds a stream | 68 // First calls without streams on any connections, and then adds a stream |
| 69 // to peer connection 1 which gets sent to peer connection 2. We must wait | 69 // to peer connection 1 which gets sent to peer connection 2. We must wait |
| 70 // for the first negotiation to complete before starting the second one, which | 70 // for the first negotiation to complete before starting the second one, which |
| 71 // is why we wait until the connection is stable before re-negotiating. | 71 // is why we wait until the connection is stable before re-negotiating. |
| 72 function callEmptyThenAddOneStreamAndRenegotiate(constraints) { | 72 function callEmptyThenAddOneStreamAndRenegotiate(constraints) { |
| 73 createConnections(null); | 73 createConnections(null); |
| 74 negotiate(); | 74 negotiate(); |
| 75 waitForConnectionToStabilize(gFirstConnection); | 75 waitForConnectionToStabilize(gFirstConnection, function() { |
| 76 navigator.webkitGetUserMedia(constraints, | 76 navigator.webkitGetUserMedia(constraints, |
| 77 addStreamToTheFirstConnectionAndNegotiate, printGetUserMediaError); | 77 addStreamToTheFirstConnectionAndNegotiate, printGetUserMediaError); |
| 78 // Only the first connection is sending here. | 78 // Only the first connection is sending here. |
| 79 waitForVideo('remote-view-2'); | 79 waitForVideo('remote-view-2'); |
| 80 }); |
| 80 } | 81 } |
| 81 | 82 |
| 82 // First makes a call between pc1 and pc2, and then makes a call between pc3 | 83 // First makes a call between pc1 and pc2, and then makes a call between pc3 |
| 83 // and pc4 where the remote streams from pc1 and pc2 will be used as the local | 84 // and pc4 where the remote streams from pc1 and pc2 will be used as the local |
| 84 // streams of pc3 and pc4. | 85 // streams of pc3 and pc4. |
| 85 function callAndForwardRemoteStream(constraints) { | 86 function callAndForwardRemoteStream(constraints) { |
| 86 createConnections(null); | 87 createConnections(null); |
| 87 navigator.webkitGetUserMedia(constraints, | 88 navigator.webkitGetUserMedia(constraints, |
| 88 addStreamToBothConnectionsAndNegotiate, | 89 addStreamToBothConnectionsAndNegotiate, |
| 89 printGetUserMediaError); | 90 printGetUserMediaError); |
| (...skipping 168 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 258 clearInterval(waitDtmf); | 259 clearInterval(waitDtmf); |
| 259 eventOccured(); | 260 eventOccured(); |
| 260 } | 261 } |
| 261 }, 100); | 262 }, 100); |
| 262 } | 263 } |
| 263 | 264 |
| 264 // Do the DTMF test after we have received video. | 265 // Do the DTMF test after we have received video. |
| 265 detectVideoPlaying('remote-view-2', onCallEstablished); | 266 detectVideoPlaying('remote-view-2', onCallEstablished); |
| 266 } | 267 } |
| 267 | 268 |
| 269 function enableRemoteVideo(peerConnection, enabled) { |
| 270 remoteStream = peerConnection.getRemoteStreams()[0]; |
| 271 remoteVideoTrack = remoteStream.getVideoTracks()[0]; |
| 272 remoteVideoTrack.enabled = enabled; |
| 273 } |
| 274 |
| 275 function enableRemoteAudio(peerConnection, enabled) { |
| 276 remoteStream = peerConnection.getRemoteStreams()[0]; |
| 277 remoteAudioTrack = remoteStream.getAudioTracks()[0]; |
| 278 remoteAudioTrack.enabled = enabled; |
| 279 } |
| 280 |
| 268 function callAndEnsureAudioIsPlaying() { | 281 function callAndEnsureAudioIsPlaying() { |
| 269 createConnections(null); | 282 createConnections(null); |
| 270 navigator.webkitGetUserMedia({audio: true, video: true}, | 283 navigator.webkitGetUserMedia({audio: true, video: true}, |
| 271 addStreamToBothConnectionsAndNegotiate, printGetUserMediaError); | 284 addStreamToBothConnectionsAndNegotiate, printGetUserMediaError); |
| 272 | 285 |
| 273 // Wait until we have gathered samples and can conclude if audio is playing. | 286 // Wait until we have gathered samples and can conclude if audio is playing. |
| 274 addExpectedEvent(); | 287 addExpectedEvent(); |
| 275 var onCallEstablished = function() { | 288 var onCallEstablished = function() { |
| 276 gatherAudioLevelSamples(gSecondConnection, 300, 100, | 289 gatherAudioLevelSamples(gSecondConnection, 300, 100, |
| 277 function(samples) { | 290 function(samples) { |
| 278 verifyAudioIsPlaying(samples); | 291 verifyAudioIsPlaying(samples); |
| 279 eventOccured(); | 292 eventOccured(); |
| 280 }); | 293 }); |
| 294 |
| 295 // (Also, ensure video muting doesn't affect audio). |
| 296 enableRemoteVideo(gSecondConnection, false); |
| 281 }; | 297 }; |
| 282 | 298 |
| 283 detectVideoPlaying('remote-view-2', onCallEstablished); | 299 detectVideoPlaying('remote-view-2', onCallEstablished); |
| 284 } | 300 } |
| 285 | 301 |
| 286 function callAndEnsureAudioMutingWorks(force_isac_16k) { | 302 function callAndEnsureAudioMutingWorks() { |
| 287 callAndEnsureAudioIsPlaying(force_isac_16k); | 303 callAndEnsureAudioIsPlaying(); |
| 288 setAllEventsOccuredHandler(function() { | 304 setAllEventsOccuredHandler(function() { |
| 289 var audioTrack = | |
| 290 gSecondConnection.getRemoteStreams()[0].getAudioTracks()[0]; | |
| 291 | |
| 292 // Call is up, now mute the track and check everything goes silent (give | 305 // Call is up, now mute the track and check everything goes silent (give |
| 293 // it a small delay though, we don't expect it to happen instantly). | 306 // it a small delay though, we don't expect it to happen instantly). |
| 294 audioTrack.enabled = false; | 307 enableRemoteAudio(gSecondConnection, false); |
| 295 | 308 |
| 296 setTimeout(function() { | 309 setTimeout(function() { |
| 297 gatherAudioLevelSamples(gSecondConnection, 200, 100, function(samples) { | 310 gatherAudioLevelSamples(gSecondConnection, 200, 100, function(samples) { |
| 298 verifyIsSilent(samples); | 311 verifyIsSilent(samples); |
| 299 document.title = 'OK'; | 312 document.title = 'OK'; |
| 300 }); | 313 }); |
| 301 }, 500); | 314 }, 500); |
| 302 }); | 315 }); |
| 303 } | 316 } |
| 304 | 317 |
| 318 function callAndEnsureVideoMutingWorks() { |
| 319 createConnections(null); |
| 320 navigator.webkitGetUserMedia({audio: true, video: true}, |
| 321 addStreamToBothConnectionsAndNegotiate, printGetUserMediaError); |
| 322 |
| 323 addExpectedEvent(); |
| 324 detectVideoPlaying('remote-view-2', function() { |
| 325 // Disable the receiver's remote media stream. Video should stop. |
| 326 // (Also, ensure muting audio doesn't affect video). |
| 327 enableRemoteVideo(gSecondConnection, false); |
| 328 enableRemoteAudio(gSecondConnection, false); |
| 329 |
| 330 detectVideoStopped('remote-view-2', function() { |
| 331 // Video has stopped: unmute and succeed if it starts playing again. |
| 332 enableRemoteVideo(gSecondConnection, true); |
| 333 detectVideoPlaying('remote-view-2', eventOccured); |
| 334 }) |
| 335 }); |
| 336 } |
| 337 |
| 305 // Test call with a new Video MediaStream that has been created based on a | 338 // Test call with a new Video MediaStream that has been created based on a |
| 306 // stream generated by getUserMedia. | 339 // stream generated by getUserMedia. |
| 307 function callWithNewVideoMediaStream() { | 340 function callWithNewVideoMediaStream() { |
| 308 createConnections(null); | 341 createConnections(null); |
| 309 navigator.webkitGetUserMedia({audio: true, video: true}, | 342 navigator.webkitGetUserMedia({audio: true, video: true}, |
| 310 createNewVideoStreamAndAddToBothConnections, printGetUserMediaError); | 343 createNewVideoStreamAndAddToBothConnections, printGetUserMediaError); |
| 311 waitForVideo('remote-view-1'); | 344 waitForVideo('remote-view-1'); |
| 312 waitForVideo('remote-view-2'); | 345 waitForVideo('remote-view-2'); |
| 313 } | 346 } |
| 314 | 347 |
| (...skipping 431 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 746 <td><canvas width="320" height="240" id="remote-view-2-canvas" | 779 <td><canvas width="320" height="240" id="remote-view-2-canvas" |
| 747 style="display:none"></canvas></td> | 780 style="display:none"></canvas></td> |
| 748 <td><canvas width="320" height="240" id="remote-view-3-canvas" | 781 <td><canvas width="320" height="240" id="remote-view-3-canvas" |
| 749 style="display:none"></canvas></td> | 782 style="display:none"></canvas></td> |
| 750 <td><canvas width="320" height="240" id="remote-view-4-canvas" | 783 <td><canvas width="320" height="240" id="remote-view-4-canvas" |
| 751 style="display:none"></canvas></td> | 784 style="display:none"></canvas></td> |
| 752 </tr> | 785 </tr> |
| 753 </table> | 786 </table> |
| 754 </body> | 787 </body> |
| 755 </html> | 788 </html> |
| OLD | NEW |