From 29a804c3250ca745a2050e08998122d7f5000d51 Mon Sep 17 00:00:00 2001 From: Nanang Izzuddin Date: Wed, 20 May 2015 08:46:11 +0000 Subject: Fixed #1854: - Hangup the call immediately when there is no active media, this is only for initial INVITE. - Stop media and destroy media transport properly upon any error. git-svn-id: http://svn.pjsip.org/repos/pjproject/trunk@5099 74dad513-b988-da41-8d7b-12977e46ad98 --- pjsip/src/pjsua-lib/pjsua_call.c | 11 +++++++++++ pjsip/src/pjsua-lib/pjsua_media.c | 35 ++++++++++++++++++++++++++--------- 2 files changed, 37 insertions(+), 9 deletions(-) diff --git a/pjsip/src/pjsua-lib/pjsua_call.c b/pjsip/src/pjsua-lib/pjsua_call.c index 41b9e030..03d90547 100644 --- a/pjsip/src/pjsua-lib/pjsua_call.c +++ b/pjsip/src/pjsua-lib/pjsua_call.c @@ -3889,6 +3889,17 @@ static void pjsua_call_on_media_update(pjsip_inv_session *inv, /* Update media channel with the new SDP */ status = pjsua_media_channel_update(call->index, local_sdp, remote_sdp); + + /* If this is not the initial INVITE, don't disconnect call due to + * no media after SDP negotiation. + */ + if (status == PJMEDIA_SDPNEG_ENOMEDIA && + call->inv->state == PJSIP_INV_STATE_CONFIRMED) + { + status = PJ_SUCCESS; + } + + /* Disconnect call after failure in media channel update */ if (status != PJ_SUCCESS) { pjsua_perror(THIS_FILE, "Unable to create media session", status); diff --git a/pjsip/src/pjsua-lib/pjsua_media.c b/pjsip/src/pjsua-lib/pjsua_media.c index 9f6a065b..321f2c6d 100644 --- a/pjsip/src/pjsua-lib/pjsua_media.c +++ b/pjsip/src/pjsua-lib/pjsua_media.c @@ -2649,7 +2649,7 @@ pj_status_t pjsua_media_channel_update(pjsua_call_id call_id, "pjmedia_stream_info_from_sdp() failed " "for call_id %d media %d", call_id, mi)); - continue; + goto on_check_med_status; } /* Codec parameter of stream info (si->param) can be NULL if @@ -2707,7 +2707,7 @@ pj_status_t pjsua_media_channel_update(pjsua_call_id call_id, "pjmedia_transport_media_stop() failed " "for call_id %d media %d", call_id, mi)); - continue; + goto on_check_med_status; } status = pjmedia_transport_media_create(call_med->tp, tmp_pool, @@ -2717,7 +2717,7 @@ pj_status_t pjsua_media_channel_update(pjsua_call_id call_id, "pjmedia_transport_media_create() failed " "for call_id %d media %d", call_id, mi)); - continue; + goto on_check_med_status; } } @@ -2730,7 +2730,7 @@ pj_status_t pjsua_media_channel_update(pjsua_call_id call_id, "pjmedia_transport_media_start() failed " "for call_id %d media %d", call_id, mi)); - continue; + goto on_check_med_status; } pjsua_set_media_tp_state(call_med, PJSUA_MED_TP_RUNNING); @@ -2755,7 +2755,7 @@ pj_status_t pjsua_media_channel_update(pjsua_call_id call_id, "pjsua_aud_channel_update() failed " "for call_id %d media %d", call_id, mi)); - continue; + goto on_check_med_status; } } @@ -2825,7 +2825,7 @@ pj_status_t pjsua_media_channel_update(pjsua_call_id call_id, "pjmedia_vid_stream_info_from_sdp() failed " "for call_id %d media %d", call_id, mi)); - continue; + goto on_check_med_status; } /* Check if this media is changed */ @@ -2860,7 +2860,7 @@ pj_status_t pjsua_media_channel_update(pjsua_call_id call_id, "pjmedia_transport_media_start() failed " "for call_id %d media %d", call_id, mi)); - continue; + goto on_check_med_status; } pjsua_set_media_tp_state(call_med, PJSUA_MED_TP_RUNNING); @@ -2885,7 +2885,7 @@ pj_status_t pjsua_media_channel_update(pjsua_call_id call_id, "pjsua_vid_channel_update() failed " "for call_id %d media %d", call_id, mi)); - continue; + goto on_check_med_status; } } @@ -2950,11 +2950,28 @@ pj_status_t pjsua_media_channel_update(pjsua_call_id call_id, call_med->tp = call_med->tp_orig = NULL; } +on_check_med_status: if (status != PJ_SUCCESS) { + /* Stop stream */ + stop_media_stream(call, mi); + + /* Close the media transport */ + if (call_med->tp) { + pjsua_set_media_tp_state(call_med, PJSUA_MED_TP_NULL); + pjmedia_transport_close(call_med->tp); + call_med->tp = call_med->tp_orig = NULL; + } + + /* Update media states */ + call_med->state = PJSUA_CALL_MEDIA_ERROR; + call_med->dir = PJMEDIA_DIR_NONE; + PJ_PERROR(1,(THIS_FILE, status, "Error updating media call%02d:%d", call_id, mi)); } else { - got_media = PJ_TRUE; + /* Only set 'got_media' flag if this media is not disabled */ + if (local_sdp->media[mi]->desc.port != 0) + got_media = PJ_TRUE; } } -- cgit v1.2.3