Changeset 1122


Ignore:
Timestamp:
Apr 2, 2007 11:22:49 AM (17 years ago)
Author:
bennylp
Message:

Added PJSUA API to create request using account config

Location:
pjproject/branches/pjproject-0.5-stable
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • pjproject/branches/pjproject-0.5-stable/pjsip-apps/src/pjsua/pjsua_app.c

    r1043 r1122  
    20822082    pjsip_method method; 
    20832083    pjsip_tx_data *tdata; 
    2084     pjsua_acc_info acc_info; 
    20852084    pjsip_endpoint *endpt; 
    20862085    pj_status_t status; 
     
    20912090    pjsip_method_init_np(&method, &str_method); 
    20922091 
    2093     pjsua_acc_get_info(current_acc, &acc_info); 
    2094  
    2095     status = pjsip_endpt_create_request(endpt, &method, dst_uri,  
    2096                                         &acc_info.acc_uri, dst_uri, 
    2097                                         NULL, NULL, -1, NULL, &tdata); 
    2098     if (status != PJ_SUCCESS) { 
    2099         pjsua_perror(THIS_FILE, "Unable to create request", status); 
    2100         return; 
    2101     } 
     2092    status = pjsua_acc_create_request(current_acc, &method, dst_uri, &tdata); 
    21022093 
    21032094    status = pjsip_endpt_send_request(endpt, tdata, -1, NULL, NULL); 
  • pjproject/branches/pjproject-0.5-stable/pjsip/include/pjsua-lib/pjsua.h

    r974 r1122  
    22892289 
    22902290/** 
     2291 * Create arbitrary requests using the account. Application should only use 
     2292 * this function to create auxiliary requests outside dialog, such as 
     2293 * OPTIONS, and use the call or presence API to create dialog related 
     2294 * requests. 
     2295 * 
     2296 * @param acc_id        The account ID. 
     2297 * @param method        The SIP method of the request. 
     2298 * @param target        Target URI. 
     2299 * @param p_tdata       Pointer to receive the request. 
     2300 * 
     2301 * @return              PJ_SUCCESS or the error code. 
     2302 */ 
     2303PJ_DECL(pj_status_t) pjsua_acc_create_request(pjsua_acc_id acc_id, 
     2304                                              const pjsip_method *method, 
     2305                                              const pj_str_t *target, 
     2306                                              pjsip_tx_data **p_tdata); 
     2307 
     2308 
     2309/** 
    22912310 * Create a suitable URI to be put as Contact based on the specified 
    22922311 * target URI for the specified account. 
  • pjproject/branches/pjproject-0.5-stable/pjsip/src/pjsua-lib/pjsua_acc.c

    r1105 r1122  
    926926 
    927927 
     928/* 
     929 * Create arbitrary requests for this account.  
     930 */ 
     931PJ_DEF(pj_status_t) pjsua_acc_create_request(pjsua_acc_id acc_id, 
     932                                             const pjsip_method *method, 
     933                                             const pj_str_t *target, 
     934                                             pjsip_tx_data **p_tdata) 
     935{ 
     936    pjsip_tx_data *tdata; 
     937    pjsua_acc *acc; 
     938    pjsip_route_hdr *r; 
     939    pj_status_t status; 
     940 
     941    PJ_ASSERT_RETURN(method && target && p_tdata, PJ_EINVAL); 
     942    PJ_ASSERT_RETURN(pjsua_acc_is_valid(acc_id), PJ_EINVAL); 
     943 
     944    acc = &pjsua_var.acc[acc_id]; 
     945 
     946    status = pjsip_endpt_create_request(pjsua_var.endpt, method, target,  
     947                                        &acc->cfg.id, target, 
     948                                        NULL, NULL, -1, NULL, &tdata); 
     949    if (status != PJ_SUCCESS) { 
     950        pjsua_perror(THIS_FILE, "Unable to create request", status); 
     951        return status; 
     952    } 
     953 
     954    /* Copy routeset */ 
     955    r = acc->route_set.next; 
     956    while (r != &acc->route_set) { 
     957        pjsip_msg_add_hdr(tdata->msg, pjsip_hdr_clone(tdata->pool, r)); 
     958        r = r->next; 
     959    } 
     960     
     961    /* Done */ 
     962    *p_tdata = tdata; 
     963    return PJ_SUCCESS; 
     964} 
     965 
     966 
    928967PJ_DEF(pj_status_t) pjsua_acc_create_uac_contact( pj_pool_t *pool, 
    929968                                                  pj_str_t *contact, 
Note: See TracChangeset for help on using the changeset viewer.