Categories

See More
Popular Forum

MBA (4887) B.Tech (1769) Engineering (1486) Class 12 (1030) Study Abroad (1004) Computer Science and Engineering (988) Business Management Studies (865) BBA (846) Diploma (746) CAT (651) B.Com (648) B.Sc (643) JEE Mains (618) Mechanical Engineering (574) Exam (525) India (462) Career (452) All Time Q&A (439) Mass Communication (427) BCA (417) Science (384) Computers & IT (Non-Engg) (383) Medicine & Health Sciences (381) Hotel Management (373) Civil Engineering (353) MCA (349) Tuteehub Top Questions (348) Distance (340) Colleges in India (334)
See More

Split SDP (string) for m line to change video codecs

General Tech Bugs & Fixes

Max. 2000 characters
Tuteehub
Replies

usr_profile.png

User

( 7 months ago )

 

I want to have a method at the end that can set VP9 or H.264 as preferred video codec in a SDP.

So I am looking for the m line in my SDP:

m=video 9 UDP/TLS/RTP/SAVPF 96 98 100 102 127 97 99 101 125

Console log of my SDP:

Screenshot of console log

In this case I would get and use VP8 (96) as video codec instead of VP9 (98). So I want to check if 98/VP9 is possible/available and want to set it at the beginning/first position to actually use it.

What I got so far:

if(sdpOrigin == 'local') {
    let lines = sdp.split('\n').map(l => l.trim());
    lines.forEach(function(line) {
        if (line.indexOf('m=video') === 0) {
            let parts = line.substr(28); // Should be avoided!
            let vp9_order = parts.indexOf("98");
            let array = parts.split(/\s+/);
            console.log("array", array); // 96 98 100 102 127 97 99 101 125
            if (vp9_order > 0) {
                array.splice(vp9_order, 1);
                array.unshift("98");
            }
            console.log("array-new", array); // 98 96 100 102 127 97 99 101 125

            // How do I update my SDP now with the new codec order?

        }
    })
}

This approach is bad in my opinion, because I get my desired m line but I do a fix substring at the position '28', so it will break if something before changes.

At the end I should have the following "m line" in my SDP:

m=video 9 UDP/TLS/RTP/SAVPF 98 96 100 102 127 97 99 101 125

Can somebody help me with that?

what's your interest


forum_ban8_5d8c5fd7cf6f7.gif