Changeset 6085


Ignore:
Timestamp:
Oct 4, 2019 4:26:39 AM (4 years ago)
Author:
nanang
Message:

Fixed #2239:

  • Deinit OpenGL immediately when initialization fails, so video device start() and put_frame() will return immediately.
  • Introduced new media event PJMEDIA_EVENT_VID_DEV_ERROR, used for notifying app when video device reinit (due to format change) fails.
Location:
pjproject/trunk
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • pjproject/trunk/pjmedia/include/pjmedia/event.h

    r6005 r6085  
    2727#include <pjmedia/format.h> 
    2828#include <pjmedia/signatures.h> 
     29#include <pjmedia/videodev.h> 
    2930 
    3031PJ_BEGIN_DECL 
     
    9798 
    9899    /** 
     100     * Video device stopped on error. 
     101     */ 
     102    PJMEDIA_EVENT_VID_DEV_ERROR = PJMEDIA_FOURCC('V', 'E', 'R', 'R'), 
     103 
     104    /** 
    99105     * Transport media error. 
    100106     */ 
     
    159165    /** The error code */ 
    160166    pj_status_t              status; 
     167 
    161168} pjmedia_event_aud_dev_err_data; 
     169 
     170/** 
     171 * Additional data/parameters for video device error event. 
     172 */ 
     173typedef struct pjmedia_event_vid_dev_err_data 
     174{ 
     175    /** The media direction that fails */ 
     176    pjmedia_dir              dir; 
     177 
     178    /** The video device ID */ 
     179    pjmedia_vid_dev_index    id; 
     180 
     181    /** The error code */ 
     182    pj_status_t              status; 
     183 
     184} pjmedia_event_vid_dev_err_data; 
    162185 
    163186/** 
     
    265288        /** Audio device error event data */ 
    266289        pjmedia_event_aud_dev_err_data          aud_dev_err; 
     290 
     291        /** Video device error event data */ 
     292        pjmedia_event_vid_dev_err_data          vid_dev_err; 
    267293 
    268294        /** Storage for user event data */ 
  • pjproject/trunk/pjmedia/include/pjmedia/videodev.h

    r5255 r6085  
    2626#include <pjmedia-videodev/config.h> 
    2727#include <pjmedia-videodev/errno.h> 
    28 #include <pjmedia/event.h> 
    2928#include <pjmedia/frame.h> 
    3029#include <pjmedia/format.h> 
  • pjproject/trunk/pjmedia/src/pjmedia-videodev/android_opengl.c

    r5028 r6085  
    115115static pj_status_t andgl_stream_destroy(pjmedia_vid_dev_stream *strm); 
    116116 
     117static pj_status_t init_opengl(void * data); 
     118static pj_status_t deinit_opengl(void * data); 
     119 
    117120/* Job queue prototypes */ 
    118121static pj_status_t job_queue_create(pj_pool_t *pool, job_queue **pjq); 
     
    155158    { \ 
    156159        PJ_LOG(3, (THIS_FILE, "Unable to %s %d", str, eglGetError())); \ 
    157         return PJMEDIA_EVID_SYSERR; \ 
     160        status = PJMEDIA_EVID_SYSERR; \ 
     161        goto on_return; \ 
    158162    } 
    159163 
     
    173177    EGLint width; 
    174178    EGLint height; 
     179    pj_status_t status; 
    175180     
    176181    strm->display = eglGetDisplay(EGL_DEFAULT_DISPLAY); 
     
    220225     
    221226    /* Init GL buffers */ 
    222     return pjmedia_vid_dev_opengl_init_buffers(strm->gl_buf); 
    223 } 
     227    status = pjmedia_vid_dev_opengl_init_buffers(strm->gl_buf); 
     228     
     229on_return: 
     230    if (status != PJ_SUCCESS) 
     231        deinit_opengl(strm); 
     232 
     233    return status; 
     234} 
     235 
     236#undef EGL_ERR 
    224237 
    225238static pj_status_t render(void * data) 
     
    387400        pjmedia_format *fmt = (pjmedia_format *)pval; 
    388401        andgl_fmt_info *ifi; 
     402        pj_status_t status = PJ_SUCCESS; 
    389403         
    390404        if (!(ifi = get_andgl_format_info(fmt->id))) 
     
    407421         
    408422        if (strm->window) 
    409             job_queue_post_job(strm->jq, init_opengl, strm, 0, NULL); 
     423            job_queue_post_job(strm->jq, init_opengl, strm, 0, &status); 
    410424             
    411         PJ_LOG(4, (THIS_FILE, "Re-initializing OpenGL due to format change")); 
    412          
    413         return PJ_SUCCESS; 
     425        PJ_PERROR(4,(THIS_FILE, status, 
     426                     "Re-initializing OpenGL due to format change")); 
     427        return status; 
     428         
    414429    } else if (cap == PJMEDIA_VID_DEV_CAP_OUTPUT_WINDOW) { 
    415430        pj_status_t status = PJ_SUCCESS; 
     
    430445        } 
    431446 
    432         PJ_LOG(4, (THIS_FILE, "Re-initializing OpenGL with native window" 
    433                               " %p: %s", strm->window, 
    434                               (status == PJ_SUCCESS? "success": "failed"))); 
    435          
     447        PJ_PERROR(4,(THIS_FILE, status, 
     448                     "Re-initializing OpenGL with native window %p", 
     449                     strm->window)); 
    436450        return status; 
    437451    } 
  • pjproject/trunk/pjmedia/src/pjmedia-videodev/sdl_dev.c

    r5982 r6085  
    1818 */ 
    1919#include <pjmedia-videodev/videodev_imp.h> 
     20#include <pjmedia/event.h> 
    2021#include <pj/assert.h> 
    2122#include <pj/log.h> 
  • pjproject/trunk/pjmedia/src/pjmedia/vid_port.c

    r6041 r6085  
    10041004                                                &vp->conv.conv_param.dst); 
    10051005            if (status != PJ_SUCCESS) { 
     1006                pjmedia_event e; 
     1007 
    10061008                PJ_PERROR(3,(THIS_FILE, status, 
    10071009                    "failure in changing the format of the video device")); 
     
    10091011                                      status != PJMEDIA_EVID_ERR ? "success" : 
    10101012                                      "failure")); 
     1013 
     1014                pjmedia_event_init(&e, PJMEDIA_EVENT_VID_DEV_ERROR, NULL, vp); 
     1015                e.data.vid_dev_err.dir = vp->dir; 
     1016                e.data.vid_dev_err.status = status; 
     1017                e.data.vid_dev_err.id = (vp->dir==PJMEDIA_DIR_ENCODING? 
     1018                                         vid_param.cap_id : vid_param.rend_id); 
     1019                pjmedia_event_publish(NULL, vp, &e, 
     1020                                      PJMEDIA_EVENT_PUBLISH_POST_EVENT); 
     1021 
    10111022                return status; 
    10121023            } 
  • pjproject/trunk/pjsip/src/pjsua-lib/pjsua_media.c

    r6037 r6085  
    15501550                                           w->rend_slot, NULL); 
    15511551                } 
     1552            } 
     1553            break; 
     1554 
     1555        case PJMEDIA_EVENT_VID_DEV_ERROR: 
     1556            { 
     1557                PJ_PERROR(3,(THIS_FILE, event->data.vid_dev_err.status, 
     1558                             "Video device id=%d error for call %d", 
     1559                             event->data.vid_dev_err.id, 
     1560                             call->index)); 
    15521561            } 
    15531562            break; 
Note: See TracChangeset for help on using the changeset viewer.