Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(54)

Side by Side Diff: content/test/data/media/peerconnection-call.html

Issue 468243003: Adding local stream mute tests, tightening up WebRTC audio tests. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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 141 matching lines...) Expand 10 before | Expand all | Expand 10 after
152 gSecondConnection.getRemoteStreams()[0].getAudioTracks()[0]); 152 gSecondConnection.getRemoteStreams()[0].getAudioTracks()[0]);
153 newStream.addTrack( 153 newStream.addTrack(
154 gSecondConnection.getRemoteStreams()[0].getVideoTracks()[0]); 154 gSecondConnection.getRemoteStreams()[0].getVideoTracks()[0]);
155 var videoElement = document.createElement('video'); 155 var videoElement = document.createElement('video');
156 156
157 // No crash for this operation. 157 // No crash for this operation.
158 videoElement.src = URL.createObjectURL(newStream); 158 videoElement.src = URL.createObjectURL(newStream);
159 waitForVideo('remote-view-2'); 159 waitForVideo('remote-view-2');
160 }); 160 });
161 } 161 }
162 162
163 // Test that we can setup call with an audio and video track and 163 // Test that we can setup call with an audio and video track and
164 // simulate that the remote peer don't support MSID. 164 // simulate that the remote peer don't support MSID.
165 function callWithoutMsidAndBundle() { 165 function callWithoutMsidAndBundle() {
166 createConnections(null); 166 createConnections(null);
167 transformSdp = removeBundle; 167 transformSdp = removeBundle;
168 transformRemoteSdp = removeMsid; 168 transformRemoteSdp = removeMsid;
169 gTestWithoutMsid = true; 169 gTestWithoutMsid = true;
170 navigator.webkitGetUserMedia({audio: true, video: true}, 170 navigator.webkitGetUserMedia({audio: true, video: true},
171 addStreamToBothConnectionsAndNegotiate, printGetUserMediaError); 171 addStreamToBothConnectionsAndNegotiate, printGetUserMediaError);
172 waitForVideo('remote-view-1'); 172 waitForVideo('remote-view-1');
(...skipping 145 matching lines...) Expand 10 before | Expand all | Expand 10 after
318 function(offer) { 318 function(offer) {
319 assertEquals(-1, offer.sdp.search('m=audio')); 319 assertEquals(-1, offer.sdp.search('m=audio'));
320 assertNotEquals(-1, offer.sdp.search('m=video')); 320 assertNotEquals(-1, offer.sdp.search('m=video'));
321 321
322 reportTestSuccess(); 322 reportTestSuccess();
323 }, 323 },
324 function(error) { failTest(error); }, 324 function(error) { failTest(error); },
325 offerOptions); 325 offerOptions);
326 } 326 }
327 327
328 function enableRemoteVideo(peerConnection, enabled) {
329 remoteStream = peerConnection.getRemoteStreams()[0];
330 remoteVideoTrack = remoteStream.getVideoTracks()[0];
331 remoteVideoTrack.enabled = enabled;
332 }
333
334 function enableRemoteAudio(peerConnection, enabled) {
335 remoteStream = peerConnection.getRemoteStreams()[0];
336 remoteAudioTrack = remoteStream.getAudioTracks()[0];
337 remoteAudioTrack.enabled = enabled;
338 }
339
340 function callAndEnsureAudioIsPlaying(beLenient, constraints) { 328 function callAndEnsureAudioIsPlaying(beLenient, constraints) {
341 createConnections(null); 329 createConnections(null);
330
331 // Add the local stream to gFirstConnection to play one-way audio.
342 navigator.webkitGetUserMedia(constraints, 332 navigator.webkitGetUserMedia(constraints,
343 addStreamToBothConnectionsAndNegotiate, printGetUserMediaError); 333 addStreamToTheFirstConnectionAndNegotiate, printGetUserMediaError);
344 334
345 // Wait until we have gathered samples and can conclude if audio is playing.
346 addExpectedEvent();
347 var onCallEstablished = function() { 335 var onCallEstablished = function() {
348 // Gather 50 samples per second for 2 seconds. 336 ensureAudioPlaying(gSecondConnection, beLenient);
349 gatherAudioLevelSamples(gSecondConnection, 100, 50, function(samples) {
350 verifyAudioIsPlaying(samples, beLenient);
351 eventOccured();
352 });
353 }; 337 };
354 338
355 waitForConnectionToStabilize(gFirstConnection, onCallEstablished); 339 waitForConnectionToStabilize(gFirstConnection, onCallEstablished);
356 } 340 }
357 341
358 function callAndEnsureAudioTrackMutingWorks(beLenient) { 342 function enableRemoteVideo(peerConnection, enabled) {
343 remoteStream = peerConnection.getRemoteStreams()[0];
344 remoteStream.getVideoTracks()[0].enabled = enabled;
345 }
346
347 function enableRemoteAudio(peerConnection, enabled) {
348 remoteStream = peerConnection.getRemoteStreams()[0];
349 remoteStream.getAudioTracks()[0].enabled = enabled;
350 }
351
352 function enableLocalVideo(peerConnection, enabled) {
353 localStream = peerConnection.getLocalStreams()[0];
354 localStream.getVideoTracks()[0].enabled = enabled;
355 }
356
357 function enableLocalAudio(peerConnection, enabled) {
358 localStream = peerConnection.getLocalStreams()[0];
359 localStream.getAudioTracks()[0].enabled = enabled;
360 }
361
362 function callAndEnsureRemoteAudioTrackMutingWorks(beLenient) {
359 callAndEnsureAudioIsPlaying(beLenient, {audio: true, video: true}); 363 callAndEnsureAudioIsPlaying(beLenient, {audio: true, video: true});
360 setAllEventsOccuredHandler(function() { 364 setAllEventsOccuredHandler(function() {
361 // Call is up, now mute the track and check everything goes silent (give 365 setAllEventsOccuredHandler(reportTestSuccess);
362 // it a small delay though, we don't expect it to happen instantly). 366
367 // Call is up, now mute the remote track and check we stop playing out
368 // audio (after a small delay, we don't expect it to happen instantly).
363 enableRemoteAudio(gSecondConnection, false); 369 enableRemoteAudio(gSecondConnection, false);
370 ensureSilence(gSecondConnection);
371 });
372 }
364 373
365 setTimeout(function() { 374 function callAndEnsureLocalAudioTrackMutingWorks(beLenient) {
366 gatherAudioLevelSamples(gSecondConnection, 100, 50, function(samples) { 375 callAndEnsureAudioIsPlaying(beLenient, {audio: true, video: true});
367 verifyIsSilent(samples); 376 setAllEventsOccuredHandler(function() {
368 reportTestSuccess(); 377 setAllEventsOccuredHandler(reportTestSuccess);
369 }); 378
370 }, 500); 379 // Call is up, now mute the local track of the sending side and ensure
380 // the receiving side stops receiving audio.
381 enableLocalAudio(gFirstConnection, false);
382 ensureSilence(gSecondConnection);
371 }); 383 });
372 } 384 }
373 385
374 function callAndEnsureAudioTrackUnmutingWorks(beLenient) { 386 function callAndEnsureAudioTrackUnmutingWorks(beLenient) {
375 callAndEnsureAudioIsPlaying(beLenient, {audio: true, video: true}); 387 callAndEnsureAudioIsPlaying(beLenient, {audio: true, video: true});
376 setAllEventsOccuredHandler(function() { 388 setAllEventsOccuredHandler(function() {
389 setAllEventsOccuredHandler(reportTestSuccess);
390
377 // Mute, wait a while, unmute, verify audio gets back up. 391 // Mute, wait a while, unmute, verify audio gets back up.
378 // (Also, ensure video muting doesn't affect audio). 392 // (Also, ensure video muting doesn't affect audio).
379 enableRemoteAudio(gSecondConnection, false); 393 enableRemoteAudio(gSecondConnection, false);
380 enableRemoteVideo(gSecondConnection, false); 394 enableRemoteVideo(gSecondConnection, false);
381 395
382 setTimeout(function() { 396 setTimeout(function() {
383 enableRemoteAudio(gSecondConnection, true); 397 enableRemoteAudio(gSecondConnection, true);
384 }, 500); 398 }, 500);
385 399
386 setTimeout(function() { 400 setTimeout(function() {
387 // Sample for four seconds here; it can take a bit of time for audio to 401 ensureAudioPlaying(gSecondConnection, beLenient);
388 // get back up after the unmute.
389 gatherAudioLevelSamples(gSecondConnection, 200, 50, function(samples) {
390 verifyAudioIsPlaying(samples, beLenient);
391 reportTestSuccess();
392 });
393 }, 1500); 402 }, 1500);
394 }); 403 });
395 } 404 }
396 405
406 function callAndEnsureLocalVideoMutingDoesntMuteAudio(beLenient) {
407 callAndEnsureAudioIsPlaying(beLenient, {audio: true, video: true});
408 setAllEventsOccuredHandler(function() {
409 setAllEventsOccuredHandler(reportTestSuccess);
410 enableLocalVideo(gFirstConnection, false);
411 ensureAudioPlaying(gSecondConnection, beLenient);
412 });
413 }
414
415 function callAndEnsureRemoteVideoMutingDoesntMuteAudio(beLenient) {
416 callAndEnsureAudioIsPlaying(beLenient, {audio: true, video: true});
417 setAllEventsOccuredHandler(function() {
418 setAllEventsOccuredHandler(reportTestSuccess);
419 enableRemoteVideo(gSecondConnection, false);
420 ensureAudioPlaying(gSecondConnection, beLenient);
421 });
422 }
423
397 function callAndEnsureVideoTrackMutingWorks() { 424 function callAndEnsureVideoTrackMutingWorks() {
398 createConnections(null); 425 createConnections(null);
399 navigator.webkitGetUserMedia({audio: true, video: true}, 426 navigator.webkitGetUserMedia({audio: true, video: true},
400 addStreamToBothConnectionsAndNegotiate, printGetUserMediaError); 427 addStreamToBothConnectionsAndNegotiate, printGetUserMediaError);
401 428
402 addExpectedEvent(); 429 addExpectedEvent();
403 detectVideoPlaying('remote-view-2', function() { 430 detectVideoPlaying('remote-view-2', function() {
404 // Disable the receiver's remote media stream. Video should stop. 431 // Disable the receiver's remote media stream. Video should stop.
405 // (Also, ensure muting audio doesn't affect video). 432 // (Also, ensure muting audio doesn't affect video).
406 enableRemoteVideo(gSecondConnection, false); 433 enableRemoteVideo(gSecondConnection, false);
(...skipping 339 matching lines...) Expand 10 before | Expand all | Expand 10 after
746 773
747 function onOfferCreated(offer, caller, callee) { 774 function onOfferCreated(offer, caller, callee) {
748 offer.sdp = maybeForceIsac16K(transformSdp(offer.sdp)); 775 offer.sdp = maybeForceIsac16K(transformSdp(offer.sdp));
749 caller.setLocalDescription(offer, function() { 776 caller.setLocalDescription(offer, function() {
750 assertEquals('have-local-offer', caller.signalingState); 777 assertEquals('have-local-offer', caller.signalingState);
751 receiveOffer(offer.sdp, caller, callee); 778 receiveOffer(offer.sdp, caller, callee);
752 }, onLocalDescriptionError); 779 }, onLocalDescriptionError);
753 } 780 }
754 781
755 function receiveOffer(offerSdp, caller, callee) { 782 function receiveOffer(offerSdp, caller, callee) {
756 console.log("Receiving offer...\n" + offerSdp); 783 console.log("Receiving offer...");
757 offerSdp = transformRemoteSdp(offerSdp); 784 offerSdp = transformRemoteSdp(offerSdp);
758 785
759 var parsedOffer = new RTCSessionDescription({ type: 'offer', 786 var parsedOffer = new RTCSessionDescription({ type: 'offer',
760 sdp: offerSdp }); 787 sdp: offerSdp });
761 callee.setRemoteDescription(parsedOffer, function() {}, 788 callee.setRemoteDescription(parsedOffer, function() {},
762 onRemoteDescriptionError); 789 onRemoteDescriptionError);
763 callee.createAnswer(function (answer) { 790 callee.createAnswer(function (answer) {
764 onAnswerCreated(answer, caller, callee); 791 onAnswerCreated(answer, caller, callee);
765 }); 792 });
766 assertEquals('have-remote-offer', callee.signalingState); 793 assertEquals('have-remote-offer', callee.signalingState);
(...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after
867 <body> 894 <body>
868 <table border="0"> 895 <table border="0">
869 <tr> 896 <tr>
870 <td>Local Preview</td> 897 <td>Local Preview</td>
871 <td>Remote Stream for Connection 1</td> 898 <td>Remote Stream for Connection 1</td>
872 <td>Remote Stream for Connection 2</td> 899 <td>Remote Stream for Connection 2</td>
873 <td>Remote Stream for Connection 3</td> 900 <td>Remote Stream for Connection 3</td>
874 <td>Remote Stream for Connection 4</td> 901 <td>Remote Stream for Connection 4</td>
875 </tr> 902 </tr>
876 <tr> 903 <tr>
877 <td><video width="320" height="240" id="local-view" 904 <td><video width="320" height="240" id="local-view" autoplay muted>
878 autoplay="autoplay"></video></td> 905 </video></td>
879 <td><video width="320" height="240" id="remote-view-1" 906 <td><video width="320" height="240" id="remote-view-1" autoplay>
880 autoplay="autoplay"></video></td> 907 </video></td>
881 <td><video width="320" height="240" id="remote-view-2" 908 <td><video width="320" height="240" id="remote-view-2" autoplay>
882 autoplay="autoplay"></video></td> 909 </video></td>
883 <td><video width="320" height="240" id="remote-view-3" 910 <td><video width="320" height="240" id="remote-view-3" autoplay>
884 autoplay="autoplay"></video></td> 911 </video></td>
885 <td><video width="320" height="240" id="remote-view-4" 912 <td><video width="320" height="240" id="remote-view-4" autoplay>
886 autoplay="autoplay"></video></td> 913 </video></td>
887 <!-- Canvases are named after their corresponding video elements. --> 914 <!-- Canvases are named after their corresponding video elements. -->
888 <td><canvas width="320" height="240" id="remote-view-1-canvas" 915 <td><canvas width="320" height="240" id="remote-view-1-canvas"
889 style="display:none"></canvas></td> 916 style="display:none"></canvas></td>
890 <td><canvas width="320" height="240" id="remote-view-2-canvas" 917 <td><canvas width="320" height="240" id="remote-view-2-canvas"
891 style="display:none"></canvas></td> 918 style="display:none"></canvas></td>
892 <td><canvas width="320" height="240" id="remote-view-3-canvas" 919 <td><canvas width="320" height="240" id="remote-view-3-canvas"
893 style="display:none"></canvas></td> 920 style="display:none"></canvas></td>
894 <td><canvas width="320" height="240" id="remote-view-4-canvas" 921 <td><canvas width="320" height="240" id="remote-view-4-canvas"
895 style="display:none"></canvas></td> 922 style="display:none"></canvas></td>
896 </tr> 923 </tr>
897 </table> 924 </table>
898 </body> 925 </body>
899 </html> 926 </html>
OLDNEW
« no previous file with comments | « content/browser/media/webrtc_browsertest.cc ('k') | content/test/data/media/webrtc_test_audio.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698