Changeset 3330 for pjproject


Ignore:
Timestamp:
Oct 1, 2010 2:03:42 AM (14 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>
Location:
pjproject/trunk/pjsip
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • pjproject/trunk/pjsip/include/pjsua-lib/pjsua.h

    r3326 r3330  
    20422042 
    20432043/** 
     2044 * This enumeration specifies how we should offer call hold request to 
     2045 * remote peer. The default value is set by compile time constant 
     2046 * PJSUA_CALL_HOLD_TYPE_DEFAULT, and application may control the setting 
     2047 * on per-account basis by manipulating \a call_hold_type field in 
     2048 * #pjsua_acc_config. 
     2049 */ 
     2050typedef enum pjsua_call_hold_type 
     2051{ 
     2052    /** 
     2053     * This will follow RFC 3264 recommendation to use a=sendonly, 
     2054     * a=recvonly, and a=inactive attribute as means to signal call 
     2055     * hold status. This is the correct value to use. 
     2056     */ 
     2057    PJSUA_CALL_HOLD_TYPE_RFC3264, 
     2058 
     2059    /** 
     2060     * This will use the old and deprecated method as specified in RFC 2543, 
     2061     * and will offer c=0.0.0.0 in the SDP instead. Using this has many 
     2062     * drawbacks such as inability to keep the media transport alive while 
     2063     * the call is being put on hold, and should only be used if remote 
     2064     * does not understand RFC 3264 style call hold offer. 
     2065     */ 
     2066    PJSUA_CALL_HOLD_TYPE_RFC2543 
     2067 
     2068} pjsua_call_hold_type; 
     2069 
     2070 
     2071/** 
     2072 * Specify the default call hold type to be used in #pjsua_acc_config. 
     2073 * 
     2074 * Default is PJSUA_CALL_HOLD_TYPE_RFC3264, and there's no reason to change 
     2075 * this except if you're communicating with an old/non-standard peer. 
     2076 */ 
     2077#ifndef PJSUA_CALL_HOLD_TYPE_DEFAULT 
     2078#   define PJSUA_CALL_HOLD_TYPE_DEFAULT         PJSUA_CALL_HOLD_TYPE_RFC3264 
     2079#endif 
     2080 
     2081 
     2082/** 
    20442083 * This structure describes account configuration to be specified when 
    20452084 * adding a new account with #pjsua_acc_add(). Application MUST initialize 
     
    23702409    pj_bool_t        use_stream_ka; 
    23712410#endif 
     2411 
     2412    /** 
     2413     * Specify how to offer call hold to remote peer. Please see the 
     2414     * documentation on #pjsua_call_hold_type for more info. 
     2415     * 
     2416     * Default: PJSUA_CALL_HOLD_TYPE_DEFAULT 
     2417     */ 
     2418    pjsua_call_hold_type call_hold_type; 
    23722419 
    23732420} pjsua_acc_config; 
  • pjproject/trunk/pjsip/include/pjsua-lib/pjsua_internal.h

    r3216 r3330  
    6262    pjsua_acc_id         acc_id;    /**< Account index being used.          */ 
    6363    int                  secure_level;/**< Signaling security level.        */ 
     64    pjsua_call_hold_type call_hold_type; /**< How to do call hold.          */ 
    6465    pj_bool_t            local_hold;/**< Flag for call-hold by local.       */ 
    6566    pjsua_call_media_status media_st;/**< Media state.                      */ 
  • 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 
  • pjproject/trunk/pjsip/src/pjsua-lib/pjsua_core.c

    r3326 r3330  
    190190#endif 
    191191    pj_list_init(&cfg->reg_hdr_list); 
     192    cfg->call_hold_type = PJSUA_CALL_HOLD_TYPE_DEFAULT; 
    192193} 
    193194 
Note: See TracChangeset for help on using the changeset viewer.