call progress tones

574 views
Skip to first unread message

Gaetano Volpe

unread,
May 23, 2014, 11:25:27 AM5/23/14
to sip...@googlegroups.com
Hi guys,

I successfully registered on a FreeSwitch instance and I can make calls.

The only problem I have is that I cannot hear call progress tones.

I guessed that the problem was related to the fact that I attached the media stream only on "accepted" event.

Is there any way to attach a media stream on progress event?

My Code below:

 (function () {
var config = {
  // Replace this IP address with your FreeSWITCH IP address
  
  // Replace this IP address with your FreeSWITCH IP address
  // and replace the port with your FreeSWITCH port
  wsServers: 'ws://192.168.18.130:5066',
  
  // FreeSWITCH Default Username
  authorizationUser: '1001',
  
  // FreeSWITCH Default Password
  password: '1234'
};

var ua = new SIP.UA(config);

  var session;

  function onAccepted () {
        //gets the video elements
    var remoteVideo = document.getElementById('remoteVideo');
    var localVideo = document.getElementById('localVideo');

    //attached the received video stream to the Video Elements
    attachMediaStream(remoteVideo, session.mediaHandler.getRemoteStreams()[0]);
    attachMediaStream(localVideo, session.mediaHandler.getLocalStreams()[0]);

    //plays the Video Elements
    remoteVideo.play();
    localVideo.play();
  }
    
  //var endButton = document.getElementById('endCall');
  //endButton.addEventListener("click", function() {
  //  session.bye();
  //  alert("Call Ended");
//}, false);

  //here you determine whether the call has video and audio
  var options = {
    mediaConstraints: {
      audio: true,
      video: false
    }
  };
  
    function attachMediaStream(element, stream) {
    if (typeof element.srcObject !== 'undefined') {
      element.srcObject = stream;
    } else if (typeof element.mozSrcObject !== 'undefined') {
      element.mozSrcObject = stream;
    } else if (typeof element.src !== 'undefined') {
      element.src = URL.createObjectURL(stream);
    } else {
      console.log('Error attaching stream to element.');
    }
  }
  
    var endButton = document.getElementById('endCall');
  endButton.addEventListener("click", function() {
    session.bye();
    alert("Call Ended");
}, false);

  //makes the call
  session = ua.invite('sip:10...@192.168.18.130', options);
  session.on('accepted', onAccepted);
    
}) ();

Will Mitchell

unread,
May 23, 2014, 2:05:14 PM5/23/14
to sip...@googlegroups.com
Hi Gaetano,

Are you looking for a generic ringtone to play while the call progresses, or is FreeSWITCH playing early media that you would like to render?  It sounds like the latter, but I'll include both answers, just in case.

1. To negotiate early media on the peer connection, you must use the 100rel options.  The actual use of this changes depending on whether you are inviting the session or being invited to the session, but in this case it sounds like you are only making outbound calls.  You can declare support for 100rel by setting the option when making the INVITE request:

 //here you determine whether the call has video and audio
  var options = {
    mediaConstraints: {
      audio: true,
      video: false
    },
    rel100: SIP.C.supported.REQUIRED // or SIP.C.supported.SUPPORTED
  };

The option is documented under the UA.invite parameters. You can then attach the media stream just like you do now, but listen for the `progress` event instead of the `accepted` event.

If you are unfamiliar with 100rel, it basically tells the UA that the SDP offer will be in a reliable 1xx response, rather than the SDP.  If unreliable (default) responses contain SDP, that SDP is ignored.  I'd highly recommend reading the RFC (RFC 3262) to learn more about how that works.

2.  If by chance you don't care about the media that FreeSWITCH is playing and just want to hear any ringback tone at all, we usually create an <audio> element and play it when we start a call or receive a `progress` event, pausing it again when we see an `accepted` or `failed` event.

In any case, thank you for trying SIP.js, and please let us know if there is any other information we can give to help.

Cheers,
Will

Gaetano Volpe

unread,
May 27, 2014, 12:59:32 PM5/27/14
to sip...@googlegroups.com
Hi Will,

thank you for your answer.

I followed your instructions and I changed my options to include 

rel100: SIP.C.supported.REQUIRED

I changed also the listener to "progress" event. Now I get no audio at all but the call is regularly placed..

Can you help me?

Cheers
Gaetano
  session = ua.invite('sip:...@192.168.18.130', options);
  session.on('accepted', onAccepted);
    
}) ();
  session = ua.invite('sip:...@192.168.18.130', options);
  session.on('accepted', onAccepted);
    
}) ();
  session = ua.invite('sip:...@192.168.18.130', options);
  session.on('accepted', onAccepted);
    
}) ();
  session = ua.invite('sip:...@192.168.18.130', options);

Will Mitchell

unread,
May 27, 2014, 2:31:27 PM5/27/14
to sip...@googlegroups.com
Hi Gaetano,

Could you include a log with the traceSip option enabled?  That will help us narrow down if the early media is being set up or not.

-Will


On Friday, May 23, 2014 11:25:27 AM UTC-4, Gaetano Volpe wrote:

Gaetano Volpe

unread,
May 28, 2014, 2:26:36 AM5/28/14
to sip...@googlegroups.com
Hi Will,

please find attached traces with binding on "accept" and on "progress".

Thank you for your help.

Cheers
Gaetano

  session = ua.invite('sip:...@192.168.18.130', options);
on_accepted.txt
on_progress.txt

Will Mitchell

unread,
May 28, 2014, 9:08:29 AM5/28/14
to sip...@googlegroups.com
Hi Gaetano,

