Ignore:
Timestamp:
Jan 17, 2017 4:28:39 AM (8 years ago)
Author:
ming
Message:

Re #1945 (misc): Fixed occasional crash in pjsua Android sample app when initializing OpenGL renderer (crash in init_opengl()->ANativeWindow_setBuffersGeometry()). It doesn't happen in pjsua2 sample app.

Location:
pjproject/trunk/pjsip-apps/src/pjsua/android/jni
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • pjproject/trunk/pjsip-apps/src/pjsua/android/jni/pjsua.i

    r5506 r5525  
    1515%feature("director") PjsuaAppCallback; 
    1616 
    17 /* Convert Surface object to ANativeWindow for setIncomingVideoRenderer() */ 
     17/* Convert Surface object to ANativeWindow */ 
    1818%typemap(in) jobject surface { 
    1919    $1 = $input? (jobject)ANativeWindow_fromSurface(jenv, $input) : NULL; 
    2020} 
    2121 
     22%extend WindowHandle { 
     23    void setWindow(jobject surface) { $self->window = surface; } 
     24} 
     25 
    2226%include "pjsua_app_callback.h" 
  • pjproject/trunk/pjsip-apps/src/pjsua/android/jni/pjsua_app_callback.cpp

    r5030 r5525  
    3131static char **restart_argv; 
    3232static pjsua_callback pjsua_cb_orig; 
    33 static jobject callVideoSurface; 
     33static pjsua_vid_win_id winId = PJSUA_INVALID_ID; 
     34 
     35void setVideoWindow(const WindowHandle& win) 
     36{ 
     37    pjmedia_vid_dev_hwnd vhwnd; 
     38    
     39    vhwnd.info.window = win.window; 
     40    if (winId != PJSUA_INVALID_ID) 
     41        pjsua_vid_win_set_win(winId, &vhwnd); 
     42} 
    3443 
    3544extern const char *pjsua_app_def_argv[]; 
     
    5867            med_info->stream.vid.win_in != PJSUA_INVALID_ID) 
    5968        { 
    60             pjmedia_vid_dev_hwnd vhwnd; 
    61  
    62             /* Setup renderer surface */ 
    63             pj_bzero(&vhwnd, sizeof(vhwnd)); 
    64             vhwnd.type = PJMEDIA_VID_DEV_HWND_TYPE_ANDROID; 
    65             vhwnd.info.window = callVideoSurface; 
    66             pjsua_vid_win_set_win(med_info->stream.vid.win_in, &vhwnd); 
     69            winId = med_info->stream.vid.win_in; 
     70            registeredCallbackObject->onCallVideoStart(); 
    6771            break; 
    6872        } 
     
    163167} 
    164168 
    165  
    166 void setIncomingVideoRenderer(jobject surface) 
    167 { 
    168     callVideoSurface = surface; 
    169 } 
    170  
    171169#endif 
  • pjproject/trunk/pjsip-apps/src/pjsua/android/jni/pjsua_app_callback.h

    r5014 r5525  
    2020#define __PJSUA_APP_CALLBACK_H__ 
    2121 
    22 #include <jni.h> 
    23  
    2422class PjsuaAppCallback { 
    2523public: 
     
    2725    virtual void onStarted(const char *msg) {} 
    2826    virtual void onStopped(int restart) {} 
     27    virtual void onCallVideoStart() {} 
    2928}; 
     29 
     30typedef struct WindowHandle { 
     31    void        *window; 
     32} WindowHandle; 
     33 
     34void setVideoWindow(const WindowHandle& win); 
    3035 
    3136extern "C" { 
     
    3439int pjsuaRestart(); 
    3540void setCallbackObject(PjsuaAppCallback* callback); 
    36 void setIncomingVideoRenderer(jobject surface); 
    3741} 
    3842 
Note: See TracChangeset for help on using the changeset viewer.