Changeset 4750


Ignore:
Timestamp:
Feb 19, 2014 4:11:43 AM (11 years ago)
Author:
bennylp
Message:

Fixed #1738: Infinite loop when re-INVITE is received while adding new media

Location:
pjproject/trunk/pjsip
Files:
4 edited

Legend:

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

    r4592 r4750  
    636636pj_status_t pjsua_media_channel_deinit(pjsua_call_id call_id); 
    637637 
     638/* 
     639 * Error message when media operation is requested while another is in progress 
     640 */ 
     641#define ERR_MEDIA_CHANGING  " because another media operation is in progress" 
     642 
     643pj_bool_t   pjsua_call_media_is_changing(pjsua_call *call); 
    638644pj_status_t pjsua_call_media_init(pjsua_call_media *call_med, 
    639645                                  pjmedia_type type, 
  • pjproject/trunk/pjsip/src/pjsua-lib/pjsua_call.c

    r4728 r4750  
    3434 */ 
    3535#define LOCK_CODEC_MAX_RETRY         5 
    36  
    3736 
    3837/* 
     
    23932392        goto on_return; 
    23942393 
     2394    if (pjsua_call_media_is_changing(call)) { 
     2395        PJ_LOG(1,(THIS_FILE, "Unable to reinvite" ERR_MEDIA_CHANGING)); 
     2396        status = PJ_EINVALIDOP; 
     2397        goto on_return; 
     2398    } 
     2399 
    23952400    if (call->inv->state != PJSIP_INV_STATE_CONFIRMED) { 
    23962401        PJ_LOG(3,(THIS_FILE, "Can not re-INVITE call that is not confirmed")); 
     
    24992504    if (status != PJ_SUCCESS) 
    25002505        goto on_return; 
     2506 
     2507    if (pjsua_call_media_is_changing(call)) { 
     2508        PJ_LOG(1,(THIS_FILE, "Unable to send UPDATE" ERR_MEDIA_CHANGING)); 
     2509        status = PJ_EINVALIDOP; 
     2510        goto on_return; 
     2511    } 
    25012512 
    25022513    status = apply_call_setting(call, opt, NULL); 
     
    38793890    PJ_LOG(4,(THIS_FILE, "Call %d: received updated media offer", 
    38803891              call->index)); 
     3892 
    38813893    pj_log_push_indent(); 
     3894 
     3895    if (pjsua_call_media_is_changing(call)) { 
     3896        PJ_LOG(1,(THIS_FILE, "Unable to process offer" ERR_MEDIA_CHANGING)); 
     3897        goto on_return; 
     3898    } 
    38823899 
    38833900    if (pjsua_var.ua_cfg.cb.on_call_rx_offer) { 
     
    39703987 
    39713988    call = (pjsua_call*) inv->dlg->mod_data[pjsua_var.mod.id]; 
     3989    if (pjsua_call_media_is_changing(call)) { 
     3990        *offer = NULL; 
     3991        PJ_LOG(1,(THIS_FILE, "Unable to create offer" ERR_MEDIA_CHANGING)); 
     3992        goto on_return; 
     3993    } 
    39723994 
    39733995    /* See if we've put call on hold. */ 
  • pjproject/trunk/pjsip/src/pjsua-lib/pjsua_media.c

    r4749 r4750  
    13031303 
    13041304    return status; 
     1305} 
     1306 
     1307/* Determine if call's media is being changed, for example when video is being 
     1308 * added. Then we can reject incoming re-INVITE, for example. This is the 
     1309 * solution for https://trac.pjsip.org/repos/ticket/1738 
     1310 */ 
     1311pj_bool_t  pjsua_call_media_is_changing(pjsua_call *call) 
     1312{ 
     1313    /* The problem in #1738 occurs because we do handle_events() loop while 
     1314     * adding media, which could cause incoming re-INVITE to be processed and 
     1315     * cause havoc. Since the handle_events() loop only happens while adding 
     1316     * media, it is sufficient to only check if "prov > cnt" for now. 
     1317     */ 
     1318    return call->med_prov_cnt > call->med_cnt; 
    13051319} 
    13061320 
  • pjproject/trunk/pjsip/src/pjsua-lib/pjsua_vid.c

    r4560 r4750  
    15361536        return PJ_ETOOMANY; 
    15371537 
     1538    if (pjsua_call_media_is_changing(call)) { 
     1539        PJ_LOG(1,(THIS_FILE, "Unable to add video" ERR_MEDIA_CHANGING)); 
     1540        return PJ_EINVALIDOP; 
     1541    } 
     1542 
    15381543    /* Get active local SDP and clone it */ 
    15391544    status = pjmedia_sdp_neg_get_active_local(call->inv->neg, &current_sdp); 
     
    16361641    pjmedia_sdp_session *sdp; 
    16371642    pj_status_t status; 
     1643 
     1644    if (pjsua_call_media_is_changing(call)) { 
     1645        PJ_LOG(1,(THIS_FILE, "Unable to modify video" ERR_MEDIA_CHANGING)); 
     1646        return PJ_EINVALIDOP; 
     1647    } 
    16381648 
    16391649    /* Verify and normalize media index */ 
Note: See TracChangeset for help on using the changeset viewer.