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" 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 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 48 waitForVideo('remote-view-2'); | 48 waitForVideo('remote-view-2'); |
| 49 } | 49 } |
| 50 | 50 |
| 51 // First calls without streams on any connections, and then adds a stream | 51 // First calls without streams on any connections, and then adds a stream |
| 52 // to peer connection 1 which gets sent to peer connection 2. We must wait | 52 // to peer connection 1 which gets sent to peer connection 2. We must wait |
| 53 // for the first negotiation to complete before starting the second one, which | 53 // for the first negotiation to complete before starting the second one, which |
| 54 // is why we wait until the connection is stable before re-negotiating. | 54 // is why we wait until the connection is stable before re-negotiating. |
| 55 function callEmptyThenAddOneStreamAndRenegotiate(constraints) { | 55 function callEmptyThenAddOneStreamAndRenegotiate(constraints) { |
| 56 createConnections(null); | 56 createConnections(null); |
| 57 negotiate(); | 57 negotiate(); |
| 58 waitForConnectionToStabilize(gFirstConnection); | 58 waitForConnectionToStabilize(gFirstConnection, function() { |
| 59 navigator.webkitGetUserMedia(constraints, | 59 navigator.webkitGetUserMedia(constraints, |
| 60 addStreamToTheFirstConnectionAndNegotiate, printGetUserMediaError); | 60 addStreamToTheFirstConnectionAndNegotiate, printGetUserMediaError); |
| 61 // Only the first connection is sending here. | 61 // Only the first connection is sending here. |
| 62 waitForVideo('remote-view-2'); | 62 waitForVideo('remote-view-2'); |
| 63 }); | |
| 63 } | 64 } |
| 64 | 65 |
| 65 // First makes a call between pc1 and pc2, and then makes a call between pc3 | 66 // First makes a call between pc1 and pc2, and then makes a call between pc3 |
| 66 // and pc4 where the remote streams from pc1 and pc2 will be used as the local | 67 // and pc4 where the remote streams from pc1 and pc2 will be used as the local |
| 67 // streams of pc3 and pc4. | 68 // streams of pc3 and pc4. |
| 68 function callAndForwardRemoteStream(constraints) { | 69 function callAndForwardRemoteStream(constraints) { |
| 69 createConnections(null); | 70 createConnections(null); |
| 70 navigator.webkitGetUserMedia(constraints, | 71 navigator.webkitGetUserMedia(constraints, |
| 71 addStreamToBothConnectionsAndNegotiate, | 72 addStreamToBothConnectionsAndNegotiate, |
| 72 printGetUserMediaError); | 73 printGetUserMediaError); |
| (...skipping 179 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 252 /** @private */ | 253 /** @private */ |
| 253 function forceIsac16k_(sdp) { | 254 function forceIsac16k_(sdp) { |
| 254 // Remove all other codecs (not the video codecs though). | 255 // Remove all other codecs (not the video codecs though). |
| 255 sdp = sdp.replace(/m=audio (\d+) RTP\/SAVPF.*\r\n/g, | 256 sdp = sdp.replace(/m=audio (\d+) RTP\/SAVPF.*\r\n/g, |
| 256 'm=audio $1 RTP/SAVPF 103\r\n'); | 257 'm=audio $1 RTP/SAVPF 103\r\n'); |
| 257 sdp = sdp.replace('a=fmtp:111 minptime=10', 'a=fmtp:103 minptime=10'); | 258 sdp = sdp.replace('a=fmtp:111 minptime=10', 'a=fmtp:103 minptime=10'); |
| 258 sdp = sdp.replace(/a=rtpmap:(?!103)\d{1,3} (?!VP8|red|ulpfec).*\r\n/g, ''); | 259 sdp = sdp.replace(/a=rtpmap:(?!103)\d{1,3} (?!VP8|red|ulpfec).*\r\n/g, ''); |
| 259 return sdp; | 260 return sdp; |
| 260 } | 261 } |
| 261 | 262 |
| 263 function enableRemoteVideo(peerConnection, enabled) { | |
| 264 remoteStream = gSecondConnection.getRemoteStreams()[0]; | |
|
perkj_chrome
2014/01/07 06:51:26
peerConnection ?
phoglund_chromium
2014/01/07 14:41:59
Good catch, done
| |
| 265 remoteVideoTrack = remoteStream.getVideoTracks()[0]; | |
| 266 remoteVideoTrack.enabled = enabled; | |
| 267 } | |
| 268 | |
| 269 function enableRemoteAudio(peerConnection, enabled) { | |
| 270 remoteStream = gSecondConnection.getRemoteStreams()[0]; | |
|
perkj_chrome
2014/01/07 06:51:26
peerConnection?
phoglund_chromium
2014/01/07 14:41:59
Done.
| |
| 271 remoteAudioTrack = remoteStream.getAudioTracks()[0]; | |
| 272 remoteAudioTrack.enabled = enabled; | |
| 273 } | |
| 274 | |
| 262 function callAndEnsureAudioIsPlaying(force_isac_16k) { | 275 function callAndEnsureAudioIsPlaying(force_isac_16k) { |
| 263 if (force_isac_16k) | 276 if (force_isac_16k) |
| 264 transformSdp = forceIsac16k_; | 277 transformSdp = forceIsac16k_; |
| 265 createConnections(null); | 278 createConnections(null); |
| 266 navigator.webkitGetUserMedia({audio: true, video: true}, | 279 navigator.webkitGetUserMedia({audio: true, video: true}, |
| 267 addStreamToBothConnectionsAndNegotiate, printGetUserMediaError); | 280 addStreamToBothConnectionsAndNegotiate, printGetUserMediaError); |
| 268 | 281 |
| 269 // Wait until we have gathered samples and can conclude if audio is playing. | 282 // Wait until we have gathered samples and can conclude if audio is playing. |
| 270 addExpectedEvent(); | 283 addExpectedEvent(); |
| 271 var onCallEstablished = function() { | 284 var onCallEstablished = function() { |
| 272 gatherAudioLevelSamples(gSecondConnection, 300, 100, | 285 gatherAudioLevelSamples(gSecondConnection, 300, 100, |
| 273 function(samples) { | 286 function(samples) { |
| 274 verifyAudioIsPlaying(samples); | 287 verifyAudioIsPlaying(samples); |
| 275 eventOccured(); | 288 eventOccured(); |
| 276 }); | 289 }); |
| 290 | |
| 291 // (Also, ensure video muting doesn't affect audio). | |
| 292 enableRemoteVideo(gSecondConnection, false); | |
| 277 }; | 293 }; |
| 278 | 294 |
| 279 detectVideoPlaying('remote-view-2', onCallEstablished); | 295 detectVideoPlaying('remote-view-2', onCallEstablished); |
| 280 } | 296 } |
| 281 | 297 |
|
perkj_chrome
2014/01/07 06:51:26
nit: remove extra blank
phoglund_chromium
2014/01/07 14:41:59
Done.
| |
| 298 | |
| 282 function callAndEnsureAudioMutingWorks(force_isac_16k) { | 299 function callAndEnsureAudioMutingWorks(force_isac_16k) { |
| 283 callAndEnsureAudioIsPlaying(force_isac_16k); | 300 callAndEnsureAudioIsPlaying(force_isac_16k); |
| 284 setAllEventsOccuredHandler(function() { | 301 setAllEventsOccuredHandler(function() { |
| 285 var audioTrack = | |
| 286 gSecondConnection.getRemoteStreams()[0].getAudioTracks()[0]; | |
| 287 | |
| 288 // Call is up, now mute the track and check everything goes silent (give | 302 // Call is up, now mute the track and check everything goes silent (give |
| 289 // it a small delay though, we don't expect it to happen instantly). | 303 // it a small delay though, we don't expect it to happen instantly). |
| 290 audioTrack.enabled = false; | 304 enableRemoteAudio(gSecondConnection, false); |
| 291 | 305 |
| 292 setTimeout(function() { | 306 setTimeout(function() { |
| 293 gatherAudioLevelSamples(gSecondConnection, 200, 100, function(samples) { | 307 gatherAudioLevelSamples(gSecondConnection, 200, 100, function(samples) { |
| 294 verifyIsSilent(samples); | 308 verifyIsSilent(samples); |
| 295 document.title = 'OK'; | 309 document.title = 'OK'; |
| 296 }); | 310 }); |
| 297 }, 500); | 311 }, 500); |
| 298 }); | 312 }); |
| 299 } | 313 } |
| 300 | 314 |
| 315 function callAndEnsureVideoMutingWorks() { | |
| 316 createConnections(null); | |
| 317 navigator.webkitGetUserMedia({audio: true, video: true}, | |
| 318 addStreamToBothConnectionsAndNegotiate, printGetUserMediaError); | |
| 319 | |
| 320 addExpectedEvent(); | |
| 321 detectVideoPlaying('remote-view-2', function() { | |
| 322 // Disable the receiver's remote media stream. Video should stop. | |
| 323 // (Also, ensure muting audio doesn't affect video). | |
| 324 enableRemoteVideo(gSecondConnection, false); | |
| 325 enableRemoteAudio(gSecondConnection, false); | |
| 326 | |
| 327 detectVideoStopped('remote-view-2', function() { | |
| 328 // Video has stopped: unmute and succeed if it starts playing again. | |
| 329 enableRemoteVideo(gSecondConnection, true); | |
| 330 detectVideoPlaying('remote-view-2', eventOccured); | |
| 331 }) | |
| 332 }); | |
| 333 } | |
| 334 | |
| 301 // Test call with a new Video MediaStream that has been created based on a | 335 // Test call with a new Video MediaStream that has been created based on a |
| 302 // stream generated by getUserMedia. | 336 // stream generated by getUserMedia. |
| 303 function callWithNewVideoMediaStream() { | 337 function callWithNewVideoMediaStream() { |
| 304 createConnections(null); | 338 createConnections(null); |
| 305 navigator.webkitGetUserMedia({audio: true, video: true}, | 339 navigator.webkitGetUserMedia({audio: true, video: true}, |
| 306 createNewVideoStreamAndAddToBothConnections, printGetUserMediaError); | 340 createNewVideoStreamAndAddToBothConnections, printGetUserMediaError); |
| 307 waitForVideo('remote-view-1'); | 341 waitForVideo('remote-view-1'); |
| 308 waitForVideo('remote-view-2'); | 342 waitForVideo('remote-view-2'); |
| 309 } | 343 } |
| 310 | 344 |
| (...skipping 431 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 742 <td><canvas width="320" height="240" id="remote-view-2-canvas" | 776 <td><canvas width="320" height="240" id="remote-view-2-canvas" |
| 743 style="display:none"></canvas></td> | 777 style="display:none"></canvas></td> |
| 744 <td><canvas width="320" height="240" id="remote-view-3-canvas" | 778 <td><canvas width="320" height="240" id="remote-view-3-canvas" |
| 745 style="display:none"></canvas></td> | 779 style="display:none"></canvas></td> |
| 746 <td><canvas width="320" height="240" id="remote-view-4-canvas" | 780 <td><canvas width="320" height="240" id="remote-view-4-canvas" |
| 747 style="display:none"></canvas></td> | 781 style="display:none"></canvas></td> |
| 748 </tr> | 782 </tr> |
| 749 </table> | 783 </table> |
| 750 </body> | 784 </body> |
| 751 </html> | 785 </html> |
| OLD | NEW |