Man Linux: Main Page and Category List

NAME

       How-To initiate, modify or terminate calls. - eXosip2 offers a flexible
       API to help you controling calls.

   Initiate a call
       To start an outgoing call, you typically need a few headers which will
       be used by eXosip2 to build a default SIP INVITE request. The code
       below is used to start a call:

         osip_message_t *invite;
         int i;

         i = eXosip_call_build_initial_invite (&invite, ’<sip:to@antisip.com>’,
                                               ’<sip:from@antisip.com>’,
                                               NULL, // optionnal route header
                                               ’This is a call for a conversation’);
         if (i != 0)
           {
             return -1;
           }

         osip_message_set_supported (invite, ’100rel’);

         {
           char tmp[4096];
           char localip[128];

           eXosip_guess_localip (AF_INET, localip, 128);
           snprintf (tmp, 4096,
                     ’v=0\r\n’
                     ’o=josua 0 0 IN IP4 %s\r\n’
                     ’s=conversation\r\n’
                     ’c=IN IP4 %s\r\n’
                     ’t=0 0\r\n’
                     ’m=audio %s RTP/AVP 0 8 101\r\n’
                     ’a=rtpmap:0 PCMU/8000\r\n’
                     ’a=rtpmap:8 PCMA/8000\r\n’
                     ’a=rtpmap:101 telephone-event/8000\r\n’
                     ’a=fmtp:101 0-11\r\n’, localip, localip, port);
           osip_message_set_body (invite, tmp, strlen (tmp));
           osip_message_set_content_type (invite, ’application/sdp’);
         }

         eXosip_lock ();
         i = eXosip_call_send_initial_invite (invite);
         if (i > 0)
           {
             eXosip_call_set_reference (i, reference);
           }
         eXosip_unlock ();
         return i;

       The above code is using eXosip_call_build_initial_invite to build a
       default SIP INVITE request for a new call. You have to insert a SDP
       body announcing your audio parameter for the RTP stream.

       The above code also show the flexibility of the eXosip2 API which allow
       you to insert additionnal headers such as ’Supported: 100rel’
       (announcing support for a SIP extension). Thus you can enterely control
       the creation of SIP requests.

       The returned element of eXosip_call_send_initial_invite is the call
       identifier that you can use to send a CANCEL. In future events other
       than 100 Trying, you’ll also get the dialog identifier that will also
       be needed to control established calls.

       eXosip_call_set_reference is also a mean to attach one of your own
       context to a call so that you’ll get your pointer back in eXosip_event.

   Answer a call
       The code below is another example that teach you how to answer an
       incoming call.

       You’ll usually need to send a ’180 Ringing’ SIP answer when receiving a
       SIP INVITE:

         eXosip_lock ();
         eXosip_call_send_answer (ca->tid, 180, NULL);
         eXosip_unlock ();

       Note: The above code also shows that the stack is sometimes able to
       build and send a default SIP messages with only one API call

       Then, when the user wants to answer the call, you’ll need to send a 200
       ok and insert a SDP body in your SIP answer:

         osip_message_t *answer = NULL;

         eXosip_lock ();
         i = eXosip_call_build_answer (ca->tid, 200, &answer);
         if (i != 0)
         {
            eXosip_call_send_answer (ca->tid, 400, NULL);
         }
         else
         {
            i = sdp_complete_200ok (ca->did, answer);
            if (i != 0)
            {
               osip_message_free (answer);
               eXosip_call_send_answer (ca->tid, 415, NULL);
            }
            else
               eXosip_call_send_answer (ca->tid, 200, answer);
         }
         eXosip_unlock ();

       Note: In the above code, you can note that to send a response to a
       request, you have to use the transaction identifier (and not a call
       identifier or a dialog identifier!)

       Note2: For sending a 200ok, you’ll usually need to insert a SDP body in
       the answer and before this, to negotiate the parameters and codecs that
       you want to support. In the test tool, provided by eXosip2 (josua
       application), you’ll find a very basic implementation of the SDP
       negotiation.

   Sending other request
       The call control API allows you to send and receive REFER, UPDATE,
       INFO, OPTIONS, NOTIFY and INVITEs whitin calls. A few limitations still
       exist for answering other requests within calls, but it should be
       already possible to send any kind of request.

       Here you have a code sample to send an INFO requests used to send an
       out of band dtmf within the signalling layer.

         osip_message_t *info;
         char dtmf_body[1000];
         int i;

         eXosip_lock ();
         i = eXosip_call_build_info (ca->did, &info);
         if (i == 0)
         {
            snprintf (dtmf_body, 999, ’Signal=%c\r\nDuration=250\r\n’, c);
            osip_message_set_content_type (info, ’application/dtmf-relay’);
            osip_message_set_body (info, dtmf_body, strlen (dtmf_body));
            i = eXosip_call_send_request (ca->did, info);
         }
         eXosip_unlock ();

Author

       Generated automatically by Doxygen for libeXosip2 from the source code.

Version 3.1.0                   How-Toyinitiate, modify or terminate calls.(3)