Ignore:
Timestamp:
Oct 1, 2010 2:03:42 AM (12 years ago)
Author:
bennylp
Message:

Closed #1142 (Account based configuration to specify if "c=0.0.0.0" method should be used when putting call on hold):

  • use PJSUA_CALL_HOLD_TYPE_DEFAULT to specify default global call hold type
  • use pjsua_acc_config.call_hold_type to specify call hold type for the account
  • call hold type can also be set on per call basis by changing the call_hold_type in the call structure (requires inclusion of <pjsua-lib/pjsua_internal.h>
File:
1 edited

Legend:

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

    r3305 r3330  
    8383/* Create SDP for call hold. */ 
    8484static pj_status_t create_sdp_of_call_hold(pjsua_call *call, 
    85                                            pjmedia_sdp_session **p_answer); 
     85                                           pjmedia_sdp_session **p_sdp); 
    8686 
    8787/* 
     
    405405    /* Associate session with account */ 
    406406    call->acc_id = acc_id; 
     407    call->call_hold_type = acc->cfg.call_hold_type; 
    407408 
    408409    /* Create temporary pool */ 
     
    759760     */ 
    760761    acc_id = call->acc_id = pjsua_acc_find_for_incoming(rdata); 
     762    call->call_hold_type = pjsua_var.acc[acc_id].cfg.call_hold_type; 
    761763 
    762764    /* Get call's secure level */ 
     
    35743576 
    35753577 
    3576 /* Create SDP for call hold. */ 
    3577 static pj_status_t create_sdp_of_call_hold(pjsua_call *call, 
    3578                                            pjmedia_sdp_session **p_answer) 
    3579 { 
    3580     pj_status_t status; 
    3581     pj_pool_t *pool; 
    3582     pjmedia_sdp_session *sdp; 
    3583  
    3584     /* Use call's provisional pool */ 
    3585     pool = call->inv->pool_prov; 
    3586  
    3587     /* Create new offer */ 
    3588     status = pjsua_media_channel_create_sdp(call->index, pool, NULL, &sdp,  
    3589                                             NULL); 
    3590     if (status != PJ_SUCCESS) { 
    3591         pjsua_perror(THIS_FILE, "Unable to create local SDP", status); 
    3592         return status; 
    3593     } 
    3594  
     3578/* Modify SDP for call hold. */ 
     3579static pj_status_t modify_sdp_of_call_hold(pjsua_call *call, 
     3580                                           pj_pool_t *pool, 
     3581                                           pjmedia_sdp_session *sdp) 
     3582{ 
    35953583    /* Call-hold is done by set the media direction to 'sendonly'  
    35963584     * (PJMEDIA_DIR_ENCODING), except when current media direction is  
     
    36013589       if (call->media_dir != PJMEDIA_DIR_ENCODING) { 
    36023590     */ 
    3603     if (1) { 
     3591    /* https://trac.pjsip.org/repos/ticket/1142: 
     3592     *  configuration to use c=0.0.0.0 for call hold. 
     3593     */ 
     3594    if (call->call_hold_type == PJSUA_CALL_HOLD_TYPE_RFC2543) { 
     3595        pjmedia_sdp_conn *conn; 
     3596        pjmedia_sdp_attr *attr; 
     3597 
     3598        /* Get SDP media connection line */ 
     3599        conn = sdp->media[0]->conn; 
     3600        if (!conn) 
     3601            conn = sdp->conn; 
     3602 
     3603        /* Modify address */ 
     3604        conn->addr = pj_str("0.0.0.0"); 
     3605 
     3606        /* Remove existing directions attributes */ 
     3607        pjmedia_sdp_media_remove_all_attr(sdp->media[0], "sendrecv"); 
     3608        pjmedia_sdp_media_remove_all_attr(sdp->media[0], "sendonly"); 
     3609        pjmedia_sdp_media_remove_all_attr(sdp->media[0], "recvonly"); 
     3610        pjmedia_sdp_media_remove_all_attr(sdp->media[0], "inactive"); 
     3611 
     3612        /* Add inactive attribute */ 
     3613        attr = pjmedia_sdp_attr_create(pool, "inactive", NULL); 
     3614        pjmedia_sdp_media_add_attr(sdp->media[0], attr); 
     3615 
     3616 
     3617    } else { 
    36043618        pjmedia_sdp_attr *attr; 
    36053619 
     
    36213635    } 
    36223636 
    3623     *p_answer = sdp; 
    3624  
    3625     return status; 
     3637    return PJ_SUCCESS; 
     3638} 
     3639 
     3640/* Create SDP for call hold. */ 
     3641static pj_status_t create_sdp_of_call_hold(pjsua_call *call, 
     3642                                           pjmedia_sdp_session **p_sdp) 
     3643{ 
     3644    pj_status_t status; 
     3645    pj_pool_t *pool; 
     3646    pjmedia_sdp_session *sdp; 
     3647 
     3648    /* Use call's provisional pool */ 
     3649    pool = call->inv->pool_prov; 
     3650 
     3651    /* Create new offer */ 
     3652    status = pjsua_media_channel_create_sdp(call->index, pool, NULL, &sdp, 
     3653                                            NULL); 
     3654    if (status != PJ_SUCCESS) { 
     3655        pjsua_perror(THIS_FILE, "Unable to create local SDP", status); 
     3656        return status; 
     3657    } 
     3658 
     3659    status = modify_sdp_of_call_hold(call, pool, sdp); 
     3660    if (status != PJ_SUCCESS) 
     3661        return status; 
     3662 
     3663    *p_sdp = sdp; 
     3664 
     3665    return PJ_SUCCESS; 
    36263666} 
    36273667 
     
    36683708    /* Check if call is on-hold */ 
    36693709    if (call->local_hold) { 
    3670         pjmedia_sdp_attr *attr; 
    3671  
    3672         /* Remove existing directions attributes */ 
    3673         pjmedia_sdp_media_remove_all_attr(answer->media[0], "sendrecv"); 
    3674         pjmedia_sdp_media_remove_all_attr(answer->media[0], "sendonly"); 
    3675         pjmedia_sdp_media_remove_all_attr(answer->media[0], "recvonly"); 
    3676         pjmedia_sdp_media_remove_all_attr(answer->media[0], "inactive"); 
    3677  
    3678         /* Keep call on-hold by setting 'sendonly' attribute. 
    3679          * (See RFC 3264 Section 8.4 and RFC 4317 Section 3.1) 
    3680          */ 
    3681         attr = pjmedia_sdp_attr_create(call->inv->pool_prov, "sendonly", NULL); 
    3682         pjmedia_sdp_media_add_attr(answer->media[0], attr); 
     3710        modify_sdp_of_call_hold(call, call->inv->pool_prov, answer); 
    36833711    } 
    36843712 
Note: See TracChangeset for help on using the changeset viewer.