| 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"> | 4 <script type="text/javascript"> |
| 5 $ = function(id) { | 5 $ = function(id) { |
| 6 return document.getElementById(id); | 6 return document.getElementById(id); |
| 7 }; | 7 }; |
| 8 | 8 |
| 9 var gFirstConnection = null; | 9 var gFirstConnection = null; |
| 10 var gSecondConnection = null; | 10 var gSecondConnection = null; |
| 11 var gTestWithoutMsid = false; | 11 var gTestWithoutMsid = false; |
| 12 |
| 12 var gLocalStream = null; | 13 var gLocalStream = null; |
| 13 var gSentTones = ''; | 14 var gSentTones = ''; |
| 14 | 15 |
| 15 var gRemoteStreams = {}; | 16 var gRemoteStreams = {}; |
| 16 | 17 |
| 17 // Default transform functions, overridden by some test cases. | 18 // Default transform functions, overridden by some test cases. |
| 18 var transformSdp = function(sdp) { return sdp; }; | 19 var transformSdp = function(sdp) { return sdp; }; |
| 19 var transformRemoteSdp = function(sdp) { return sdp; }; | 20 var transformRemoteSdp = function(sdp) { return sdp; }; |
| 20 var transformCandidate = function(candidate) { return candidate; }; | 21 var transformCandidate = function(candidate) { return candidate; }; |
| 21 var onLocalDescriptionError = function(error) { }; | |
| 22 | 22 |
| 23 // When using external SDES, the crypto key is chosen by javascript. | 23 // When using external SDES, the crypto key is chosen by javascript. |
| 24 var EXTERNAL_SDES_LINES = { | 24 var EXTERNAL_SDES_LINES = { |
| 25 'audio': 'a=crypto:1 AES_CM_128_HMAC_SHA1_80 ' + | 25 'audio': 'a=crypto:1 AES_CM_128_HMAC_SHA1_80 ' + |
| 26 'inline:PS1uQCVeeCFCanVmcjkpPywjNWhcYD0mXXtxaVBR', | 26 'inline:PS1uQCVeeCFCanVmcjkpPywjNWhcYD0mXXtxaVBR', |
| 27 'video': 'a=crypto:1 AES_CM_128_HMAC_SHA1_80 ' + | 27 'video': 'a=crypto:1 AES_CM_128_HMAC_SHA1_80 ' + |
| 28 'inline:d0RmdmcmVCspeEc3QGZiNWpVLFJhQX1cfHAwJSoj', | 28 'inline:d0RmdmcmVCspeEc3QGZiNWpVLFJhQX1cfHAwJSoj', |
| 29 'data': 'a=crypto:1 AES_CM_128_HMAC_SHA1_80 ' + | 29 'data': 'a=crypto:1 AES_CM_128_HMAC_SHA1_80 ' + |
| 30 'inline:NzB4d1BINUAvLEw6UzF3WSJ+PSdFcGdUJShpX1Zj' | 30 'inline:NzB4d1BINUAvLEw6UzF3WSJ+PSdFcGdUJShpX1Zj' |
| 31 }; | 31 }; |
| (...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 107 } | 107 } |
| 108 | 108 |
| 109 // Test that we can setup call with an audio and video track and | 109 // Test that we can setup call with an audio and video track and |
| 110 // simulate that the remote peer don't support MSID. | 110 // simulate that the remote peer don't support MSID. |
| 111 function callWithoutMsidAndBundle() { | 111 function callWithoutMsidAndBundle() { |
| 112 createConnections(null); | 112 createConnections(null); |
| 113 transformSdp = removeBundle; | 113 transformSdp = removeBundle; |
| 114 transformRemoteSdp = removeMsid; | 114 transformRemoteSdp = removeMsid; |
| 115 gTestWithoutMsid = true; | 115 gTestWithoutMsid = true; |
| 116 navigator.webkitGetUserMedia({audio: true, video: true}, | 116 navigator.webkitGetUserMedia({audio: true, video: true}, |
| 117 addStreamToBothConnectionsAndNegotiate, printGetUserMediaError); | 117 addStreamToBothConnectionsAndNegotiate, printGetUserMediaError); |
| 118 waitForVideo('remote-view-1'); | 118 waitForVideo('remote-view-1'); |
| 119 waitForVideo('remote-view-2'); | 119 waitForVideo('remote-view-2'); |
| 120 } | 120 } |
| 121 | |
| 122 // Test that we can't setup a call with an unsupported video codec | |
| 123 function negotiateUnsupportedVideoCodec() { | |
| 124 createConnections(null); | |
| 125 transformSdp = removeVideoCodec; | |
| 126 navigator.webkitGetUserMedia({audio: true, video: true}, | |
| 127 addStreamToBothConnectionsAndNegotiate, printGetUserMediaError); | |
| 128 onLocalDescriptionError = function(error) { | |
| 129 var expectedMsg = 'SetLocalDescription failed: Failed to' + | |
| 130 ' update session state: ERROR_CONTENT'; | |
| 131 expectEquals(expectedMsg, error); | |
| 132 | |
| 133 // Got the right message, test succeeded. | |
| 134 document.title = 'OK'; | |
| 135 }; | |
| 136 } | |
| 137 | |
| 138 // Test that we can't setup a call if one peer does not support encryption | |
| 139 function negotiateNonCryptoCall() { | |
| 140 createConnections(null); | |
| 141 transformSdp = removeCrypto; | |
| 142 navigator.webkitGetUserMedia({audio: true, video: true}, | |
| 143 addStreamToBothConnectionsAndNegotiate, printGetUserMediaError); | |
| 144 onLocalDescriptionError = function(error) { | |
| 145 var expectedMsg = 'SetLocalDescription failed: Called with a SDP without' | |
| 146 + ' crypto enabled.'; | |
| 147 expectEquals(expectedMsg, error); | |
| 148 | |
| 149 // Got the right message, test succeeded. | |
| 150 document.title = 'OK'; | |
| 151 }; | |
| 152 } | |
| 153 | |
| 154 // Test that we can negotiate a call with an SDP offer that includes a | |
| 155 // b=AS:XX line to control audio and video bandwidth | |
| 156 function negotiateOfferWithBLine() { | |
| 157 createConnections(null); | |
| 158 transformSdp = addBandwithControl; | |
| 159 navigator.webkitGetUserMedia({audio: true, video: true}, | |
| 160 addStreamToBothConnectionsAndNegotiate, printGetUserMediaError); | |
| 161 waitForVideo('remote-view-1'); | |
| 162 waitForVideo('remote-view-2'); | |
| 163 } | |
| 164 | 121 |
| 165 // Test that we can setup call with legacy settings. | 122 // Test that we can setup call with legacy settings. |
| 166 function callWithLegacySdp() { | 123 function callWithLegacySdp() { |
| 167 transformSdp = function(sdp) { | 124 transformSdp = function(sdp) { |
| 168 return removeBundle(useGice(useExternalSdes(sdp))); | 125 return removeBundle(useGice(useExternalSdes(sdp))); |
| 169 }; | 126 }; |
| 170 transformCandidate = addGiceCredsToCandidate; | 127 transformCandidate = addGiceCredsToCandidate; |
| 171 createConnections({ | 128 createConnections({ |
| 172 'mandatory': {'RtpDataChannels': true, 'DtlsSrtpKeyAgreement': false} | 129 'mandatory': {'RtpDataChannels': true, 'DtlsSrtpKeyAgreement': false} |
| 173 }); | 130 }); |
| (...skipping 280 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 454 } | 411 } |
| 455 return pc; | 412 return pc; |
| 456 } | 413 } |
| 457 | 414 |
| 458 function displayAndRemember(localStream) { | 415 function displayAndRemember(localStream) { |
| 459 var localStreamUrl = webkitURL.createObjectURL(localStream); | 416 var localStreamUrl = webkitURL.createObjectURL(localStream); |
| 460 $('local-view').src = localStreamUrl; | 417 $('local-view').src = localStreamUrl; |
| 461 | 418 |
| 462 gLocalStream = localStream; | 419 gLocalStream = localStream; |
| 463 } | 420 } |
| 464 | 421 |
| 465 // Called if getUserMedia fails. | 422 // Called if getUserMedia fails. |
| 466 function printGetUserMediaError(error) { | 423 function printGetUserMediaError(error) { |
| 467 document.title = 'getUserMedia request failed with code ' + error.code; | 424 document.title = 'getUserMedia request failed with code ' + error.code; |
| 468 } | 425 } |
| 469 | 426 |
| 470 // Called if getUserMedia succeeds and we want to send from both connections. | 427 // Called if getUserMedia succeeds and we want to send from both connections. |
| 471 function addStreamToBothConnectionsAndNegotiate(localStream) { | 428 function addStreamToBothConnectionsAndNegotiate(localStream) { |
| 472 displayAndRemember(localStream); | 429 displayAndRemember(localStream); |
| 473 gFirstConnection.addStream(localStream); | 430 gFirstConnection.addStream(localStream); |
| 474 gSecondConnection.addStream(localStream); | 431 gSecondConnection.addStream(localStream); |
| 475 negotiate(); | 432 negotiate(); |
| 476 } | 433 } |
| 477 | 434 |
| (...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 546 connectOnIceCandidate(caller, callee); | 503 connectOnIceCandidate(caller, callee); |
| 547 | 504 |
| 548 caller.createOffer( | 505 caller.createOffer( |
| 549 function (offer) { | 506 function (offer) { |
| 550 onOfferCreated(offer, caller, callee); | 507 onOfferCreated(offer, caller, callee); |
| 551 }); | 508 }); |
| 552 } | 509 } |
| 553 | 510 |
| 554 function onOfferCreated(offer, caller, callee) { | 511 function onOfferCreated(offer, caller, callee) { |
| 555 offer.sdp = transformSdp(offer.sdp); | 512 offer.sdp = transformSdp(offer.sdp); |
| 556 caller.setLocalDescription(offer, null, onLocalDescriptionError); | 513 caller.setLocalDescription(offer); |
| 557 | |
| 558 expectEquals('have-local-offer', caller.signalingState); | 514 expectEquals('have-local-offer', caller.signalingState); |
| 559 receiveOffer(offer.sdp, caller, callee); | 515 receiveOffer(offer.sdp, caller, callee); |
| 560 } | 516 } |
| 561 | 517 |
| 562 function receiveOffer(offerSdp, caller, callee) { | 518 function receiveOffer(offerSdp, caller, callee) { |
| 563 offerSdp = transformRemoteSdp(offerSdp); | 519 offerSdp = transformRemoteSdp(offerSdp); |
| 564 | 520 |
| 565 var parsedOffer = new RTCSessionDescription({ type: 'offer', | 521 var parsedOffer = new RTCSessionDescription({ type: 'offer', |
| 566 sdp: offerSdp }); | 522 sdp: offerSdp }); |
| 567 callee.setRemoteDescription(parsedOffer); | 523 callee.setRemoteDescription(parsedOffer); |
| 568 callee.createAnswer(function (answer) { | 524 callee.createAnswer(function (answer) { |
| 569 onAnswerCreated(answer, caller, callee); | 525 onAnswerCreated(answer, caller, callee); |
| 570 }); | 526 }); |
| 571 expectEquals('have-remote-offer', callee.signalingState); | 527 expectEquals('have-remote-offer', callee.signalingState); |
| 572 } | 528 } |
| 573 | 529 |
| 574 function removeMsid(offerSdp) { | 530 function removeMsid(offerSdp) { |
| 575 offerSdp = offerSdp.replace(/a=msid-semantic.*\r\n/g, ''); | 531 offerSdp = offerSdp.replace(/a=msid-semantic.*\r\n/g, ''); |
| 576 offerSdp = offerSdp.replace('a=mid:audio\r\n', ''); | 532 offerSdp = offerSdp.replace('a=mid:audio\r\n', ''); |
| 577 offerSdp = offerSdp.replace('a=mid:video\r\n', ''); | 533 offerSdp = offerSdp.replace('a=mid:video\r\n', ''); |
| 578 offerSdp = offerSdp.replace(/a=ssrc.*\r\n/g, ''); | 534 offerSdp = offerSdp.replace(/a=ssrc.*\r\n/g, ''); |
| 579 return offerSdp; | 535 return offerSdp; |
| 580 } | 536 } |
| 581 | 537 |
| 582 function removeVideoCodec(offerSdp) { | |
| 583 offerSdp = offerSdp.replace('a=rtpmap:100 VP8/90000\r\n', | |
| 584 'a=rtpmap:100 XVP8/90000\r\n'); | |
| 585 return offerSdp; | |
| 586 } | |
| 587 | |
| 588 function removeCrypto(offerSdp) { | |
| 589 offerSdp = offerSdp.replace(/a=crypto.*\r\n/g, 'a=Xcrypto\r\n'); | |
| 590 offerSdp = offerSdp.replace(/a=fingerprint.*\r\n/g, ''); | |
| 591 return offerSdp; | |
| 592 } | |
| 593 | |
| 594 function addBandwithControl(offerSdp) { | |
| 595 offerSdp = offerSdp.replace('a=mid:audio\r\n', 'a=mid:audio\r\n'+'b=AS:16\r\
n'); | |
| 596 offerSdp = offerSdp.replace('a=mid:video\r\n', 'a=mid:video\r\n'+'b=AS:512\r
\n'); | |
| 597 return offerSdp; | |
| 598 } | |
| 599 | |
| 600 function removeBundle(sdp) { | 538 function removeBundle(sdp) { |
| 601 return sdp.replace(/a=group:BUNDLE .*\r\n/g, ''); | 539 return sdp.replace(/a=group:BUNDLE .*\r\n/g, ''); |
| 602 } | 540 } |
| 603 | 541 |
| 604 function useGice(sdp) { | 542 function useGice(sdp) { |
| 605 sdp = sdp.replace(/t=.*\r\n/g, function(subString) { | 543 sdp = sdp.replace(/t=.*\r\n/g, function(subString) { |
| 606 return subString + 'a=ice-options:google-ice\r\n'; | 544 return subString + 'a=ice-options:google-ice\r\n'; |
| 607 }); | 545 }); |
| 608 sdp = sdp.replace(/a=ice-ufrag:.*\r\n/g, | 546 sdp = sdp.replace(/a=ice-ufrag:.*\r\n/g, |
| 609 'a=ice-ufrag:' + EXTERNAL_GICE_UFRAG + '\r\n'); | 547 'a=ice-ufrag:' + EXTERNAL_GICE_UFRAG + '\r\n'); |
| (...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 696 <td><canvas width="320" height="240" id="remote-view-2-canvas" | 634 <td><canvas width="320" height="240" id="remote-view-2-canvas" |
| 697 style="display:none"></canvas></td> | 635 style="display:none"></canvas></td> |
| 698 <td><canvas width="320" height="240" id="remote-view-3-canvas" | 636 <td><canvas width="320" height="240" id="remote-view-3-canvas" |
| 699 style="display:none"></canvas></td> | 637 style="display:none"></canvas></td> |
| 700 <td><canvas width="320" height="240" id="remote-view-4-canvas" | 638 <td><canvas width="320" height="240" id="remote-view-4-canvas" |
| 701 style="display:none"></canvas></td> | 639 style="display:none"></canvas></td> |
| 702 </tr> | 640 </tr> |
| 703 </table> | 641 </table> |
| 704 </body> | 642 </body> |
| 705 </html> | 643 </html> |
| OLD | NEW |