Changeset 167


Ignore:
Timestamp:
Feb 9, 2006 9:30:09 AM (18 years ago)
Author:
bennylp
Message:

Setting svn:eol-style attribute

Location:
pjproject/trunk/pjsip
Files:
1 added
1 deleted
10 edited

Legend:

Unmodified
Added
Removed
  • pjproject/trunk/pjsip/build/pjsua.dsp

    r156 r167  
    9999# Begin Source File 
    100100 
    101 SOURCE=..\src\pjsua\main_old.c 
    102 # PROP Exclude_From_Build 1 
     101SOURCE=..\src\pjsua\pjsua_core.c 
    103102# End Source File 
    104103# Begin Source File 
    105104 
    106 SOURCE=..\src\pjsua\misc.c 
    107 # PROP Exclude_From_Build 1 
    108 # End Source File 
    109 # Begin Source File 
    110  
    111 SOURCE=..\src\pjsua\pjsua_core.c 
     105SOURCE=..\src\pjsua\pjsua_inv.c 
    112106# End Source File 
    113107# Begin Source File 
  • pjproject/trunk/pjsip/include/pjsip-ua/sip_regc.h

    • Property svn:keywords set to id
    r141 r167  
    142142 * Set authentication credentials to use by this registration. 
    143143 * 
    144  * @param dlg       The registration structure. 
     144 * @param regc      The registration structure. 
    145145 * @param count     Number of credentials in the array. 
    146146 * @param cred      Array of credentials. 
     
    153153 
    154154/** 
     155 * Set route set to be used for outgoing requests. 
     156 * 
     157 * @param regc      The client registration structure. 
     158 * @param route_set List containing Route headers. 
     159 * 
     160 * @return          PJ_SUCCESS on success. 
     161 */ 
     162PJ_DECL(pj_status_t) pjsip_regc_set_route_set(pjsip_regc *regc, 
     163                                              const pjsip_route_hdr*route_set); 
     164 
     165/** 
    155166 * Create REGISTER request for the specified client registration structure. 
    156167 * 
  • pjproject/trunk/pjsip/include/pjsip/print_util.h

    • Property svn:keywords changed from Id to id
  • pjproject/trunk/pjsip/src/pjsip-ua/sip_reg.c

    • Property svn:keywords set to id
    r141 r167  
    4242struct pjsip_regc 
    4343{ 
    44     pj_pool_t           *pool; 
    45     pjsip_endpoint      *endpt; 
    46     pj_bool_t            _delete_flag; 
    47     int                  pending_tsx; 
    48  
    49     void                *token; 
    50     pjsip_regc_cb       *cb; 
    51  
    52     pj_str_t            str_srv_url; 
    53     pjsip_uri           *srv_url; 
    54     pjsip_cid_hdr       *cid_hdr; 
    55     pjsip_cseq_hdr      *cseq_hdr; 
    56     pjsip_from_hdr      *from_hdr; 
    57     pjsip_to_hdr        *to_hdr; 
    58     char                *contact_buf; 
     44    pj_pool_t                   *pool; 
     45    pjsip_endpoint              *endpt; 
     46    pj_bool_t                   _delete_flag; 
     47    int                         pending_tsx; 
     48 
     49    void                        *token; 
     50    pjsip_regc_cb               *cb; 
     51 
     52    pj_str_t                    str_srv_url; 
     53    pjsip_uri                   *srv_url; 
     54    pjsip_cid_hdr               *cid_hdr; 
     55    pjsip_cseq_hdr              *cseq_hdr; 
     56    pjsip_from_hdr              *from_hdr; 
     57    pjsip_to_hdr                *to_hdr; 
     58    char                        *contact_buf; 
    5959    pjsip_generic_string_hdr    *contact_hdr; 
    60     pjsip_expires_hdr   *expires_hdr; 
    61     pjsip_contact_hdr   *unreg_contact_hdr; 
    62     pjsip_expires_hdr   *unreg_expires_hdr; 
    63     pj_uint32_t          expires; 
     60    pjsip_expires_hdr           *expires_hdr; 
     61    pjsip_contact_hdr           *unreg_contact_hdr; 
     62    pjsip_expires_hdr           *unreg_expires_hdr; 
     63    pj_uint32_t                  expires; 
     64    pjsip_route_hdr              route_set; 
    6465 
    6566    /* Authorization sessions. */ 
    66     pjsip_auth_clt_sess auth_sess; 
     67    pjsip_auth_clt_sess         auth_sess; 
    6768 
    6869    /* Auto refresh registration. */ 
    69     pj_bool_t            auto_reg; 
    70     pj_timer_entry      timer; 
     70    pj_bool_t                   auto_reg; 
     71    pj_timer_entry              timer; 
    7172}; 
    7273 
     
    99100    if (status != PJ_SUCCESS) 
    100101        return status; 
     102 
     103    pj_list_init(&regc->route_set); 
    101104 
    102105    /* Done */ 
     
    247250    PJ_ASSERT_RETURN(regc && count && cred, PJ_EINVAL); 
    248251    return pjsip_auth_clt_set_credentials(&regc->auth_sess, count, cred); 
     252} 
     253 
     254PJ_DEF(pj_status_t) pjsip_regc_set_route_set( pjsip_regc *regc, 
     255                                              const pjsip_route_hdr *route_set) 
     256{ 
     257    const pjsip_route_hdr *chdr; 
     258 
     259    PJ_ASSERT_RETURN(regc && route_set, PJ_EINVAL); 
     260 
     261    pj_list_init(&regc->route_set); 
     262 
     263    chdr = route_set->next; 
     264    while (chdr != route_set) { 
     265        pj_list_push_back(&regc->route_set, pjsip_hdr_clone(regc->pool, chdr)); 
     266        chdr = chdr->next; 
     267    } 
     268 
     269    return PJ_SUCCESS; 
    249270} 
    250271 
     
    273294    /* Add cached authorization headers. */ 
    274295    pjsip_auth_clt_init_req( &regc->auth_sess, tdata ); 
     296 
     297    /* Add Route headers from route set, ideally after Via header */ 
     298    if (!pj_list_empty(&regc->route_set)) { 
     299        pjsip_hdr *route_pos; 
     300        const pjsip_route_hdr *route; 
     301 
     302        route_pos = pjsip_msg_find_hdr(tdata->msg, PJSIP_H_VIA, NULL); 
     303        if (!route_pos) 
     304            route_pos = &tdata->msg->hdr; 
     305 
     306        route = regc->route_set.next; 
     307        while (route != &regc->route_set) { 
     308            pjsip_hdr *new_hdr = pjsip_hdr_shallow_clone(tdata->pool, route); 
     309            pj_list_insert_after(route_pos, new_hdr); 
     310            route_pos = new_hdr; 
     311            route = route->next; 
     312        } 
     313    } 
    275314 
    276315    /* Done. */ 
  • pjproject/trunk/pjsip/src/pjsua/getopt.c

    • Property svn:keywords set to id
  • pjproject/trunk/pjsip/src/pjsua/getopt.h

    • Property svn:keywords set to id
  • pjproject/trunk/pjsip/src/pjsua/main.c

    • Property svn:keywords set to id
    r160 r167  
    6262    puts(""); 
    6363    puts("Console keys:"); 
    64     puts("  m    Make a call"); 
     64    puts("  m    Make a call/another call"); 
    6565    puts("  a    Answer incoming call"); 
    6666    puts("  h    Hangup current call"); 
     
    353353    puts("  --use-stun2=host[:port]  Use STUN and set host name and port of STUN servers"); 
    354354    puts(""); 
    355     puts("SIMPLE options (may be specified more than once):"); 
    356     puts("  --add-buddy url     Add the specified URL to the buddy list."); 
    357     puts("  --offer-x-ms-msg    Offer \"x-ms-message\" in outgoing INVITE"); 
    358     puts("  --no-presence       Do not subscribe presence of buddies"); 
     355    //puts("SIMPLE options (may be specified more than once):"); 
     356    //puts("  --add-buddy url     Add the specified URL to the buddy list."); 
     357    //puts("  --offer-x-ms-msg    Offer \"x-ms-message\" in outgoing INVITE"); 
     358    //puts("  --no-presence     Do not subscribe presence of buddies"); 
    359359    puts(""); 
    360360    fflush(stdout); 
  • pjproject/trunk/pjsip/src/pjsua/pjsua.h

    r162 r167  
    129129 
    130130/***************************************************************************** 
    131  * PJSUA API. 
     131 * PJSUA API (defined in pjsua_core.c). 
    132132 */ 
    133133 
     
    172172 
    173173 
     174/***************************************************************************** 
     175 * PJSUA Invite session API (defined in pjsua_inv.c). 
     176 */ 
     177 
    174178/** 
    175179 * Make outgoing call. 
     
    179183 
    180184 
    181 /***************************************************************************** 
    182  * PJSUA Client Registration API. 
     185/** 
     186 * Handle incoming invite request. 
     187 */ 
     188pj_bool_t pjsua_inv_on_incoming(pjsip_rx_data *rdata); 
     189 
     190 
     191/** 
     192 * Callback to be called by session when invite session's state has changed. 
     193 */ 
     194void pjsua_inv_on_state_changed(pjsip_inv_session *inv, pjsip_event *e); 
     195 
     196 
     197/** 
     198 * Callback to be called by session when outgoing dialog has forked. 
     199 * This function will create a forked dialog. 
     200 */ 
     201void pjsua_inv_on_new_session(pjsip_inv_session *inv, pjsip_event *e); 
     202 
     203 
     204/** 
     205 * Callback to be called when SDP offer/answer negotiation has just completed 
     206 * in the session. This function will start/update media if negotiation 
     207 * has succeeded. 
     208 */ 
     209void pjsua_inv_on_media_update(pjsip_inv_session *inv, pj_status_t status); 
     210 
     211 
     212/***************************************************************************** 
     213 * PJSUA Client Registration API (defined in pjsua_reg.c). 
    183214 */ 
    184215 
     
    199230/***************************************************************************** 
    200231 * User Interface API. 
     232 * 
    201233 * The UI API specifies functions that will be called by pjsua upon 
    202234 * occurence of various events. 
  • pjproject/trunk/pjsip/src/pjsua/pjsua_core.c

    r163 r167  
    1919#include "pjsua.h" 
    2020 
    21  
    22 #define THIS_FILE   "pjsua.c" 
    23  
     21/* 
     22 * pjsua_core.c 
     23 * 
     24 * Core application functionalities. 
     25 */ 
     26 
     27#define THIS_FILE   "pjsua_core.c" 
     28 
     29 
     30/*  
     31 * Global variable. 
     32 */ 
    2433struct pjsua pjsua; 
    2534 
     35 
    2636/*  
    27  * Default local URI, if not specified in cmd-line  
     37 * Default local URI, if none is specified in cmd-line  
    2838 */ 
    2939#define PJSUA_LOCAL_URI     "<sip:user@127.0.0.1>" 
     
    93103static pj_bool_t mod_pjsua_on_rx_request(pjsip_rx_data *rdata) 
    94104{ 
    95     pjsip_dialog *dlg = pjsip_rdata_get_dlg(rdata); 
    96     pjsip_transaction *tsx = pjsip_rdata_get_tsx(rdata); 
    97     pjsip_msg *msg = rdata->msg_info.msg; 
    98  
    99     /* 
    100      * Handle incoming INVITE outside dialog. 
    101      */ 
    102     if (dlg == NULL && tsx == NULL && 
    103         msg->line.req.method.id == PJSIP_INVITE_METHOD) 
    104     { 
    105         pj_status_t status; 
    106         pjsip_tx_data *response = NULL; 
    107         unsigned options = 0; 
    108  
    109         /* Verify that we can handle the request. */ 
    110         status = pjsip_inv_verify_request(rdata, &options, NULL, NULL, 
    111                                           pjsua.endpt, &response); 
    112         if (status != PJ_SUCCESS) { 
    113  
    114             /* 
    115              * No we can't handle the incoming INVITE request. 
    116              */ 
    117  
    118             if (response) { 
    119                 pjsip_response_addr res_addr; 
    120  
    121                 pjsip_get_response_addr(response->pool, rdata, &res_addr); 
    122                 pjsip_endpt_send_response(pjsua.endpt, &res_addr, response,  
    123                                           NULL, NULL); 
    124  
    125             } else { 
    126  
    127                 /* Respond with 500 (Internal Server Error) */ 
    128                 pjsip_endpt_respond_stateless(pjsua.endpt, rdata, 500, NULL, 
    129                                               NULL, NULL); 
    130             } 
    131  
    132         } else { 
    133             /* 
    134              * Yes we can handle the incoming INVITE request. 
    135              */ 
    136             pjsip_inv_session *inv; 
    137             struct pjsua_inv_data *inv_data; 
    138             pjmedia_sdp_session *answer; 
    139  
    140  
    141             /* Get media capability from media endpoint: */ 
    142  
    143             status = pjmedia_endpt_create_sdp( pjsua.med_endpt, rdata->tp_info.pool, 
    144                                                1, &pjsua.med_skinfo, &answer ); 
    145             if (status != PJ_SUCCESS) { 
    146  
    147                 pjsip_endpt_respond_stateless(pjsua.endpt, rdata, 500, NULL, 
    148                                               NULL, NULL); 
    149                 return PJ_TRUE; 
    150             } 
    151  
    152             /* Create dialog: */ 
    153  
    154             status = pjsip_dlg_create_uas( pjsip_ua_instance(), rdata, 
    155                                            &pjsua.contact_uri, &dlg); 
    156             if (status != PJ_SUCCESS) 
    157                 return PJ_TRUE; 
    158  
    159  
    160             /* Create invite session: */ 
    161  
    162             status = pjsip_inv_create_uas( dlg, rdata, answer, 0, &inv); 
    163             if (status != PJ_SUCCESS) { 
    164  
    165                 status = pjsip_dlg_create_response( dlg, rdata, 500, NULL, 
    166                                                     &response); 
    167                 if (status == PJ_SUCCESS) 
    168                     status = pjsip_dlg_send_response(dlg,  
    169                                                      pjsip_rdata_get_tsx(rdata), 
    170                                                      response); 
    171                 return PJ_TRUE; 
    172  
    173             } 
    174  
    175  
    176             /* Create and attach pjsua data to the dialog: */ 
    177  
    178             inv_data = pj_pool_zalloc(dlg->pool, sizeof(struct pjsua_inv_data)); 
    179             dlg->mod_data[pjsua.mod.id] = inv_data; 
    180  
    181  
    182             /* Answer with 100 (using the dialog, not invite): */ 
    183  
    184             status = pjsip_dlg_create_response(dlg, rdata, 100, NULL, &response); 
    185             if (status == PJ_SUCCESS) 
    186                 status = pjsip_dlg_send_response(dlg, pjsip_rdata_get_tsx(rdata), response); 
    187         } 
    188  
    189         /* This INVITE request has been handled. */ 
    190         return PJ_TRUE; 
    191     } 
    192  
    193      
     105 
     106    if (rdata->msg_info.msg->line.req.method.id == PJSIP_INVITE_METHOD) { 
     107 
     108        return pjsua_inv_on_incoming(rdata); 
     109 
     110    } 
    194111 
    195112    return PJ_FALSE; 
     
    214131} 
    215132 
    216  
    217 /* 
    218  * This callback receives notification from invite session when the 
    219  * session state has changed. 
    220  */ 
    221 static void pjsua_inv_on_state_changed(pjsip_inv_session *inv, pjsip_event *e) 
    222 { 
    223  
    224     /* Destroy media session when invite session is disconnected. */ 
    225     if (inv->state == PJSIP_INV_STATE_DISCONNECTED) { 
    226         struct pjsua_inv_data *inv_data; 
    227  
    228         inv_data = inv->dlg->mod_data[pjsua.mod.id]; 
    229         if (inv_data && inv_data->session) { 
    230             pjmedia_session_destroy(inv_data->session); 
    231             inv_data->session = NULL; 
    232  
    233             PJ_LOG(3,(THIS_FILE,"Media session is destroyed")); 
    234         } 
    235  
    236     } 
    237  
    238     pjsua_ui_inv_on_state_changed(inv, e); 
    239 } 
    240  
    241  
    242 /* 
    243  * This callback is called by invite session framework when UAC session 
    244  * has forked. 
    245  */ 
    246 static void pjsua_inv_on_new_session(pjsip_inv_session *inv, pjsip_event *e) 
    247 { 
    248     PJ_UNUSED_ARG(inv); 
    249     PJ_UNUSED_ARG(e); 
    250  
    251     PJ_TODO(HANDLE_FORKED_DIALOG); 
    252 } 
    253  
    254 /* 
    255  * 
    256  */ 
    257 static void pjsua_inv_on_media_update(pjsip_inv_session *inv,  
    258                                       pj_status_t status) 
    259 { 
    260     struct pjsua_inv_data *inv_data; 
    261     const pjmedia_sdp_session *local_sdp; 
    262     const pjmedia_sdp_session *remote_sdp; 
    263  
    264     if (status != PJ_SUCCESS) { 
    265  
    266         pjsua_perror("SDP negotiation has failed", status); 
    267         return; 
    268  
    269     } 
    270  
    271     /* Destroy existing media session, if any. */ 
    272  
    273     inv_data = inv->dlg->mod_data[pjsua.mod.id]; 
    274     if (inv_data && inv_data->session) { 
    275         pjmedia_session_destroy(inv_data->session); 
    276         inv_data->session = NULL; 
    277     } 
    278  
    279     /* Get local and remote SDP */ 
    280  
    281     status = pjmedia_sdp_neg_get_active_local(inv->neg, &local_sdp); 
    282     if (status != PJ_SUCCESS) { 
    283         pjsua_perror("Unable to retrieve currently active local SDP", status); 
    284         return; 
    285     } 
    286  
    287  
    288     status = pjmedia_sdp_neg_get_active_remote(inv->neg, &remote_sdp); 
    289     if (status != PJ_SUCCESS) { 
    290         pjsua_perror("Unable to retrieve currently active remote SDP", status); 
    291         return; 
    292     } 
    293  
    294  
    295     /* Create new media session.  
    296      * The media session is active immediately. 
    297      */ 
    298  
    299     status = pjmedia_session_create( pjsua.med_endpt, 1, &pjsua.med_skinfo, 
    300                                      local_sdp, remote_sdp, &inv_data->session ); 
    301     if (status != PJ_SUCCESS) { 
    302         pjsua_perror("Unable to create media session", status); 
    303         return; 
    304     } 
    305  
    306     PJ_LOG(3,(THIS_FILE,"Media has been started successfully")); 
    307 } 
    308133 
    309134/*  
     
    846671 
    847672    /* Destroy endpoint. */ 
     673 
    848674    pjsip_endpt_destroy(pjsua.endpt); 
    849675    pjsua.endpt = NULL; 
    850676 
    851677    /* Destroy caching pool. */ 
     678 
    852679    pj_caching_pool_destroy(&pjsua.cp); 
    853680 
     
    858685} 
    859686 
    860  
    861 /** 
    862  * Make outgoing call. 
    863  */ 
    864 pj_status_t pjsua_invite(const char *cstr_dest_uri, 
    865                          pjsip_inv_session **p_inv) 
    866 { 
    867     pj_str_t dest_uri; 
    868     pjsip_dialog *dlg; 
    869     pjmedia_sdp_session *offer; 
    870     pjsip_inv_session *inv; 
    871     struct pjsua_inv_data *inv_data; 
    872     pjsip_tx_data *tdata; 
    873     pj_status_t status; 
    874  
    875     /* Convert cstr_dest_uri to dest_uri */ 
    876      
    877     dest_uri = pj_str((char*)cstr_dest_uri); 
    878  
    879     /* Create outgoing dialog: */ 
    880  
    881     status = pjsip_dlg_create_uac( pjsip_ua_instance(), &pjsua.local_uri, 
    882                                    &pjsua.contact_uri, &dest_uri, &dest_uri, 
    883                                    &dlg); 
    884     if (status != PJ_SUCCESS) { 
    885         pjsua_perror("Dialog creation failed", status); 
    886         return status; 
    887     } 
    888  
    889     /* Get media capability from media endpoint: */ 
    890  
    891     status = pjmedia_endpt_create_sdp( pjsua.med_endpt, dlg->pool, 
    892                                        1, &pjsua.med_skinfo, &offer); 
    893     if (status != PJ_SUCCESS) { 
    894         pjsua_perror("pjmedia unable to create SDP", status); 
    895         goto on_error; 
    896     } 
    897  
    898     /* Create the INVITE session: */ 
    899  
    900     status = pjsip_inv_create_uac( dlg, offer, 0, &inv); 
    901     if (status != PJ_SUCCESS) { 
    902         pjsua_perror("Invite session creation failed", status); 
    903         goto on_error; 
    904     } 
    905  
    906  
    907     /* Create and associate our data in the session. */ 
    908  
    909     inv_data = pj_pool_zalloc( dlg->pool, sizeof(struct pjsua_inv_data)); 
    910     dlg->mod_data[pjsua.mod.id] = inv_data; 
    911  
    912  
    913     /* Set dialog Route-Set: */ 
    914  
    915     if (!pj_list_empty(&pjsua.route_set)) 
    916         pjsip_dlg_set_route_set(dlg, &pjsua.route_set); 
    917  
    918  
    919     /* Set credentials: */ 
    920  
    921     pjsip_auth_clt_set_credentials( &dlg->auth_sess, pjsua.cred_count,  
    922                                     pjsua.cred_info); 
    923  
    924  
    925     /* Create initial INVITE: */ 
    926  
    927     status = pjsip_inv_invite(inv, &tdata); 
    928     if (status != PJ_SUCCESS) { 
    929         pjsua_perror("Unable to create initial INVITE request", status); 
    930         goto on_error; 
    931     } 
    932  
    933  
    934     /* Send initial INVITE: */ 
    935  
    936     status = pjsip_inv_send_msg(inv, tdata, NULL); 
    937     if (status != PJ_SUCCESS) { 
    938         pjsua_perror("Unable to send initial INVITE request", status); 
    939         goto on_error; 
    940     } 
    941  
    942  
    943     /* Done. */ 
    944  
    945     *p_inv = inv; 
    946  
    947     return PJ_SUCCESS; 
    948  
    949  
    950 on_error: 
    951  
    952     PJ_TODO(DESTROY_DIALOG_ON_FAIL); 
    953     return status; 
    954 } 
    955  
  • pjproject/trunk/pjsip/src/pjsua/pjsua_reg.c

    r149 r167  
    1919#include "pjsua.h" 
    2020 
     21 
     22/* 
     23 * pjsua_reg.c 
     24 * 
     25 * Client registration handler. 
     26 */ 
     27 
    2128#define THIS_FILE   "pjsua_reg.c" 
    2229 
     30 
     31/* 
     32 * This callback is called by pjsip_regc when outgoing register 
     33 * request has completed. 
     34 */ 
    2335static void regc_cb(struct pjsip_regc_cbparam *param) 
    2436{ 
     
    98110        pjsip_regc_set_credentials( pjsua.regc, pjsua.cred_count,  
    99111                                    pjsua.cred_info ); 
     112 
     113        pjsip_regc_set_route_set( pjsua.regc, &pjsua.route_set ); 
    100114    } 
    101115 
Note: See TracChangeset for help on using the changeset viewer.