Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adding grammar for precondition a attributes #100

Open
wants to merge 8 commits into
base: master
Choose a base branch
from
Open
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
27 changes: 26 additions & 1 deletion lib/grammar.js
Original file line number Diff line number Diff line change
Expand Up @@ -472,6 +472,31 @@ var grammar = module.exports = {
names: ['id', 'mStream'],
format: 'floorid:%s mstrm:%s'
},
{
// RFC 3312 precondition
push: 'precondition',
reg: /^(curr|des|conf):(qos|\S*)(?: (mandatory|optional|none|failure|unknown))? (e2e|local|remote) (none|sendrecv|send|recv)/,
names: ['state', 'type', 'strength', 'status', 'direction'],
format: function (o) {
var str = '%s:%s ';
str += o.strength != null ? '%s ' : '%v';
str += o.status != null ? '%s ' : '';
str += o.direction != null ? '%s ' : '';
return str;
},
Comment on lines +476 to +486
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This seems to be the part of the thing that you are actually adding. From a quick scan, looks sensible.
Are you able to add some tests for it?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi, I tried but not sure why tests are not runnable. I'll spend more time.

},
{
// RFC 6787; a=cmid:1
name: 'resource',
reg: /^resource:([^\s]*)/,
format: 'resource:%s',
},
{
// RFC 6787; a=cmid:1
name: 'cmid',
reg: /^cmid:([^\s]*)/,
format: 'cmid:%s'
},
{
// any a= that we don't understand is kept verbatim on media.invalid
push: 'invalid',
Expand All @@ -491,4 +516,4 @@ Object.keys(grammar).forEach(function (key) {
obj.format = '%s';
}
});
});
});
3 changes: 2 additions & 1 deletion test/compose.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,8 @@
'mediaclk-rtp.sdp',
'ts-refclk-media.sdp',
'ts-refclk-sess.sdp',
'rtcp-fb.sdp'
'rtcp-fb.sdp',
`precondition.sdp`,

Check failure on line 52 in test/compose.test.js

View workflow job for this annotation

GitHub Actions / build

Strings must use singlequote
];

sdps.forEach((name) => {
Expand Down
3 changes: 2 additions & 1 deletion test/coverage.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,8 @@
'mediaclk-rtp.sdp',
'ts-refclk-media.sdp',
'ts-refclk-sess.sdp',
'rtcp-fb.sdp'
'rtcp-fb.sdp',
`precondition.sdp`,

Check failure on line 43 in test/coverage.test.js

View workflow job for this annotation

GitHub Actions / build

Strings must use singlequote
];

sdps.forEach((name) => {
Expand Down
21 changes: 21 additions & 0 deletions test/mrcp.sdp
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
v=0
o=hossein 2890844526 2890844527 IN IP4 192.0.2.12
s=-
c=IN IP4 192.0.2.12
t=0 0
m=application 9 TCP/MRCPv2 1
a=setup:active
a=connection:existing
a=resource:speechsynth
a=cmid:1
m=audio 49170 RTP/AVP 0 96
a=rtpmap:0 pcmu/8000
a=rtpmap:96 telephone-event/8000
a=fmtp:96 0-15
a=sendrecv
a=mid:1
m=application 9 TCP/MRCPv2 1
a=setup:active
a=connection:existing
a=resource:speechrecog
a=cmid:1
26 changes: 26 additions & 0 deletions test/parse.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -975,4 +975,30 @@ test('ts-refclk-sess', function *(t) {
t.ok(sessTsRefClocks && sessTsRefClocks.length == 1, 'got one TS Ref Clock at Session Level');
t.equal(sessTsRefClocks[0].clksrc, 'ntp', 'NTP Clock Source');
t.equal(sessTsRefClocks[0].clksrcExt, '/traceable/', 'traceable Clock Source');
});

test('precondition', function* (t) {
var sdp = yield fs.readFile(__dirname + '/precondition.sdp', 'utf8');

var session = parse(sdp + '');
t.ok(session, 'got session info');
t.equal(session.media[0].precondition[0].status, 'local', 'precondition parsed');

var rew = write(session);
t.ok(rew.indexOf('a=curr:qos') >= 0, 'got qos precondition');
t.ok(rew.indexOf('a=des:qos') > rew.indexOf('a=curr:qos'), 'precondition curr and then des state');
});


test('mrcp', function* (t) {
var sdp = yield fs.readFile(__dirname + '/mrcp.sdp', 'utf8');

var session = parse(sdp + '');
t.ok(session, 'got session info');
t.equal(session.media[0].resource, 'speechsynth', 'MRCP resource parsed');
t.equal(session.media[0].cmid, 1, 'MRCP cmid parsed');

var rew = write(session);
t.ok(rew.indexOf('a=resource:') >= 0, 'got MRCP resource');
t.ok(rew.indexOf('a=cmid:') >= 0, 'got MRCP cmid');
});
27 changes: 27 additions & 0 deletions test/precondition.sdp
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
v=0
o=KSIC 564321 0 IN IP6 2001:56f:b006:abf7:8d62:bff:7d9c:79f9
s=SS VoLTE
i=A VoLTE IMS Session
c=IN IP6 2001:55f:b006:abf7:8d62:bff:7d9c:79f9
t=0 0
m=audio 30000 RTP/AVP 114 116 118 111 110
b=AS:50
b=RS:0
b=RR:2000
a=rtpmap:114 EVS/16000/1
a=fmtp:114 br=16.4; br-send=16.4; br-recv=16.4; bw=WB; bw-send=WB; bw-recv=WB; hf-only=0; max-red=220
a=rtpmap:116 AMR-WB/16000/1
a=fmtp:116 mode-set=8; mode-change-capability=2; max-red=220
a=rtpmap:111 telephone-event/16000
a=fmtp:111 0-15
a=rtpmap:118 AMR/8000/1
a=fmtp:118 mode-set=7; mode-change-capability=2; max-red=220
a=rtpmap:110 telephone-event/8000
a=fmtp:110 0-15
a=curr:qos local none
a=curr:qos remote none
a=des:qos mandatory local sendrecv
a=des:qos none remote sendrecv
a=sendrecv
a=ptime:20
a=maxptime:240
Loading