Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions lib/grammar.js
Original file line number Diff line number Diff line change
Expand Up @@ -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";
}
},
{
Expand Down
10 changes: 10 additions & 0 deletions test/alac.sdp
Original file line number Diff line number Diff line change
@@ -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
27 changes: 27 additions & 0 deletions test/parse.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -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();
});
};