diff options
author | Nanang Izzuddin <nanang@teluu.com> | 2011-10-03 05:23:59 +0000 |
---|---|---|
committer | Nanang Izzuddin <nanang@teluu.com> | 2011-10-03 05:23:59 +0000 |
commit | 1685526712e312b701db96c977604343c3550ba1 (patch) | |
tree | 44b0942e67a36496b97cb3fceee64ecdb3d79a94 /pjsip/src | |
parent | dd10c1af79c2a0d4d4720245b7f5d28a63a5292c (diff) |
Fix #1358:
- Fixed wrong place of video capture & render event subscription initialization, causing it getting reinitted while being subscribed.
- Moved capture/render event unsubscription to be after capture/render port stopped. Also restart the capturer (after being stopped for unsubsciption & stream detachment) only when the capturer is being used by other, e.g: stream or preview.
- Fixed error handling in pjsua_call_reinvite(), call pjsip_dlg_dec_lock() only if dlg is successfully acquired.
- Minor: added [un]subscribtion log to event.
git-svn-id: http://svn.pjsip.org/repos/pjproject/trunk@3778 74dad513-b988-da41-8d7b-12977e46ad98
Diffstat (limited to 'pjsip/src')
-rw-r--r-- | pjsip/src/pjsua-lib/pjsua_call.c | 2 | ||||
-rw-r--r-- | pjsip/src/pjsua-lib/pjsua_media.c | 11 | ||||
-rw-r--r-- | pjsip/src/pjsua-lib/pjsua_vid.c | 40 |
3 files changed, 31 insertions, 22 deletions
diff --git a/pjsip/src/pjsua-lib/pjsua_call.c b/pjsip/src/pjsua-lib/pjsua_call.c index d5ff2408..fe9befd4 100644 --- a/pjsip/src/pjsua-lib/pjsua_call.c +++ b/pjsip/src/pjsua-lib/pjsua_call.c @@ -2038,7 +2038,7 @@ PJ_DEF(pj_status_t) pjsua_call_reinvite( pjsua_call_id call_id, } on_return: - pjsip_dlg_dec_lock(dlg); + if (dlg) pjsip_dlg_dec_lock(dlg); pj_log_pop_indent(); return status; } diff --git a/pjsip/src/pjsua-lib/pjsua_media.c b/pjsip/src/pjsua-lib/pjsua_media.c index 5a9530e9..7cd133a4 100644 --- a/pjsip/src/pjsua-lib/pjsua_media.c +++ b/pjsip/src/pjsua-lib/pjsua_media.c @@ -1339,11 +1339,6 @@ static pj_status_t call_media_init_cb(pjsua_call_media *call_med, PJ_UNUSED_ARG(security_level); #endif - pjmedia_event_subscription_init(&call_med->esub_rend, &call_media_on_event, - call_med); - pjmedia_event_subscription_init(&call_med->esub_cap, &call_media_on_event, - call_med); - on_error: if (status != PJ_SUCCESS && call_med->tp) { pjmedia_transport_close(call_med->tp); @@ -1402,6 +1397,12 @@ pj_status_t pjsua_call_media_init(pjsua_call_media *call_med, pjmedia_vid_dev_get_info(call_med->strm.v.cap_dev, &info); call_med->strm.v.cap_dev = info.id; } + + /* Init event subscribtion */ + pjmedia_event_subscription_init(&call_med->esub_rend, &call_media_on_event, + call_med); + pjmedia_event_subscription_init(&call_med->esub_cap, &call_media_on_event, + call_med); } #endif diff --git a/pjsip/src/pjsua-lib/pjsua_vid.c b/pjsip/src/pjsua-lib/pjsua_vid.c index e24578b8..0410260c 100644 --- a/pjsip/src/pjsua-lib/pjsua_vid.c +++ b/pjsip/src/pjsua-lib/pjsua_vid.c @@ -23,7 +23,7 @@ #if PJSUA_HAS_VIDEO -#define ENABLE_EVENT 0 +#define ENABLE_EVENT 1 #define VID_TEE_MAX_PORT (PJSUA_MAX_CALLS + 1) #define PJSUA_SHOW_WINDOW 1 @@ -971,32 +971,40 @@ void stop_video_stream(pjsua_call_media *call_med) PJ_LOG(4,(THIS_FILE, "Stopping video stream..")); pj_log_push_indent(); - /* Unsubscribe events */ - pjmedia_event_unsubscribe(&call_med->esub_rend); - pjmedia_event_unsubscribe(&call_med->esub_cap); - if (call_med->strm.v.cap_win_id != PJSUA_INVALID_ID) { pjmedia_port *media_port; - pjsua_vid_win *w = - &pjsua_var.win[call_med->strm.v.cap_win_id]; + pjsua_vid_win *w = &pjsua_var.win[call_med->strm.v.cap_win_id]; pj_status_t status; + /* Stop the capture before detaching stream and unsubscribing event */ + pjmedia_vid_port_stop(w->vp_cap); + /* Disconnect video stream from capture device */ status = pjmedia_vid_stream_get_port(call_med->strm.v.stream, PJMEDIA_DIR_ENCODING, &media_port); if (status == PJ_SUCCESS) { - /* Video tee is not threadsafe, so stop the capture first */ - pjmedia_vid_port_stop(w->vp_cap); pjmedia_vid_tee_remove_dst_port(w->tee, media_port); - pjmedia_vid_port_start(w->vp_cap); } + /* Unsubscribe event */ + pjmedia_event_unsubscribe(&call_med->esub_cap); + + /* Re-start capture again, if it is used by other stream */ + if (w->ref_cnt > 1) + pjmedia_vid_port_start(w->vp_cap); + dec_vid_win(call_med->strm.v.cap_win_id); call_med->strm.v.cap_win_id = PJSUA_INVALID_ID; } if (call_med->strm.v.rdr_win_id != PJSUA_INVALID_ID) { + pjsua_vid_win *w = &pjsua_var.win[call_med->strm.v.rdr_win_id]; + + /* Stop the render before unsubscribing event */ + pjmedia_vid_port_stop(w->vp_rend); + pjmedia_event_unsubscribe(&call_med->esub_rend); + dec_vid_win(call_med->strm.v.rdr_win_id); call_med->strm.v.rdr_win_id = PJSUA_INVALID_ID; } @@ -1839,18 +1847,18 @@ static pj_status_t call_change_cap_dev(pjsua_call *call, return status; if (w->vp_rend) { -#if ENABLE_EVENT - pjmedia_event_subscribe( - pjmedia_vid_port_get_event_publisher(w->vp_rend), - &call_med->esub_cap); -#endif - /* Start renderer */ status = pjmedia_vid_port_start(new_w->vp_rend); if (status != PJ_SUCCESS) goto on_error; } +#if ENABLE_EVENT + pjmedia_event_subscribe( + pjmedia_vid_port_get_event_publisher(new_w->vp_cap), + &call_med->esub_cap); +#endif + /* Start capturer */ status = pjmedia_vid_port_start(new_w->vp_cap); if (status != PJ_SUCCESS) |