jcallback.c

来自「mediastreamer2是开源的网络传输媒体流的库」· C语言 代码 · 共 2,026 行 · 第 1/5 页

C
2,026
字号
  OSIP_TRACE (osip_trace              (__FILE__, __LINE__, OSIP_INFO3, NULL,               "cb_rcvcancel (id=%i)\r\n", tr->transactionid));}#endifstatic voidcb_rcvregister (int type, osip_transaction_t * tr, osip_message_t * sip){  eXosip_event_t *je;  OSIP_TRACE (osip_trace              (__FILE__, __LINE__, OSIP_INFO3, NULL,               "cb_rcvregister (id=%i)\r\n", tr->transactionid));  je = eXosip_event_init_for_message (EXOSIP_MESSAGE_NEW, tr);  eXosip_event_add (je);  return;}static voidcb_rcvrequest (int type, osip_transaction_t * tr, osip_message_t * sip){  eXosip_dialog_t *jd;  eXosip_call_t *jc;#ifndef MINISIZE  eXosip_notify_t *jn;  eXosip_subscribe_t *js;#endif  jinfo_t *jinfo = (jinfo_t *) osip_transaction_get_your_instance (tr);  OSIP_TRACE (osip_trace              (__FILE__, __LINE__, OSIP_INFO3, NULL,               "cb_rcvunkrequest (id=%i)\r\n", tr->transactionid));  if (jinfo == NULL)    {      eXosip_event_t *je;      je = eXosip_event_init_for_message (EXOSIP_MESSAGE_NEW, tr);      eXosip_event_add (je);      return;    }  jd = jinfo->jd;  jc = jinfo->jc;#ifndef MINISIZE  jn = jinfo->jn;  js = jinfo->js;  if (jc == NULL && jn == NULL && js == NULL)    {      eXosip_event_t *je;      je = eXosip_event_init_for_message (EXOSIP_MESSAGE_NEW, tr);      eXosip_event_add (je);      return;    }#else  if (jc == NULL)    {      eXosip_event_t *je;      je = eXosip_event_init_for_message (EXOSIP_MESSAGE_NEW, tr);      eXosip_event_add (je);      return;    }#endif  else if (jc != NULL)    {      OSIP_TRACE (osip_trace                  (__FILE__, __LINE__, OSIP_INFO3, NULL,                   "cb_rcv? (id=%i)\r\n", tr->transactionid));      if (MSG_IS_BYE (sip))        {          /* already sent */      } else        report_call_event (EXOSIP_CALL_MESSAGE_NEW, jc, jd, tr);      return;    }#ifndef MINISIZE  else if (jn != NULL)    {      if (MSG_IS_SUBSCRIBE (sip))        {          eXosip_event_t *je;          je =            eXosip_event_init_for_notify (EXOSIP_IN_SUBSCRIPTION_NEW, jn, jd, tr);          report_event (je, NULL);          return;        }      return;  } else if (js != NULL)    {      if (MSG_IS_NOTIFY (sip))        {          eXosip_event_t *je;          je =            eXosip_event_init_for_subscribe (EXOSIP_SUBSCRIPTION_NOTIFY, js,                                             jd, tr);          report_event (je, NULL);          return;        }      return;    }#endif}#ifndef MINISIZEstatic voidcb_sndinvite (int type, osip_transaction_t * tr, osip_message_t * sip){  OSIP_TRACE (osip_trace              (__FILE__, __LINE__, OSIP_INFO3, NULL,               "cb_sndinvite (id=%i)\r\n", tr->transactionid));}static voidcb_sndack (int type, osip_transaction_t * tr, osip_message_t * sip){  OSIP_TRACE (osip_trace              (__FILE__, __LINE__, OSIP_INFO3, NULL, "cb_sndack (id=%i)\r\n",               tr->transactionid));}static voidcb_sndregister (int type, osip_transaction_t * tr, osip_message_t * sip){  OSIP_TRACE (osip_trace              (__FILE__, __LINE__, OSIP_INFO3, NULL,               "cb_sndregister (id=%i)\r\n", tr->transactionid));}static voidcb_sndbye (int type, osip_transaction_t * tr, osip_message_t * sip){  OSIP_TRACE (osip_trace              (__FILE__, __LINE__, OSIP_INFO3, NULL, "cb_sndbye (id=%i)\r\n",               tr->transactionid));}static voidcb_sndcancel (int type, osip_transaction_t * tr, osip_message_t * sip){  OSIP_TRACE (osip_trace              (__FILE__, __LINE__, OSIP_INFO3, NULL,               "cb_sndcancel (id=%i)\r\n", tr->transactionid));}static voidcb_sndinfo (int type, osip_transaction_t * tr, osip_message_t * sip){  OSIP_TRACE (osip_trace              (__FILE__, __LINE__, OSIP_INFO3, NULL, "cb_sndinfo (id=%i)\r\n",               tr->transactionid));}static voidcb_sndoptions (int type, osip_transaction_t * tr, osip_message_t * sip){  OSIP_TRACE (osip_trace              (__FILE__, __LINE__, OSIP_INFO3, NULL,               "cb_sndoptions (id=%i)\r\n", tr->transactionid));}static voidcb_sndnotify (int type, osip_transaction_t * tr, osip_message_t * sip){  OSIP_TRACE (osip_trace              (__FILE__, __LINE__, OSIP_INFO3, NULL,               "cb_sndnotify (id=%i)\r\n", tr->transactionid));}static voidcb_sndsubscribe (int type, osip_transaction_t * tr, osip_message_t * sip){  OSIP_TRACE (osip_trace              (__FILE__, __LINE__, OSIP_INFO3, NULL,               "cb_sndsubscibe (id=%i)\r\n", tr->transactionid));}static voidcb_sndunkrequest (int type, osip_transaction_t * tr, osip_message_t * sip){  OSIP_TRACE (osip_trace              (__FILE__, __LINE__, OSIP_INFO3, NULL,               "cb_sndunkrequest (id=%i)\r\n", tr->transactionid));}#endifvoid__eXosip_delete_jinfo (osip_transaction_t * transaction){  jinfo_t *ji;  if (transaction == NULL)    return;  ji = osip_transaction_get_your_instance (transaction);  osip_free (ji);  osip_transaction_set_your_instance (transaction, NULL);}#ifndef MINISIZEjinfo_t *__eXosip_new_jinfo (eXosip_call_t * jc, eXosip_dialog_t * jd,                    eXosip_subscribe_t * js, eXosip_notify_t * jn)#elsejinfo_t *__eXosip_new_jinfo (eXosip_call_t * jc, eXosip_dialog_t * jd)#endif{  jinfo_t *ji = (jinfo_t *) osip_malloc (sizeof (jinfo_t));  if (ji == NULL)    return NULL;  ji->jd = jd;  ji->jc = jc;#ifndef MINISIZE  ji->js = js;  ji->jn = jn;#endif  return ji;}static voidcb_rcv1xx (int type, osip_transaction_t * tr, osip_message_t * sip){  eXosip_dialog_t *jd;  eXosip_call_t *jc;#ifndef MINISIZE  eXosip_subscribe_t *js;  eXosip_notify_t *jn;#endif  jinfo_t *jinfo = (jinfo_t *) osip_transaction_get_your_instance (tr);  OSIP_TRACE (osip_trace              (__FILE__, __LINE__, OSIP_INFO3, NULL, "cb_rcv1xx (id=%i)\r\n",               tr->transactionid));  udp_tl_learn_port_from_via (sip);  if (jinfo == NULL)    return;  jd = jinfo->jd;  jc = jinfo->jc;#ifndef MINISIZE  jn = jinfo->jn;  js = jinfo->js;#endif  if (MSG_IS_RESPONSE_FOR (sip, "OPTIONS"))    {      if (jc == NULL)        {          eXosip_event_t *je;          OSIP_TRACE (osip_trace                      (__FILE__, __LINE__, OSIP_INFO3, NULL,                       "cb_rcv1xx (id=%i) OPTIONS outside of any call\r\n",                       tr->transactionid));          je = eXosip_event_init_for_message (EXOSIP_MESSAGE_PROCEEDING, tr);          eXosip_event_add (je);          return;        }      report_call_event (EXOSIP_CALL_MESSAGE_PROCEEDING, jc, jd, tr);      return;    }  if (MSG_IS_RESPONSE_FOR (sip, "INVITE") && MSG_TEST_CODE (sip, 100))    {      report_call_event (EXOSIP_CALL_PROCEEDING, jc, jd, tr);    }  if ((MSG_IS_RESPONSE_FOR (sip, "INVITE")#ifndef MINISIZE       || MSG_IS_RESPONSE_FOR (sip, "SUBSCRIBE")#endif      ) && !MSG_TEST_CODE (sip, 100))    {      int i;#ifndef MINISIZE      /* for SUBSCRIBE, test if the dialog has been already created         with a previous NOTIFY */      if (jd == NULL && js != NULL && js->s_dialogs != NULL          && MSG_IS_RESPONSE_FOR (sip, "SUBSCRIBE"))        {          /* find if existing dialog match the to tag */          osip_generic_param_t *tag;          int i;          i = osip_to_get_tag (sip->to, &tag);          if (i == 0 && tag != NULL && tag->gvalue != NULL)            {              for (jd = js->s_dialogs; jd != NULL; jd = jd->next)                {                  if (0 == strcmp (jd->d_dialog->remote_tag, tag->gvalue))                    {                      OSIP_TRACE (osip_trace                                  (__FILE__, __LINE__, OSIP_INFO1, NULL,                                   "eXosip: found established early dialog for this subscribe\n"));                      jinfo->jd = jd;                      break;                    }                }            }        }#endif      if (jd == NULL)           /* This transaction initiate a dialog in the case of                                   INVITE (else it would be attached to a "jd" element. */        {          /* allocate a jd */          i = eXosip_dialog_init_as_uac (&jd, sip);          if (i != 0)            {              OSIP_TRACE (osip_trace                          (__FILE__, __LINE__, OSIP_ERROR, NULL,                           "eXosip: cannot establish a dialog\n"));              return;            }          if (jc != NULL)            {              ADD_ELEMENT (jc->c_dialogs, jd);              jinfo->jd = jd;              eXosip_update ();            }#ifndef MINISIZE          else if (js != NULL)            {              ADD_ELEMENT (js->s_dialogs, jd);              jinfo->jd = jd;              eXosip_update ();          } else if (jn != NULL)            {              ADD_ELEMENT (jn->n_dialogs, jd);              jinfo->jd = jd;              eXosip_update ();            }#endif          else            {            }          osip_transaction_set_your_instance (tr, jinfo);      } else        {          if (jd->d_dialog == NULL)            {          } else if (jd->d_dialog->remote_tag == NULL)            {              osip_dialog_update_route_set_as_uac (jd->d_dialog, sip);              osip_dialog_update_tag_as_uac (jd->d_dialog, sip);          } else            {              osip_generic_param_t *tag;              int i;              i = osip_to_get_tag (sip->to, &tag);              if (tag != NULL && tag->gvalue != NULL                  && 0 == strcmp (jd->d_dialog->remote_tag, tag->gvalue))                {                  /* Update only if it is the same dialog */                  osip_dialog_update_route_set_as_uac (jd->d_dialog, sip);                }#if 1                           /* to be tested */              else                {                  /* the best thing is to replace the current dialog                     information... Much easier than creating a useless dialog! */                  osip_dialog_free (jd->d_dialog);                  i = osip_dialog_init_as_uac (&(jd->d_dialog), sip);                  if (i != 0)                    {                      OSIP_TRACE (osip_trace                                  (__FILE__, __LINE__, OSIP_ERROR, NULL,                                   "Cannot replace the dialog.\r\n"));                  } else                    {                      OSIP_TRACE (osip_trace                                  (__FILE__, __LINE__, OSIP_WARNING, NULL,                                   "The dialog has been replaced with the new one from 1xx.\r\n"));                    }                }#endif            }        }      if (jd != NULL)        jd->d_STATE = JD_TRYING;      if (jd != NULL && MSG_IS_RESPONSE_FOR (sip, "INVITE")          && sip->status_code < 180)        {          report_call_event (EXOSIP_CALL_PROCEEDING, jc, jd, tr);      } else if (jd != NULL && MSG_IS_RESPONSE_FOR (sip, "INVITE")                 && sip->status_code >= 180)        {          report_call_event (EXOSIP_CALL_RINGING, jc, jd, tr);        }#ifndef MINISIZE

⌨️ 快捷键说明

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