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 gTestWithoutMsidAndBundle = false; | 11 var gTestWithoutMsidAndBundle = false; |
12 var gTestNonCrypto = false; | |
phoglund_chromium
2013/11/04 09:34:56
You don't need these. See more below.
| |
13 var gTestUnsupportedVideoCodec = false; | |
12 | 14 |
13 var gLocalStream = null; | 15 var gLocalStream = null; |
14 var gSentTones = ''; | 16 var gSentTones = ''; |
15 | 17 |
16 var gRemoteStreams = {}; | 18 var gRemoteStreams = {}; |
17 | 19 |
18 setAllEventsOccuredHandler(function() { | 20 setAllEventsOccuredHandler(function() { |
19 document.title = 'OK'; | 21 document.title = 'OK'; |
20 }); | 22 }); |
21 | 23 |
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
91 // simulate that the remote peer don't support MSID. | 93 // simulate that the remote peer don't support MSID. |
92 function callWithoutMsidAndBundle() { | 94 function callWithoutMsidAndBundle() { |
93 createConnections(null); | 95 createConnections(null); |
94 gTestWithoutMsidAndBundle = true; | 96 gTestWithoutMsidAndBundle = true; |
95 navigator.webkitGetUserMedia({audio: true, video: true}, | 97 navigator.webkitGetUserMedia({audio: true, video: true}, |
96 addStreamToBothConnectionsAndNegotiate, printGetUserMediaError); | 98 addStreamToBothConnectionsAndNegotiate, printGetUserMediaError); |
97 waitForVideo('remote-view-1'); | 99 waitForVideo('remote-view-1'); |
98 waitForVideo('remote-view-2'); | 100 waitForVideo('remote-view-2'); |
99 } | 101 } |
100 | 102 |
103 // Test that we can't setup a call with an unsupported video codec | |
phoglund_chromium
2013/11/04 09:34:56
Nit: indentation
elham
2013/11/07 23:48:00
Done.
| |
104 function negotiateUnsupportedVideoCodec() { | |
105 createConnections(null); | |
106 gTestUnsupportedVideoCodec = true; | |
107 navigator.webkitGetUserMedia({audio:true, video:true}, | |
108 addStreamToBothConnectionsAndNegotiate, printGetUserMediaError); | |
phoglund_chromium
2013/11/04 09:34:56
It's weird to pass in addStreamToBothConnectionsAn
elham
2013/11/07 23:48:00
No GetUserMedia had nothing to do with offer.sdp a
phoglund_chromium
2013/11/08 09:17:29
You are right: my bad.
| |
109 } | |
110 | |
111 // Test that we can't setup a call if one peer does not support encryption | |
112 function negotiateNonCryptoCall() { | |
113 createConnections(null); | |
114 gTestNonCrypto = true; | |
115 navigator.webkitGetUserMedia({audio: true, video: true}, | |
116 addStreamToBothConnectionsAndNegotiate, printGetUserMediaError); | |
117 } | |
118 | |
101 // Test only a data channel. | 119 // Test only a data channel. |
102 function callWithDataOnly() { | 120 function callWithDataOnly() { |
103 createConnections({optional:[{RtpDataChannels: true}]}); | 121 createConnections({optional:[{RtpDataChannels: true}]}); |
104 setupDataChannel({reliable: false}); | 122 setupDataChannel({reliable: false}); |
105 negotiate(); | 123 negotiate(); |
106 } | 124 } |
107 | 125 |
108 function callWithSctpDataOnly() { | 126 function callWithSctpDataOnly() { |
109 createConnections({optional: [{DtlsSrtpKeyAgreement: true}]}); | 127 createConnections({optional: [{DtlsSrtpKeyAgreement: true}]}); |
110 setupSctpDataChannel({reliable: true}); | 128 setupSctpDataChannel({reliable: true}); |
(...skipping 269 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
380 $('local-view').src = localStreamUrl; | 398 $('local-view').src = localStreamUrl; |
381 | 399 |
382 gLocalStream = localStream; | 400 gLocalStream = localStream; |
383 } | 401 } |
384 | 402 |
385 // Called if getUserMedia fails. | 403 // Called if getUserMedia fails. |
386 function printGetUserMediaError(error) { | 404 function printGetUserMediaError(error) { |
387 document.title = 'getUserMedia request failed with code ' + error.code; | 405 document.title = 'getUserMedia request failed with code ' + error.code; |
388 } | 406 } |
389 | 407 |
408 // Called if setLocaDescription fails. | |
phoglund_chromium
2013/11/04 09:34:56
Nit: setLocalDescription.
elham
2013/11/07 23:48:00
I still need this, since I wanted to check if we g
| |
409 function printLocalDescriptionError(error) { | |
phoglund_chromium
2013/11/04 09:34:56
It's misleading to call this function printLocalDe
phoglund_chromium
2013/11/08 09:17:29
Oh, you are right again. You are passing this call
| |
410 if ((gTestUnsupportedVideoCodec == true) && | |
411 (error=='SetLocalDescription failed: Failed to update session state:' | |
412 +'ERROR_CONTENT', error)) { | |
413 document.title = 'OK'; | |
414 gTestUnsupportedVideoCodec = false; | |
415 } | |
416 if ((gTestNonCrypto == true) && | |
417 (error=='SetLocalDescription failed: Called with a SDP without crypto' | |
418 +'enabled', error)) { | |
419 document.title = 'OK'; | |
420 gTestNonCrypto = false; | |
421 } | |
422 } | |
423 | |
424 // Called if setLocalDescription success | |
phoglund_chromium
2013/11/04 09:34:56
This doesn't seem to be used.
elham
2013/11/07 23:48:00
It will be used every time setLocalDescription suc
phoglund_chromium
2013/11/08 09:17:29
Yes, except you pass in the error handler function
| |
425 function printLocalDescriptionSuccess(error) { | |
426 document.title = 'setLocalDescription Success' | |
427 } | |
428 | |
429 | |
390 // Called if getUserMedia succeeds and we want to send from both connections. | 430 // Called if getUserMedia succeeds and we want to send from both connections. |
391 function addStreamToBothConnectionsAndNegotiate(localStream) { | 431 function addStreamToBothConnectionsAndNegotiate(localStream) { |
392 displayAndRemember(localStream); | 432 displayAndRemember(localStream); |
393 gFirstConnection.addStream(localStream); | 433 gFirstConnection.addStream(localStream); |
394 gSecondConnection.addStream(localStream); | 434 gSecondConnection.addStream(localStream); |
395 negotiate(); | 435 negotiate(); |
396 } | 436 } |
397 | 437 |
398 // Called if getUserMedia succeeds when we want to send from one connection. | 438 // Called if getUserMedia succeeds when we want to send from one connection. |
399 function addStreamToTheFirstConnectionAndNegotiate(localStream) { | 439 function addStreamToTheFirstConnectionAndNegotiate(localStream) { |
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
460 function negotiateBetween(caller, callee) { | 500 function negotiateBetween(caller, callee) { |
461 // Not stable = negotiation is ongoing. The behavior of re-negotiating while | 501 // Not stable = negotiation is ongoing. The behavior of re-negotiating while |
462 // a negotiation is ongoing is more or less undefined, so avoid this. | 502 // a negotiation is ongoing is more or less undefined, so avoid this. |
463 if (caller.signalingState != 'stable') | 503 if (caller.signalingState != 'stable') |
464 throw 'You can only negotiate when the connection is stable!'; | 504 throw 'You can only negotiate when the connection is stable!'; |
465 | 505 |
466 connectOnIceCandidate(caller, callee); | 506 connectOnIceCandidate(caller, callee); |
467 | 507 |
468 caller.createOffer( | 508 caller.createOffer( |
469 function (offer) { | 509 function (offer) { |
470 caller.setLocalDescription(offer); | 510 if (gTestNonCrypto) { |
phoglund_chromium
2013/11/04 09:34:56
Good news and bad news: bemasc@ just refactored th
elham
2013/11/07 23:48:00
Done.
| |
511 offer.sdp = offer.sdp.replace(/a=crypto.*\r\n/g, 'a=Xcrypto\r\n'); | |
512 offer.sdp = offer.sdp.replace(/a=fingerprint.*\r\n/g, ''); | |
513 } | |
514 if (gTestUnsupportedVideoCodec) { | |
515 offer.sdp = offer.sdp.replace('a=rtpmap:100 VP8/90000\r\n', | |
516 'a=rtpmap:100 XVP8/90000\r\n'); | |
517 } | |
518 caller.setLocalDescription(offer, printLocalDescriptionSuccess, | |
519 printLocalDescriptionError); | |
471 expectEquals('have-local-offer', caller.signalingState); | 520 expectEquals('have-local-offer', caller.signalingState); |
472 receiveOffer(offer.sdp, caller, callee); | 521 receiveOffer(offer.sdp, caller, callee); |
473 }); | 522 }); |
474 } | 523 } |
475 | 524 |
476 function receiveOffer(offerSdp, caller, callee) { | 525 function receiveOffer(offerSdp, caller, callee) { |
477 if (gTestWithoutMsidAndBundle) { | 526 if (gTestWithoutMsidAndBundle) { |
478 offerSdp = removeMsidAndBundle(offerSdp); | 527 offerSdp = removeMsidAndBundle(offerSdp); |
479 } | 528 } |
480 | 529 |
(...skipping 18 matching lines...) Expand all Loading... | |
499 function onAnswerCreated(answer, caller, callee) { | 548 function onAnswerCreated(answer, caller, callee) { |
500 callee.setLocalDescription(answer); | 549 callee.setLocalDescription(answer); |
501 expectEquals('stable', callee.signalingState); | 550 expectEquals('stable', callee.signalingState); |
502 receiveAnswer(answer.sdp, caller); | 551 receiveAnswer(answer.sdp, caller); |
503 } | 552 } |
504 | 553 |
505 function receiveAnswer(answerSdp, caller) { | 554 function receiveAnswer(answerSdp, caller) { |
506 if (gTestWithoutMsidAndBundle) { | 555 if (gTestWithoutMsidAndBundle) { |
507 answerSdp = removeMsidAndBundle(answerSdp); | 556 answerSdp = removeMsidAndBundle(answerSdp); |
508 } | 557 } |
558 | |
509 var parsedAnswer = new RTCSessionDescription({ type: 'answer', | 559 var parsedAnswer = new RTCSessionDescription({ type: 'answer', |
510 sdp: answerSdp }); | 560 sdp: answerSdp }); |
511 caller.setRemoteDescription(parsedAnswer); | 561 caller.setRemoteDescription(parsedAnswer); |
512 expectEquals('stable', caller.signalingState); | 562 expectEquals('stable', caller.signalingState); |
513 } | 563 } |
514 | 564 |
515 function connectOnIceCandidate(caller, callee) { | 565 function connectOnIceCandidate(caller, callee) { |
516 caller.onicecandidate = function(event) { onIceCandidate(event, callee); } | 566 caller.onicecandidate = function(event) { onIceCandidate(event, callee); } |
517 callee.onicecandidate = function(event) { onIceCandidate(event, caller); } | 567 callee.onicecandidate = function(event) { onIceCandidate(event, caller); } |
518 } | 568 } |
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
564 <td><canvas width="320" height="240" id="remote-view-2-canvas" | 614 <td><canvas width="320" height="240" id="remote-view-2-canvas" |
565 style="display:none"></canvas></td> | 615 style="display:none"></canvas></td> |
566 <td><canvas width="320" height="240" id="remote-view-3-canvas" | 616 <td><canvas width="320" height="240" id="remote-view-3-canvas" |
567 style="display:none"></canvas></td> | 617 style="display:none"></canvas></td> |
568 <td><canvas width="320" height="240" id="remote-view-4-canvas" | 618 <td><canvas width="320" height="240" id="remote-view-4-canvas" |
569 style="display:none"></canvas></td> | 619 style="display:none"></canvas></td> |
570 </tr> | 620 </tr> |
571 </table> | 621 </table> |
572 </body> | 622 </body> |
573 </html> | 623 </html> |
OLD | NEW |