Ignore:
Timestamp:
Aug 11, 2009 12:42:38 PM (15 years ago)
Author:
nanang
Message:

Ticket #833:

  • Initial version of Session Timers (RFC 4028).
  • Added new options in pjsua app to configure Session Timers settings.
  • Added python tests for Session Timers.
File:
1 edited

Legend:

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

    r2752 r2858  
    480480    /* Create the INVITE session: */ 
    481481    options |= PJSIP_INV_SUPPORT_100REL; 
     482    options |= PJSIP_INV_SUPPORT_TIMER; 
    482483    if (acc->cfg.require_100rel) 
    483484        options |= PJSIP_INV_REQUIRE_100REL; 
     485    if (acc->cfg.require_timer) 
     486        options |= PJSIP_INV_REQUIRE_TIMER; 
    484487 
    485488    status = pjsip_inv_create_uac( dlg, offer, options, &inv); 
     
    489492    } 
    490493 
     494    /* Init Session Timers */ 
     495    { 
     496        pjsip_timer_setting timer_setting; 
     497 
     498        pjsip_timer_default_setting(&timer_setting); 
     499        timer_setting.sess_expires = acc->cfg.timer_se; 
     500        timer_setting.min_se = acc->cfg.timer_min_se; 
     501 
     502        status = pjsip_timer_init_session(inv, &timer_setting); 
     503        if (status != PJ_SUCCESS) { 
     504            pjsua_perror(THIS_FILE, "Session Timer init failed", status); 
     505            goto on_error; 
     506        } 
     507    } 
    491508 
    492509    /* Create and associate our data in the session. */ 
     
    806823    /* Verify that we can handle the request. */ 
    807824    options |= PJSIP_INV_SUPPORT_100REL; 
     825    options |= PJSIP_INV_SUPPORT_TIMER; 
    808826    if (pjsua_var.acc[acc_id].cfg.require_100rel) 
    809827        options |= PJSIP_INV_REQUIRE_100REL; 
     828    if (pjsua_var.acc[acc_id].cfg.require_timer) 
     829        options |= PJSIP_INV_REQUIRE_TIMER; 
    810830 
    811831    status = pjsip_inv_verify_request2(rdata, &options, offer, answer, NULL, 
     
    896916    } 
    897917 
     918    /* Init Session Timers */ 
     919    { 
     920        pjsip_timer_setting timer_setting; 
     921 
     922        pjsip_timer_default_setting(&timer_setting); 
     923        timer_setting.sess_expires = pjsua_var.acc[acc_id].cfg.timer_se; 
     924        timer_setting.min_se = pjsua_var.acc[acc_id].cfg.timer_min_se; 
     925 
     926        status = pjsip_timer_init_session(inv, &timer_setting); 
     927        if (status != PJ_SUCCESS) { 
     928            pjsua_perror(THIS_FILE, "Session Timer init failed", status); 
     929            status = pjsip_inv_end_session(inv, PJSIP_SC_INTERNAL_SERVER_ERROR, 
     930                                           NULL, &response); 
     931            if (status == PJ_SUCCESS && response) 
     932                status = pjsip_inv_send_msg(inv, response); 
     933 
     934            pjsua_media_channel_deinit(call->index); 
     935 
     936            PJSUA_UNLOCK(); 
     937            return PJ_TRUE; 
     938        } 
     939    } 
     940 
    898941    /* Update NAT type of remote endpoint, only when there is SDP in 
    899942     * incoming INVITE!  
     
    929972                                      100, NULL, NULL, &response); 
    930973    if (status != PJ_SUCCESS) { 
    931         pjsua_perror(THIS_FILE, "Unable to send answer to incoming INVITE",  
    932                      status); 
    933  
    934         pjsip_dlg_respond(dlg, rdata, 500, NULL, NULL, NULL); 
    935         pjsip_inv_terminate(inv, 500, PJ_FALSE); 
     974        if (response == NULL) { 
     975            pjsua_perror(THIS_FILE, "Unable to send answer to incoming INVITE", 
     976                         status); 
     977            pjsip_dlg_respond(dlg, rdata, 500, NULL, NULL, NULL); 
     978            pjsip_inv_terminate(inv, 500, PJ_FALSE); 
     979        } else { 
     980            pjsip_inv_send_msg(inv, response); 
     981            pjsip_inv_terminate(inv, PJSIP_ERRNO_TO_SIP_STATUS(status),  
     982                                PJ_FALSE); 
     983        } 
    936984        pjsua_media_channel_deinit(call->index); 
    937985        PJSUA_UNLOCK(); 
Note: See TracChangeset for help on using the changeset viewer.