Ticket #817: pjsip-2830-allow_cancel_reinvite.patch
File pjsip-2830-allow_cancel_reinvite.patch, 3.2 KB (added by bennylp, 13 years ago) |
---|
-
pjsip/include/pjsip-ua/sip_inv.h
687 687 688 688 689 689 690 /** 691 * Creates a CANCEL request for an ongoing re-INVITE transaction. 692 * 693 * @param inv The invite session. 694 * @param p_tdata Pointer to receive the message to be created. Note 695 * that it's possible to receive NULL here while the 696 * function returns PJ_SUCCESS, see the description. 697 * 698 * @return PJ_SUCCESS if termination is initiated. 699 */ 700 PJ_DECL(pj_status_t) pjsip_inv_cancel_reinvite( pjsip_inv_session *inv, 701 pjsip_tx_data **p_tdata ); 702 703 704 705 690 706 /** 691 707 * Create a re-INVITE request. 692 708 * -
pjsip/src/pjsip-ua/sip_inv.c
1936 1936 return PJ_SUCCESS; 1937 1937 } 1938 1938 1939 /* 1940 * Cancel re-INVITE transaction. 1941 */ 1942 PJ_DEF(pj_status_t) pjsip_inv_cancel_reinvite( pjsip_inv_session *inv, 1943 pjsip_tx_data **p_tdata ) 1944 { 1945 pjsip_tx_data *tdata; 1946 pj_status_t status; 1947 1948 /* Verify arguments. */ 1949 PJ_ASSERT_RETURN(inv && p_tdata, PJ_EINVAL); 1950 1951 /* Create appropriate message. */ 1952 switch (inv->state) { 1953 case PJSIP_INV_STATE_CONFIRMED: 1954 /* MUST have the original UAC INVITE transaction */ 1955 PJ_ASSERT_RETURN(inv->invite_tsx != NULL, PJ_EBUG); 1956 1957 /* CANCEL should only be called when we have received a 1958 * provisional response. If we haven't received any responses, 1959 * just destroy the transaction. 1960 */ 1961 if (inv->invite_tsx->status_code < 100) { 1962 inv->pending_cancel = PJ_TRUE; 1963 *p_tdata = NULL; 1964 PJ_LOG(4, (inv->obj_name, "Delaying CANCEL since no " 1965 "provisional response is received yet")); 1966 return PJ_SUCCESS; 1967 } 1968 1969 status = pjsip_endpt_create_cancel(inv->dlg->endpt, 1970 inv->invite_tsx->last_tx, 1971 &tdata); 1972 if (status != PJ_SUCCESS) 1973 return status; 1974 break; 1975 1976 default: 1977 /* We can send a CANCEL to a re-INVITE if the INVITE session is not confirmed. */ 1978 status = PJ_FALSE; 1979 break; 1980 } 1981 1982 if (status != PJ_SUCCESS) 1983 return status; 1984 1985 *p_tdata = tdata; 1986 return PJ_SUCCESS; 1987 } 1988 1939 1989 /* Following redirection recursion, get next target from the target set and 1940 1990 * notify user. 1941 1991 * … … 3746 3796 /* Save pending invite transaction */ 3747 3797 inv->invite_tsx = tsx; 3748 3798 3799 } else if (tsx->state == PJSIP_TSX_STATE_PROCEEDING) { 3800 3801 /* CANCEL the re-INVITE if necessary */ 3802 if (inv->pending_cancel) { 3803 pj_status_t status; 3804 pjsip_tx_data *cancel; 3805 3806 inv->pending_cancel = PJ_FALSE; 3807 3808 status = pjsip_inv_cancel_reinvite(inv, &cancel); 3809 if (status == PJ_SUCCESS && cancel) 3810 status = pjsip_inv_send_msg(inv, cancel); 3811 } 3812 3749 3813 } else if (tsx->state == PJSIP_TSX_STATE_TERMINATED && 3750 3814 tsx->status_code/100 == 2) 3751 3815 {