Ignore:
Timestamp:
Oct 24, 2011 9:28:13 AM (13 years ago)
Author:
ming
Message:

Re #1395: Backport of PJSIP 1.x branch into PJSIP 2.0 trunk

TODO: ticket #1268 (Option for automatic/manual sending of RTCP SDES/BYE for the stream) for video stream.

Location:
pjproject/trunk
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • pjproject/trunk

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

    r3796 r3841  
    972972    options |= PJSIP_INV_SUPPORT_100REL; 
    973973    options |= PJSIP_INV_SUPPORT_TIMER; 
    974     if (pjsua_var.acc[acc_id].cfg.require_100rel) 
     974    if (pjsua_var.acc[acc_id].cfg.require_100rel == PJSUA_100REL_MANDATORY) 
    975975        options |= PJSIP_INV_REQUIRE_100REL; 
    976976    if (pjsua_var.media_cfg.enable_ice) 
     
    10461046    { 
    10471047        options &= ~(PJSIP_INV_SUPPORT_TIMER); 
     1048    } 
     1049 
     1050    /* If 100rel is optional and UAC supports it, use it. */ 
     1051    if ((options & PJSIP_INV_REQUIRE_100REL)==0 && 
     1052        pjsua_var.acc[acc_id].cfg.require_100rel == PJSUA_100REL_OPTIONAL) 
     1053    { 
     1054        const pj_str_t token = { "100rel", 6}; 
     1055        pjsip_dialog_cap_status cap_status; 
     1056 
     1057        cap_status = pjsip_dlg_remote_has_cap(dlg, PJSIP_H_SUPPORTED, NULL, 
     1058                                              &token); 
     1059        if (cap_status == PJSIP_DIALOG_CAP_SUPPORTED) 
     1060            options |= PJSIP_INV_REQUIRE_100REL; 
    10481061    } 
    10491062 
     
    12891302 
    12901303    pj_gettimeofday(&time_start); 
     1304    timeout.sec = 0; 
    12911305    timeout.msec = PJSUA_ACQUIRE_CALL_TIMEOUT; 
    12921306    pj_time_val_normalize(&timeout); 
     
    13571371{ 
    13581372    pjsua_call *call; 
    1359     pjsua_conf_port_id port_id; 
    1360     pjsip_dialog *dlg; 
    1361     pj_status_t status; 
     1373    pjsua_conf_port_id port_id = PJSUA_INVALID_ID; 
    13621374 
    13631375    PJ_ASSERT_RETURN(call_id>=0 && call_id<(int)pjsua_var.ua_cfg.max_calls,  
    13641376                     PJ_EINVAL); 
    13651377 
    1366     status = acquire_call("pjsua_call_get_conf_port()", call_id, &call, &dlg); 
    1367     if (status != PJ_SUCCESS) 
    1368         return PJSUA_INVALID_ID; 
    1369  
     1378    /* Use PJSUA_LOCK() instead of acquire_call(): 
     1379     *  https://trac.pjsip.org/repos/ticket/1371 
     1380     */ 
     1381    PJSUA_LOCK(); 
     1382 
     1383    if (!pjsua_call_is_active(call_id)) 
     1384        goto on_return; 
     1385 
     1386    call = &pjsua_var.calls[call_id]; 
    13701387    port_id = call->media[call->audio_idx].strm.a.conf_slot; 
    13711388 
    1372     pjsip_dlg_dec_lock(dlg); 
     1389on_return: 
     1390    PJSUA_UNLOCK(); 
    13731391 
    13741392    return port_id; 
     
    13841402{ 
    13851403    pjsua_call *call; 
    1386     pjsip_dialog *dlg; 
    13871404    unsigned mi; 
    1388     pj_status_t status; 
    13891405 
    13901406    PJ_ASSERT_RETURN(call_id>=0 && call_id<(int)pjsua_var.ua_cfg.max_calls, 
     
    13931409    pj_bzero(info, sizeof(*info)); 
    13941410 
    1395     status = acquire_call("pjsua_call_get_info()", call_id, &call, &dlg); 
    1396     if (status != PJ_SUCCESS) { 
    1397         return status; 
     1411    /* Use PJSUA_LOCK() instead of acquire_call(): 
     1412     *  https://trac.pjsip.org/repos/ticket/1371 
     1413     */ 
     1414    PJSUA_LOCK(); 
     1415 
     1416    call = &pjsua_var.calls[call_id]; 
     1417 
     1418    if (!call->inv) { 
     1419        PJSUA_UNLOCK(); 
     1420        return PJSIP_ESESSIONTERMINATED; 
    13981421    } 
    13991422 
     
    15211544    } 
    15221545 
    1523     pjsip_dlg_dec_lock(dlg); 
     1546    PJSUA_UNLOCK(); 
    15241547 
    15251548    return PJ_SUCCESS; 
     
    19621985    pjsua_process_msg_data( tdata, msg_data); 
    19631986 
     1987    /* Record the tx_data to keep track the operation */ 
     1988    call->hold_msg = (void*) tdata; 
     1989 
    19641990    /* Send the request */ 
    19651991    status = pjsip_inv_send_msg( call->inv, tdata); 
    19661992    if (status != PJ_SUCCESS) { 
    19671993        pjsua_perror(THIS_FILE, "Unable to send re-INVITE", status); 
     1994        call->hold_msg = NULL; 
    19681995        goto on_return; 
    19691996    } 
     
    25322559    pj_log_push_indent(); 
    25332560 
    2534     PJSUA_LOCK(); 
     2561    // This may deadlock, see https://trac.pjsip.org/repos/ticket/1305 
     2562    //PJSUA_LOCK(); 
    25352563 
    25362564    for (i=0; i<pjsua_var.ua_cfg.max_calls; ++i) { 
     
    25392567    } 
    25402568 
    2541     PJSUA_UNLOCK(); 
     2569    //PJSUA_UNLOCK(); 
    25422570    pj_log_pop_indent(); 
    25432571} 
     
    39724000            } 
    39734001        } 
     4002    } else if (tsx->role == PJSIP_ROLE_UAC && 
     4003               tsx->last_tx == (pjsip_tx_data*)call->hold_msg && 
     4004               tsx->state >= PJSIP_TSX_STATE_COMPLETED) 
     4005    { 
     4006        /* Monitor the status of call hold request */ 
     4007        call->hold_msg = NULL; 
     4008        if (tsx->status_code/100 != 2) { 
     4009            /* Outgoing call hold failed */ 
     4010            call->local_hold = PJ_FALSE; 
     4011            PJ_LOG(3,(THIS_FILE, "Error putting call %d on hold (reason=%d)", 
     4012                      call->index, tsx->status_code)); 
     4013        } 
    39744014    } 
    39754015 
    39764016on_return: 
     4017 
    39774018    PJSUA_UNLOCK(); 
    39784019    pj_log_pop_indent(); 
Note: See TracChangeset for help on using the changeset viewer.