Ignore:
Timestamp:
Oct 3, 2011 5:23:59 AM (13 years ago)
Author:
nanang
Message:

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.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • pjproject/trunk/pjsip/src/pjsua-lib/pjsua_vid.c

    r3776 r3778  
    2424#if PJSUA_HAS_VIDEO 
    2525 
    26 #define ENABLE_EVENT            0 
     26#define ENABLE_EVENT            1 
    2727#define VID_TEE_MAX_PORT        (PJSUA_MAX_CALLS + 1) 
    2828 
     
    972972    pj_log_push_indent(); 
    973973 
    974     /* Unsubscribe events */ 
    975     pjmedia_event_unsubscribe(&call_med->esub_rend); 
    976     pjmedia_event_unsubscribe(&call_med->esub_cap); 
    977  
    978974    if (call_med->strm.v.cap_win_id != PJSUA_INVALID_ID) { 
    979975        pjmedia_port *media_port; 
    980         pjsua_vid_win *w = 
    981                     &pjsua_var.win[call_med->strm.v.cap_win_id]; 
     976        pjsua_vid_win *w = &pjsua_var.win[call_med->strm.v.cap_win_id]; 
    982977        pj_status_t status; 
     978 
     979        /* Stop the capture before detaching stream and unsubscribing event */ 
     980        pjmedia_vid_port_stop(w->vp_cap); 
    983981 
    984982        /* Disconnect video stream from capture device */ 
     
    987985                                             &media_port); 
    988986        if (status == PJ_SUCCESS) { 
    989             /* Video tee is not threadsafe, so stop the capture first */ 
    990             pjmedia_vid_port_stop(w->vp_cap); 
    991987            pjmedia_vid_tee_remove_dst_port(w->tee, media_port); 
     988        } 
     989 
     990        /* Unsubscribe event */ 
     991        pjmedia_event_unsubscribe(&call_med->esub_cap); 
     992 
     993        /* Re-start capture again, if it is used by other stream */ 
     994        if (w->ref_cnt > 1) 
    992995            pjmedia_vid_port_start(w->vp_cap); 
    993         } 
    994996 
    995997        dec_vid_win(call_med->strm.v.cap_win_id); 
     
    9981000 
    9991001    if (call_med->strm.v.rdr_win_id != PJSUA_INVALID_ID) { 
     1002        pjsua_vid_win *w = &pjsua_var.win[call_med->strm.v.rdr_win_id]; 
     1003 
     1004        /* Stop the render before unsubscribing event */ 
     1005        pjmedia_vid_port_stop(w->vp_rend); 
     1006        pjmedia_event_unsubscribe(&call_med->esub_rend); 
     1007 
    10001008        dec_vid_win(call_med->strm.v.rdr_win_id); 
    10011009        call_med->strm.v.rdr_win_id = PJSUA_INVALID_ID; 
     
    18401848 
    18411849    if (w->vp_rend) { 
    1842 #if ENABLE_EVENT 
    1843         pjmedia_event_subscribe( 
    1844                 pjmedia_vid_port_get_event_publisher(w->vp_rend), 
    1845                 &call_med->esub_cap); 
    1846 #endif 
    1847  
    18481850        /* Start renderer */ 
    18491851        status = pjmedia_vid_port_start(new_w->vp_rend); 
     
    18511853            goto on_error; 
    18521854    } 
     1855 
     1856#if ENABLE_EVENT 
     1857    pjmedia_event_subscribe( 
     1858            pjmedia_vid_port_get_event_publisher(new_w->vp_cap), 
     1859            &call_med->esub_cap); 
     1860#endif 
    18531861 
    18541862    /* Start capturer */ 
Note: See TracChangeset for help on using the changeset viewer.