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

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: Fixed spelling error Created 6 years, 3 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) { 328 function ensureAudioPlaying(beLenient) {
329 remoteStream = peerConnection.getRemoteStreams()[0]; 329 addExpectedEvent();
330 remoteVideoTrack = remoteStream.getVideoTracks()[0];
331 remoteVideoTrack.enabled = enabled;
332 }
333 330
334 function enableRemoteAudio(peerConnection, enabled) { 331 // Gather 50 samples per second for 2 seconds.
335 remoteStream = peerConnection.getRemoteStreams()[0]; 332 gatherAudioLevelSamples(gSecondConnection, 100, 50, function(samples) {
336 remoteAudioTrack = remoteStream.getAudioTracks()[0]; 333 verifyAudioIsPlaying(samples, beLenient);
337 remoteAudioTrack.enabled = enabled; 334 eventOccured();
335 });
338 } 336 }
339 337
340 function callAndEnsureAudioIsPlaying(beLenient, constraints) { 338 function callAndEnsureAudioIsPlaying(beLenient, constraints) {
341 createConnections(null); 339 createConnections(null);
340
341 // Add the local stream to gFirstConnection to play one-way audio.
342 navigator.webkitGetUserMedia(constraints, 342 navigator.webkitGetUserMedia(constraints,
343 addStreamToBothConnectionsAndNegotiate, printGetUserMediaError); 343 addStreamToTheFirstConnectionAndNegotiate, printGetUserMediaError);
344 344
345 // Wait until we have gathered samples and can conclude if audio is playing.
346 addExpectedEvent();
347 var onCallEstablished = function() { 345 var onCallEstablished = function() {
348 // Gather 50 samples per second for 2 seconds. 346 ensureAudioPlaying(beLenient);
349 gatherAudioLevelSamples(gSecondConnection, 100, 50, function(samples) {
350 verifyAudioIsPlaying(samples, beLenient);
351 eventOccured();
352 });
353 }; 347 };
354 348
355 waitForConnectionToStabilize(gFirstConnection, onCallEstablished); 349 waitForConnectionToStabilize(gFirstConnection, onCallEstablished);
356 } 350 }
357 351
358 function callAndEnsureAudioTrackMutingWorks(beLenient) { 352 function enableRemoteVideo(peerConnection, enabled) {
353 remoteStream = peerConnection.getRemoteStreams()[0];
354 remoteStream.getVideoTracks()[0].enabled = enabled;
355 }
356
357 function enableRemoteAudio(peerConnection, enabled) {
358 remoteStream = peerConnection.getRemoteStreams()[0];
359 remoteStream.getAudioTracks()[0].enabled = enabled;
360 }
361
362 function enableLocalVideo(peerConnection, enabled) {
363 localStream = peerConnection.getLocalStreams()[0];
364 localStream.getVideoTracks()[0].enabled = enabled;
365 }
366
367 function enableLocalAudio(peerConnection, enabled) {
368 localStream = peerConnection.getLocalStreams()[0];
369 localStream.getAudioTracks()[0].enabled = enabled;
370 }
371
372 function ensureSilence() {
perkj_chrome 2014/08/25 12:05:47 Should this be moved to the utility.js?
phoglund_chromium 2014/08/25 14:25:32 Done. Moved some other stuff as well and raised th
373 addExpectedEvent();
374 setTimeout(function() {
375 gatherAudioLevelSamples(gSecondConnection, 100, 50, function(samples) {
376 verifyIsSilent(samples);
377 eventOccured();
378 });
379 }, 500);
380 }
381
382 function callAndEnsureRemoteAudioTrackMutingWorks(beLenient) {
359 callAndEnsureAudioIsPlaying(beLenient, {audio: true, video: true}); 383 callAndEnsureAudioIsPlaying(beLenient, {audio: true, video: true});
perkj_chrome 2014/08/25 12:05:47 Is there a risk that callAndEnsureAudioIsPlaying c
phoglund_chromium 2014/08/25 14:25:32 You mean line 384? No, callAndEnsure is async so i
360 setAllEventsOccuredHandler(function() { 384 setAllEventsOccuredHandler(function() {
361 // Call is up, now mute the track and check everything goes silent (give 385 setAllEventsOccuredHandler(reportTestSuccess);
362 // it a small delay though, we don't expect it to happen instantly). 386
387 // Call is up, now mute the remote track and check we stop playing out
388 // audio (after a small delay, we don't expect it to happen instantly).
363 enableRemoteAudio(gSecondConnection, false); 389 enableRemoteAudio(gSecondConnection, false);
364 390 ensureSilence();
365 setTimeout(function() {
366 gatherAudioLevelSamples(gSecondConnection, 100, 50, function(samples) {
367 verifyIsSilent(samples);
368 reportTestSuccess();
369 });
370 }, 500);
371 }); 391 });
372 } 392 }
373 393
394 function callAndEnsureLocalAudioTrackMutingWorks(beLenient) {
395 callAndEnsureAudioIsPlaying(beLenient, {audio: true, video: true});
396 setAllEventsOccuredHandler(function() {
397 setAllEventsOccuredHandler(reportTestSuccess);
398
399 // Call is up, now mute the local track of the sending side and ensure
400 // the receiving side stops receiving audio.
401 enableLocalAudio(gFirstConnection, false);
402 ensureSilence();
403 });
404 }
405
374 function callAndEnsureAudioTrackUnmutingWorks(beLenient) { 406 function callAndEnsureAudioTrackUnmutingWorks(beLenient) {
375 callAndEnsureAudioIsPlaying(beLenient, {audio: true, video: true}); 407 callAndEnsureAudioIsPlaying(beLenient, {audio: true, video: true});
376 setAllEventsOccuredHandler(function() { 408 setAllEventsOccuredHandler(function() {
377 // Mute, wait a while, unmute, verify audio gets back up. 409 // Mute, wait a while, unmute, verify audio gets back up.
378 // (Also, ensure video muting doesn't affect audio). 410 // (Also, ensure video muting doesn't affect audio).
379 enableRemoteAudio(gSecondConnection, false); 411 enableRemoteAudio(gSecondConnection, false);
380 enableRemoteVideo(gSecondConnection, false); 412 enableRemoteVideo(gSecondConnection, false);
381 413
382 setTimeout(function() { 414 setTimeout(function() {
383 enableRemoteAudio(gSecondConnection, true); 415 enableRemoteAudio(gSecondConnection, true);
384 }, 500); 416 }, 500);
385 417
386 setTimeout(function() { 418 setTimeout(function() {
387 // Sample for four seconds here; it can take a bit of time for audio to 419 // Sample for four seconds here; it can take a bit of time for audio to
388 // get back up after the unmute. 420 // get back up after the unmute.
389 gatherAudioLevelSamples(gSecondConnection, 200, 50, function(samples) { 421 gatherAudioLevelSamples(gSecondConnection, 200, 50, function(samples) {
390 verifyAudioIsPlaying(samples, beLenient); 422 verifyAudioIsPlaying(samples, beLenient);
391 reportTestSuccess(); 423 reportTestSuccess();
392 }); 424 });
393 }, 1500); 425 }, 1500);
394 }); 426 });
395 } 427 }
396 428
429 function callAndEnsureLocalVideoMutingDoesntMuteAudio(beLenient) {
430 callAndEnsureAudioIsPlaying(beLenient, {audio: true, video: true});
431 setAllEventsOccuredHandler(function() {
432 setAllEventsOccuredHandler(reportTestSuccess);
433 enableLocalVideo(gFirstConnection, false);
434 ensureAudioPlaying(beLenient);
435 });
436 }
437
438 function callAndEnsureRemoteVideoMutingDoesntMuteAudio(beLenient) {
439 callAndEnsureAudioIsPlaying(beLenient, {audio: true, video: true});
440 setAllEventsOccuredHandler(function() {
441 setAllEventsOccuredHandler(reportTestSuccess);
442 enableRemoteVideo(gSecondConnection, false);
443 ensureAudioPlaying(beLenient);
444 });
445 }
446
397 function callAndEnsureVideoTrackMutingWorks() { 447 function callAndEnsureVideoTrackMutingWorks() {
398 createConnections(null); 448 createConnections(null);
399 navigator.webkitGetUserMedia({audio: true, video: true}, 449 navigator.webkitGetUserMedia({audio: true, video: true},
400 addStreamToBothConnectionsAndNegotiate, printGetUserMediaError); 450 addStreamToBothConnectionsAndNegotiate, printGetUserMediaError);
401 451
402 addExpectedEvent(); 452 addExpectedEvent();
403 detectVideoPlaying('remote-view-2', function() { 453 detectVideoPlaying('remote-view-2', function() {
404 // Disable the receiver's remote media stream. Video should stop. 454 // Disable the receiver's remote media stream. Video should stop.
405 // (Also, ensure muting audio doesn't affect video). 455 // (Also, ensure muting audio doesn't affect video).
406 enableRemoteVideo(gSecondConnection, false); 456 enableRemoteVideo(gSecondConnection, false);
(...skipping 460 matching lines...) Expand 10 before | Expand all | Expand 10 after
867 <body> 917 <body>
868 <table border="0"> 918 <table border="0">
869 <tr> 919 <tr>
870 <td>Local Preview</td> 920 <td>Local Preview</td>
871 <td>Remote Stream for Connection 1</td> 921 <td>Remote Stream for Connection 1</td>
872 <td>Remote Stream for Connection 2</td> 922 <td>Remote Stream for Connection 2</td>
873 <td>Remote Stream for Connection 3</td> 923 <td>Remote Stream for Connection 3</td>
874 <td>Remote Stream for Connection 4</td> 924 <td>Remote Stream for Connection 4</td>
875 </tr> 925 </tr>
876 <tr> 926 <tr>
877 <td><video width="320" height="240" id="local-view" 927 <td><video width="320" height="240" id="local-view" autoplay muted>
878 autoplay="autoplay"></video></td> 928 </video></td>
879 <td><video width="320" height="240" id="remote-view-1" 929 <td><video width="320" height="240" id="remote-view-1" autoplay>
880 autoplay="autoplay"></video></td> 930 </video></td>
881 <td><video width="320" height="240" id="remote-view-2" 931 <td><video width="320" height="240" id="remote-view-2" autoplay>
882 autoplay="autoplay"></video></td> 932 </video></td>
883 <td><video width="320" height="240" id="remote-view-3" 933 <td><video width="320" height="240" id="remote-view-3" autoplay>
884 autoplay="autoplay"></video></td> 934 </video></td>
885 <td><video width="320" height="240" id="remote-view-4" 935 <td><video width="320" height="240" id="remote-view-4" autoplay>
886 autoplay="autoplay"></video></td> 936 </video></td>
887 <!-- Canvases are named after their corresponding video elements. --> 937 <!-- Canvases are named after their corresponding video elements. -->
888 <td><canvas width="320" height="240" id="remote-view-1-canvas" 938 <td><canvas width="320" height="240" id="remote-view-1-canvas"
889 style="display:none"></canvas></td> 939 style="display:none"></canvas></td>
890 <td><canvas width="320" height="240" id="remote-view-2-canvas" 940 <td><canvas width="320" height="240" id="remote-view-2-canvas"
891 style="display:none"></canvas></td> 941 style="display:none"></canvas></td>
892 <td><canvas width="320" height="240" id="remote-view-3-canvas" 942 <td><canvas width="320" height="240" id="remote-view-3-canvas"
893 style="display:none"></canvas></td> 943 style="display:none"></canvas></td>
894 <td><canvas width="320" height="240" id="remote-view-4-canvas" 944 <td><canvas width="320" height="240" id="remote-view-4-canvas"
895 style="display:none"></canvas></td> 945 style="display:none"></canvas></td>
896 </tr> 946 </tr>
897 </table> 947 </table>
898 </body> 948 </body>
899 </html> 949 </html>
OLDNEW
« content/browser/media/webrtc_browsertest.cc ('K') | « content/browser/media/webrtc_browsertest.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698