Changeset 3903 for pjproject


Ignore:
Timestamp:
Dec 8, 2011 8:18:02 AM (12 years ago)
Author:
nanang
Message:

Re #1419: updated call transfer to allow both the transferee and the transfer destination to update the current call setting:

  • for transferee (attended & unattended): via new PJSUA-LIB callback on_call_transfer_request2()
  • for transfer destination (attended only): via new PJSUA-LIB callback on_call_replace_request2()
Location:
pjproject/trunk/pjsip
Files:
2 edited

Legend:

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

    r3901 r3903  
    567567 
    568568/** 
     569 * Call settings. 
     570 */ 
     571typedef struct pjsua_call_setting 
     572{ 
     573    /** 
     574     * Bitmask of #pjsua_call_flag constants. 
     575     * 
     576     * Default: 0 
     577     */ 
     578    unsigned         flag; 
     579 
     580    /** 
     581     * This flag controls what methods to request keyframe are allowed on 
     582     * the call. Value is bitmask of #pjsua_vid_req_keyframe_method. 
     583     */ 
     584    unsigned         req_keyframe_method; 
     585 
     586    /** 
     587     * Number of simultaneous active audio streams for this call. Setting 
     588     * this to zero will disable audio in this call. 
     589     * 
     590     * Default: 1 
     591     */ 
     592    unsigned         audio_cnt; 
     593 
     594    /** 
     595     * Number of simultaneous active video streams for this call. Setting 
     596     * this to zero will disable video in this call. 
     597     * 
     598     * Default: 1 (if video feature is enabled, otherwise it is zero) 
     599     */ 
     600    unsigned         video_cnt; 
     601 
     602} pjsua_call_setting; 
     603 
     604 
     605/** 
    569606 * This structure describes application callback to receive various event 
    570607 * notification from PJSUA-API. All of these callbacks are OPTIONAL, 
     
    666703     * by setting the code (default is 202). When this callback 
    667704     * is not defined, the default behavior is to accept the 
    668      * transfer. 
     705     * transfer. See also on_call_transfer_request2() callback for 
     706     * the version with \a pjsua_call_setting in the argument list. 
    669707     * 
    670708     * @param call_id   The call index. 
     
    677715                                     const pj_str_t *dst, 
    678716                                     pjsip_status_code *code); 
     717 
     718    /** 
     719     * Notify application on call being transfered (i.e. REFER is received). 
     720     * Application can decide to accept/reject transfer request 
     721     * by setting the code (default is 202). When this callback 
     722     * is not defined, the default behavior is to accept the 
     723     * transfer. 
     724     * 
     725     * @param call_id   The call index. 
     726     * @param dst       The destination where the call will be  
     727     *                  transfered to. 
     728     * @param code      Status code to be returned for the call transfer 
     729     *                  request. On input, it contains status code 200. 
     730     * @param opt       The current call setting, application can update 
     731     *                  this setting for the call being transfered. 
     732     */ 
     733    void (*on_call_transfer_request2)(pjsua_call_id call_id, 
     734                                      const pj_str_t *dst, 
     735                                      pjsip_status_code *code, 
     736                                      pjsua_call_setting *opt); 
    679737 
    680738    /** 
     
    704762     * Notify application about incoming INVITE with Replaces header. 
    705763     * Application may reject the request by setting non-2xx code. 
     764     * See also on_call_replace_request2() callback for the version 
     765     * with \a pjsua_call_setting in the argument list. 
    706766     * 
    707767     * @param call_id       The call ID to be replaced. 
     
    715775                                    int *st_code, 
    716776                                    pj_str_t *st_text); 
     777 
     778    /** 
     779     * Notify application about incoming INVITE with Replaces header. 
     780     * Application may reject the request by setting non-2xx code. 
     781     * 
     782     * @param call_id       The call ID to be replaced. 
     783     * @param rdata         The incoming INVITE request to replace the call. 
     784     * @param st_code       Status code to be set by application. Application 
     785     *                      should only return a final status (200-699). 
     786     * @param st_text       Optional status text to be set by application. 
     787     * @param opt           The current call setting, application can update 
     788     *                      this setting for the call being replaced. 
     789     */ 
     790    void (*on_call_replace_request2)(pjsua_call_id call_id, 
     791                                     pjsip_rx_data *rdata, 
     792                                     int *st_code, 
     793                                     pj_str_t *st_text, 
     794                                     pjsua_call_setting *opt); 
    717795 
    718796    /** 
     
    34053483 
    34063484/** 
    3407  * Call settings. 
    3408  */ 
    3409 typedef struct pjsua_call_setting 
    3410 { 
    3411     /** 
    3412      * Bitmask of #pjsua_call_flag constants. 
    3413      * 
    3414      * Default: 0 
    3415      */ 
    3416     unsigned         flag; 
    3417  
    3418     /** 
    3419      * This flag controls what methods to request keyframe are allowed on 
    3420      * the call. Value is bitmask of #pjsua_vid_req_keyframe_method. 
    3421      */ 
    3422     unsigned         req_keyframe_method; 
    3423  
    3424     /** 
    3425      * Number of simultaneous active audio streams for this call. Setting 
    3426      * this to zero will disable audio in this call. 
    3427      * 
    3428      * Default: 1 
    3429      */ 
    3430     unsigned         audio_cnt; 
    3431  
    3432     /** 
    3433      * Number of simultaneous active video streams for this call. Setting 
    3434      * this to zero will disable video in this call. 
    3435      * 
    3436      * Default: 1 (if video feature is enabled, otherwise it is zero) 
    3437      */ 
    3438     unsigned         video_cnt; 
    3439  
    3440 } pjsua_call_setting; 
    3441  
    3442  
    3443 /** 
    34443485 * This structure describes the information and current status of a call. 
    34453486 */ 
     
    40674108 * 
    40684109 * @param call_id       Call identification. 
    4069  * @param opt           Optional call setting. 
     4110 * @param opt           Optional call setting, if NULL, the current call 
     4111 *                      setting will remain unchanged. 
    40704112 * @param msg_data      Optional message components to be sent with 
    40714113 *                      the request. 
     
    40974139 * 
    40984140 * @param call_id       Call identification. 
    4099  * @param opt           Optional call setting. 
     4141 * @param opt           Optional call setting, if NULL, the current call 
     4142 *                      setting will remain unchanged. 
    41004143 * @param msg_data      Optional message components to be sent with 
    41014144 *                      the request. 
  • pjproject/trunk/pjsip/src/pjsua-lib/pjsua_call.c

    r3901 r3903  
    965965     * if it wants to. 
    966966     */ 
    967     if (replaced_dlg != NULL && pjsua_var.ua_cfg.cb.on_call_replace_request) { 
     967    if (replaced_dlg != NULL && 
     968        (pjsua_var.ua_cfg.cb.on_call_replace_request || 
     969         pjsua_var.ua_cfg.cb.on_call_replace_request2)) 
     970    { 
    968971        pjsua_call *replaced_call; 
    969972        int st_code = 200; 
     
    973976        replaced_call = (pjsua_call*) replaced_dlg->mod_data[pjsua_var.mod.id]; 
    974977 
     978        /* Copy call setting from the replaced call */ 
     979        call->opt = replaced_call->opt; 
     980 
    975981        /* Notify application */ 
    976         pjsua_var.ua_cfg.cb.on_call_replace_request(replaced_call->index, 
    977                                                     rdata, &st_code, &st_text); 
     982        if (pjsua_var.ua_cfg.cb.on_call_replace_request) { 
     983            pjsua_var.ua_cfg.cb.on_call_replace_request(replaced_call->index, 
     984                                                        rdata, 
     985                                                        &st_code, &st_text); 
     986        } 
     987 
     988        if (pjsua_var.ua_cfg.cb.on_call_replace_request2) { 
     989            pjsua_var.ua_cfg.cb.on_call_replace_request2(replaced_call->index, 
     990                                                         rdata, 
     991                                                         &st_code, &st_text, 
     992                                                         &call->opt); 
     993        } 
    978994 
    979995        /* Must specify final response */ 
     
    38753891    pjsip_status_code code; 
    38763892    pjsip_evsub *sub; 
     3893    pjsua_call_setting call_opt; 
    38773894 
    38783895    pj_log_push_indent(); 
     
    39113928    /* Notify callback */ 
    39123929    code = PJSIP_SC_ACCEPTED; 
    3913     if (pjsua_var.ua_cfg.cb.on_call_transfer_request) 
     3930    if (pjsua_var.ua_cfg.cb.on_call_transfer_request) { 
    39143931        (*pjsua_var.ua_cfg.cb.on_call_transfer_request)(existing_call->index, 
    39153932                                                        &refer_to->hvalue,  
    39163933                                                        &code); 
     3934    } 
     3935 
     3936    call_opt = existing_call->opt; 
     3937    if (pjsua_var.ua_cfg.cb.on_call_transfer_request2) { 
     3938        (*pjsua_var.ua_cfg.cb.on_call_transfer_request2)(existing_call->index, 
     3939                                                         &refer_to->hvalue,  
     3940                                                         &code, 
     3941                                                         &call_opt); 
     3942    } 
    39173943 
    39183944    if (code < 200) 
     
    40414067    /* Now make the outgoing call. */ 
    40424068    tmp = pj_str(uri); 
    4043     status = pjsua_call_make_call(existing_call->acc_id, &tmp, 0, 
     4069    status = pjsua_call_make_call(existing_call->acc_id, &tmp, &call_opt, 
    40444070                                  existing_call->user_data, &msg_data,  
    40454071                                  &new_call); 
Note: See TracChangeset for help on using the changeset viewer.