Skip to content

Commit

Permalink
v0.0.6 - accomodate pegjs changes
Browse files Browse the repository at this point in the history
  • Loading branch information
beradrian committed Jan 16, 2017
1 parent 449f39d commit aa92726
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 36 deletions.
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "sdpparser"
, "version": "0.0.4"
, "version": "0.0.6"
, "description": "SdpParser - JavaScript parser for SDP (RFC 4566)"
, "author": {
"name": "Adrian Ber",
Expand All @@ -16,7 +16,7 @@
"jscommon": "beradrian/jscommon"
}
, "devDependencies" : {
"pegjs": ">=0.10.0"
"pegjs": "latest"
, "jasmine": ">=2.3.1"
}
, "scripts": {
Expand Down
68 changes: 34 additions & 34 deletions src/main/pegjs/SdpParser.pegjs
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ var aggregateSdpProperties = function(sdpProperties) {
}
obj[p].push(sdpProperties[i][p]);
} else {
obj[p] = sdpProperties[i][p];
obj[p] = sdpProperties[i][p];
}
if (options.useMediaSections !== false && p == SDP_TYPES["m"]) {
obj = sdpProperties[i][p];
Expand Down Expand Up @@ -90,13 +90,13 @@ var aggregatePayloads = function(sdp) {
if (!sdp.media || !sdp.media.length) {
return sdp;
}
for (var i = 0; i < sdp.media.length; i++) {
for (var i = 0; i < sdp.media.length; i++) {
var m = sdp.media[i];
if (!m.payloads) {
continue;
}
var payloads = [];
for (var j = 0; j < m.payloads.length; j++) {
for (var j = 0; j < m.payloads.length; j++) {
var payload = {id: m.payloads[j]};
aggregatePayloadAttribute(payload, m, "rtp");
aggregatePayloadAttribute(payload, m, "fmtp");
Expand Down Expand Up @@ -169,16 +169,16 @@ parser.format = formatSdp;
var formatSdpSection = function(section, excluded, order) {
var s = "";

jsCommon.forEach(section,
jsCommon.forEach(section,
function(value, property, section) {
s += formatSdpProperty(section, property);
},
},
{
blacklist: excluded ? function(p) { return excluded.indexOf(p) >= 0 || excluded.indexOf(SDP_TYPES[p]) >= 0;} : null,
comparator: ordering(order)
});

// remove empty lines - it seems that browsers cannot deal with empty lines in SDP, even at the end
// remove empty lines - it seems that browsers cannot deal with empty lines in SDP, even at the end
s = s.replace(/[\r\n]{2,}/g, EOL);
return s;
};
Expand Down Expand Up @@ -224,8 +224,8 @@ var FORMATTERS = {
return value.toString();
}
, origin: function(origin) {
return origin.username + " " + origin.sessionId
+ " " + origin.sessionVersion
return origin.username + " " + origin.sessionId
+ " " + origin.sessionVersion
+ " " + origin.networkType
+ " " + origin.addressType
+ " " + origin.unicastAddress;
Expand Down Expand Up @@ -263,8 +263,8 @@ var FORMATTERS = {
return encryptionKey.method + (encryptionKey.key ? ":" + encryptionKey.key : "");
}
, media: function(media) {
var s = media.type
+ " " + media.port
var s = media.type
+ " " + media.port
+ (media.numberOfPorts ? "/" + media.numberOfPorts : "")
+ " " + media.protocol;
if (media.formats) {
Expand Down Expand Up @@ -314,8 +314,8 @@ var FORMATTERS = {


sdp
= line:(line:SdpLine {return line;}) lines:(_eol line:SdpLine {return line;})* _eol*
{
= line:(line:SdpLine {return line;}) lines:(_eol line2:SdpLine {return line2;})* _eol*
{
lines.splice(0, 0, line);
var sdp = aggregate(lines);
return sdp;
Expand Down Expand Up @@ -346,21 +346,21 @@ time
= t: number { return options.useUnixTimes ? t - NTP_OFFSET : t;};

duration
= x:number p:("d" / "h" / "m" / "s") { return x * DURATIONS[p];}
= x:number p:("d" / "h" / "m" / "s") { return x * DURATIONS[p];}
/ x:number { return x;};


origin
= "o" eq
username:str
= "o" eq
username:str
_ sessionId:str
_ sessionVersion:versionNumber
_ networkType:str
_ addressType:str
_ unicastAddress:str
_ unicastAddress:str
{
var o = {
username: username,
username: username,
sessionId: sessionId,
sessionVersion: sessionVersion,
networkType: networkType,
Expand All @@ -373,11 +373,11 @@ origin
};

connection
= "c" eq
= "c" eq
networkType:str
_ addressType:str
_ connectionAddress: str
{
{
return {connection: {
networkType: networkType,
addressType: addressType,
Expand All @@ -386,8 +386,8 @@ connection
};

media
= "m" eq type:str
_ port:number
= "m" eq type:str
_ port:number
numberOfPorts:("/" n:number {return n;}) ?
_ protocol:([^ \t]+ {return text();})
formats:(_ format:str { return format;})+
Expand Down Expand Up @@ -423,7 +423,7 @@ repeat
{ return {repeat: {interval: interval, activeDuration: activeDuration, offsets: offsets}}};

timezones
= "z" eq t:timezone ts:(_ t:timezone {return t;})+
= "z" eq t:timezone ts:(_ t2:timezone {return t2;})+
{ return {timezones: [t].concat(ts)};};

timezone
Expand All @@ -437,7 +437,7 @@ attribute
= rtpmapAttribute / fmtpAttribute / valueAttribute / propertyAttribute;

rtpmapAttribute
= "a" eq "rtpmap" ":" payload:number
= "a" eq "rtpmap" ":" payload:number
_ codec:([^/]+ {return text();})
"/" rate:number codecParams:("/" params:str {return guessType(params);})?
{
Expand All @@ -453,7 +453,7 @@ rtpmapAttribute
};

fmtpAttribute
= "a" eq "fmtp" ":" payload:number
= "a" eq "fmtp" ":" payload:number
_ params:formatParameters
{
return { fmtp: {
Expand All @@ -475,39 +475,39 @@ formatParameters
/ config:[^\r\n]+ { return text();};

formatParameter
= name:([^=;\r\n]+ {return text()})
eq value:([^;\r\n]+ {return guessType(text());})
= name:([^=;\r\n]+ {return text()})
eq value:([^;\r\n]+ {return guessType(text());})
{ var param = {}; param[name] = value; return param;}

propertyAttribute
= "a" eq property: attributeName
{
var p = {};
p[property] = true;
var p = {};
p[property] = true;
return p;
}

valueAttribute
= "a" eq property: attributeName ":" value:([^\n\r]+ {return guessType(text());})
{
var p = {};
p[property] = value;
var p = {};
p[property] = value;
return p;
}

attributeName
= ([^\n\r:]+)
{
var name = text();
var name = text();
if (options["useLongNames"] !== false && SDP_TYPES[name]) {
return SDP_TYPES[name];
}
return name;
};

otherType
= type: [a-z] eq value: ([^\r\n]+ {return text();})
{
= type: [a-z] eq value: ([^\r\n]+ {return text();})
{
var t = {};
t[SDP_TYPES[type] ? SDP_TYPES[type] : type] = value;
return t;
Expand Down

0 comments on commit aa92726

Please sign in to comment.