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

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
« no previous file with comments | « content/browser/media/webrtc_browsertest.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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;
perkj_chrome 2014/08/14 08:53:41 nit add assert that stream 0 and video track 0 exi
phoglund_chromium 2014/08/25 09:41:45 I think that will be a lot of code that doesn't ma
perkj_chrome 2014/08/25 12:05:47 Acknowledged.
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() {
373 setTimeout(function() {
374 gatherAudioLevelSamples(gSecondConnection, 100, 50, function(samples) {
375 verifyIsSilent(samples);
376 reportTestSuccess();
perkj_chrome 2014/08/14 08:53:41 Why reportTextSuccess? Why not add addExpectedEven
phoglund_chromium 2014/08/25 09:41:45 Done.
377 });
378 }, 500);
379 }
380
381 function callAndEnsureRemoteAudioTrackMutingWorks(beLenient) {
359 callAndEnsureAudioIsPlaying(beLenient, {audio: true, video: true}); 382 callAndEnsureAudioIsPlaying(beLenient, {audio: true, video: true});
360 setAllEventsOccuredHandler(function() { 383 setAllEventsOccuredHandler(function() {
361 // Call is up, now mute the track and check everything goes silent (give 384 // Call is up, now mute the remote track and check we stop playing out
362 // it a small delay though, we don't expect it to happen instantly). 385 // audio (after a small delay, we don't expect it to happen instantly).
363 enableRemoteAudio(gSecondConnection, false); 386 enableRemoteAudio(gSecondConnection, false);
364 387 ensureSilence();
perkj_chrome 2014/08/14 08:53:42 ie - change ensureSilence and call setAllEventsOcc
phoglund_chromium 2014/08/25 09:41:45 Done.
365 setTimeout(function() {
366 gatherAudioLevelSamples(gSecondConnection, 100, 50, function(samples) {
367 verifyIsSilent(samples);
368 reportTestSuccess();
369 });
370 }, 500);
371 }); 388 });
372 } 389 }
373 390
391 function callAndEnsureLocalAudioTrackMutingWorks(beLenient) {
392 callAndEnsureAudioIsPlaying(beLenient, {audio: true, video: true});
393 setAllEventsOccuredHandler(function() {
394 // Call is up, now mute the local track of the sending side and ensure
395 // the receiving side stops receiving audio.
396 enableLocalAudio(gFirstConnection, false);
397 ensureSilence();
398 });
399 }
400
374 function callAndEnsureAudioTrackUnmutingWorks(beLenient) { 401 function callAndEnsureAudioTrackUnmutingWorks(beLenient) {
375 callAndEnsureAudioIsPlaying(beLenient, {audio: true, video: true}); 402 callAndEnsureAudioIsPlaying(beLenient, {audio: true, video: true});
376 setAllEventsOccuredHandler(function() { 403 setAllEventsOccuredHandler(function() {
377 // Mute, wait a while, unmute, verify audio gets back up. 404 // Mute, wait a while, unmute, verify audio gets back up.
378 // (Also, ensure video muting doesn't affect audio). 405 // (Also, ensure video muting doesn't affect audio).
379 enableRemoteAudio(gSecondConnection, false); 406 enableRemoteAudio(gSecondConnection, false);
380 enableRemoteVideo(gSecondConnection, false); 407 enableRemoteVideo(gSecondConnection, false);
381 408
382 setTimeout(function() { 409 setTimeout(function() {
383 enableRemoteAudio(gSecondConnection, true); 410 enableRemoteAudio(gSecondConnection, true);
384 }, 500); 411 }, 500);
385 412
386 setTimeout(function() { 413 setTimeout(function() {
387 // Sample for four seconds here; it can take a bit of time for audio to 414 // Sample for four seconds here; it can take a bit of time for audio to
388 // get back up after the unmute. 415 // get back up after the unmute.
389 gatherAudioLevelSamples(gSecondConnection, 200, 50, function(samples) { 416 gatherAudioLevelSamples(gSecondConnection, 200, 50, function(samples) {
390 verifyAudioIsPlaying(samples, beLenient); 417 verifyAudioIsPlaying(samples, beLenient);
391 reportTestSuccess(); 418 reportTestSuccess();
392 }); 419 });
393 }, 1500); 420 }, 1500);
394 }); 421 });
395 } 422 }
396 423
424 function callAndEnsureLocalVideoMutingDoesntMuteAudio(beLenient) {
425 callAndEnsureAudioIsPlaying(beLenient, {audio: true, video: true});
perkj_chrome 2014/08/14 08:53:42 The problem we had is that the media player expect
phoglund_chromium 2014/08/14 09:17:37 Yes. I tried that, and it repros, but the problem
426 setAllEventsOccuredHandler(function() {
427 setAllEventsOccuredHandler(reportTestSuccess);
428 enableLocalVideo(gFirstConnection, false);
429 ensureAudioPlaying(beLenient);
430 });
431 }
432
433 function callAndEnsureRemoteVideoMutingDoesntMuteAudio(beLenient) {
434 callAndEnsureAudioIsPlaying(beLenient, {audio: true, video: true});
435 setAllEventsOccuredHandler(function() {
436 setAllEventsOccuredHandler(reportTestSuccess);
437 enableRemoteVideo(gSecondConnection, false);
438 ensureAudioPlaying(beLenient);
439 });
440 }
441
397 function callAndEnsureVideoTrackMutingWorks() { 442 function callAndEnsureVideoTrackMutingWorks() {
398 createConnections(null); 443 createConnections(null);
399 navigator.webkitGetUserMedia({audio: true, video: true}, 444 navigator.webkitGetUserMedia({audio: true, video: true},
400 addStreamToBothConnectionsAndNegotiate, printGetUserMediaError); 445 addStreamToBothConnectionsAndNegotiate, printGetUserMediaError);
401 446
402 addExpectedEvent(); 447 addExpectedEvent();
403 detectVideoPlaying('remote-view-2', function() { 448 detectVideoPlaying('remote-view-2', function() {
404 // Disable the receiver's remote media stream. Video should stop. 449 // Disable the receiver's remote media stream. Video should stop.
405 // (Also, ensure muting audio doesn't affect video). 450 // (Also, ensure muting audio doesn't affect video).
406 enableRemoteVideo(gSecondConnection, false); 451 enableRemoteVideo(gSecondConnection, false);
(...skipping 460 matching lines...) Expand 10 before | Expand all | Expand 10 after
867 <body> 912 <body>
868 <table border="0"> 913 <table border="0">
869 <tr> 914 <tr>
870 <td>Local Preview</td> 915 <td>Local Preview</td>
871 <td>Remote Stream for Connection 1</td> 916 <td>Remote Stream for Connection 1</td>
872 <td>Remote Stream for Connection 2</td> 917 <td>Remote Stream for Connection 2</td>
873 <td>Remote Stream for Connection 3</td> 918 <td>Remote Stream for Connection 3</td>
874 <td>Remote Stream for Connection 4</td> 919 <td>Remote Stream for Connection 4</td>
875 </tr> 920 </tr>
876 <tr> 921 <tr>
877 <td><video width="320" height="240" id="local-view" 922 <td><video width="320" height="240" id="local-view" autoplay muted>
878 autoplay="autoplay"></video></td> 923 </video></td>
879 <td><video width="320" height="240" id="remote-view-1" 924 <td><video width="320" height="240" id="remote-view-1" autoplay>
880 autoplay="autoplay"></video></td> 925 </video></td>
881 <td><video width="320" height="240" id="remote-view-2" 926 <td><video width="320" height="240" id="remote-view-2" autoplay>
882 autoplay="autoplay"></video></td> 927 </video></td>
883 <td><video width="320" height="240" id="remote-view-3" 928 <td><video width="320" height="240" id="remote-view-3" autoplay>
884 autoplay="autoplay"></video></td> 929 </video></td>
885 <td><video width="320" height="240" id="remote-view-4" 930 <td><video width="320" height="240" id="remote-view-4" autoplay>
886 autoplay="autoplay"></video></td> 931 </video></td>
887 <!-- Canvases are named after their corresponding video elements. --> 932 <!-- Canvases are named after their corresponding video elements. -->
888 <td><canvas width="320" height="240" id="remote-view-1-canvas" 933 <td><canvas width="320" height="240" id="remote-view-1-canvas"
889 style="display:none"></canvas></td> 934 style="display:none"></canvas></td>
890 <td><canvas width="320" height="240" id="remote-view-2-canvas" 935 <td><canvas width="320" height="240" id="remote-view-2-canvas"
891 style="display:none"></canvas></td> 936 style="display:none"></canvas></td>
892 <td><canvas width="320" height="240" id="remote-view-3-canvas" 937 <td><canvas width="320" height="240" id="remote-view-3-canvas"
893 style="display:none"></canvas></td> 938 style="display:none"></canvas></td>
894 <td><canvas width="320" height="240" id="remote-view-4-canvas" 939 <td><canvas width="320" height="240" id="remote-view-4-canvas"
895 style="display:none"></canvas></td> 940 style="display:none"></canvas></td>
896 </tr> 941 </tr>
897 </table> 942 </table>
898 </body> 943 </body>
899 </html> 944 </html>
OLDNEW
« no previous file with comments | « content/browser/media/webrtc_browsertest.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698