youenn@apple.com | 6d97381 | 2018-12-13 01:13:29 +0000 | [diff] [blame] | 1 | <!doctype html>
|
| 2 | <html>
|
| 3 | <head>
|
| 4 | <meta charset="utf-8">
|
| 5 | <title>Trying to recycle m sections</title>
|
| 6 | <script src="../resources/testharness.js"></script>
|
| 7 | <script src="../resources/testharnessreport.js"></script>
|
| 8 | </head>
|
| 9 | <body>
|
| 10 | <script>
|
| 11 | promise_test(async test => {
|
| 12 | const stream = await navigator.mediaDevices.getUserMedia({audio: true, video: true});
|
| 13 |
|
| 14 | const firstConnection = new RTCPeerConnection({sdpSemantics:'unified-plan'});
|
| 15 | const secondConnection = new RTCPeerConnection({sdpSemantics:'unified-plan'});
|
| 16 |
|
| 17 | firstConnection.addTrack(stream.getAudioTracks()[0], stream);
|
| 18 | firstConnection.addTrack(stream.getVideoTracks()[0], stream);
|
| 19 | firstConnection.addTransceiver("audio", {direction: "recvonly"});
|
| 20 | firstConnection.addTransceiver("video", {direction: "recvonly"});
|
| 21 |
|
| 22 | let desc = await firstConnection.createOffer();
|
| 23 | await firstConnection.setLocalDescription(desc);
|
| 24 |
|
| 25 | await secondConnection.setRemoteDescription(desc);
|
| 26 | const desc2 = await secondConnection.createAnswer();
|
| 27 |
|
| 28 | let lines = desc2.sdp.trim().split('\r\n');
|
| 29 |
|
| 30 | let counter;
|
| 31 | for (counter = 0; counter < lines.length; ++counter) {
|
| 32 | if (lines[counter] == "a=mid:2")
|
| 33 | break;
|
| 34 | }
|
| 35 | for (;counter < lines.length; ++counter) {
|
| 36 | if (lines[counter].startsWith("m=video ")) {
|
| 37 | lines[counter] = "m=video 0 RTP/SAVPF 0";
|
| 38 | break;
|
| 39 | }
|
| 40 | }
|
| 41 | for (counter = 0; counter < lines.length; ++counter) {
|
| 42 | if (lines[counter] == "a=mid:3")
|
| 43 | break;
|
| 44 | }
|
| 45 |
|
| 46 | for (;counter < lines.length; ++counter) {
|
| 47 | if (lines[counter].startsWith("m=audio "))
|
| 48 | lines[counter] = "m=audio 0 RTP/SAVPF 0";
|
| 49 | else if (lines[counter].startsWith("m=video "))
|
| 50 | lines[counter] = "m=video 0 RTP/SAVPF 0";
|
| 51 | else if (lines[counter] === "a=inactive" || lines[counter].startsWith("a=mid")) {
|
| 52 | } else
|
| 53 | lines[counter] = "XXX";
|
| 54 | }
|
| 55 | lines = lines.filter((line) => { return line != "XXX"; });
|
| 56 |
|
| 57 | desc2.sdp = lines.join('\r\n') + '\r\n';
|
| 58 |
|
| 59 | await firstConnection.setRemoteDescription(desc2);
|
| 60 |
|
| 61 | firstConnection.addTransceiver("audio");
|
| 62 | firstConnection.addTransceiver("audio");
|
| 63 |
|
| 64 | await firstConnection.createOffer();
|
| 65 | }, "Recycle m-section with different media type");
|
| 66 | </script>
|
| 67 | </body>
|
| 68 | </html>
|