Changeset 3778 for pjproject


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.
Location:
pjproject/trunk
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • pjproject/trunk/pjmedia/src/pjmedia/event.c

    r3666 r3778  
    7373                                             pjmedia_event_subscription *esub) 
    7474{ 
     75    char epub_name[5]; 
     76 
    7577    PJ_ASSERT_RETURN(epub && esub && esub->cb, PJ_EINVAL); 
    7678    /* Must not currently subscribe to anything */ 
    7779    PJ_ASSERT_RETURN(esub->subscribe_to == NULL, PJ_EINVALIDOP); 
     80 
     81    TRACE_((THIS_FILE, "Subscription to publisher %s", 
     82                       pjmedia_fourcc_name(epub->sig, epub_name))); 
    7883 
    7984    pj_list_push_back(&epub->subscription_list, esub); 
     
    8590{ 
    8691    PJ_ASSERT_RETURN(esub, PJ_EINVAL); 
     92 
    8793    if (esub->subscribe_to) { 
     94        char epub_name[5]; 
     95        TRACE_((THIS_FILE, "Unsubscription to publisher %s", 
     96                           pjmedia_fourcc_name(esub->subscribe_to->sig, 
     97                                               epub_name))); 
     98 
    8899        PJ_ASSERT_RETURN( 
    89100            pj_list_find_node(&esub->subscribe_to->subscription_list, 
  • pjproject/trunk/pjsip/src/pjsua-lib/pjsua_call.c

    r3777 r3778  
    20392039 
    20402040on_return: 
    2041     pjsip_dlg_dec_lock(dlg); 
     2041    if (dlg) pjsip_dlg_dec_lock(dlg); 
    20422042    pj_log_pop_indent(); 
    20432043    return status; 
  • pjproject/trunk/pjsip/src/pjsua-lib/pjsua_media.c

    r3777 r3778  
    13401340#endif 
    13411341 
    1342     pjmedia_event_subscription_init(&call_med->esub_rend, &call_media_on_event, 
    1343                                     call_med); 
    1344     pjmedia_event_subscription_init(&call_med->esub_cap, &call_media_on_event, 
    1345                                     call_med); 
    1346  
    13471342on_error: 
    13481343    if (status != PJ_SUCCESS && call_med->tp) { 
     
    14031398                call_med->strm.v.cap_dev = info.id; 
    14041399            } 
     1400 
     1401            /* Init event subscribtion */ 
     1402            pjmedia_event_subscription_init(&call_med->esub_rend, &call_media_on_event, 
     1403                                            call_med); 
     1404            pjmedia_event_subscription_init(&call_med->esub_cap, &call_media_on_event, 
     1405                                            call_med); 
    14051406        } 
    14061407#endif 
  • 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.