📄 jcallback.c
字号:
#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 (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 else if (jd != NULL && MSG_IS_RESPONSE_FOR (sip, "SUBSCRIBE")) { eXosip_event_t *je; je = eXosip_event_init_for_subscribe (EXOSIP_SUBSCRIPTION_PROCEEDING, js, jd, tr); report_event (je, sip); }#endif if (MSG_TEST_CODE (sip, 180) && jd != NULL) { jd->d_STATE = JD_RINGING; } else if (MSG_TEST_CODE (sip, 183) && jd != NULL) { jd->d_STATE = JD_QUEUED; } }}static voidcb_rcv2xx_4invite (osip_transaction_t * tr, osip_message_t * sip){ int i; eXosip_dialog_t *jd; eXosip_call_t *jc; jinfo_t *jinfo = (jinfo_t *) osip_transaction_get_your_instance (tr); if (jinfo == NULL) return; jd = jinfo->jd; jc = jinfo->jc; 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; } ADD_ELEMENT (jc->c_dialogs, jd); jinfo->jd = jd; eXosip_update (); osip_transaction_set_your_instance (tr, jinfo); } else { /* Here is a special case: We have initiated a dialog and we have received informationnal answers from 2 or more remote SIP UA. Those answer can be differentiated with the "To" header's tag. We have used the first informationnal answer to create a dialog, but we now want to be sure the 200ok received is for the dialog this dialog. We have to check the To tag and if it does not match, we just have to modify the existing dialog and replace it. */ osip_generic_param_t *tag; int i; i = osip_to_get_tag (sip->to, &tag); i = 1; /* default is the same dialog */ if (jd->d_dialog == NULL || jd->d_dialog->remote_tag == NULL) { /* There are real use-case where a BYE is received/processed before the 200ok of the previous INVITE. In this case, jd->d_dialog is empty and the transaction should be silently discarded. */ /* a ACK should still be sent... -but there is no dialog built- */ return; } if (jd->d_dialog->remote_tag == NULL && tag == NULL) { } /* non compliant remote UA -> assume it is the same dialog */ else if (jd->d_dialog->remote_tag != NULL && tag == NULL) { i = 0; } /* different dialog! */ else if (jd->d_dialog->remote_tag == NULL && tag != NULL) { i = 0; } /* different dialog! */ else if (jd->d_dialog->remote_tag != NULL && tag != NULL && tag->gvalue != NULL && 0 != strcmp (jd->d_dialog->remote_tag, tag->gvalue)) { i = 0; } /* different dialog! */ if (i == 1) /* just update the dialog */ { osip_dialog_update_route_set_as_uac (jd->d_dialog, sip); if (jd->d_dialog->remote_tag==NULL) osip_dialog_update_tag_as_uac (jd->d_dialog, sip); osip_dialog_set_state (jd->d_dialog, DIALOG_CONFIRMED); } 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 fro 200ok.\r\n")); } } } jd->d_STATE = JD_ESTABLISHED; /* eXosip_dialog_set_200ok (jd, sip); */ report_call_event (EXOSIP_CALL_ANSWERED, jc, jd, tr); /* look for the SDP information and decide if this answer was for an initial INVITE, an HoldCall, or a RetreiveCall */ /* don't handle hold/unhold by now... */ /* eXosip_update_audio_session(tr); */}#ifndef MINISIZEstatic voidcb_rcv2xx_4subscribe (osip_transaction_t * tr, osip_message_t * sip){ int i; eXosip_dialog_t *jd; eXosip_subscribe_t *js; jinfo_t *jinfo = (jinfo_t *) osip_transaction_get_your_instance (tr); if (jinfo == NULL) return; jd = jinfo->jd; js = jinfo->js; _eXosip_subscribe_set_refresh_interval (js, sip); /* 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; } } } } if (jd == NULL) /* This transaction initiate a dialog in the case of SUBSCRIBE (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; } ADD_ELEMENT (js->s_dialogs, jd); jinfo->jd = jd; eXosip_update (); osip_transaction_set_your_instance (tr, jinfo); } else { osip_dialog_update_route_set_as_uac (jd->d_dialog, sip); if (jd->d_dialog->remote_tag==NULL) osip_dialog_update_tag_as_uac (jd->d_dialog, sip); osip_dialog_set_state (jd->d_dialog, DIALOG_CONFIRMED); } jd->d_STATE = JD_ESTABLISHED; /* look for the body information */ { eXosip_event_t *je; je = eXosip_event_init_for_subscribe (EXOSIP_SUBSCRIPTION_ANSWERED, js, jd, tr); report_event (je, sip); }}#endifstatic voidcb_rcv2xx (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_rcv2xx (id=%i)\r\n", tr->transactionid)); udp_tl_learn_port_from_via(sip);#ifndef MINISIZE if (MSG_IS_RESPONSE_FOR (sip, "PUBLISH")) { eXosip_pub_t *pub; eXosip_event_t *je; int i; i = _eXosip_pub_update (&pub, tr, sip); if (i != 0) { OSIP_TRACE (osip_trace (__FILE__, __LINE__, OSIP_ERROR, NULL, "cb_rcv2xx (id=%i) No publication to update\r\n", tr->transactionid)); } je = eXosip_event_init_for_message (EXOSIP_MESSAGE_ANSWERED, tr); report_event (je, sip); return; } else#endif if (MSG_IS_RESPONSE_FOR (sip, "REGISTER")) { eXosip_event_t *je; eXosip_reg_t *jreg = NULL;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -