Chromium Code Reviews| OLD | NEW |
|---|---|
| 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; |
| 11 var gSecondConnection = null; | 11 var gSecondConnection = null; |
| 12 var gTestWithoutMsid = false; | 12 var gTestWithoutMsid = false; |
| 13 var gLocalStream = null; | 13 var gLocalStream = null; |
| 14 var gSentTones = ''; | 14 var gSentTones = ''; |
| 15 | 15 |
| 16 var gRemoteStreams = {}; | 16 var gRemoteStreams = {}; |
| 17 | 17 |
| 18 // Default transform functions, overridden by some test cases. | 18 // Default transform functions, overridden by some test cases. |
| 19 var transformSdp = function(sdp) { return sdp; }; | 19 var transformSdp = function(sdp) { return sdp; }; |
| 20 var transformRemoteSdp = function(sdp) { return sdp; }; | 20 var transformRemoteSdp = function(sdp) { return sdp; }; |
| 21 var transformCandidate = function(candidate) { return candidate; }; | |
| 22 var onLocalDescriptionError = function(error) { failTest(error); }; | 21 var onLocalDescriptionError = function(error) { failTest(error); }; |
| 23 var onRemoteDescriptionError = function(error) { failTest(error); }; | 22 var onRemoteDescriptionError = function(error) { failTest(error); }; |
| 24 | 23 |
| 25 // Temporary measure to be able to force iSAC 16K where needed, particularly | 24 // Temporary measure to be able to force iSAC 16K where needed, particularly |
| 26 // on Android. This applies to every test which is why it's implemented like | 25 // on Android. This applies to every test which is why it's implemented like |
| 27 // this. | 26 // this. |
| 28 var maybeForceIsac16K = function(sdp) { return sdp; }; | 27 var maybeForceIsac16K = function(sdp) { return sdp; }; |
| 29 function forceIsac16KInSdp() { | 28 function forceIsac16KInSdp() { |
| 30 maybeForceIsac16K = function(sdp) { | 29 maybeForceIsac16K = function(sdp) { |
| 31 sdp = sdp.replace(/m=audio (\d+) RTP\/SAVPF.*\r\n/g, | 30 sdp = sdp.replace(/m=audio (\d+) RTP\/SAVPF.*\r\n/g, |
| 32 'm=audio $1 RTP/SAVPF 103 126\r\n'); | 31 'm=audio $1 RTP/SAVPF 103 126\r\n'); |
| 33 sdp = sdp.replace('a=fmtp:111 minptime=10', 'a=fmtp:103 minptime=10'); | 32 sdp = sdp.replace('a=fmtp:111 minptime=10', 'a=fmtp:103 minptime=10'); |
| 34 if (sdp.search('a=rtpmap:103 ISAC/16000') == -1) | 33 if (sdp.search('a=rtpmap:103 ISAC/16000') == -1) |
| 35 failTest('Missing iSAC 16K codec on Android; cannot force codec.'); | 34 failTest('Missing iSAC 16K codec on Android; cannot force codec.'); |
| 36 return sdp; | 35 return sdp; |
| 37 }; | 36 }; |
| 38 sendValueToTest('isac-forced'); | 37 sendValueToTest('isac-forced'); |
| 39 } | 38 } |
| 40 | 39 |
| 41 // When using external SDES, the crypto key is chosen by javascript. | 40 // When using external SDES, the crypto key is chosen by javascript. |
| 42 var EXTERNAL_SDES_LINES = { | 41 var EXTERNAL_SDES_LINES = { |
| 43 'audio': 'a=crypto:1 AES_CM_128_HMAC_SHA1_80 ' + | 42 'audio': 'a=crypto:1 AES_CM_128_HMAC_SHA1_80 ' + |
| 44 'inline:PS1uQCVeeCFCanVmcjkpPywjNWhcYD0mXXtxaVBR', | 43 'inline:PS1uQCVeeCFCanVmcjkpPywjNWhcYD0mXXtxaVBR', |
| 45 'video': 'a=crypto:1 AES_CM_128_HMAC_SHA1_80 ' + | 44 'video': 'a=crypto:1 AES_CM_128_HMAC_SHA1_80 ' + |
| 46 'inline:d0RmdmcmVCspeEc3QGZiNWpVLFJhQX1cfHAwJSoj', | 45 'inline:d0RmdmcmVCspeEc3QGZiNWpVLFJhQX1cfHAwJSoj', |
| 47 'data': 'a=crypto:1 AES_CM_128_HMAC_SHA1_80 ' + | 46 'data': 'a=crypto:1 AES_CM_128_HMAC_SHA1_80 ' + |
| 48 'inline:NzB4d1BINUAvLEw6UzF3WSJ+PSdFcGdUJShpX1Zj' | 47 'inline:NzB4d1BINUAvLEw6UzF3WSJ+PSdFcGdUJShpX1Zj' |
| 49 }; | 48 }; |
| 50 | 49 |
| 51 // When using GICE, the ICE credentials can be chosen by javascript. | |
| 52 var EXTERNAL_GICE_UFRAG = '1234567890123456'; | |
| 53 var EXTERNAL_GICE_PWD = '123456789012345678901234'; | |
| 54 | |
| 55 setAllEventsOccuredHandler(reportTestSuccess); | 50 setAllEventsOccuredHandler(reportTestSuccess); |
| 56 | 51 |
| 57 // Test that we can setup call with an audio and video track. | 52 // Test that we can setup call with an audio and video track. |
| 58 function call(constraints) { | 53 function call(constraints) { |
| 59 createConnections(null); | 54 createConnections(null); |
| 60 navigator.webkitGetUserMedia(constraints, | 55 navigator.webkitGetUserMedia(constraints, |
| 61 addStreamToBothConnectionsAndNegotiate, printGetUserMediaError); | 56 addStreamToBothConnectionsAndNegotiate, printGetUserMediaError); |
| 62 waitForVideo('remote-view-1'); | 57 waitForVideo('remote-view-1'); |
| 63 waitForVideo('remote-view-2'); | 58 waitForVideo('remote-view-2'); |
| 64 } | 59 } |
| (...skipping 129 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 194 addStreamToBothConnectionsAndNegotiate, printGetUserMediaError); | 189 addStreamToBothConnectionsAndNegotiate, printGetUserMediaError); |
| 195 waitForVideo('remote-view-1'); | 190 waitForVideo('remote-view-1'); |
| 196 waitForVideo('remote-view-2'); | 191 waitForVideo('remote-view-2'); |
| 197 } | 192 } |
| 198 | 193 |
| 199 // Test that we can setup call with legacy settings. | 194 // Test that we can setup call with legacy settings. |
| 200 function callWithLegacySdp() { | 195 function callWithLegacySdp() { |
| 201 transformSdp = function(sdp) { | 196 transformSdp = function(sdp) { |
| 202 return removeBundle(useGice(useExternalSdes(sdp))); | 197 return removeBundle(useGice(useExternalSdes(sdp))); |
| 203 }; | 198 }; |
| 204 transformCandidate = addGiceCredsToCandidate; | |
| 205 createConnections({ | 199 createConnections({ |
| 206 'mandatory': {'RtpDataChannels': true, 'DtlsSrtpKeyAgreement': false} | 200 'mandatory': {'RtpDataChannels': true, 'DtlsSrtpKeyAgreement': false} |
| 207 }); | 201 }); |
| 208 setupDataChannel({reliable: false}); | 202 setupDataChannel({reliable: false}); |
| 209 navigator.webkitGetUserMedia({audio: true, video: true}, | 203 navigator.webkitGetUserMedia({audio: true, video: true}, |
| 210 addStreamToBothConnectionsAndNegotiate, printGetUserMediaError); | 204 addStreamToBothConnectionsAndNegotiate, printGetUserMediaError); |
| 211 waitForVideo('remote-view-1'); | 205 waitForVideo('remote-view-1'); |
| 212 waitForVideo('remote-view-2'); | 206 waitForVideo('remote-view-2'); |
| 213 } | 207 } |
| 214 | 208 |
| (...skipping 495 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 710 | 704 |
| 711 function onOfferCreated(offer, caller, callee) { | 705 function onOfferCreated(offer, caller, callee) { |
| 712 offer.sdp = maybeForceIsac16K(transformSdp(offer.sdp)); | 706 offer.sdp = maybeForceIsac16K(transformSdp(offer.sdp)); |
| 713 caller.setLocalDescription(offer, function() { | 707 caller.setLocalDescription(offer, function() { |
| 714 assertEquals('have-local-offer', caller.signalingState); | 708 assertEquals('have-local-offer', caller.signalingState); |
| 715 receiveOffer(offer.sdp, caller, callee); | 709 receiveOffer(offer.sdp, caller, callee); |
| 716 }, onLocalDescriptionError); | 710 }, onLocalDescriptionError); |
| 717 } | 711 } |
| 718 | 712 |
| 719 function receiveOffer(offerSdp, caller, callee) { | 713 function receiveOffer(offerSdp, caller, callee) { |
| 720 console.log("Receiving offer..."); | 714 console.log("Receiving offer...\n" + offerSdp); |
| 721 offerSdp = transformRemoteSdp(offerSdp); | 715 offerSdp = transformRemoteSdp(offerSdp); |
| 722 | 716 |
| 723 var parsedOffer = new RTCSessionDescription({ type: 'offer', | 717 var parsedOffer = new RTCSessionDescription({ type: 'offer', |
| 724 sdp: offerSdp }); | 718 sdp: offerSdp }); |
| 725 callee.setRemoteDescription(parsedOffer, function() {}, | 719 callee.setRemoteDescription(parsedOffer, function() {}, |
| 726 onRemoteDescriptionError); | 720 onRemoteDescriptionError); |
| 727 callee.createAnswer(function (answer) { | 721 callee.createAnswer(function (answer) { |
| 728 onAnswerCreated(answer, caller, callee); | 722 onAnswerCreated(answer, caller, callee); |
| 729 }); | 723 }); |
| 730 assertEquals('have-remote-offer', callee.signalingState); | 724 assertEquals('have-remote-offer', callee.signalingState); |
| (...skipping 28 matching lines...) Expand all Loading... | |
| 759 } | 753 } |
| 760 | 754 |
| 761 function removeBundle(sdp) { | 755 function removeBundle(sdp) { |
| 762 return sdp.replace(/a=group:BUNDLE .*\r\n/g, ''); | 756 return sdp.replace(/a=group:BUNDLE .*\r\n/g, ''); |
| 763 } | 757 } |
| 764 | 758 |
| 765 function useGice(sdp) { | 759 function useGice(sdp) { |
| 766 sdp = sdp.replace(/t=.*\r\n/g, function(subString) { | 760 sdp = sdp.replace(/t=.*\r\n/g, function(subString) { |
| 767 return subString + 'a=ice-options:google-ice\r\n'; | 761 return subString + 'a=ice-options:google-ice\r\n'; |
| 768 }); | 762 }); |
| 769 sdp = sdp.replace(/a=ice-ufrag:.*\r\n/g, | |
| 770 'a=ice-ufrag:' + EXTERNAL_GICE_UFRAG + '\r\n'); | |
| 771 sdp = sdp.replace(/a=ice-pwd:.*\r\n/g, | |
| 772 'a=ice-pwd:' + EXTERNAL_GICE_PWD + '\r\n'); | |
| 773 return sdp; | 763 return sdp; |
| 774 } | 764 } |
| 775 | 765 |
| 776 function useExternalSdes(sdp) { | 766 function useExternalSdes(sdp) { |
| 777 // Remove current crypto specification. | 767 // Remove current crypto specification. |
| 778 sdp = sdp.replace(/a=crypto.*\r\n/g, ''); | 768 sdp = sdp.replace(/a=crypto.*\r\n/g, ''); |
| 779 sdp = sdp.replace(/a=fingerprint.*\r\n/g, ''); | 769 sdp = sdp.replace(/a=fingerprint.*\r\n/g, ''); |
| 780 // Add external crypto. This is not compatible with |removeMsid|. | 770 // Add external crypto. This is not compatible with |removeMsid|. |
| 781 sdp = sdp.replace(/a=mid:(\w+)\r\n/g, function(subString, group) { | 771 sdp = sdp.replace(/a=mid:(\w+)\r\n/g, function(subString, group) { |
| 782 return subString + EXTERNAL_SDES_LINES[group] + '\r\n'; | 772 return subString + EXTERNAL_SDES_LINES[group] + '\r\n'; |
| (...skipping 21 matching lines...) Expand all Loading... | |
| 804 assertEquals('stable', caller.signalingState); | 794 assertEquals('stable', caller.signalingState); |
| 805 }, | 795 }, |
| 806 onRemoteDescriptionError); | 796 onRemoteDescriptionError); |
| 807 } | 797 } |
| 808 | 798 |
| 809 function connectOnIceCandidate(caller, callee) { | 799 function connectOnIceCandidate(caller, callee) { |
| 810 caller.onicecandidate = function(event) { onIceCandidate(event, callee); } | 800 caller.onicecandidate = function(event) { onIceCandidate(event, callee); } |
| 811 callee.onicecandidate = function(event) { onIceCandidate(event, caller); } | 801 callee.onicecandidate = function(event) { onIceCandidate(event, caller); } |
| 812 } | 802 } |
| 813 | 803 |
| 814 function addGiceCredsToCandidate(candidate) { | |
| 815 return candidate.trimRight() + | |
| 816 ' username ' + EXTERNAL_GICE_UFRAG + ' password ' + EXTERNAL_GICE_PWD; | |
| 817 } | |
| 818 | |
| 819 function onIceCandidate(event, target) { | 804 function onIceCandidate(event, target) { |
| 820 if (event.candidate) { | 805 if (event.candidate) { |
| 821 var candidate = new RTCIceCandidate(event.candidate); | 806 var candidate = new RTCIceCandidate(event.candidate); |
| 822 candidate.candidate = transformCandidate(candidate.candidate); | |
|
bemasc
2014/07/08 15:17:38
I think this should probably also check the format
phoglund_chromium
2014/07/08 15:35:22
Hm, doesn't work. This is the value I get for cand
| |
| 823 target.addIceCandidate(candidate); | 807 target.addIceCandidate(candidate); |
| 824 } | 808 } |
| 825 } | 809 } |
| 826 | 810 |
| 827 function onRemoteStream(e, target) { | 811 function onRemoteStream(e, target) { |
| 828 console.log("Receiving remote stream..."); | 812 console.log("Receiving remote stream..."); |
| 829 if (gTestWithoutMsid && e.stream.id != "default") { | 813 if (gTestWithoutMsid && e.stream.id != "default") { |
| 830 failTest('a default remote stream was expected but instead ' + | 814 failTest('a default remote stream was expected but instead ' + |
| 831 e.stream.id + ' was received.'); | 815 e.stream.id + ' was received.'); |
| 832 } | 816 } |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 864 <td><canvas width="320" height="240" id="remote-view-2-canvas" | 848 <td><canvas width="320" height="240" id="remote-view-2-canvas" |
| 865 style="display:none"></canvas></td> | 849 style="display:none"></canvas></td> |
| 866 <td><canvas width="320" height="240" id="remote-view-3-canvas" | 850 <td><canvas width="320" height="240" id="remote-view-3-canvas" |
| 867 style="display:none"></canvas></td> | 851 style="display:none"></canvas></td> |
| 868 <td><canvas width="320" height="240" id="remote-view-4-canvas" | 852 <td><canvas width="320" height="240" id="remote-view-4-canvas" |
| 869 style="display:none"></canvas></td> | 853 style="display:none"></canvas></td> |
| 870 </tr> | 854 </tr> |
| 871 </table> | 855 </table> |
| 872 </body> | 856 </body> |
| 873 </html> | 857 </html> |
| OLD | NEW |