diff --git a/pjmedia/src/pjmedia/stream.c b/pjmedia/src/pjmedia/stream.c index bbecb20be0..ac9b0d3e3a 100644 --- a/pjmedia/src/pjmedia/stream.c +++ b/pjmedia/src/pjmedia/stream.c @@ -3168,6 +3168,12 @@ PJ_DEF(pj_status_t) pjmedia_stream_destroy( pjmedia_stream *stream ) PJ_LOG(4,(stream->port.info.name.ptr, "Stream destroying")); + /* Stop the streaming */ + if (stream->enc) + stream->port.put_frame = NULL; + if (stream->dec) + stream->port.get_frame = NULL; + /* Send RTCP BYE (also SDES & XR) */ if (stream->transport && !stream->rtcp_sdes_bye_disabled) { #if defined(PJMEDIA_HAS_RTCP_XR) && (PJMEDIA_HAS_RTCP_XR != 0) diff --git a/pjsip/src/pjsua-lib/pjsua_media.c b/pjsip/src/pjsua-lib/pjsua_media.c index 9d5dc560ec..bfcd5d0b24 100644 --- a/pjsip/src/pjsua-lib/pjsua_media.c +++ b/pjsip/src/pjsua-lib/pjsua_media.c @@ -2269,6 +2269,7 @@ static pj_status_t media_channel_init_cb(pjsua_call_id call_id, if (call_med->use_custom_med_tp) { unsigned custom_med_tp_flags = PJSUA_MED_TP_CLOSE_MEMBER; + pj_grp_lock_t *tp_grp_lock = call_med->tp->grp_lock; /* Use custom media transport returned by the application */ call_med->tp = @@ -2279,6 +2280,19 @@ static pj_status_t media_channel_init_cb(pjsua_call_id call_id, status = PJSIP_ERRNO_FROM_SIP_STATUS(PJSIP_SC_TEMPORARILY_UNAVAILABLE); } + + /* Check if the media transport adapter has no group lock. */ + if (call_med->tp && call_med->tp->grp_lock==NULL) { + PJ_LOG(3, (THIS_FILE, "Call %d media %d: Warning, " + "media transport adapter should manage its " + "lifetime using group lock of the underlying " + "transport", call_id, mi)); + + /* Assign group lock, this will maintain the lifetime of + * the original transport only, not the transport adapter. + */ + call_med->tp->grp_lock = tp_grp_lock; + } } if (call_med->tp) {