handover.html (2802B)
1 <!doctype html> 2 <meta charset=utf-8> 3 <title>RTCPeerConnection Handovers</title> 4 <script src="/resources/testharness.js"></script> 5 <script src="/resources/testharnessreport.js"></script> 6 <script src="../RTCPeerConnection-helper.js"></script> 7 <script> 8 'use strict'; 9 10 promise_test(async t => { 11 const offerPc = new RTCPeerConnection(); 12 const answerPcFirst = new RTCPeerConnection(); 13 const answerPcSecond = new RTCPeerConnection(); 14 t.add_cleanup(() => { 15 offerPc.close(); 16 answerPcFirst.close(); 17 answerPcSecond.close(); 18 }); 19 offerPc.addTransceiver('audio'); 20 // Negotiate connection with PC 1 21 const offer1 = await offerPc.createOffer(); 22 await offerPc.setLocalDescription(offer1); 23 await answerPcFirst.setRemoteDescription(offer1); 24 const answer1 = await answerPcFirst.createAnswer(); 25 await offerPc.setRemoteDescription(answer1); 26 await answerPcFirst.setLocalDescription(answer1); 27 // Renegotiate with PC 2 28 const offer2 = await offerPc.createOffer(); 29 await offerPc.setLocalDescription(offer2); 30 await answerPcSecond.setRemoteDescription(offer2); 31 const answer2 = await answerPcSecond.createAnswer(); 32 await offerPc.setRemoteDescription(answer2); 33 await answerPcSecond.setLocalDescription(answer2); 34 }, 'Negotiation of handover initiated at caller works'); 35 36 promise_test(async t => { 37 const offerPc = new RTCPeerConnection(); 38 const answerPcFirst = new RTCPeerConnection(); 39 const answerPcSecond = new RTCPeerConnection(); 40 t.add_cleanup(() => { 41 offerPc.close(); 42 answerPcFirst.close(); 43 answerPcSecond.close(); 44 }); 45 offerPc.addTransceiver('audio'); 46 // Negotiate connection with PC 1 47 const offer1 = await offerPc.createOffer(); 48 await offerPc.setLocalDescription(offer1); 49 await answerPcFirst.setRemoteDescription(offer1); 50 const answer1 = await answerPcFirst.createAnswer(); 51 await offerPc.setRemoteDescription(answer1); 52 await answerPcFirst.setLocalDescription(answer1); 53 // Renegotiate with PC 2 54 // The offer from PC 2 needs to be consistent on at least the following: 55 // - Number, type and order of media sections 56 // - MID values 57 // - Payload type values 58 // Do a "fake" offer/answer using the original offer against PC2 to achieve this. 59 await answerPcSecond.setRemoteDescription(offer1); 60 // Discard the output of this round. 61 await answerPcSecond.setLocalDescription(await answerPcSecond.createAnswer()); 62 63 // Now we can initiate an offer from the new PC. 64 const offer2 = await answerPcSecond.createOffer(); 65 await answerPcSecond.setLocalDescription(offer2); 66 await offerPc.setRemoteDescription(offer2); 67 const answer2 = await offerPc.createAnswer(); 68 await answerPcSecond.setRemoteDescription(answer2); 69 await offerPc.setLocalDescription(answer2); 70 }, 'Negotiation of handover initiated at callee works'); 71 72 </script>