Ignore:
Timestamp:
Sep 22, 2006 12:48:18 PM (18 years ago)
Author:
bennylp
Message:

In pjsua, outgoing REFER now always put Refer-Sub: false

File:
1 edited

Legend:

Unmodified
Added
Removed
  • pjproject/trunk/pjsip/src/pjsua-lib/pjsua_call.c

    r729 r733  
    6868                                       pjmedia_sdp_session **p_answer); 
    6969 
     70/* 
     71 * Callback called by event framework when the xfer subscription state 
     72 * has changed. 
     73 */ 
     74static void xfer_on_evsub_state( pjsip_evsub *sub, pjsip_event *event); 
    7075 
    7176/* 
     
    581586    enum { MAX_RETRY=50 }; 
    582587    unsigned retry; 
    583     pjsua_call *call; 
    584     pj_bool_t has_pjsua_lock; 
    585     pj_status_t status; 
     588    pjsua_call *call = NULL; 
     589    pj_bool_t has_pjsua_lock = PJ_FALSE; 
     590    pj_status_t status = PJ_SUCCESS; 
    586591 
    587592    for (retry=0; retry<MAX_RETRY; ++retry) { 
     
    648653    status = acquire_call("pjsua_call_get_conf_port()", call_id, &call); 
    649654    if (status != PJ_SUCCESS) 
    650         return -1; 
     655        return PJSUA_INVALID_ID; 
    651656 
    652657    port_id = call->conf_slot; 
     
    10501055    pjsip_tx_data *tdata; 
    10511056    pjsua_call *call; 
     1057    struct pjsip_evsub_user xfer_cb; 
    10521058    pj_status_t status; 
    10531059 
     
    10561062                     PJ_EINVAL); 
    10571063     
    1058     pjsip_dlg_dec_lock(call->inv->dlg); 
    10591064    status = acquire_call("pjsua_call_xfer()", call_id, &call); 
    10601065    if (status != PJ_SUCCESS) 
     
    10621067 
    10631068    
    1064     /* Create xfer client subscription. 
    1065      * We're not interested in knowing the transfer result, so we 
    1066      * put NULL as the callback. 
    1067      */ 
    1068     status = pjsip_xfer_create_uac(call->inv->dlg, NULL, &sub); 
     1069    /* Create xfer client subscription. */ 
     1070    pj_bzero(&xfer_cb, sizeof(xfer_cb)); 
     1071    xfer_cb.on_evsub_state = &xfer_on_evsub_state; 
     1072 
     1073    status = pjsip_xfer_create_uac(call->inv->dlg, &xfer_cb, &sub); 
    10691074    if (status != PJ_SUCCESS) { 
    10701075        pjsua_perror(THIS_FILE, "Unable to create xfer", status); 
     
    11211126    if (status != PJ_SUCCESS) 
    11221127        return status; 
    1123  
    1124     call = &pjsua_var.calls[call_id]; 
    11251128 
    11261129    if (!call->session) { 
     
    21312134 
    21322135    /* 
    2133      * We're only interested when subscription is terminated, to  
    2134      * clear the xfer_sub member of the inv_data. 
     2136     * When subscription is terminated, clear the xfer_sub member of  
     2137     * the inv_data. 
    21352138     */ 
    21362139    if (pjsip_evsub_get_state(sub) == PJSIP_EVSUB_STATE_TERMINATED) { 
     
    21442147        call->xfer_sub = NULL; 
    21452148 
    2146         PJ_LOG(3,(THIS_FILE, "Xfer subscription terminated")); 
     2149        PJ_LOG(4,(THIS_FILE, "Xfer subscription terminated")); 
     2150 
     2151    } 
     2152    /* 
     2153     * When subscription is accepted (got 200/OK to REFER), check if  
     2154     * subscription suppressed. 
     2155     */ 
     2156    else if (pjsip_evsub_get_state(sub) == PJSIP_EVSUB_STATE_ACCEPTED) { 
     2157 
     2158        pjsip_rx_data *rdata; 
     2159        pjsip_generic_string_hdr *refer_sub; 
     2160        const pj_str_t REFER_SUB = { "Refer-Sub", 9 }; 
     2161 
     2162        /* Must be receipt of response message */ 
     2163        pj_assert(event->type == PJSIP_EVENT_TSX_STATE &&  
     2164                  event->body.tsx_state.type == PJSIP_EVENT_RX_MSG); 
     2165        rdata = event->body.tsx_state.src.rdata; 
     2166 
     2167        /* Find Refer-Sub header */ 
     2168        refer_sub = (pjsip_generic_string_hdr*) 
     2169                    pjsip_msg_find_hdr_by_name(rdata->msg_info.msg,  
     2170                                               &REFER_SUB, NULL); 
     2171 
     2172        /* Check if subscription is suppressed */ 
     2173        if (refer_sub && pj_stricmp2(&refer_sub->hvalue, "false")==0) { 
     2174            /* Yes, subscription is suppressed. 
     2175             * Terminate our subscription now. 
     2176             */ 
     2177            PJ_LOG(4,(THIS_FILE, "Xfer subscription suppressed, terminating " 
     2178                                 "event subcription...")); 
     2179            pjsip_evsub_terminate(sub, PJ_TRUE); 
     2180        } 
    21472181    } 
    21482182} 
Note: See TracChangeset for help on using the changeset viewer.