test_peerConnection_addSecondAudioStream.html (1697B)
1 <!DOCTYPE HTML> 2 <html> 3 <head> 4 <script type="application/javascript" src="pc.js"></script> 5 </head> 6 <body> 7 <pre id="test"> 8 <script type="application/javascript"> 9 createHTML({ 10 bug: "1017888", 11 title: "Renegotiation: add second audio stream" 12 }); 13 14 runNetworkTest(function (options) { 15 const test = new PeerConnectionTest(options); 16 addRenegotiation(test.chain, 17 [ 18 function PC_LOCAL_ADD_SECOND_STREAM(test) { 19 test.setMediaConstraints([{audio: true}, {audio: true}], 20 [{audio: true}]); 21 return test.pcLocal.getAllUserMediaAndAddStreams([{audio: true}]); 22 }, 23 ], 24 [ 25 function PC_REMOTE_CHECK_ADDED_TRACK(test) { 26 // We test both tracks to avoid an ordering problem 27 is(test.pcRemote._pc.getReceivers().length, 2, 28 "pcRemote should have two receivers"); 29 const audioContext = new AudioContext(); 30 // Start a tone so that the gUM call will record something even 31 // with --use-test-media-devices. 32 const tone = new LoopbackTone(audioContext, TEST_AUDIO_FREQ); 33 tone.start(); 34 return Promise.all(test.pcRemote._pc.getReceivers().map(r => { 35 const analyser = new AudioStreamAnalyser( 36 audioContext, new MediaStream([r.track])); 37 const freq = analyser.binIndexForFrequency(TEST_AUDIO_FREQ); 38 return analyser.waitForAnalysisSuccess(arr => arr[freq] > 200); 39 })) 40 .finally(() => tone.stop()); 41 }, 42 ] 43 ); 44 45 test.setMediaConstraints([{audio: true}], [{audio: true}]); 46 return test.run(); 47 }); 48 </script> 49 </pre> 50 </body> 51 </html>