diff --git a/lib/grammar.js b/lib/grammar.js index 0a07164..3459633 100644 --- a/lib/grammar.js +++ b/lib/grammar.js @@ -47,12 +47,14 @@ var grammar = module.exports = { a: [ { //a=rtpmap:110 opus/48000/2 push: 'rtp', - reg: /^rtpmap:(\d*) ([\w\-]*)\/(\d*)(?:\s*\/(\S*))?/, + reg: /^rtpmap:(\d*) ([\w\-]*)(?:\s*\/(\d*)(?:\s*\/(\S*))?)?/, names: ['payload', 'codec', 'rate', 'encoding'], format: function (o) { return (o.encoding) ? "rtpmap:%d %s/%s/%s": - "rtpmap:%d %s/%s"; + o.rate ? + "rtpmap:%d %s/%s": + "rtpmap:%d %s"; } }, { diff --git a/test/alac.sdp b/test/alac.sdp new file mode 100644 index 0000000..1b21f28 --- /dev/null +++ b/test/alac.sdp @@ -0,0 +1,10 @@ +v=0 +o=iTunes 3413821438 0 IN IP4 fe80::217:f2ff:fe0f:e0f6 +s=iTunes +c=IN IP4 fe80::5a55:caff:fe1a:e187 +t=0 0 +m=audio 0 RTP/AVP 96 +a=rtpmap:96 AppleLossless +a=fmtp:96 352 0 16 40 10 14 2 255 0 0 44100 +a=fpaeskey:RlBMWQECAQAAAAA8AAAAAPFOnNe+zWb5/n4L5KZkE2AAAAAQlDx69reTdwHF9LaNmhiRURTAbcL4brYAceAkZ49YirXm62N4 +a=aesiv:5b+YZi9Ikb845BmNhaVo+Q diff --git a/test/parse.test.js b/test/parse.test.js index afcc407..b940890 100644 --- a/test/parse.test.js +++ b/test/parse.test.js @@ -325,3 +325,30 @@ exports.jsepSdp = function (t) { t.done(); }); }; + +exports.alacSdp = function (t) { + fs.readFile(__dirname + '/alac.sdp', function (err, sdp) { + if (err) { + t.ok(false, "failed to read file:" + err); + t.done(); + return; + } + var session = parse(sdp+''); + t.ok(session, "got session info"); + var media = session.media; + t.ok(media && media.length > 0, "got media"); + + console.log(require('util').inspect(session, {depth: null})); + + var audio = media[0]; + t.equal(audio.type, "audio", "audio type"); + t.equal(audio.protocol, "RTP/AVP", "audio protocol"); + t.equal(audio.fmtp[0].payload, 96, "audio fmtp 0 payload"); + t.equal(audio.fmtp[0].config, "352 0 16 40 10 14 2 255 0 0 44100", "audio fmtp 0 config"); + t.equal(audio.rtp[0].payload, 96, "audio rtp 0 payload"); + t.equal(audio.rtp[0].codec, "AppleLossless", "audio rtp 0 codec"); + t.equal(audio.rtp[0].rate, undefined, "audio rtp 0 rate"); + + t.done(); + }); +};