Gathering detailed insights and metrics for semantic-sdp
Gathering detailed insights and metrics for semantic-sdp
Gathering detailed insights and metrics for semantic-sdp
Gathering detailed insights and metrics for semantic-sdp
npm install semantic-sdp
Module System
Min. Node Version
Typescript Support
Node Version
NPM Version
73 Stars
282 Commits
14 Forks
8 Watching
9 Branches
13 Contributors
Updated on 20 Sept 2024
Minified
Minified + Gzipped
JavaScript (97.53%)
TypeScript (2.47%)
Cumulative downloads
Total Downloads
Last day
21.9%
914
Compared to previous day
Last week
28.6%
5,008
Compared to previous week
Last month
10%
20,233
Compared to previous month
Last year
13.1%
220,118
Compared to previous year
3
3
Minimal SDP information semantic data model and parsing tools.
Have you ever tried to mangle or process an SDP and got stuck about how to you change the information instead of what information do you want to access?
This project provies an abstraction layer on top of SDP that allows to acces and modify the information semantically, that is, it stores the SDP information and their relationships and allows you to get free of the acutal SDP semantics.
As it is meant to be used on WebRTC to WebRTC scenarios, so some SDP information can be safelly ignored, allowing to provide a simple and intuitive API.
Both Unified and Plan B are currently supported
We assume that:
If you think it further exchanging the SDP information is all that it is needed to perform a peer to peer SDP exchange, so the intention is to provide serialization functions to be able to use this over the wire and only parse/serialize it on the endpoints or server side.
Note also that there is some similarity ORTC RTP parameters, but well done ;)
npm i --save semantic-sdp
1const SemanticSDP = require('semantic-sdp');
You can check the full object documentation here.
1const SemanticSDP = require("semantic-sdp"); 2 3//Process the sdp 4var offer = SemanticSDP.SDPInfo.process(sdp); 5 6//Set the local DTLS and ICE info 7const dtls = new DTLSInfo(Setup.PASSIVE,"sha-256","F2:AA:0E:C3:22:59:5E:14:95:69:92:3D:13:B4:84:24:2C:C2:A2:C0:3E:FD:34:8E:5E:EA:6F:AF:52:CE:E6:0F"); 8const ice = new ICEInfo("af46F","a34FasdS++jdfofdslkjsd/SDV"); 9 10//Get local candidte 11const candidate = new CandidateInfo(1,1, "udp", 2122260223, "192.168.0.196", 56143, "host"); 12 13//Create local SDP info 14let answer = new SDPInfo(); 15 16 17//Add ice and dtls info 18answer.setDTLS(dtls); 19answer.setICE(ice); 20answer.addCandidate(candidate); 21 22//Get remote audio m-line info 23let audioOffer = offer.getMedia("audio"); 24 25//If we have audio 26if (audioOffer) 27{ 28 //Create audio media 29 let audio = new MediaInfo("audio", "audio"); 30 31 //Get codec type 32 let opus = audioOffer.getCodec("opus"); 33 //Add opus codec 34 audio.addCodec(opus); 35 36 //Add audio extensions 37 for (let extension of audioOffer.getExtensions().entries()) 38 //Add it 39 audio.addExtension(extension[0], extension[1]); 40 //Add it to answer 41 answer.addMedia(audio); 42} 43 44//Get remote video m-line info 45let videoOffer = offer.getMedia("video"); 46 47//If offer had video 48if (videoOffer) 49{ 50 //Create video media 51 let video = new MediaInfo("video", "video"); 52 //Get codec types 53 let vp9 = videoOffer.getCodec("vp9"); 54 let fec = videoOffer.getCodec("flexfec-03"); 55 //Add video codecs 56 video.addCodec(vp9); 57 if (fec) 58 video.addCodec(fec); 59 //Limit incoming bitrate 60 video.setBitrate(1024); 61 62 //Add video extensions 63 for (let extension of videoOffer.getExtensions().entries()) 64 //Add it 65 video.addExtension(extension[0], extension[1]); 66 67 //Add it to answer 68 answer.addMedia(video); 69} 70 71let ssrc = 1000; 72//For each stream 73for (let i=1;i<4;i++) 74{ 75 let track; 76 //Create stream 77 let stream = new StreamInfo("sream"+i); 78 //Create track 79 track = new TrackInfo("video", "track1"); 80 //Get ssrc, rtx and fec 81 const media = ssrc++; 82 const rtx = ssrc++; 83 const fec = ssrc++; 84 //Add ssrcs to track 85 track.addSSRC(media); 86 track.addSSRC(rtx); 87 track.addSSRC(fec); 88 //Add RTX and FEC group 89 track.addSourceGroup(new SourceGroupInfo("FID",[media,rtx])); 90 track.addSourceGroup(new SourceGroupInfo("FEC-FR",[media,fec])); 91 //Add it 92 stream.addTrack(track); 93 //Create track 94 track = new TrackInfo("audio", "track2"); 95 //Add ssrc 96 track.addSSRC(ssrc++); 97 //Add it 98 stream.addTrack(track); 99 //Add stream 100 answer.addStream(stream); 101} 102 103//Get answer SDP 104const str = answer.toString(); 105const json = JSON.stringifu(answer.plain());
The SDP output will be :
v=0
o=- 1489500633629 1 IN IP4 127.0.0.1
s=semantic-sdp
c=IN IP4 0.0.0.0
t=0 0
a=msid-semantic: WMS *
m=audio 9 UDP/TLS/RTP/SAVPF 111
a=rtpmap:111 opus/48000/2
a=rtcp-fb:111 transport-cc
a=extmap:1 urn:ietf:params:rtp-hdrext:ssrc-audio-level
a=setup:passive
a=mid:audio
a=sendrecv
a=ice-ufrag:af46F
a=ice-pwd:a34FasdS++jdfofdslkjsd/SDV
a=fingerprint:sha-256 F2:AA:0E:C3:22:59:5E:14:95:69:92:3D:13:B4:84:24:2C:C2:A2:C0:3E:FD:34:8E:5E:EA:6F:AF:52:CE:E6:0F
a=candidate:1 1 udp 2122260223 192.168.0.196 56143 typ host
a=ssrc:1003 cname:sream1
a=ssrc:1003 msid:sream1 track2
a=ssrc:1007 cname:sream2
a=ssrc:1007 msid:sream2 track2
a=ssrc:1011 cname:sream3
a=ssrc:1011 msid:sream3 track2
a=rtcp-mux
a=rtcp-rsize
m=video 9 UDP/TLS/RTP/SAVPF 98 99 125
b=AS:1024
a=rtpmap:98 VP9/90000
a=rtpmap:99 rtx/90000
a=rtpmap:125 flexfec-03/90000
a=fmtp:99 apt=98
a=rtcp-fb:98 transport-cc
a=rtcp-fb:125 transport-cc
a=extmap:2 urn:ietf:params:rtp-hdrext:toffset
a=extmap:3 http://www.webrtc.org/experiments/rtp-hdrext/abs-send-time
a=extmap:4 urn:3gpp:video-orientation
a=extmap:5 http://www.ietf.org/id/draft-holmer-rmcat-transport-wide-cc-extensions-01
a=extmap:6 http://www.webrtc.org/experiments/rtp-hdrext/playout-delay
a=setup:passive
a=mid:video
a=sendrecv
a=ice-ufrag:af46F
a=ice-pwd:a34FasdS++jdfofdslkjsd/SDV
a=fingerprint:sha-256 F2:AA:0E:C3:22:59:5E:14:95:69:92:3D:13:B4:84:24:2C:C2:A2:C0:3E:FD:34:8E:5E:EA:6F:AF:52:CE:E6:0F
a=candidate:1 1 udp 2122260223 192.168.0.196 56143 typ host
a=ssrc:1000 cname:sream1
a=ssrc:1000 msid:sream1 track1
a=ssrc:1001 cname:sream1
a=ssrc:1001 msid:sream1 track1
a=ssrc:1002 cname:sream1
a=ssrc:1002 msid:sream1 track1
a=ssrc:1004 cname:sream2
a=ssrc:1004 msid:sream2 track1
a=ssrc:1005 cname:sream2
a=ssrc:1005 msid:sream2 track1
a=ssrc:1006 cname:sream2
a=ssrc:1006 msid:sream2 track1
a=ssrc:1008 cname:sream3
a=ssrc:1008 msid:sream3 track1
a=ssrc:1009 cname:sream3
a=ssrc:1009 msid:sream3 track1
a=ssrc:1010 cname:sream3
a=ssrc:1010 msid:sream3 track1
a=ssrc-group:FID 1000 1001
a=ssrc-group:FEC-FR 1000 1002
a=ssrc-group:FID 1004 1005
a=ssrc-group:FEC-FR 1004 1006
a=ssrc-group:FID 1008 1009
a=ssrc-group:FEC-FR 1008 1010
a=rtcp-mux
a=rtcp-rsize
And the serialized JSON string:
1{ 2 "version": 1, 3 "streams": [ 4 { 5 "tracks": [ 6 { 7 "media": "video", 8 "id": "track1", 9 "ssrcs": [ 10 1000, 11 1001, 12 1002 13 ], 14 "groups": [ 15 { 16 "semantics": "FID", 17 "ssrcs": [ 18 1000, 19 1001 20 ] 21 }, 22 { 23 "semantics": "FEC-FR", 24 "ssrcs": [ 25 1000, 26 1002 27 ] 28 } 29 ] 30 }, 31 { 32 "media": "audio", 33 "id": "track2", 34 "ssrcs": [ 35 1003 36 ], 37 "groups": [ 38 39 ] 40 } 41 ] 42 }, 43 { 44 "tracks": [ 45 { 46 "media": "video", 47 "id": "track1", 48 "ssrcs": [ 49 1004, 50 1005, 51 1006 52 ], 53 "groups": [ 54 { 55 "semantics": "FID", 56 "ssrcs": [ 57 1004, 58 1005 59 ] 60 }, 61 { 62 "semantics": "FEC-FR", 63 "ssrcs": [ 64 1004, 65 1006 66 ] 67 } 68 ] 69 }, 70 { 71 "media": "audio", 72 "id": "track2", 73 "ssrcs": [ 74 1007 75 ], 76 "groups": [ 77 78 ] 79 } 80 ] 81 }, 82 { 83 "tracks": [ 84 { 85 "media": "video", 86 "id": "track1", 87 "ssrcs": [ 88 1008, 89 1009, 90 1010 91 ], 92 "groups": [ 93 { 94 "semantics": "FID", 95 "ssrcs": [ 96 1008, 97 1009 98 ] 99 }, 100 { 101 "semantics": "FEC-FR", 102 "ssrcs": [ 103 1008, 104 1010 105 ] 106 } 107 ] 108 }, 109 { 110 "media": "audio", 111 "id": "track2", 112 "ssrcs": [ 113 1011 114 ], 115 "groups": [ 116 117 ] 118 } 119 ] 120 } 121 ], 122 "medias": [ 123 { 124 "type": "audio", 125 "direction": "sendrecv", 126 "extensions": { 127 "1": "urn:ietf:params:rtp-hdrext:ssrc-audio-level" 128 }, 129 "codecs": [ 130 { 131 "codec": "opus", 132 "type": 111, 133 "params": { 134 "minptime": "10", 135 "useinbandfec": "1" 136 } 137 } 138 ] 139 }, 140 { 141 "type": "video", 142 "direction": "sendrecv", 143 "extensions": { 144 "2": "urn:ietf:params:rtp-hdrext:toffset", 145 "3": "http:\/\/www.webrtc.org\/experiments\/rtp-hdrext\/abs-send-time", 146 "4": "urn:3gpp:video-orientation", 147 "5": "http:\/\/www.ietf.org\/id\/draft-holmer-rmcat-transport-wide-cc-extensions-01", 148 "6": "http:\/\/www.webrtc.org\/experiments\/rtp-hdrext\/playout-delay" 149 }, 150 "codecs": [ 151 { 152 "codec": "VP9", 153 "type": 98, 154 "params": { 155 156 } 157 }, 158 { 159 "codec": "flexfec-03", 160 "type": 125, 161 "params": { 162 "repair-window": "10000000" 163 } 164 } 165 ], 166 "bitrate": 1024 167 } 168 ], 169 "candidates": [ 170 { 171 "foundation": 1, 172 "componentId": 1, 173 "transport": "udp", 174 "priority": 2122260223, 175 "address": "192.168.0.196", 176 "port": 56143, 177 "type": "host" 178 } 179 ], 180 "ice": { 181 "ufrag": "af46F", 182 "pwd": "a34FasdS++jdfofdslkjsd\/SDV" 183 }, 184 "dtls": { 185 "hash": "sha-256", 186 "fingerprint": "F2:AA:0E:C3:22:59:5E:14:95:69:92:3D:13:B4:84:24:2C:C2:A2:C0:3E:FD:34:8E:5E:EA:6F:AF:52:CE:E6:0F" 187 } 188}
Sergio Garcia Murillo @ Medooze
MIT
No vulnerabilities found.
Reason
no binaries found in the repo
Reason
license file detected
Details
Reason
0 existing vulnerabilities detected
Reason
11 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 9
Reason
Found 6/28 approved changesets -- score normalized to 2
Reason
no effort to earn an OpenSSF best practices badge detected
Reason
security policy file not detected
Details
Reason
project is not fuzzed
Details
Reason
branch protection not enabled on development/release branches
Details
Reason
SAST tool is not run on all commits -- score normalized to 0
Details
Score
Last Scanned on 2024-11-18
The Open Source Security Foundation is a cross-industry collaboration to improve the security of open source software (OSS). The Scorecard provides security health metrics for open source projects.
Learn More