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

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

Issue 252703003: Wrote a test which exercises audio-only WebRTC calls. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 6 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 283 matching lines...) Expand 10 before | Expand all | Expand 10 after
294 remoteVideoTrack = remoteStream.getVideoTracks()[0]; 294 remoteVideoTrack = remoteStream.getVideoTracks()[0];
295 remoteVideoTrack.enabled = enabled; 295 remoteVideoTrack.enabled = enabled;
296 } 296 }
297 297
298 function enableRemoteAudio(peerConnection, enabled) { 298 function enableRemoteAudio(peerConnection, enabled) {
299 remoteStream = peerConnection.getRemoteStreams()[0]; 299 remoteStream = peerConnection.getRemoteStreams()[0];
300 remoteAudioTrack = remoteStream.getAudioTracks()[0]; 300 remoteAudioTrack = remoteStream.getAudioTracks()[0];
301 remoteAudioTrack.enabled = enabled; 301 remoteAudioTrack.enabled = enabled;
302 } 302 }
303 303
304 function callAndEnsureAudioIsPlaying(beLenient) { 304 function callAndEnsureAudioIsPlaying(beLenient, constraints) {
305 createConnections(null); 305 createConnections(null);
306 navigator.webkitGetUserMedia({audio: true, video: true}, 306 navigator.webkitGetUserMedia(constraints,
307 addStreamToBothConnectionsAndNegotiate, printGetUserMediaError); 307 addStreamToBothConnectionsAndNegotiate, printGetUserMediaError);
308 308
309 // Wait until we have gathered samples and can conclude if audio is playing. 309 // Wait until we have gathered samples and can conclude if audio is playing.
310 addExpectedEvent(); 310 addExpectedEvent();
311 var onCallEstablished = function() { 311 var onCallEstablished = function() {
312 // Gather 50 samples per second for 2 seconds. 312 // Gather 50 samples per second for 2 seconds.
313 gatherAudioLevelSamples(gSecondConnection, 100, 50, function(samples) { 313 gatherAudioLevelSamples(gSecondConnection, 100, 50, function(samples) {
314 verifyAudioIsPlaying(samples, beLenient); 314 verifyAudioIsPlaying(samples, beLenient);
315 eventOccured(); 315 eventOccured();
316 }); 316 });
317
318 // (Also, ensure video muting doesn't affect audio).
319 enableRemoteVideo(gSecondConnection, false);
320 }; 317 };
321 318
322 detectVideoPlaying('remote-view-2', onCallEstablished); 319 waitForConnectionToStabilize(gFirstConnection, onCallEstablished);
323 } 320 }
324 321
325 function callAndEnsureAudioTrackMutingWorks(beLenient) { 322 function callAndEnsureAudioTrackMutingWorks(beLenient) {
326 callAndEnsureAudioIsPlaying(beLenient); 323 callAndEnsureAudioIsPlaying(beLenient, {audio: true, video: true});
327 setAllEventsOccuredHandler(function() { 324 setAllEventsOccuredHandler(function() {
328 // Call is up, now mute the track and check everything goes silent (give 325 // Call is up, now mute the track and check everything goes silent (give
329 // it a small delay though, we don't expect it to happen instantly). 326 // it a small delay though, we don't expect it to happen instantly).
330 enableRemoteAudio(gSecondConnection, false); 327 enableRemoteAudio(gSecondConnection, false);
331 328
332 setTimeout(function() { 329 setTimeout(function() {
333 gatherAudioLevelSamples(gSecondConnection, 100, 50, function(samples) { 330 gatherAudioLevelSamples(gSecondConnection, 100, 50, function(samples) {
334 verifyIsSilent(samples); 331 verifyIsSilent(samples);
335 reportTestSuccess(); 332 reportTestSuccess();
336 }); 333 });
337 }, 500); 334 }, 500);
338 }); 335 });
339 } 336 }
340 337
341 function callAndEnsureAudioTrackUnmutingWorks(beLenient) { 338 function callAndEnsureAudioTrackUnmutingWorks(beLenient) {
342 callAndEnsureAudioIsPlaying(beLenient); 339 callAndEnsureAudioIsPlaying(beLenient, {audio: true, video: true});
343 setAllEventsOccuredHandler(function() { 340 setAllEventsOccuredHandler(function() {
344 // Mute, wait a while, unmute, verify audio gets back up. 341 // Mute, wait a while, unmute, verify audio gets back up.
342 // (Also, ensure video muting doesn't affect audio).
345 enableRemoteAudio(gSecondConnection, false); 343 enableRemoteAudio(gSecondConnection, false);
344 enableRemoteVideo(gSecondConnection, false);
346 345
347 setTimeout(function() { 346 setTimeout(function() {
348 enableRemoteAudio(gSecondConnection, true); 347 enableRemoteAudio(gSecondConnection, true);
349 }, 500); 348 }, 500);
350 349
351 setTimeout(function() { 350 setTimeout(function() {
352 // Sample for four seconds here; it can take a bit of time for audio to 351 // Sample for four seconds here; it can take a bit of time for audio to
353 // get back up after the unmute. 352 // get back up after the unmute.
354 gatherAudioLevelSamples(gSecondConnection, 200, 50, function(samples) { 353 gatherAudioLevelSamples(gSecondConnection, 200, 50, function(samples) {
355 verifyAudioIsPlaying(samples, beLenient); 354 verifyAudioIsPlaying(samples, beLenient);
(...skipping 504 matching lines...) Expand 10 before | Expand all | Expand 10 after
860 <td><canvas width="320" height="240" id="remote-view-2-canvas" 859 <td><canvas width="320" height="240" id="remote-view-2-canvas"
861 style="display:none"></canvas></td> 860 style="display:none"></canvas></td>
862 <td><canvas width="320" height="240" id="remote-view-3-canvas" 861 <td><canvas width="320" height="240" id="remote-view-3-canvas"
863 style="display:none"></canvas></td> 862 style="display:none"></canvas></td>
864 <td><canvas width="320" height="240" id="remote-view-4-canvas" 863 <td><canvas width="320" height="240" id="remote-view-4-canvas"
865 style="display:none"></canvas></td> 864 style="display:none"></canvas></td>
866 </tr> 865 </tr>
867 </table> 866 </table>
868 </body> 867 </body>
869 </html> 868 </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