Changeset 3799


Ignore:
Timestamp:
Oct 6, 2011 7:37:46 AM (13 years ago)
Author:
bennylp
Message:

Misc (re #1370): fixed change video capture device for a call implementation

File:
1 edited

Legend:

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

    r3793 r3799  
    18221822    pjmedia_event_unsubscribe(&call_med->esub_cap); 
    18231823     
    1824     /* = Detach stream port from the old capture device = */ 
    1825     status = pjmedia_vid_port_disconnect(w->vp_cap); 
    1826     if (status != PJ_SUCCESS) 
    1827         return status; 
    1828  
     1824    /* temporarily disconnect while we operate on the tee. */ 
     1825    pjmedia_vid_port_disconnect(w->vp_cap); 
     1826 
     1827    /* = Detach stream port from the old capture device's tee = */ 
    18291828    status = pjmedia_vid_tee_remove_dst_port(w->tee, media_port); 
    18301829    if (status != PJ_SUCCESS) { 
    1831         /* Connect back the old capturer */ 
    1832         pjmedia_vid_port_connect(w->vp_cap, media_port, PJ_FALSE); 
    1833         return status; 
    1834     } 
     1830        /* Something wrong, assume that media_port has been removed 
     1831         * and continue. 
     1832         */ 
     1833        PJ_PERROR(4,(THIS_FILE, status, 
     1834                     "Warning: call %d: unable to remove video from tee", 
     1835                     call->index)); 
     1836    } 
     1837 
     1838    /* Reconnect again immediately. We're done with w->tee */ 
     1839    pjmedia_vid_port_connect(w->vp_cap, w->tee, PJ_FALSE); 
    18351840 
    18361841    /* = Attach stream port to the new capture device = */ 
     
    18621867        goto on_error; 
    18631868 
    1864     /* Connect capturer to tee */ 
    1865     status = pjmedia_vid_port_connect(new_w->vp_cap, new_w->tee, PJ_FALSE); 
    1866     if (status != PJ_SUCCESS) 
    1867         return status; 
    1868  
    18691869    if (w->vp_rend) { 
    18701870        /* Start renderer */ 
     
    18811881 
    18821882    /* Start capturer */ 
    1883     status = pjmedia_vid_port_start(new_w->vp_cap); 
    1884     if (status != PJ_SUCCESS) 
    1885         goto on_error; 
     1883    if (!pjmedia_vid_port_is_running(new_w->vp_cap)) { 
     1884        status = pjmedia_vid_port_start(new_w->vp_cap); 
     1885        if (status != PJ_SUCCESS) 
     1886            goto on_error; 
     1887    } 
    18861888 
    18871889    /* Finally */ 
     
    18931895 
    18941896on_error: 
     1897    PJ_PERROR(4,(THIS_FILE, status, 
     1898                 "Call %d: error changing capture device to %d", 
     1899                 call->index, cap_dev)); 
     1900 
    18951901    if (new_w) { 
     1902        /* Unsubscribe, just in case */ 
     1903        pjmedia_event_unsubscribe(&call_med->esub_cap); 
    18961904        /* Disconnect media port from the new capturer */ 
    18971905        pjmedia_vid_tee_remove_dst_port(new_w->tee, media_port); 
     
    19011909 
    19021910    /* Revert back to the old capturer */ 
     1911    pjmedia_vid_port_disconnect(w->vp_cap); 
    19031912    status = pjmedia_vid_tee_add_dst_port2(w->tee, 0, media_port); 
     1913    pjmedia_vid_port_connect(w->vp_cap, w->tee, PJ_FALSE); 
    19041914    if (status != PJ_SUCCESS) 
    19051915        return status; 
    19061916 
    1907     status = pjmedia_vid_port_connect(w->vp_cap, w->tee, PJ_FALSE); 
    1908     if (status != PJ_SUCCESS) 
    1909         return status; 
     1917#if ENABLE_EVENT 
     1918    /* Resubscribe */ 
     1919    pjmedia_event_subscribe( 
     1920            pjmedia_vid_port_get_event_publisher(w->vp_cap), 
     1921            &call_med->esub_cap); 
     1922#endif 
    19101923 
    19111924    return status; 
Note: See TracChangeset for help on using the changeset viewer.