pjsip_inv_set_local_sdp(session->inv_session, offer);
pjmedia_sdp_neg_set_prefer_remote_codec_order(session->inv_session->neg, PJ_FALSE);
+#ifdef PJMEDIA_SDP_NEG_ANSWER_MULTIPLE_CODECS
+ pjmedia_sdp_neg_set_answer_multiple_codecs(session->inv_session->neg, PJ_TRUE);
+#endif
if (pjsip_inv_invite(session->inv_session, tdata) != PJ_SUCCESS) {
return -1;
}
return NULL;
}
- if (!(dlg = ast_sip_create_dialog(endpoint, uri, request_user))) {
+ if (!(dlg = ast_sip_create_dialog_uac(endpoint, uri, request_user))) {
return NULL;
}
}
return NULL;
}
- if (pjsip_dlg_create_uas(pjsip_ua_instance(), rdata, NULL, &dlg) != PJ_SUCCESS) {
+ dlg = ast_sip_create_dialog_uas(endpoint, rdata);
+ if (!dlg) {
pjsip_endpt_respond_stateless(ast_sip_get_pjsip_endpoint(), rdata, 500, NULL, NULL, NULL);
return NULL;
}
} else {
pjsip_inv_set_local_sdp(invite->session->inv_session, local);
pjmedia_sdp_neg_set_prefer_remote_codec_order(invite->session->inv_session->neg, PJ_FALSE);
+#ifdef PJMEDIA_SDP_NEG_ANSWER_MULTIPLE_CODECS
+ pjmedia_sdp_neg_set_answer_multiple_codecs(invite->session->inv_session->neg, PJ_TRUE);
+#endif
}
pjsip_timer_setting_default(&timer);
break;
case PJSIP_EVENT_RX_MSG:
if (tsx->method.id == PJSIP_INVITE_METHOD) {
- if (tsx->role == PJSIP_ROLE_UAC && tsx->state == PJSIP_TSX_STATE_COMPLETED) {
- /* This means we got a non 2XX final response to our outgoing INVITE */
- if (tsx->status_code == PJSIP_SC_REQUEST_PENDING) {
- reschedule_reinvite(session, tsx->mod_data[session_module.id], tsx->last_tx);
- return;
- } else if (inv->state == PJSIP_INV_STATE_CONFIRMED &&
- tsx->status_code != 488) {
- /* Other reinvite failures (except 488) result in destroying the session. */
- pjsip_tx_data *tdata;
- if (pjsip_inv_end_session(inv, 500, NULL, &tdata) == PJ_SUCCESS) {
- ast_sip_session_send_request(session, tdata);
+ if (tsx->role == PJSIP_ROLE_UAC) {
+ if (tsx->state == PJSIP_TSX_STATE_COMPLETED) {
+ /* This means we got a non 2XX final response to our outgoing INVITE */
+ if (tsx->status_code == PJSIP_SC_REQUEST_PENDING) {
+ reschedule_reinvite(session, tsx->mod_data[session_module.id], tsx->last_tx);
+ return;
+ } else if (inv->state == PJSIP_INV_STATE_CONFIRMED &&
+ tsx->status_code != 488) {
+ /* Other reinvite failures (except 488) result in destroying the session. */
+ pjsip_tx_data *tdata;
+ if (pjsip_inv_end_session(inv, 500, NULL, &tdata) == PJ_SUCCESS) {
+ ast_sip_session_send_request(session, tdata);
+ }
+ }
+ } else if (tsx->state == PJSIP_TSX_STATE_TERMINATED) {
+ if (inv->cancelling && tsx->status_code == PJSIP_SC_OK) {
+ /* This is a race condition detailed in RFC 5407 section 3.1.2.
+ * We sent a CANCEL at the same time that the UAS sent us a 200 OK for
+ * the original INVITE. As a result, we have now received a 200 OK for
+ * a cancelled call. Our role is to immediately send a BYE to end the
+ * dialog.
+ */
+ pjsip_tx_data *tdata;
+
+ if (pjsip_inv_end_session(inv, 500, NULL, &tdata) == PJ_SUCCESS) {
+ ast_sip_session_send_request(session, tdata);
+ }
}
}
}