【正文】
..............................39 Enumeration Type Documentation..................................................................40 Function Documentation.................................................................................41 eXosip2 SUBSCRIBE and ining subscriptions....................................................43 Functions.........................................................................................................43 Function Documentation.................................................................................43 eXosip2 authentication API.........................................................................................46 Functions.........................................................................................................46 Function Documentation.................................................................................46 Xosip2 SDP helper API...............................................................................................48 Functions.........................................................................................................48 Function Documentation.................................................................................481 The eXtented eXosip stack HowTo initialize libeXosip2.When using eXosip, your first task is to initialize both eXosip context and libosiplibrary (parser and state machines). This must be done prior to any use of libeXosip2.include eXosip2/int i。}... then you have to send messages and wait for eXosip events...In the previous code, you39。if (jetype == EXOSIP_CALL_NEW){........}else if (jetype == EXOSIP_CALL_ACK){........}else if (jetype == EXOSIP_CALL_ANSWERED){........}else .............eXosip_event_free(je)。invite,sip:to,sip:from,NULL, // optionnal route headerThis is a call for aconversation)。osip_message_set_content_type (invite, application/sdp)。ll get your pointer back in eXosip_event. Answer a callThe code below is another example that teach you how to answer an ining call.You39。answer)。ll usually need to insert a SDP body in the answerand before this, to negotiate the parameters and codecs that you want to support. Inthe test tool, provided by eXosip2 (josua application), you39。osip_message_set_content_type (info, application/dtmfrelay)。id = eXosip_register_build_initial_register (identity, registrar,NULL,1800, amp。return i。}eXosip_register_send_register (id, reg)。if (i 0){eXosip_unlock ()。i = eXosip_register_send_register (id, reg)。int i。info)。}eXosip_unlock ()。eXosip_lock ()。The above code is using eXosip_call_build_initial_invite to build a default SIP INVITErequest for a new call. You have to insert a SDP body announcing your audioparameter for the RTP stream.The above code also show the flexibility of the eXosip2 API which allow you to insertadditionnal headers such as Supported: 100rel (announcing support for a SIPextension). Thus you can enterely control the creation of SIP requests.The returned element of eXosip_call_send_initial_invite is the call identifier that youcan use to send a CANCEL. In future events other than 100 Trying, you39。snprintf (tmp, 4096,v=0\r\no=josua 0 0 IN IP4 %s\r\ns=conversation\r\nc=IN IP4 %s\r\nt=0 0\r\nm=audio %s RTP/AVP 0 8 101\r\na=rtpmap:0 PCMU/8000\r\na=rtpmap:8 PCMA/8000\r\na=rtpmap:101 telephoneevent/8000\r\na=fmtp:101 011\r\n, localip, localip, port)。int i。eXosip_unlock()。fprintf (stderr, could not initialize transport layer\n)。TRACE_INITIALIZE (6, stdout)。ve learned how to:? Initialize the osip trace (pile this code with DENABLE_TRACE)? Initialize eXosip (and osip) stack? Open a socket for signalling (only UDP with initial eXosip2 version)Now you have to handle eXosip events. Here is some code to get eXosip_event from the eXosip2 stack. eXosip_event_t *je。}You will receive one event for each SIP message sent. Each event contains theoriginal request of the affected transaction and the last response that triggers theevent when available.You can access all headers from those messages and store them in your own contextfor other actions or graphic displays.For example, when you receive a REFER request for a call transfer, you39。if (i != 0){return 1。}eXosip_lock ()。ll usually need to send a 180 Ringing SIP answer when receiving a SIP INVITE:eXosip_lock ()。if (i != 0){eXosip_call_send_answer (catid, 400, NULL)。ll find a very basicimplementation of the SDP negotiation. Sending other requestThe call control API allows you to send and receive REFER, UPDATE, INFO,OPTIONS, NOTIFY and INVITEs whitin calls. A few limitations still exist for answeringother requests within calls, but it should be already possible to send any kind ofrequest.Here you have a code sample to send an INFO requests used to send an out of banddtmf within the signalling layer.osip_message_t *info。osip_message_set_body (info, dtmf_body, strlen (dtmf_body))。reg)。The returned element of eXosip_register_build_initial_register is the registrationidentifier that you can use to update your registration. In future events about thisregistration, you39。eXosip_unlock ()。reg)。osip_message_set_supported(reg, path)。int id。i = eXosip_call_build_info (cadid, amp。}elseeXosip_call_send_answer (catid, 200, answer)。ll need to send a 200 ok and inserta SDP body in your SIP answer:osip_message_t *answer = NULL。return i。eXosip_guess_localip (AF_INET, localip, 128)。if (referto_head == NULL || referto_headhvalue == NULL)The eXosip_event also contains identifiers for calls, registrations, iningsubscriptions or outgoing subscriptions when applicable. Those identifiers are used inAPI to control calls, registrations, ining or outgoing subscriptions. These API willbuild default messages with usua