Ignore:
Timestamp:
Apr 28, 2009 10:19:49 PM (16 years ago)
Author:
bennylp
Message:

Ticket #760: Enhancements to PUBLISH management (thanks Johan Lantz for the suggestion)

  • Changes in PJSUA-LIB
    • retry with fresh request on 412/Conditional Request Failed response
    • changed default Expires in PUBLISH request to none (we will not put Expires), to avoid getting 423/Interval Too Brief response
    • if the PUBLISH fails for any reason, it will be retried on every PJSUA_PRES_TIMER (default 300 seconds), similar to how failed SUBSCRIBE will be retried
  • Changes to publish.h:
    • added API to add headers in every PUBLISH request
  • Added test scenario in Python unit tests
File:
1 edited

Legend:

Unmodified
Added
Removed
  • pjproject/trunk/pjsip/src/pjsip-simple/publishc.c

    r2394 r2661  
    8282    pj_uint32_t                  expires; 
    8383    pjsip_route_hdr              route_set; 
     84    pjsip_hdr                    usr_hdr; 
    8485 
    8586    /* Authorization sessions. */ 
     
    158159 
    159160    pj_list_init(&pubc->route_set); 
     161    pj_list_init(&pubc->usr_hdr); 
    160162 
    161163    /* Done */ 
     
    187189static void set_expires( pjsip_publishc *pubc, pj_uint32_t expires) 
    188190{ 
    189     if (expires != pubc->expires) { 
     191    if (expires != pubc->expires &&  
     192        expires != PJSIP_PUBC_EXPIRATION_NOT_SPECIFIED)  
     193    { 
    190194        pubc->expires_hdr = pjsip_expires_hdr_create(pubc->pool, expires); 
    191195    } else { 
     
    277281        pj_list_push_back(&pubc->route_set, pjsip_hdr_clone(pubc->pool, chdr)); 
    278282        chdr = chdr->next; 
     283    } 
     284 
     285    return PJ_SUCCESS; 
     286} 
     287 
     288PJ_DEF(pj_status_t) pjsip_publishc_set_headers( pjsip_publishc *pubc, 
     289                                                const pjsip_hdr *hdr_list) 
     290{ 
     291    const pjsip_hdr *h; 
     292 
     293    PJ_ASSERT_RETURN(pubc && hdr_list, PJ_EINVAL); 
     294 
     295    pj_list_init(&pubc->usr_hdr); 
     296    h = hdr_list->next; 
     297    while (h != hdr_list) { 
     298        pj_list_push_back(&pubc->usr_hdr, pjsip_hdr_clone(pubc->pool, h)); 
     299        h = h->next; 
    279300    } 
    280301 
     
    346367    } 
    347368 
     369    /* Add user headers */ 
     370    if (!pj_list_empty(&pubc->usr_hdr)) { 
     371        const pjsip_hdr *hdr; 
     372 
     373        hdr = pubc->usr_hdr.next; 
     374        while (hdr != &pubc->usr_hdr) { 
     375            pjsip_hdr *new_hdr = (pjsip_hdr*) 
     376                                 pjsip_hdr_shallow_clone(tdata->pool, hdr); 
     377            pjsip_msg_add_hdr(tdata->msg, new_hdr); 
     378            hdr = hdr->next; 
     379        } 
     380    } 
     381 
    348382 
    349383    /* Done. */ 
     
    531565                      pjsip_msg_find_hdr(msg, PJSIP_H_EXPIRES, NULL); 
    532566 
    533             if (expires) 
     567            if (pubc->auto_refresh && expires) 
    534568                expiration = expires->ivalue; 
    535569             
Note: See TracChangeset for help on using the changeset viewer.