Last active
September 26, 2021 07:01
-
-
Save ggarber/a19b4c33510028b9c657 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var lines = desc.sdp.split("\r\n"); | |
var ssrc, ssrc_fid, msid; | |
for (var i=0; i<lines.length; i++) { | |
var fid = lines[i].match(/a=ssrc-group:FID (\d+) (\d+)/); | |
if (fid) { | |
ssrc = fid[1]; | |
ssrc_fid = fid[2]; | |
lines.splice(i, 1); i--; | |
continue; | |
} | |
if (lines[i].indexOf("m=video 1 RTP/SAVPF") == 0) { | |
lines[i] = 'm=video 1 RTP/SAVPF 100'; | |
} | |
if (lines[i] == 'a=rtpmap:116 red/90000') { | |
lines.splice(i, 1); i--; | |
continue; | |
} | |
if (lines[i] == 'a=rtpmap:117 ulpfec/90000') { | |
lines.splice(i, 1); i--; | |
continue; | |
} | |
if (lines[i] == 'a=rtpmap:96 rtx/90000') { | |
lines.splice(i, 1); i--; | |
continue; | |
} | |
if (lines[i] == 'a=fmtp:96 apt=100') { | |
lines.splice(i, 1); i--; | |
continue; | |
} | |
if (ssrc) { | |
var match = lines[i].match('a=ssrc:' + ssrc + ' msid:(.+)') | |
if (match) { | |
msid = match[1]; | |
} | |
if (lines[i].indexOf('a=ssrc:' + ssrc_fid) === 0) { | |
lines.splice(i, 1); i--; | |
continue; | |
} | |
if (lines[i].indexOf('a=ssrc:' + ssrc) === 0) { | |
lines.splice(i, 1); i--; | |
continue; | |
} | |
} | |
if (lines[i].length == 0) { | |
lines.splice(i, 1); i--; | |
continue; | |
} | |
} | |
lines.push('a=ssrc-group:SIM ' + ssrc +' 4084008107 2771988318') | |
lines.push('a=ssrc:' + ssrc +' cname:localCname') | |
lines.push('a=ssrc:' + ssrc +' msid:' + msid) | |
lines.push('a=ssrc:4084008107 cname:localCname') | |
lines.push('a=ssrc:4084008107 msid:' + msid) | |
lines.push('a=ssrc:2771988318 cname:localCname') | |
lines.push('a=ssrc:2771988318 msid:' + msid) | |
lines.push('') |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment