Index: content/test/data/media/peerconnection-call.html |
=================================================================== |
--- content/test/data/media/peerconnection-call.html (revision 229411) |
+++ content/test/data/media/peerconnection-call.html (working copy) |
@@ -8,13 +8,30 @@ |
var gFirstConnection = null; |
var gSecondConnection = null; |
- var gTestWithoutMsidAndBundle = false; |
+ var gTestWithoutMsid = false; |
phoglund_chromium
2013/10/25 00:45:05
This growing amount of global state is a bit unfor
bemasc
2013/10/25 17:39:55
Done.
|
+ var gTestWithoutBundle = false; |
+ var gTestWithGice = false; |
+ var gTestWithExternalSdes = false; |
var gLocalStream = null; |
var gSentTones = ''; |
var gRemoteStreams = {}; |
+ // When using external SDES, the crypto key is chosen by javascript. |
+ var externalSdesLines = { |
phoglund_chromium
2013/10/25 00:45:05
Nit: I guess the external* variables are constants
bemasc
2013/10/25 17:39:55
Done.
|
+ 'audio': 'a=crypto:1 AES_CM_128_HMAC_SHA1_80 ' + |
+ 'inline:PS1uQCVeeCFCanVmcjkpPywjNWhcYD0mXXtxaVBR', |
+ 'video': 'a=crypto:1 AES_CM_128_HMAC_SHA1_80 ' + |
+ 'inline:d0RmdmcmVCspeEc3QGZiNWpVLFJhQX1cfHAwJSoj', |
+ 'data': 'a=crypto:1 AES_CM_128_HMAC_SHA1_80 ' + |
+ 'inline:NzB4d1BINUAvLEw6UzF3WSJ+PSdFcGdUJShpX1Zj' |
+ }; |
+ |
+ // When using GICE, the ICE credentials can be chosen by javascript. |
+ var externalGiceUfrag = '1234567890123456'; |
+ var externalGicePwd = '123456789012345678901234'; |
+ |
setAllEventsOccuredHandler(function() { |
document.title = 'OK'; |
}); |
@@ -91,13 +108,29 @@ |
// simulate that the remote peer don't support MSID. |
function callWithoutMsidAndBundle() { |
createConnections(null); |
- gTestWithoutMsidAndBundle = true; |
+ gTestWithoutMsid = true; |
+ gTestWithoutBundle = true; |
navigator.webkitGetUserMedia({audio: true, video: true}, |
addStreamToBothConnectionsAndNegotiate, printGetUserMediaError); |
waitForVideo('remote-view-1'); |
waitForVideo('remote-view-2'); |
} |
+ // Test that we can setup call with legacy settings. |
+ function callWithLegacySdp() { |
+ gTestWithoutBundle = true; |
+ gTestWithGice = true; |
+ gTestWithExternalSdes = true; |
+ createConnections({ |
+ 'mandatory': {'RtpDataChannels': true, 'DtlsSrtpKeyAgreement': false} |
+ }); |
+ setupDataChannel({reliable: false}); |
+ navigator.webkitGetUserMedia({audio: true, video: true}, |
+ addStreamToBothConnectionsAndNegotiate, printGetUserMediaError); |
+ waitForVideo('remote-view-1'); |
+ waitForVideo('remote-view-2'); |
+ } |
+ |
// Test only a data channel. |
function callWithDataOnly() { |
createConnections({optional:[{RtpDataChannels: true}]}); |
@@ -467,15 +500,20 @@ |
caller.createOffer( |
function (offer) { |
- caller.setLocalDescription(offer); |
- expectEquals('have-local-offer', caller.signalingState); |
- receiveOffer(offer.sdp, caller, callee); |
+ onOfferCreated(offer, caller, callee); |
}); |
} |
+ function onOfferCreated(offer, caller, callee) { |
+ offer.sdp = mungeSdp(offer.sdp); |
phoglund_chromium
2013/10/25 00:45:05
Like I said above, try replacing this with the new
bemasc
2013/10/25 17:39:55
Done.
|
+ caller.setLocalDescription(offer); |
+ expectEquals('have-local-offer', caller.signalingState); |
+ receiveOffer(offer.sdp, caller, callee); |
+ } |
+ |
function receiveOffer(offerSdp, caller, callee) { |
- if (gTestWithoutMsidAndBundle) { |
- offerSdp = removeMsidAndBundle(offerSdp); |
+ if (gTestWithoutMsid) { |
phoglund_chromium
2013/10/25 00:45:05
This should be able to move into mungeSdp, or the
bemasc
2013/10/25 00:53:52
This modification has to be performed after setLoc
phoglund_chromium
2013/10/25 01:15:59
Oh, ok. Perhaps we can consider two SDP transform
bemasc
2013/10/25 17:39:55
Done.
|
+ offerSdp = removeMsid(offerSdp); |
} |
var parsedOffer = new RTCSessionDescription({ type: 'offer', |
@@ -487,25 +525,68 @@ |
expectEquals('have-remote-offer', callee.signalingState); |
} |
- function removeMsidAndBundle(offerSdp) { |
+ function removeMsid(offerSdp) { |
offerSdp = offerSdp.replace(/a=msid-semantic.*\r\n/g, ''); |
- offerSdp = offerSdp.replace('a=group:BUNDLE audio video\r\n', ''); |
offerSdp = offerSdp.replace('a=mid:audio\r\n', ''); |
offerSdp = offerSdp.replace('a=mid:video\r\n', ''); |
offerSdp = offerSdp.replace(/a=ssrc.*\r\n/g, ''); |
return offerSdp; |
} |
+ function mungeSdp(sdp) { |
+ if (gTestWithoutBundle) { |
+ sdp = removeBundle(sdp); |
+ } |
+ |
+ if (gTestWithGice) { |
+ sdp = useGice(sdp); |
+ } |
+ |
+ if (gTestWithExternalSdes) { |
+ sdp = useExternalSdes(sdp); |
+ } |
+ |
+ return sdp; |
+ } |
+ |
+ function removeBundle(sdp) { |
+ return sdp.replace(/a=group:BUNDLE .*\r\n/g, ''); |
+ } |
+ |
+ function useGice(sdp) { |
+ sdp = sdp.replace(/t=.*\r\n/g, function(subString) { |
+ return subString + 'a=ice-options:google-ice\r\n'; |
+ }); |
+ sdp = sdp.replace(/a=ice-ufrag:.*\r\n/g, |
+ 'a=ice-ufrag:' + externalGiceUfrag + '\r\n'); |
+ sdp = sdp.replace(/a=ice-pwd:.*\r\n/g, |
+ 'a=ice-pwd:' + externalGicePwd + '\r\n'); |
+ return sdp; |
+ } |
+ |
+ function useExternalSdes(sdp) { |
+ // Remove current crypto specification. |
+ sdp = sdp.replace(/a=crypto.*\r\n/g, ''); |
+ sdp = sdp.replace(/a=fingerprint.*\r\n/g, ''); |
+ // Add external crypto. This is not compatible with |removeMsid|. |
+ sdp = sdp.replace(/a=mid:(\w+)\r\n/g, function(subString, group) { |
+ return subString + externalSdesLines[group] + '\r\n'; |
+ }); |
+ return sdp; |
+ } |
+ |
function onAnswerCreated(answer, caller, callee) { |
+ answer.sdp = mungeSdp(answer.sdp); |
callee.setLocalDescription(answer); |
expectEquals('stable', callee.signalingState); |
receiveAnswer(answer.sdp, caller); |
} |
function receiveAnswer(answerSdp, caller) { |
- if (gTestWithoutMsidAndBundle) { |
- answerSdp = removeMsidAndBundle(answerSdp); |
+ if (gTestWithoutMsid) { |
+ answerSdp = removeMsid(answerSdp); |
} |
+ |
var parsedAnswer = new RTCSessionDescription({ type: 'answer', |
sdp: answerSdp }); |
caller.setRemoteDescription(parsedAnswer); |
@@ -520,12 +601,16 @@ |
function onIceCandidate(event, target) { |
if (event.candidate) { |
var candidate = new RTCIceCandidate(event.candidate); |
+ if (gTestWithGice) { |
+ candidate.candidate = candidate.candidate.trimRight() + |
+ ' username ' + externalGiceUfrag + ' password ' + externalGicePwd; |
+ } |
target.addIceCandidate(candidate); |
} |
} |
function onRemoteStream(e, target) { |
- if (gTestWithoutMsidAndBundle && e.stream.id != "default") { |
+ if (gTestWithoutMsid && e.stream.id != "default") { |
document.title = 'a default remote stream was expected but instead ' + |
e.stream.id + ' was received.'; |
return; |