Sophie

Sophie

distrib > Fedora > 14 > x86_64 > by-pkgid > d661425f055462744853e295597df6f5 > files > 57

libeXosip2-devel-3.1.0-3.fc12.i686.rpm

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html><head><meta http-equiv="Content-Type" content="text/html;charset=UTF-8">
<title>libeXosip2: How-To initialize libeXosip2.</title>
<link href="tabs.css" rel="stylesheet" type="text/css">
<link href="doxygen.css" rel="stylesheet" type="text/css">
</head><body>
<!-- Generated by Doxygen 1.5.9 -->
<div class="navigation" id="top">
  <div class="tabs">
    <ul>
      <li><a href="index.html"><span>Main&nbsp;Page</span></a></li>
      <li><a href="pages.html"><span>Related&nbsp;Pages</span></a></li>
      <li><a href="modules.html"><span>Modules</span></a></li>
      <li><a href="annotated.html"><span>Data&nbsp;Structures</span></a></li>
      <li><a href="files.html"><span>Files</span></a></li>
      <li><a href="dirs.html"><span>Directories</span></a></li>
    </ul>
  </div>
</div>
<div class="contents">
<h1>How-To initialize libeXosip2.<br>
<small>
[<a class="el" href="group__libeXosip2.html">The eXtented eXosip stack</a>]</small>
</h1><table border="0" cellpadding="0" cellspacing="0">
<tr><td></td></tr>
</table>
When using eXosip, your first task is to initialize both eXosip context and libosip library (parser and state machines). This must be done prior to any use of libeXosip2.<p>
<pre>
	include &lt;<a class="el" href="eXosip_8h.html" title="eXosip API">eXosip2/eXosip.h</a>&gt;</pre><p>
<pre>	int i;</pre><p>
<pre>	TRACE_INITIALIZE (6, stdout);</pre><p>
<pre>	i=eXosip_init();
	if (i!=0)
	  return -1;</pre><p>
<pre>	i = eXosip_listen_addr (IPPROTO_UDP, NULL, port, AF_INET, 0);
	if (i!=0)
	  {
	    <a class="el" href="group__eXosip2__conf.html#g03f2a9d54e88cbc36341cd2fcb91b05b">eXosip_quit()</a>;
	    fprintf (stderr, "could not initialize transport layer\n");
	    return -1;
	  }</pre><p>
<pre>	... then you have to send messages and wait for eXosip events...
</pre><p>
In the previous code, you've learned how to: <ul>
<li>
Initialize the osip trace (compile this code with -DENABLE_TRACE) </li>
<li>
Initialize eXosip (and osip) stack </li>
<li>
Open a socket for signalling (only UDP with initial eXosip2 version) </li>
</ul>
<p>
Now you have to handle eXosip events. Here is some code to get <a class="el" href="structeXosip__event.html">eXosip_event</a> from the eXosip2 stack.<p>
<pre>
  eXosip_event_t *je;
  for (;;)
    {
      je = eXosip_event_wait (0, 50);
      <a class="el" href="group__eXosip2__conf.html#g039d93925ac6d1fdf35c68d6c6c435f5">eXosip_lock()</a>;
      eXosip_automatic_action ();
      <a class="el" href="group__eXosip2__conf.html#gcb362e00f0e5fb68ae53f18d846cd891">eXosip_unlock()</a>;
      if (je == NULL)
        break;
      if (je-&gt;type == EXOSIP_CALL_NEW)
        {
        ....
        ....
        }
      else if (je-&gt;type == EXOSIP_CALL_ACK)
        {
        ....
        ....
        }
      else if (je-&gt;type == EXOSIP_CALL_ANSWERED)
        {
        ....
        ....
        }
      else .....
      ....
      ....</pre><p>
<pre>      eXosip_event_free(je);
    }
</pre><p>
You will receive one event for each SIP message sent. Each event contains the original request of the affected transaction and the last response that triggers the event when available.<p>
You can access all headers from those messages and store them in your own context for other actions or graphic displays.<p>
For example, when you receive a REFER request for a call transfer, you'll typically retreive the "refer-To" header:<p>
<pre>
  osip_header_t *referto_head = NULL;
  i = osip_message_header_get_byname (evt-&gt;sip, "refer-to", 0, &amp;referto_head);
  if (referto_head == NULL || referto_head-&gt;hvalue == NULL)</pre><p>
<pre></pre><p>
The <a class="el" href="structeXosip__event.html">eXosip_event</a> also contains identifiers for calls, registrations, incoming subscriptions or outgoing subscriptions when applicable. Those identifiers are used in API to control calls, registrations, incoming or outgoing subscriptions. These API will build default messages with usual SIP headers (From, To, Call-ID, CSeq, Route, Record-Route, Max-Forward...) and send thoses messages for you. </div>
<hr size="1"><address style="text-align: right;"><small>Generated on Sun Jul 26 15:51:58 2009 for libeXosip2 by&nbsp;
<a href="http://www.doxygen.org/index.html">
<img src="doxygen.png" alt="doxygen" align="middle" border="0"></a> 1.5.9 </small></address>
</body>
</html>