⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 exconf.c

📁 mediastreamer2是开源的网络传输媒体流的库
💻 C
📖 第 1 页 / 共 3 页
字号:
/*  eXosip - This is the eXtended osip library.  Copyright (C) 2002,2003,2004,2005,2006,2007  Aymeric MOIZARD  - jack@atosc.org    eXosip is free software; you can redistribute it and/or modify  it under the terms of the GNU General Public License as published by  the Free Software Foundation; either version 2 of the License, or  (at your option) any later version.    eXosip is distributed in the hope that it will be useful,  but WITHOUT ANY WARRANTY; without even the implied warranty of  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the  GNU General Public License for more details.    You should have received a copy of the GNU General Public License  along with this program; if not, write to the Free Software  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA*/#ifdef ENABLE_MPATROL#include <mpatrol.h>#endif#include "eXosip2.h"#include <eXosip2/eXosip.h>#include <osip2/osip_mt.h>#include <osip2/osip_condv.h>extern eXosip_t eXosip;int ipv6_enable = 0;#ifdef OSIP_MTstatic void *_eXosip_thread (void *arg);#endifstatic void _eXosip_keep_alive (void);#ifndef MINISIZEvoideXosip_enable_ipv6 (int _ipv6_enable){  ipv6_enable = _ipv6_enable;}#endifconst char *eXosip_get_version (void){  return EXOSIP_VERSION;}inteXosip_set_cbsip_message (CbSipCallback cbsipCallback){  eXosip.cbsipCallback = cbsipCallback;  return 0;}voideXosip_masquerade_contact (const char *public_address, int port){  eXtl_udp.tl_masquerade_contact (public_address, port);  eXtl_tcp.tl_masquerade_contact (public_address, port);#ifdef HAVE_OPENSSL_SSL_H  eXtl_tls.tl_masquerade_contact (public_address, port);#if !(OPENSSL_VERSION_NUMBER < 0x00908000L)  eXtl_dtls.tl_masquerade_contact (public_address, port);#endif#endif  return;}inteXosip_guess_localip (int family, char *address, int size){  return eXosip_guess_ip_for_via (family, address, size);}inteXosip_is_public_address (const char *c_address){  return (0 != strncmp (c_address, "192.168", 7)          && 0 != strncmp (c_address, "10.", 3)          && 0 != strncmp (c_address, "172.16.", 7)          && 0 != strncmp (c_address, "172.17.", 7)          && 0 != strncmp (c_address, "172.18.", 7)          && 0 != strncmp (c_address, "172.19.", 7)          && 0 != strncmp (c_address, "172.20.", 7)          && 0 != strncmp (c_address, "172.21.", 7)          && 0 != strncmp (c_address, "172.22.", 7)          && 0 != strncmp (c_address, "172.23.", 7)          && 0 != strncmp (c_address, "172.24.", 7)          && 0 != strncmp (c_address, "172.25.", 7)          && 0 != strncmp (c_address, "172.26.", 7)          && 0 != strncmp (c_address, "172.27.", 7)          && 0 != strncmp (c_address, "172.28.", 7)          && 0 != strncmp (c_address, "172.29.", 7)          && 0 != strncmp (c_address, "172.30.", 7)          && 0 != strncmp (c_address, "172.31.", 7)          && 0 != strncmp (c_address, "169.254", 7));}voideXosip_set_user_agent (const char *user_agent){  osip_free (eXosip.user_agent);  eXosip.user_agent = osip_strdup (user_agent);}voideXosip_kill_transaction (osip_list_t * transactions){  osip_transaction_t *transaction;  if (!osip_list_eol (transactions, 0))    {      /* some transaction are still used by osip,         transaction should be released by modules! */      OSIP_TRACE (osip_trace                  (__FILE__, __LINE__, OSIP_ERROR, NULL,                   "module sfp: _osip_kill_transaction transaction should be released by modules!\n"));    }  while (!osip_list_eol (transactions, 0))    {      transaction = osip_list_get (transactions, 0);      __eXosip_delete_jinfo (transaction);      osip_transaction_free (transaction);    }}voideXosip_quit (void){  jauthinfo_t *jauthinfo;  eXosip_call_t *jc;  eXosip_reg_t *jreg;#ifndef MINISIZE  eXosip_notify_t *jn;  eXosip_subscribe_t *js;  eXosip_pub_t *jpub;#endif#ifdef OSIP_MT  int i;#endif  if (eXosip.j_stop_ua == -1)    {      OSIP_TRACE (osip_trace                  (__FILE__, __LINE__, OSIP_WARNING, NULL,                   "eXosip: already stopped!\n"));      return;    }  eXosip.j_stop_ua = 1;         /* ask to quit the application */  __eXosip_wakeup ();  __eXosip_wakeup_event ();#ifdef OSIP_MT  if (eXosip.j_thread != NULL)    {      i = osip_thread_join ((struct osip_thread *) eXosip.j_thread);      if (i != 0)        {          OSIP_TRACE (osip_trace                      (__FILE__, __LINE__, OSIP_ERROR, NULL,                       "eXosip: can't terminate thread!\n"));        }      osip_free ((struct osip_thread *) eXosip.j_thread);    }  jpipe_close (eXosip.j_socketctl);  jpipe_close (eXosip.j_socketctl_event);#endif  osip_free (eXosip.user_agent);  for (jc = eXosip.j_calls; jc != NULL; jc = eXosip.j_calls)    {      REMOVE_ELEMENT (eXosip.j_calls, jc);      eXosip_call_free (jc);    }#ifndef MINISIZE  for (js = eXosip.j_subscribes; js != NULL; js = eXosip.j_subscribes)    {      REMOVE_ELEMENT (eXosip.j_subscribes, js);      eXosip_subscribe_free (js);    }  for (jn = eXosip.j_notifies; jn != NULL; jn = eXosip.j_notifies)    {      REMOVE_ELEMENT (eXosip.j_notifies, jn);      eXosip_notify_free (jn);    }#endif#ifdef OSIP_MT  osip_mutex_destroy ((struct osip_mutex *) eXosip.j_mutexlock);#if !defined (_WIN32_WCE)  osip_cond_destroy ((struct osip_cond *) eXosip.j_cond);#endif#endif  for (jreg = eXosip.j_reg; jreg != NULL; jreg = eXosip.j_reg)    {      REMOVE_ELEMENT (eXosip.j_reg, jreg);      eXosip_reg_free (jreg);    }#ifndef MINISIZE  for (jpub = eXosip.j_pub; jpub != NULL; jpub = eXosip.j_pub)    {      REMOVE_ELEMENT (eXosip.j_pub, jpub);      _eXosip_pub_free (jpub);    }#endif  while (!osip_list_eol (&eXosip.j_transactions, 0))    {      osip_transaction_t *tr =        (osip_transaction_t *) osip_list_get (&eXosip.j_transactions, 0);      if (tr->state == IST_TERMINATED || tr->state == ICT_TERMINATED          || tr->state == NICT_TERMINATED || tr->state == NIST_TERMINATED)        {          OSIP_TRACE (osip_trace (__FILE__, __LINE__, OSIP_INFO1, NULL,                                  "Release a terminated transaction\n"));          osip_list_remove (&eXosip.j_transactions, 0);          __eXosip_delete_jinfo (tr);          osip_transaction_free (tr);      } else        {          osip_list_remove (&eXosip.j_transactions, 0);          __eXosip_delete_jinfo (tr);          osip_transaction_free (tr);        }    }  eXosip_kill_transaction (&eXosip.j_osip->osip_ict_transactions);  eXosip_kill_transaction (&eXosip.j_osip->osip_nict_transactions);  eXosip_kill_transaction (&eXosip.j_osip->osip_ist_transactions);  eXosip_kill_transaction (&eXosip.j_osip->osip_nist_transactions);  osip_release (eXosip.j_osip);  {    eXosip_event_t *ev;    for (ev = osip_fifo_tryget (eXosip.j_events); ev != NULL;         ev = osip_fifo_tryget (eXosip.j_events))      eXosip_event_free (ev);  }  osip_fifo_free (eXosip.j_events);  for (jauthinfo = eXosip.authinfos; jauthinfo != NULL;       jauthinfo = eXosip.authinfos)    {      REMOVE_ELEMENT (eXosip.authinfos, jauthinfo);      osip_free (jauthinfo);    }  {    struct eXosip_http_auth *http_auth;    int pos;    /* update entries with same call_id */    for (pos = 0; pos < MAX_EXOSIP_HTTP_AUTH; pos++)      {        http_auth = &eXosip.http_auths[pos];        if (http_auth->pszCallId[0] == '\0')          continue;        osip_proxy_authenticate_free (http_auth->wa);        memset (http_auth, 0, sizeof (struct eXosip_http_auth));      }  }  eXtl_udp.tl_free ();  eXtl_tcp.tl_free ();#ifdef HAVE_OPENSSL_SSL_H#if !(OPENSSL_VERSION_NUMBER < 0x00908000L)  eXtl_dtls.tl_free ();#endif  eXtl_tls.tl_free ();#endif  memset (&eXosip, 0, sizeof (eXosip));  eXosip.j_stop_ua = -1;  return;}inteXosip_set_socket (int transport, int socket, int port){  eXosip.eXtl = NULL;  if (transport == IPPROTO_UDP)    {      eXtl_udp.proto_port = port;      eXtl_udp.tl_set_socket (socket);      eXosip.eXtl = &eXtl_udp;      snprintf (eXosip.transport, sizeof (eXosip.transport), "%s", "UDP");  } else if (transport == IPPROTO_TCP)    {      eXtl_tcp.proto_port = port;      eXtl_tcp.tl_set_socket (socket);      eXosip.eXtl = &eXtl_tcp;      snprintf (eXosip.transport, sizeof (eXosip.transport), "%s", "TCP");  } else    return OSIP_BADPARAMETER;#ifdef OSIP_MT  eXosip.j_thread = (void *) osip_thread_create (20000, _eXosip_thread, NULL);  if (eXosip.j_thread == NULL)    {      OSIP_TRACE (osip_trace                  (__FILE__, __LINE__, OSIP_ERROR, NULL,                   "eXosip: Cannot start thread!\n"));      return OSIP_UNDEFINED_ERROR;    }#endif  return OSIP_SUCCESS;}#ifdef IPV6_V6ONLYintsetsockopt_ipv6only (int sock){  int on = 1;  return setsockopt (sock, IPPROTO_IPV6, IPV6_V6ONLY, (char *) &on, sizeof (on));}#endif /* IPV6_V6ONLY */#ifndef MINISIZEinteXosip_find_free_port (int free_port, int transport){  int res1;  int res2;  struct addrinfo *addrinfo_rtp = NULL;  struct addrinfo *curinfo_rtp;  struct addrinfo *addrinfo_rtcp = NULL;  struct addrinfo *curinfo_rtcp;  int sock;  int count;  for (count = 0; count < 8; count++)    {      res1 =        eXosip_get_addrinfo (&addrinfo_rtp, "0.0.0.0", free_port + count * 2,                             transport);      if (res1 != 0)        return res1;      res2 =        eXosip_get_addrinfo (&addrinfo_rtcp, "0.0.0.0", free_port + count * 2 + 1,                             transport);      if (res2 != 0)        {          eXosip_freeaddrinfo (addrinfo_rtp);          return res2;        }      sock = -1;      for (curinfo_rtp = addrinfo_rtp; curinfo_rtp;           curinfo_rtp = curinfo_rtp->ai_next)        {          if (curinfo_rtp->ai_protocol && curinfo_rtp->ai_protocol != transport)            {

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -