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

update sjj to work with latest sdp examples #28

Open
wants to merge 3 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
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
node_modules
build
.vscode
2 changes: 1 addition & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
sudo: false
language: node_js
node_js:
- '0.10'
- 10
16 changes: 15 additions & 1 deletion lib/tojson.js
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ exports.toMediaJSON = function (media, session, opts) {
applicationType: 'rtp',
media: mline.media,
payloads: [],
port: mline.port,
encryption: [],
feedback: [],
headerExtensions: []
Expand All @@ -73,8 +74,17 @@ exports.toMediaJSON = function (media, session, opts) {
if (mline.media == 'application') {
// FIXME: the description is most likely to be independent
// of the SDP and should be processed by other parts of the library

var sctpLine = parsers.findLine('a=sctp-port', lines);
var sctpPort = sctpLine && sctpLine.split('sctp-port:')[1];
var maxMessageSizeLine = parsers.findLine('a=max-message-size', lines);
var maxMessageSize = maxMessageSizeLine && maxMessageSizeLine.split('max-message-size:')[1];

content.application = {
applicationType: 'datachannel'
applicationType: 'datachannel',
port: mline.port,
sctpPort: sctpPort,
maxMessageSize: maxMessageSize
Copy link
Member

Choose a reason for hiding this comment

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

this is transported via xep-0343 which would need to be updated along with the stanza definitions?

Copy link
Author

Choose a reason for hiding this comment

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

I'm a bit unclear about what you mean by this. Is there something I need to do here?

Copy link
Member

Choose a reason for hiding this comment

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

the xmpp way to transport this is currently from here

<sctpmap xmlns='urn:xmpp:jingle:transports:dtls-sctp:1' number='5000' protocol='webrtc-datachannel' streams='1024'/>

which doesn't transport things like maxMessageSize. So I expect that if you signal this you'll need to update the stanza.io version you're using as well.

};
content.transport.sctp = [];
}
Expand Down Expand Up @@ -194,6 +204,10 @@ exports.toMediaJSON = function (media, session, opts) {
trans.fingerprints.push(fp);
});

if (parsers.findLine('a=ice-options:trickle', lines)) {
Copy link
Member

Choose a reason for hiding this comment

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

i'd do this in a separate PR/commit for atomicity

Copy link
Member

Choose a reason for hiding this comment

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

actually this shouldn't be mapped. First its not really relevant in the SDP, second, as xep-0371 explains we have disco for this kind of stuff.

trans.trickleIce = true;
}

var ufragLine = parsers.findLine('a=ice-ufrag:', lines, sessionLines);
var pwdLine = parsers.findLine('a=ice-pwd:', lines, sessionLines);
if (ufragLine && pwdLine) {
Expand Down
21 changes: 16 additions & 5 deletions lib/tosdp.js
Original file line number Diff line number Diff line change
Expand Up @@ -54,16 +54,17 @@ exports.toMediaSDP = function (content, opts) {
var mline = [];
if (desc.applicationType == 'datachannel') {
mline.push('application');
mline.push('1');
mline.push('DTLS/SCTP');
mline.push(desc.port);
mline.push('UDP/DTLS/SCTP');
mline.push('webrtc-datachannel');
if (transport.sctp) {
transport.sctp.forEach(function (map) {
mline.push(map.number);
});
}
} else {
mline.push(desc.media);
mline.push('1');
mline.push(desc.port);
if (fingerprints.length > 0) {
mline.push('UDP/TLS/RTP/SAVPF');
} else if (desc.encryption && desc.encryption.length > 0) {
Expand All @@ -76,15 +77,22 @@ exports.toMediaSDP = function (content, opts) {
});
}


sdp.push('m=' + mline.join(' '));

sdp.push('c=IN IP4 0.0.0.0');
if (desc.bandwidth && desc.bandwidth.type && desc.bandwidth.bandwidth) {
sdp.push('b=' + desc.bandwidth.type + ':' + desc.bandwidth.bandwidth);
}
if (desc.applicationType == 'rtp') {
sdp.push('a=rtcp:1 IN IP4 0.0.0.0');
sdp.push('a=rtcp:' + desc.port + ' IN IP4 0.0.0.0');
}

if (desc.maxMessageSize) {
sdp.push('a=max-message-size:' + desc.maxMessageSize);
}

if (desc.sctpPort) {
sdp.push('a=sctp-port:' + desc.sctpPort);
}

if (transport) {
Expand All @@ -94,6 +102,9 @@ exports.toMediaSDP = function (content, opts) {
if (transport.pwd) {
sdp.push('a=ice-pwd:' + transport.pwd);
}
if (transport.trickleIce) {
sdp.push('a=ice-options:trickle');
}

var pushedSetup = false;
fingerprints.forEach(function (fingerprint) {
Expand Down
Loading