Changeset 5007 for pjproject/trunk


Ignore:
Timestamp:
Mar 21, 2015 4:23:07 AM (10 years ago)
Author:
ming
Message:

Re #1790: Reinitialize Android OpenGL renderer when there is format change.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • pjproject/trunk/pjmedia/src/pjmedia-videodev/android_opengl.c

    r4978 r5007  
    282282    } 
    283283     
    284     if (stream->window) { 
    285         ANativeWindow_release(stream->window); 
    286         stream->window = NULL; 
    287     } 
    288      
    289284    stream->display = EGL_NO_DISPLAY; 
    290285    stream->surface = EGL_NO_SURFACE; 
     
    427422            return PJMEDIA_EVID_BADFORMAT; 
    428423         
     424        /* Re-init OpenGL */ 
     425        if (strm->window) 
     426            job_queue_post_job(strm->jq, deinit_opengl, strm, 0, NULL); 
     427 
    429428        pjmedia_format_copy(&strm->param.fmt, fmt); 
    430          
     429 
    431430        vfd = pjmedia_format_get_video_format_detail(fmt, PJ_TRUE); 
    432431        pj_memcpy(&strm->vid_size, &vfd->size, sizeof(vfd->size)); 
    433         if (strm->param.disp_size.w == 0 || strm->param.disp_size.h == 0) 
    434             pj_memcpy(&strm->param.disp_size, &vfd->size, sizeof(vfd->size)); 
     432        pj_memcpy(&strm->param.disp_size, &vfd->size, sizeof(vfd->size)); 
     433         
     434        if (strm->window) 
     435            job_queue_post_job(strm->jq, init_opengl, strm, 0, NULL); 
     436             
     437        PJ_LOG(4, (THIS_FILE, "Re-initializing OpenGL due to format change")); 
    435438         
    436439        return PJ_SUCCESS; 
    437440    } else if (cap == PJMEDIA_VID_DEV_CAP_OUTPUT_WINDOW) { 
    438         pj_bool_t is_running = strm->is_running; 
    439441        pj_status_t status = PJ_SUCCESS; 
    440442        pjmedia_vid_dev_hwnd *wnd = (pjmedia_vid_dev_hwnd *)pval; 
     
    444446            return PJ_SUCCESS; 
    445447         
    446         /* Stop the stream and re-init OpenGL */ 
    447         andgl_stream_stop(s); 
     448        /* Re-init OpenGL */ 
    448449        job_queue_post_job(strm->jq, deinit_opengl, strm, 0, NULL); 
     450        if (strm->window) 
     451            ANativeWindow_release(strm->window); 
    449452 
    450453        strm->window = strm->param.window.info.android.window = native_wnd; 
     
    453456        } 
    454457 
    455         PJ_LOG(3, (THIS_FILE, "Re-initializing OpenGL with window %p: %s", 
     458        PJ_LOG(4, (THIS_FILE, "Re-initializing OpenGL with window %p: %s", 
    456459                              strm->window, 
    457460                              (status == PJ_SUCCESS? "success": "failed"))); 
    458461         
    459         if (is_running) 
    460             andgl_stream_start(s); 
    461  
    462462        return status; 
    463463    } else if (cap == PJMEDIA_VID_DEV_CAP_OUTPUT_RESIZE) { 
     
    526526    job_queue_post_job(stream->jq, deinit_opengl, strm, 0, NULL); 
    527527     
     528    if (stream->window) { 
     529        ANativeWindow_release(stream->window); 
     530        stream->window = NULL; 
     531    } 
     532     
    528533    if (stream->jq) { 
    529534        job_queue_destroy(stream->jq); 
Note: See TracChangeset for help on using the changeset viewer.