Documentation/guide for writing a Session Description Handler would be great.

2,112 views
Skip to first unread message

w pp

unread,
Nov 20, 2017, 7:22:25 AM11/20/17
to SIP.js
Hi everyone,

With version 0.8.x of the library ("Session description refactor" - https://github.com/onsip/SIP.js/pull/426 merged),
you provide the option of writing a custom Session Description Handler (SDH) in case the supplied SDH does not meet your requirements.

When using SIP.js in Node.js, mobile apps, or other platforms, you can define a custom 
Session Description Handler using the UA’s sessionDescriptionHandlerFactory configuration parameter.

I found myself in that situation, since we handle our media stream acquisition a bit differently and passing a stream to the default SDH
is no longer supported (unless I missed that). Anyways, while writing the custom SDH I found the current documentation a bit lacking and just
wasn't quite sure how to approach the task


- sessionDescriptionHandlerFactory - TODO
- sessionDescriptionHandlerFactoryOptions - yields a 404

I mean things worked out ok, especially since you provide a default SDH (https://github.com/onsip/SIP.js/blob/master/src/WebRTC/SessionDescriptionHandler.js),
but I believe in learning by example and a guide for writing a custom SDH would be fantastic!

I assume this might not be on the top of your priority list, I'd be happy to get started on a draft and submit that for feedback?

Cheers and thanks for your time.

Eric Green

unread,
Nov 20, 2017, 10:48:35 AM11/20/17
to SIP.js
I feel like I have some pretty extensive documentation on the Session Description Handler. I know that there is a TODO under the UA configuration option for the factory, and I will try and address that shortly. If you think that there is anything missing from that documentation let me know and I can try and update it. Additionally we do take pull requests for our website :)

-Eric Green

jeremy...@gmail.com

unread,
Nov 21, 2017, 2:35:42 AM11/21/17
to SIP.js
Hi Eric,

The API documentation seems quite up to date. The "Guides" section on the other hand is very much out of date, it still reflects the 0.7.x API concerning media handling:

https://sipjs.com/guides/make-call/

I'm of two minds as to how to update this. The "easiest" option (as in: fewer lines of documentation) would be to replace this by documentation on how to use the SIP.Simple API, but if we do that there will be absolutely no documentation on how to get the full SIP.UA to make calls.

Jeremy

w pp

unread,
Nov 21, 2017, 6:37:21 AM11/21/17
to SIP.js
Hi Eric,

Thanks for the quick reply. Yep the API documentation for the SDH itself is great. It was just a bit difficult to wrap
my head around how the UA construction is supposed to work and what a custom SDH would look like.

I think one more entry in the Guides (https://sipjs.com/guides/) section would've sped up the process for me.
I'd be happy to submit a PR to the website.

Cheers

Eric Green

unread,
Nov 21, 2017, 9:45:22 AM11/21/17
to SIP.js
Yeah. The guides section is a little out of date. This being a free project, it is tough to find the time to update the guides. I would like to get an entire section for simple, and an entire section for regular API guides. This is probably a little ways out. My plan in the short term is to update the guides to just use the regular API with a disclaimer linking to the Simple documentation. This will probably get done before our 0.9.0 release.

-Eric Green

stot...@googlemail.com

unread,
Jan 9, 2018, 5:56:06 AM1/9/18
to SIP.js
I think there should be a code snippet how to use the default sessionDescriptionHandler and how to setup iceServers since this changed from 7.* versions and there is no example code for this.

example config object:
var config = {
userAgentString: 'SIP.js/0.9.*',
traceSip: true,
register: true,
uri: "websi...@your-sip.domain.org",
password: "examplepassword",
hackViaTcp: true,
rel100: SIP.C.supported.SUPPORTED,
wsServers: "wss://your-wsSip-server:443",
sessionDescriptionHandlerFactoryOptions:{
peerConnectionOptions: {
rtcConfiguration:{
iceServers:
[
{ urls:"stun:stun.l.google.com:19302" },
{
urls:"turn:turn-ip:443?transport=tcp",
username:"turnuser",
credential:"turnpass"
}
]
}
}
}
}

//create Uaser Agent object and register
ua = new SIP.UA(config)
ua.on('connected', function () {
ua.register()
})

// Send invite
session = ua.invite(uri, {
sessionDescriptionHandlerOptions: {
constraints: {
audio: true,
video: video
}
}
});


and later you have to listen to addStream from sessionDescriptionHandler wich is not available at once after session init but later:

session.on('progress', function () {
session.sessionDescriptionHandler.on('addStream', function () {
var pc = session.sessionDescriptionHandler.peerConnection
var remoteStream = new MediaStream()
pc.getReceivers().forEach(function(receiver) {
var track = receiver.track
if (track) {
remoteStream.addTrack(track)
}
})
video.srcObject = remoteStream // video is your html-video element for viewing remote stream
video.autoplay = true
})
})


Stefan

jme...@sybernet.ie

unread,
Jan 26, 2018, 12:14:47 PM1/26/18
to SIP.js

I found this thread very useful.

I am new to SIP.JS and had gotten a bit lost using various examples from different versions of the API. However, using the above I have managed to get outbound calls working with Asterisk and a WEBRTC client using SIPJS 0.9.2 and audio going both ways.

I am now trying to sort out inbound calls through the same Asterisk setup to the same webrtc client. The call is set up but I get no audio either way. I know it is related to the SessionDescriptionHandler setup as well - is there any example that would show how to set up the sessiondescriptionhandler for an inbound call.

Thanks in advance.
John.


mak...@gmail.com

unread,
May 15, 2018, 4:13:44 PM5/15/18
to SIP.js

Hi John, any updates concerning this topic? I have the similar question.

Eric Green

unread,
May 15, 2018, 4:15:36 PM5/15/18
to SIP.js
We have guides on the Session Description Handler that cover how to create your own.

mak...@gmail.com

unread,
May 16, 2018, 3:54:53 AM5/16/18
to SIP.js
Hi Eric, hope you're doing well and want to tell thank you so much for your work.
And concerning your guide I have a couple questions:
Firstly In Chrome (Version 66.0.3359.139 (Official Build) (64-bit)) I don't have to do any actions with media, just do session.accept() and all media working well (in firefox media doesn't work).

Secondly, in Firefox Quantum 61.0b4 (64-bit) I have to prepare media and attach it to the DOM elements. I brought the code here https://pastebin.com/YRpwNYmc, as you can see this code completely the same as here https://sipjs.com/guides/attach-media/ and in this case, I have one way audio (from the remote peer sound goes to the browser well but in opposite way, it doesn't working).

And code which I have shown above absolutely doesn't affect chrome functionality (it works)
How I have to set up media sources properly in different browsers.

jme...@sybernet.ie

unread,
May 16, 2018, 4:09:04 AM5/16/18
to SIP.js
Maxim,

My journey with WebRTC/SIPJS and Asterisk is described in this post as well.

https://groups.google.com/forum/#!topic/sip_js/W_ZTmpIeTbQ

In the end my big problem was an issue with Asterisk and how it decided which of the two endpoints was ICE-CONTROLLING/CONTROLLED. I wrote up what I found on this as well.

If any of this is relevant to you - let me know and I will try to help.

Best Regards,
John


martastuart

unread,
May 17, 2018, 10:56:18 AM5/17/18
to SIP.js
@jmelody, @Eric, thank you for support and for your patience. My problem has been solved by changing the firefox version. All beta channels are not able to send media to the remote peer in case of the incoming call (outgoing is fine). I've downgraded my FF version to latest stable release (60.0.1 (64-bit) Quantum) and everything became fine


Reply all
Reply to author
Forward
0 new messages