sdp-jingle-json
Advanced tools
Comparing version 0.3.1 to 0.3.2
@@ -28,10 +28,18 @@ exports.lines = function (sdp) { | ||
exports.findLines = function (prefix, lines) { | ||
exports.findLines = function (prefix, mediaLines, sessionLines) { | ||
var results = []; | ||
var prefixLength = prefix.length; | ||
for (var i = 0; i < lines.length; i++) { | ||
if (lines[i].substr(0, prefixLength) === prefix) { | ||
results.push(lines[i]); | ||
for (var i = 0; i < mediaLines.length; i++) { | ||
if (mediaLines[i].substr(0, prefixLength) === prefix) { | ||
results.push(mediaLines[i]); | ||
} | ||
} | ||
if (results.length || !sessionLines) { | ||
return results; | ||
} | ||
for (var j = 0; j < sessionLines.length; j++) { | ||
if (sessionLines[j].substr(0, prefixLength) === prefix) { | ||
results.push(sessionLines[j]); | ||
} | ||
} | ||
return results; | ||
@@ -38,0 +46,0 @@ }; |
{ | ||
"name": "sdp-jingle-json", | ||
"version": "0.3.1", | ||
"version": "0.3.2", | ||
"description": "A parser/serializer for SDP to JSON. Useful for converting SDP to other formats like Jingle for WebRTC signalling", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
@@ -1,1 +0,1 @@ | ||
!function(n){if("function"==typeof bootstrap)bootstrap("sjj",n);else if("object"==typeof exports)module.exports=n();else if("function"==typeof define&&define.amd)define(n);else if("undefined"!=typeof ses){if(!ses.ok())return;ses.makeSJJ=n}else"undefined"!=typeof window?window.SJJ=n():global.SJJ=n()}(function(){return function(n,r,t){function e(t,s){if(!r[t]){if(!n[t]){var a="function"==typeof require&&require;if(!s&&a)return a(t,!0);if(i)return i(t,!0);throw new Error("Cannot find module '"+t+"'")}var o=r[t]={exports:{}};n[t][0].call(o.exports,function(r){var i=n[t][1][r];return e(i?i:r)},o,o.exports)}return r[t].exports}for(var i="function"==typeof require&&require,s=0;s<t.length;s++)e(t[s]);return e}({1:[function(n,r,t){var e=n("./lib/tosdp"),i=n("./lib/tojson");t.toSessionSDP=e.toSessionSDP,t.toMediaSDP=e.toMediaSDP,t.toCandidateSDP=e.toCandidateSDP,t.toSessionJSON=i.toSessionJSON,t.toMediaJSON=i.toMediaJSON,t.toCandidateJSON=i.toCandidateJSON},{"./lib/tojson":3,"./lib/tosdp":4}],2:[function(n,r,t){t.lines=function(n){return n.split("\r\n").filter(function(n){return n.length>0})},t.findLine=function(n,r,t){for(var e=n.length,i=0;i<r.length;i++)if(r[i].substr(0,e)===n)return r[i];if(!t)return!1;for(var s=0;s<t.length;s++)if(t[s].substr(0,e)===n)return t[s];return!1},t.findLines=function(n,r){for(var t=[],e=n.length,i=0;i<r.length;i++)r[i].substr(0,e)===n&&t.push(r[i]);return t},t.mline=function(n){for(var r=n.substr(2).split(" "),t={media:r[0],port:r[1],proto:r[2],formats:[]},e=3;e<r.length;e++)r[e]&&t.formats.push(r[e]);return t},t.rtpmap=function(n){var r=n.substr(9).split(" "),t={id:r.shift()};return r=r[0].split("/"),t.name=r[0],t.clockrate=r[1],t.channels=3==r.length?r[2]:"1",t},t.fmtp=function(n){for(var r,t,e,i=n.substr(n.indexOf(" ")+1).split(";"),s=[],a=0;a<i.length;a++)r=i[a].split("="),t=r[0].trim(),e=r[1],t&&e?s.push({key:t,value:e}):t&&s.push({key:"",value:t});return s},t.crypto=function(n){var r=n.substr(9).split(" "),t={tag:r[0],cipherSuite:r[1],keyParams:r[2],sessionParams:r.slice(3).join(" ")};return t},t.fingerprint=function(n){var r=n.substr(14).split(" ");return{hash:r[0],value:r[1]}},t.extmap=function(n){var r=n.substr(9).split(" "),t={},e=r.shift(),i=e.indexOf("/");return i>=0?(t.id=e.substr(0,i),t.senders=e.substr(i)):(t.id=e,t.senders="sendrecv"),t.uri=r.shift(),t},t.rtcpfb=function(n){var r=n.substr(10).split(" "),t={};return t.id=r.shift(),t.type=r.shift(),"trr-int"===t.type?t.value=r.shift():t.subtype=r.shift(),t.parameters=r,t},t.candidate=function(n){for(var r=n.substring(12).split(" "),t={foundation:r[0],component:r[1],protocol:r[2].toLowerCase(),priority:r[3],ip:r[4],port:r[5],type:r[7]},e=8;e<r.length;e+=2)"raddr"===r[e]?t.relAddr=r[e+1]:"rport"===r[e]?t.relPort=r[e+1]:"generation"===r[e]&&(t.generation=r[e+1]);return t.network="1",t},t.ssrc=function(n){for(var r,t,e=[],i={},s=0;s<n.length;s++){r=n[s].substr(7).split(" "),t=r.shift(),r=r.join(" ").split(":");var a=r.shift(),o=r.join(":")||null;i[t]||(i[t]={}),i[t][a]=o}for(t in i){var u=i[t];u.ssrc=t,e.push(u)}return e},t.grouping=function(n){for(var r,t=[],e=0;e<n.length;e++)r=n[e].substr(8).split(" "),t.push({semantics:r.shift(),contents:r});return t}},{}],3:[function(n,r,t){var e=n("./parsers"),i=Math.random();t.toSessionJSON=function(n,r){for(var i=n.split("\r\nm="),s=1;s<i.length;s++)i[s]="m="+i[s],s!==i.length-1&&(i[s]+="\r\n");var a=i.shift()+"\r\n",o=e.lines(a),u={},p=[];i.forEach(function(n){p.push(t.toMediaJSON(n,a,r))}),u.contents=p;var f=e.findLines("a=group:",o);return f.length&&(u.groupings=e.grouping(f)),u},t.toMediaJSON=function(n,r,i){var s=e.lines(n),a=e.lines(r),o=e.mline(s[0]),u={creator:i,name:o.media,description:{descType:"rtp",media:o.media,payloads:[],encryption:[],feedback:[],headerExtensions:[]},transport:{transType:"iceUdp",candidates:[],fingerprints:[]}},p=u.description,f=u.transport,c=e.findLine("a=ssrc:",s);c&&(p.ssrc=c.substr(7).split(" ")[0]);var d=e.findLine("a=mid:",s);d&&(u.name=d.substr(6)),e.findLine("a=sendrecv",s,a)?u.senders="both":e.findLine("a=sendonly",s,a)?u.senders="initiator":e.findLine("a=recvonly",s,a)?u.senders="responder":e.findLine("a=inactive",s,a)&&(u.senders="none");var h=e.findLines("a=rtpmap:",s);h.forEach(function(n){var r=e.rtpmap(n);r.feedback=[];var t=e.findLines("a=fmtp:"+r.id,s);t.forEach(function(n){r.parameters=e.fmtp(n)});var i=e.findLines("a=rtcp-fb:"+r.id,s);i.forEach(function(n){r.feedback.push(e.rtcpfb(n))}),p.payloads.push(r)});var l=e.findLines("a=crypto:",s,a);l.forEach(function(n){p.encryption.push(e.crypto(n))}),e.findLine("a=rtcp-mux",s)&&(p.mux=!0);var v=e.findLines("a=rtcp-fb:*",s);v.forEach(function(n){p.feedback.push(e.rtcpfb(n))});var m=e.findLines("a=extmap:",s);m.forEach(function(n){var r=e.extmap(n),t={sendonly:"responder",recvonly:"initiator",sendrecv:"both",inactive:"none"};r.senders=t[r.senders],p.headerExtensions.push(r)});var b=e.findLines("a=ssrc:",s);b.length&&(p.ssrcs=e.ssrc(b));var y=e.findLines("a=fingerprint:",s,a);y.forEach(function(n){f.fingerprints.push(e.fingerprint(n))});var g=e.findLine("a=ice-ufrag:",s,a),S=e.findLine("a=ice-pwd:",s,a);if(g&&S){f.ufrag=g.substr(12),f.pwd=S.substr(10),f.candidates=[];var E=e.findLines("a=candidate:",s,a);E.forEach(function(n){f.candidates.push(t.toCandidateJSON(n))})}return u},t.toCandidateJSON=function(n){var r=e.candidate(n.split("\r\n")[0]);return r.id=(i++).toString(36).substr(0,12),r}},{"./parsers":2}],4:[function(n,r,t){var e={initiator:"sendonly",responder:"recvonly",both:"sendrecv",none:"inactive",sendonly:"initator",recvonly:"responder",sendrecv:"both",inactive:"none"};t.toSessionSDP=function(n,r){var e=["v=0","o=- "+(r||n.sid||Date.now())+" "+Date.now()+" IN IP4 0.0.0.0","s=-","t=0 0"],i=n.groupings||[];i.forEach(function(n){e.push("a=group:"+n.semantics+" "+n.contents.join(" "))});var s=n.contents||[];return s.forEach(function(n){e.push(t.toMediaSDP(n))}),e.join("\r\n")+"\r\n"},t.toMediaSDP=function(n){var r=[],i=n.description,s=n.transport,a=i.payloads||[],o=s&&s.fingerprints||[],u=[i.media,"1"];i.encryption&&i.encryption.length>0||o.length>0?u.push("RTP/SAVPF"):u.push("RTP/AVPF"),a.forEach(function(n){u.push(n.id)}),r.push("m="+u.join(" ")),r.push("c=IN IP4 0.0.0.0"),r.push("a=rtcp:1 IN IP4 0.0.0.0"),s&&(s.ufrag&&r.push("a=ice-ufrag:"+s.ufrag),s.pwd&&r.push("a=ice-pwd:"+s.pwd),o.forEach(function(n){r.push("a=fingerprint:"+n.hash+" "+n.value)})),r.push("a="+(e[n.senders]||"sendrecv")),r.push("a=mid:"+n.name),i.mux&&r.push("a=rtcp-mux");var p=i.encryption||[];p.forEach(function(n){r.push("a=crypto:"+n.tag+" "+n.cipherSuite+" "+n.keyParams+" "+n.sessionParams)}),a.forEach(function(n){var t="a=rtpmap:"+n.id+" "+n.name+"/"+n.clockrate;if(n.channels&&"1"!=n.channels&&(t+="/"+n.channels),r.push(t),n.parameters&&n.parameters.length){var e=["a=fmtp:"+n.id];n.parameters.forEach(function(n){e.push((n.key?n.key+"=":"")+n.value)}),r.push(e.join(" "))}n.feedback&&n.feedback.forEach(function(t){"trr-int"===t.type?r.push("a=rtcp-fb:"+n.id+" trr-int "+t.value?t.value:"0"):r.push("a=rtcp-fb:"+n.id+" "+t.type+(t.subtype?" "+t.subtype:""))})}),i.feedback&&i.feedback.forEach(function(n){"trr-int"===n.type?r.push(n.value):r.push("a=rtcp-fb:* "+n.type+(n.subtype?" "+n.subtype:""))});var f=i.headerExtensions||[];f.forEach(function(n){r.push("a=extmap:"+n.id+(n.senders?"/"+e[n.senders]:"")+" "+n.uri)});var c=i.ssrcs||[];c.forEach(function(n){for(var t in n)"ssrc"!=t&&r.push("a=ssrc:"+n.ssrc+" "+t+(n[t]?":"+n[t]:""))});var d=s.candidates||[];return d.forEach(function(n){r.push(t.toCandidateSDP(n))}),r.join("\r\n")},t.toCandidateSDP=function(n){var r=[];r.push(n.foundation),r.push(n.component),r.push(n.protocol),r.push(n.priority),r.push(n.ip),r.push(n.port);var t=n.type;return r.push("typ"),r.push(t),("srflx"===t||"prflx"===t||"relay"===t)&&n.relAddr&&n.relPort&&(r.push("raddr"),r.push(n.relAddr),r.push("rport"),r.push(n.relPort)),r.push("generation"),r.push(n.generation||"0"),"a=candidate:"+r.join(" ")}},{}]},{},[1])(1)}); | ||
!function(n){if("function"==typeof bootstrap)bootstrap("sjj",n);else if("object"==typeof exports)module.exports=n();else if("function"==typeof define&&define.amd)define(n);else if("undefined"!=typeof ses){if(!ses.ok())return;ses.makeSJJ=n}else"undefined"!=typeof window?window.SJJ=n():global.SJJ=n()}(function(){return function(n,r,t){function e(t,s){if(!r[t]){if(!n[t]){var a="function"==typeof require&&require;if(!s&&a)return a(t,!0);if(i)return i(t,!0);throw new Error("Cannot find module '"+t+"'")}var o=r[t]={exports:{}};n[t][0].call(o.exports,function(r){var i=n[t][1][r];return e(i?i:r)},o,o.exports)}return r[t].exports}for(var i="function"==typeof require&&require,s=0;s<t.length;s++)e(t[s]);return e}({1:[function(n,r,t){var e=n("./lib/tosdp"),i=n("./lib/tojson");t.toSessionSDP=e.toSessionSDP,t.toMediaSDP=e.toMediaSDP,t.toCandidateSDP=e.toCandidateSDP,t.toSessionJSON=i.toSessionJSON,t.toMediaJSON=i.toMediaJSON,t.toCandidateJSON=i.toCandidateJSON},{"./lib/tojson":3,"./lib/tosdp":4}],2:[function(n,r,t){t.lines=function(n){return n.split("\r\n").filter(function(n){return n.length>0})},t.findLine=function(n,r,t){for(var e=n.length,i=0;i<r.length;i++)if(r[i].substr(0,e)===n)return r[i];if(!t)return!1;for(var s=0;s<t.length;s++)if(t[s].substr(0,e)===n)return t[s];return!1},t.findLines=function(n,r,t){for(var e=[],i=n.length,s=0;s<r.length;s++)r[s].substr(0,i)===n&&e.push(r[s]);if(e.length||!t)return e;for(var a=0;a<t.length;a++)t[a].substr(0,i)===n&&e.push(t[a]);return e},t.mline=function(n){for(var r=n.substr(2).split(" "),t={media:r[0],port:r[1],proto:r[2],formats:[]},e=3;e<r.length;e++)r[e]&&t.formats.push(r[e]);return t},t.rtpmap=function(n){var r=n.substr(9).split(" "),t={id:r.shift()};return r=r[0].split("/"),t.name=r[0],t.clockrate=r[1],t.channels=3==r.length?r[2]:"1",t},t.fmtp=function(n){for(var r,t,e,i=n.substr(n.indexOf(" ")+1).split(";"),s=[],a=0;a<i.length;a++)r=i[a].split("="),t=r[0].trim(),e=r[1],t&&e?s.push({key:t,value:e}):t&&s.push({key:"",value:t});return s},t.crypto=function(n){var r=n.substr(9).split(" "),t={tag:r[0],cipherSuite:r[1],keyParams:r[2],sessionParams:r.slice(3).join(" ")};return t},t.fingerprint=function(n){var r=n.substr(14).split(" ");return{hash:r[0],value:r[1]}},t.extmap=function(n){var r=n.substr(9).split(" "),t={},e=r.shift(),i=e.indexOf("/");return i>=0?(t.id=e.substr(0,i),t.senders=e.substr(i)):(t.id=e,t.senders="sendrecv"),t.uri=r.shift(),t},t.rtcpfb=function(n){var r=n.substr(10).split(" "),t={};return t.id=r.shift(),t.type=r.shift(),"trr-int"===t.type?t.value=r.shift():t.subtype=r.shift(),t.parameters=r,t},t.candidate=function(n){for(var r=n.substring(12).split(" "),t={foundation:r[0],component:r[1],protocol:r[2].toLowerCase(),priority:r[3],ip:r[4],port:r[5],type:r[7]},e=8;e<r.length;e+=2)"raddr"===r[e]?t.relAddr=r[e+1]:"rport"===r[e]?t.relPort=r[e+1]:"generation"===r[e]&&(t.generation=r[e+1]);return t.network="1",t},t.ssrc=function(n){for(var r,t,e=[],i={},s=0;s<n.length;s++){r=n[s].substr(7).split(" "),t=r.shift(),r=r.join(" ").split(":");var a=r.shift(),o=r.join(":")||null;i[t]||(i[t]={}),i[t][a]=o}for(t in i){var u=i[t];u.ssrc=t,e.push(u)}return e},t.grouping=function(n){for(var r,t=[],e=0;e<n.length;e++)r=n[e].substr(8).split(" "),t.push({semantics:r.shift(),contents:r});return t}},{}],3:[function(n,r,t){var e=n("./parsers"),i=Math.random();t.toSessionJSON=function(n,r){for(var i=n.split("\r\nm="),s=1;s<i.length;s++)i[s]="m="+i[s],s!==i.length-1&&(i[s]+="\r\n");var a=i.shift()+"\r\n",o=e.lines(a),u={},p=[];i.forEach(function(n){p.push(t.toMediaJSON(n,a,r))}),u.contents=p;var f=e.findLines("a=group:",o);return f.length&&(u.groupings=e.grouping(f)),u},t.toMediaJSON=function(n,r,i){var s=e.lines(n),a=e.lines(r),o=e.mline(s[0]),u={creator:i,name:o.media,description:{descType:"rtp",media:o.media,payloads:[],encryption:[],feedback:[],headerExtensions:[]},transport:{transType:"iceUdp",candidates:[],fingerprints:[]}},p=u.description,f=u.transport,c=e.findLine("a=ssrc:",s);c&&(p.ssrc=c.substr(7).split(" ")[0]);var d=e.findLine("a=mid:",s);d&&(u.name=d.substr(6)),e.findLine("a=sendrecv",s,a)?u.senders="both":e.findLine("a=sendonly",s,a)?u.senders="initiator":e.findLine("a=recvonly",s,a)?u.senders="responder":e.findLine("a=inactive",s,a)&&(u.senders="none");var h=e.findLines("a=rtpmap:",s);h.forEach(function(n){var r=e.rtpmap(n);r.feedback=[];var t=e.findLines("a=fmtp:"+r.id,s);t.forEach(function(n){r.parameters=e.fmtp(n)});var i=e.findLines("a=rtcp-fb:"+r.id,s);i.forEach(function(n){r.feedback.push(e.rtcpfb(n))}),p.payloads.push(r)});var l=e.findLines("a=crypto:",s,a);l.forEach(function(n){p.encryption.push(e.crypto(n))}),e.findLine("a=rtcp-mux",s)&&(p.mux=!0);var v=e.findLines("a=rtcp-fb:*",s);v.forEach(function(n){p.feedback.push(e.rtcpfb(n))});var b=e.findLines("a=extmap:",s);b.forEach(function(n){var r=e.extmap(n),t={sendonly:"responder",recvonly:"initiator",sendrecv:"both",inactive:"none"};r.senders=t[r.senders],p.headerExtensions.push(r)});var m=e.findLines("a=ssrc:",s);m.length&&(p.ssrcs=e.ssrc(m));var g=e.findLines("a=fingerprint:",s,a);g.forEach(function(n){f.fingerprints.push(e.fingerprint(n))});var y=e.findLine("a=ice-ufrag:",s,a),S=e.findLine("a=ice-pwd:",s,a);if(y&&S){f.ufrag=y.substr(12),f.pwd=S.substr(10),f.candidates=[];var E=e.findLines("a=candidate:",s,a);E.forEach(function(n){f.candidates.push(t.toCandidateJSON(n))})}return u},t.toCandidateJSON=function(n){var r=e.candidate(n.split("\r\n")[0]);return r.id=(i++).toString(36).substr(0,12),r}},{"./parsers":2}],4:[function(n,r,t){var e={initiator:"sendonly",responder:"recvonly",both:"sendrecv",none:"inactive",sendonly:"initator",recvonly:"responder",sendrecv:"both",inactive:"none"};t.toSessionSDP=function(n,r){var e=["v=0","o=- "+(r||n.sid||Date.now())+" "+Date.now()+" IN IP4 0.0.0.0","s=-","t=0 0"],i=n.groupings||[];i.forEach(function(n){e.push("a=group:"+n.semantics+" "+n.contents.join(" "))});var s=n.contents||[];return s.forEach(function(n){e.push(t.toMediaSDP(n))}),e.join("\r\n")+"\r\n"},t.toMediaSDP=function(n){var r=[],i=n.description,s=n.transport,a=i.payloads||[],o=s&&s.fingerprints||[],u=[i.media,"1"];i.encryption&&i.encryption.length>0||o.length>0?u.push("RTP/SAVPF"):u.push("RTP/AVPF"),a.forEach(function(n){u.push(n.id)}),r.push("m="+u.join(" ")),r.push("c=IN IP4 0.0.0.0"),r.push("a=rtcp:1 IN IP4 0.0.0.0"),s&&(s.ufrag&&r.push("a=ice-ufrag:"+s.ufrag),s.pwd&&r.push("a=ice-pwd:"+s.pwd),o.forEach(function(n){r.push("a=fingerprint:"+n.hash+" "+n.value)})),r.push("a="+(e[n.senders]||"sendrecv")),r.push("a=mid:"+n.name),i.mux&&r.push("a=rtcp-mux");var p=i.encryption||[];p.forEach(function(n){r.push("a=crypto:"+n.tag+" "+n.cipherSuite+" "+n.keyParams+" "+n.sessionParams)}),a.forEach(function(n){var t="a=rtpmap:"+n.id+" "+n.name+"/"+n.clockrate;if(n.channels&&"1"!=n.channels&&(t+="/"+n.channels),r.push(t),n.parameters&&n.parameters.length){var e=["a=fmtp:"+n.id];n.parameters.forEach(function(n){e.push((n.key?n.key+"=":"")+n.value)}),r.push(e.join(" "))}n.feedback&&n.feedback.forEach(function(t){"trr-int"===t.type?r.push("a=rtcp-fb:"+n.id+" trr-int "+t.value?t.value:"0"):r.push("a=rtcp-fb:"+n.id+" "+t.type+(t.subtype?" "+t.subtype:""))})}),i.feedback&&i.feedback.forEach(function(n){"trr-int"===n.type?r.push(n.value):r.push("a=rtcp-fb:* "+n.type+(n.subtype?" "+n.subtype:""))});var f=i.headerExtensions||[];f.forEach(function(n){r.push("a=extmap:"+n.id+(n.senders?"/"+e[n.senders]:"")+" "+n.uri)});var c=i.ssrcs||[];c.forEach(function(n){for(var t in n)"ssrc"!=t&&r.push("a=ssrc:"+n.ssrc+" "+t+(n[t]?":"+n[t]:""))});var d=s.candidates||[];return d.forEach(function(n){r.push(t.toCandidateSDP(n))}),r.join("\r\n")},t.toCandidateSDP=function(n){var r=[];r.push(n.foundation),r.push(n.component),r.push(n.protocol),r.push(n.priority),r.push(n.ip),r.push(n.port);var t=n.type;return r.push("typ"),r.push(t),("srflx"===t||"prflx"===t||"relay"===t)&&n.relAddr&&n.relPort&&(r.push("raddr"),r.push(n.relAddr),r.push("rport"),r.push(n.relPort)),r.push("generation"),r.push(n.generation||"0"),"a=candidate:"+r.join(" ")}},{}]},{},[1])(1)}); |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
31443
470