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

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

Issue 39033006: Add tests for legacy SDP features. (Closed) Base URL: https://src.chromium.org/chrome/trunk/src/
Patch Set: Created 7 years, 2 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
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"> 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 gTestWithoutMsidAndBundle = false; 11 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.
12 var gTestWithoutBundle = false;
13 var gTestWithGice = false;
14 var gTestWithExternalSdes = false;
12 15
13 var gLocalStream = null; 16 var gLocalStream = null;
14 var gSentTones = ''; 17 var gSentTones = '';
15 18
16 var gRemoteStreams = {}; 19 var gRemoteStreams = {};
17 20
21 // When using external SDES, the crypto key is chosen by javascript.
22 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.
23 'audio': 'a=crypto:1 AES_CM_128_HMAC_SHA1_80 ' +
24 'inline:PS1uQCVeeCFCanVmcjkpPywjNWhcYD0mXXtxaVBR',
25 'video': 'a=crypto:1 AES_CM_128_HMAC_SHA1_80 ' +
26 'inline:d0RmdmcmVCspeEc3QGZiNWpVLFJhQX1cfHAwJSoj',
27 'data': 'a=crypto:1 AES_CM_128_HMAC_SHA1_80 ' +
28 'inline:NzB4d1BINUAvLEw6UzF3WSJ+PSdFcGdUJShpX1Zj'
29 };
30
31 // When using GICE, the ICE credentials can be chosen by javascript.
32 var externalGiceUfrag = '1234567890123456';
33 var externalGicePwd = '123456789012345678901234';
34
18 setAllEventsOccuredHandler(function() { 35 setAllEventsOccuredHandler(function() {
19 document.title = 'OK'; 36 document.title = 'OK';
20 }); 37 });
21 38
22 // Test that we can setup call with an audio and video track. 39 // Test that we can setup call with an audio and video track.
23 function call(constraints) { 40 function call(constraints) {
24 createConnections(null); 41 createConnections(null);
25 navigator.webkitGetUserMedia(constraints, 42 navigator.webkitGetUserMedia(constraints,
26 addStreamToBothConnectionsAndNegotiate, printGetUserMediaError); 43 addStreamToBothConnectionsAndNegotiate, printGetUserMediaError);
27 waitForVideo('remote-view-1'); 44 waitForVideo('remote-view-1');
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after
84 101
85 // Do the forwarding after we have received video. 102 // Do the forwarding after we have received video.
86 detectVideoIn('remote-view-1', onRemoteStream1); 103 detectVideoIn('remote-view-1', onRemoteStream1);
87 detectVideoIn('remote-view-2', onRemoteStream2); 104 detectVideoIn('remote-view-2', onRemoteStream2);
88 } 105 }
89 106
90 // Test that we can setup call with an audio and video track and 107 // Test that we can setup call with an audio and video track and
91 // simulate that the remote peer don't support MSID. 108 // simulate that the remote peer don't support MSID.
92 function callWithoutMsidAndBundle() { 109 function callWithoutMsidAndBundle() {
93 createConnections(null); 110 createConnections(null);
94 gTestWithoutMsidAndBundle = true; 111 gTestWithoutMsid = true;
112 gTestWithoutBundle = true;
95 navigator.webkitGetUserMedia({audio: true, video: true}, 113 navigator.webkitGetUserMedia({audio: true, video: true},
96 addStreamToBothConnectionsAndNegotiate, printGetUserMediaError); 114 addStreamToBothConnectionsAndNegotiate, printGetUserMediaError);
97 waitForVideo('remote-view-1'); 115 waitForVideo('remote-view-1');
98 waitForVideo('remote-view-2'); 116 waitForVideo('remote-view-2');
99 } 117 }
100 118
119 // Test that we can setup call with legacy settings.
120 function callWithLegacySdp() {
121 gTestWithoutBundle = true;
122 gTestWithGice = true;
123 gTestWithExternalSdes = true;
124 createConnections({
125 'mandatory': {'RtpDataChannels': true, 'DtlsSrtpKeyAgreement': false}
126 });
127 setupDataChannel({reliable: false});
128 navigator.webkitGetUserMedia({audio: true, video: true},
129 addStreamToBothConnectionsAndNegotiate, printGetUserMediaError);
130 waitForVideo('remote-view-1');
131 waitForVideo('remote-view-2');
132 }
133
101 // Test only a data channel. 134 // Test only a data channel.
102 function callWithDataOnly() { 135 function callWithDataOnly() {
103 createConnections({optional:[{RtpDataChannels: true}]}); 136 createConnections({optional:[{RtpDataChannels: true}]});
104 setupDataChannel({reliable: false}); 137 setupDataChannel({reliable: false});
105 negotiate(); 138 negotiate();
106 } 139 }
107 140
108 function callWithSctpDataOnly() { 141 function callWithSctpDataOnly() {
109 createConnections({optional: [{DtlsSrtpKeyAgreement: true}]}); 142 createConnections({optional: [{DtlsSrtpKeyAgreement: true}]});
110 setupSctpDataChannel({reliable: true}); 143 setupSctpDataChannel({reliable: true});
(...skipping 349 matching lines...) Expand 10 before | Expand all | Expand 10 after
460 function negotiateBetween(caller, callee) { 493 function negotiateBetween(caller, callee) {
461 // Not stable = negotiation is ongoing. The behavior of re-negotiating while 494 // Not stable = negotiation is ongoing. The behavior of re-negotiating while
462 // a negotiation is ongoing is more or less undefined, so avoid this. 495 // a negotiation is ongoing is more or less undefined, so avoid this.
463 if (caller.signalingState != 'stable') 496 if (caller.signalingState != 'stable')
464 throw 'You can only negotiate when the connection is stable!'; 497 throw 'You can only negotiate when the connection is stable!';
465 498
466 connectOnIceCandidate(caller, callee); 499 connectOnIceCandidate(caller, callee);
467 500
468 caller.createOffer( 501 caller.createOffer(
469 function (offer) { 502 function (offer) {
470 caller.setLocalDescription(offer); 503 onOfferCreated(offer, caller, callee);
471 expectEquals('have-local-offer', caller.signalingState);
472 receiveOffer(offer.sdp, caller, callee);
473 }); 504 });
474 } 505 }
475 506
507 function onOfferCreated(offer, caller, callee) {
508 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.
509 caller.setLocalDescription(offer);
510 expectEquals('have-local-offer', caller.signalingState);
511 receiveOffer(offer.sdp, caller, callee);
512 }
513
476 function receiveOffer(offerSdp, caller, callee) { 514 function receiveOffer(offerSdp, caller, callee) {
477 if (gTestWithoutMsidAndBundle) { 515 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.
478 offerSdp = removeMsidAndBundle(offerSdp); 516 offerSdp = removeMsid(offerSdp);
479 } 517 }
480 518
481 var parsedOffer = new RTCSessionDescription({ type: 'offer', 519 var parsedOffer = new RTCSessionDescription({ type: 'offer',
482 sdp: offerSdp }); 520 sdp: offerSdp });
483 callee.setRemoteDescription(parsedOffer); 521 callee.setRemoteDescription(parsedOffer);
484 callee.createAnswer(function (answer) { 522 callee.createAnswer(function (answer) {
485 onAnswerCreated(answer, caller, callee); 523 onAnswerCreated(answer, caller, callee);
486 }); 524 });
487 expectEquals('have-remote-offer', callee.signalingState); 525 expectEquals('have-remote-offer', callee.signalingState);
488 } 526 }
489 527
490 function removeMsidAndBundle(offerSdp) { 528 function removeMsid(offerSdp) {
491 offerSdp = offerSdp.replace(/a=msid-semantic.*\r\n/g, ''); 529 offerSdp = offerSdp.replace(/a=msid-semantic.*\r\n/g, '');
492 offerSdp = offerSdp.replace('a=group:BUNDLE audio video\r\n', '');
493 offerSdp = offerSdp.replace('a=mid:audio\r\n', ''); 530 offerSdp = offerSdp.replace('a=mid:audio\r\n', '');
494 offerSdp = offerSdp.replace('a=mid:video\r\n', ''); 531 offerSdp = offerSdp.replace('a=mid:video\r\n', '');
495 offerSdp = offerSdp.replace(/a=ssrc.*\r\n/g, ''); 532 offerSdp = offerSdp.replace(/a=ssrc.*\r\n/g, '');
496 return offerSdp; 533 return offerSdp;
497 } 534 }
498 535
536 function mungeSdp(sdp) {
537 if (gTestWithoutBundle) {
538 sdp = removeBundle(sdp);
539 }
540
541 if (gTestWithGice) {
542 sdp = useGice(sdp);
543 }
544
545 if (gTestWithExternalSdes) {
546 sdp = useExternalSdes(sdp);
547 }
548
549 return sdp;
550 }
551
552 function removeBundle(sdp) {
553 return sdp.replace(/a=group:BUNDLE .*\r\n/g, '');
554 }
555
556 function useGice(sdp) {
557 sdp = sdp.replace(/t=.*\r\n/g, function(subString) {
558 return subString + 'a=ice-options:google-ice\r\n';
559 });
560 sdp = sdp.replace(/a=ice-ufrag:.*\r\n/g,
561 'a=ice-ufrag:' + externalGiceUfrag + '\r\n');
562 sdp = sdp.replace(/a=ice-pwd:.*\r\n/g,
563 'a=ice-pwd:' + externalGicePwd + '\r\n');
564 return sdp;
565 }
566
567 function useExternalSdes(sdp) {
568 // Remove current crypto specification.
569 sdp = sdp.replace(/a=crypto.*\r\n/g, '');
570 sdp = sdp.replace(/a=fingerprint.*\r\n/g, '');
571 // Add external crypto. This is not compatible with |removeMsid|.
572 sdp = sdp.replace(/a=mid:(\w+)\r\n/g, function(subString, group) {
573 return subString + externalSdesLines[group] + '\r\n';
574 });
575 return sdp;
576 }
577
499 function onAnswerCreated(answer, caller, callee) { 578 function onAnswerCreated(answer, caller, callee) {
579 answer.sdp = mungeSdp(answer.sdp);
500 callee.setLocalDescription(answer); 580 callee.setLocalDescription(answer);
501 expectEquals('stable', callee.signalingState); 581 expectEquals('stable', callee.signalingState);
502 receiveAnswer(answer.sdp, caller); 582 receiveAnswer(answer.sdp, caller);
503 } 583 }
504 584
505 function receiveAnswer(answerSdp, caller) { 585 function receiveAnswer(answerSdp, caller) {
506 if (gTestWithoutMsidAndBundle) { 586 if (gTestWithoutMsid) {
507 answerSdp = removeMsidAndBundle(answerSdp); 587 answerSdp = removeMsid(answerSdp);
508 } 588 }
589
509 var parsedAnswer = new RTCSessionDescription({ type: 'answer', 590 var parsedAnswer = new RTCSessionDescription({ type: 'answer',
510 sdp: answerSdp }); 591 sdp: answerSdp });
511 caller.setRemoteDescription(parsedAnswer); 592 caller.setRemoteDescription(parsedAnswer);
512 expectEquals('stable', caller.signalingState); 593 expectEquals('stable', caller.signalingState);
513 } 594 }
514 595
515 function connectOnIceCandidate(caller, callee) { 596 function connectOnIceCandidate(caller, callee) {
516 caller.onicecandidate = function(event) { onIceCandidate(event, callee); } 597 caller.onicecandidate = function(event) { onIceCandidate(event, callee); }
517 callee.onicecandidate = function(event) { onIceCandidate(event, caller); } 598 callee.onicecandidate = function(event) { onIceCandidate(event, caller); }
518 } 599 }
519 600
520 function onIceCandidate(event, target) { 601 function onIceCandidate(event, target) {
521 if (event.candidate) { 602 if (event.candidate) {
522 var candidate = new RTCIceCandidate(event.candidate); 603 var candidate = new RTCIceCandidate(event.candidate);
604 if (gTestWithGice) {
605 candidate.candidate = candidate.candidate.trimRight() +
606 ' username ' + externalGiceUfrag + ' password ' + externalGicePwd;
607 }
523 target.addIceCandidate(candidate); 608 target.addIceCandidate(candidate);
524 } 609 }
525 } 610 }
526 611
527 function onRemoteStream(e, target) { 612 function onRemoteStream(e, target) {
528 if (gTestWithoutMsidAndBundle && e.stream.id != "default") { 613 if (gTestWithoutMsid && e.stream.id != "default") {
529 document.title = 'a default remote stream was expected but instead ' + 614 document.title = 'a default remote stream was expected but instead ' +
530 e.stream.id + ' was received.'; 615 e.stream.id + ' was received.';
531 return; 616 return;
532 } 617 }
533 gRemoteStreams[target] = e.stream; 618 gRemoteStreams[target] = e.stream;
534 var remoteStreamUrl = webkitURL.createObjectURL(e.stream); 619 var remoteStreamUrl = webkitURL.createObjectURL(e.stream);
535 var remoteVideo = $(target); 620 var remoteVideo = $(target);
536 remoteVideo.src = remoteStreamUrl; 621 remoteVideo.src = remoteStreamUrl;
537 } 622 }
538 623
(...skipping 25 matching lines...) Expand all
564 <td><canvas width="320" height="240" id="remote-view-2-canvas" 649 <td><canvas width="320" height="240" id="remote-view-2-canvas"
565 style="display:none"></canvas></td> 650 style="display:none"></canvas></td>
566 <td><canvas width="320" height="240" id="remote-view-3-canvas" 651 <td><canvas width="320" height="240" id="remote-view-3-canvas"
567 style="display:none"></canvas></td> 652 style="display:none"></canvas></td>
568 <td><canvas width="320" height="240" id="remote-view-4-canvas" 653 <td><canvas width="320" height="240" id="remote-view-4-canvas"
569 style="display:none"></canvas></td> 654 style="display:none"></canvas></td>
570 </tr> 655 </tr>
571 </table> 656 </table>
572 </body> 657 </body>
573 </html> 658 </html>
OLDNEW
« content/browser/media/webrtc_browsertest.cc ('K') | « content/browser/media/webrtc_browsertest.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698