I apologize.  I gave you a bad answer.  There is some new work with the 100rel code that has mixed me up a bit.

The parameter is actually a UA configuration option, and it goes by the name `reliable` (or `rel100` if you are using the latest source from GitHub).  It will declare that 100rel is required (or supported) on all of the calls for that UA:

ua = new SIP.UA({
  reliable: SIP.C.supported.REQUIRED
  // ... other config options
});

Can you try that and let me know how it goes?

Gaetano Volpe

unread,
May 28, 2014, 9:34:05 AM5/28/14
to sip...@googlegroups.com
Hello Will,

just tried, but it doesn't work neither with reliable or rel100 in ua config, see below:

var config = {
 wsServers: 'ws://192.168.18.130:5066',
 authorizationUser: '1001',
 password: '1234',
 rel100: SIP.C.supported.REQUIRED,
 traceSip: true
};

or

var config = {
 wsServers: 'ws://192.168.18.130:5066',
 authorizationUser: '1001',
 password: '1234',
 reliable: SIP.C.supported.REQUIRED,
 traceSip: true
}; 

Thank you

Will Mitchell

unread,
May 28, 2014, 9:42:11 AM5/28/14
to sip...@googlegroups.com
Can you check that the INVITE being sent has the following header in it?

Required: 100rel

That will help us determine if the parameter is being set appropriately, or if the problem is happening later.  You should also then see the 183 from FreeSWITCH containing the same header as well.

Will Mitchell

unread,
May 28, 2014, 9:43:05 AM5/28/14
to sip...@googlegroups.com
Require: 100rel

Typo, sorry.

Gaetano Volpe

unread,
May 28, 2014, 9:58:49 AM5/28/14
to sip...@googlegroups.com
Sorry,

can't find it. When I use reliable I can find only this line in the ua config trace:

| sip.ua | · reliable: "none"

Eric Green

unread,
May 28, 2014, 10:08:07 AM5/28/14
to sip...@googlegroups.com
Hi Gaetano,

Can you send a new log with traceSip again?

Thanks,
-Eric Green

Gaetano Volpe

unread,
May 28, 2014, 10:22:50 AM5/28/14
to sip...@googlegroups.com
Hi Eric,

sure, please find attached the full trace log.
on_progress.txt

Eric Green

unread,
May 28, 2014, 10:33:06 AM5/28/14
to sip...@googlegroups.com
Thanks Gaetano,

I was double checking the information that Will sent you. It looks like there is a slight misunderstanding. Please try setting rel100:"required" instead of rel100:SIP.C.supported.REQUIRED.

I have opened GitHub Issue 27 to address this.

Let me know how that works.

Thanks,
-Eric Green

Gaetano Volpe

unread,
May 29, 2014, 1:35:14 AM5/29/14
to sip...@googlegroups.com
It works. Thank you

Iwan Budi Kusnanto

unread,
Jun 6, 2014, 6:04:51 AM6/6/14
to Eric Green, sip...@googlegroups.com
On Wed, May 28, 2014 at 9:33 PM, Eric Green <eric....@onsip.com> wrote:
> Thanks Gaetano,
>
> I was double checking the information that Will sent you. It looks like
> there is a slight misunderstanding. Please try setting rel100:"required"
> instead of rel100:SIP.C.supported.REQUIRED.

Hello,

FYI,
I use sipjs v0.5.
Instead of rel100:"required",
i need to use reliable:"required" in UA config.

From quick code reading, looks like we need to use rel100 if we use git master.
> --
> You received this message because you are subscribed to the Google Groups
> "SIP.js" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to sip_js+un...@googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.



--
Iwan Budi Kusnanto

Eric Green

unread,
Jun 6, 2014, 7:42:06 AM6/6/14
to sip...@googlegroups.com, eric....@onsip.com
Yes. 
0.5.0 => reliable : 'required'
master (as of commit ec38b519bc839250529797f0924a804f6df593fe) => rel100 : 'required'. reliable : 'required' will still work here, just prefer rel100 where applicable. We have plans to deprecate reliable eventually.
0.6.0 (future release) => rel100 : SIP.C.supported.REQUIRED. again the other methods should work here, with plans to eventually remove them in a later release. For more information see SIP.js #27.

Sorry for the confusion.

-Eric Green

ode...@gmail.com

unread,
Aug 1, 2014, 6:58:16 PM8/1/14
to sip...@googlegroups.com, eric....@onsip.com
I'm using 0.6.1 and when I use rel100: 'required' I don't get the early media from FreeSWITCH, but when I use reliable: 'required', I hear the early media.

I still get a message in my console telling me that reliable is deprecated (Fri Aug 01 2014 15:54:35 GMT-0700 (Pacific Standard Time) | sip.ua | reliable is deprecated, please use rel100 instead) so I'm a bit confused.

Am I doing something wrong or is there an issue with rel100 ?

To be clear, what I want works right now, but I'm using 'reliable' and not 'rel100' to have it work.
> > email to sip_js+un...@googlegroups.com.

Eric Green

unread,
Aug 2, 2014, 10:41:54 AM8/2/14
to sip...@googlegroups.com, eric....@onsip.com, ode...@gmail.com
Hi Odeonn,

Thanks for trying SIP.js. Sorry about the confusion with this, we were doing a lot of refactoring until we got it to where we liked it. You should be able to use the constants with the rel100 option. The constants are set to the deprecated strings as well to support backwards compatibility. Our API for rel100 should be accurate. If it does not work as described, let me know and I will investigate it further.

-Eric Green
Reply all
Reply to author
Forward
0 new messages