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
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • pjproject/trunk/pjsip-apps/src/pjsua/android/app/src/main/java/MainActivity.java

    r5508 r5525  
    139139            } 
    140140        } 
     141 
     142        @Override 
     143        public void onCallVideoStart() { 
     144            MainActivity ma = ((MyHandler)ui_handler.get()).mTarget.get(); 
     145            SurfaceView surfaceView = (SurfaceView) 
     146                ma.findViewById(R.id.surfaceViewIncomingCall); 
     147 
     148            WindowHandle wh = new WindowHandle(); 
     149            wh.setWindow(surfaceView.getHolder().getSurface()); 
     150            pjsua.setVideoWindow(wh); 
     151        } 
    141152    } 
    142153 
     
    262273    public void surfaceChanged(SurfaceHolder holder, int format, int w, int h) 
    263274    { 
    264         pjsua.setIncomingVideoRenderer(holder.getSurface()); 
     275        WindowHandle wh = new WindowHandle(); 
     276        wh.setWindow(holder.getSurface()); 
     277        pjsua.setVideoWindow(wh); 
    265278    } 
    266279 
    267280    public void surfaceCreated(SurfaceHolder holder) 
    268281    { 
    269         pjsua.setIncomingVideoRenderer(holder.getSurface()); 
     282 
    270283    } 
    271284 
    272285    public void surfaceDestroyed(SurfaceHolder holder) 
    273286    { 
    274         pjsua.setIncomingVideoRenderer(null); 
     287        WindowHandle wh = new WindowHandle(); 
     288        wh.setWindow(null); 
     289        pjsua.setVideoWindow(wh); 
    275290    } 
    276291     
  • pjproject/trunk/pjsip-apps/src/pjsua/android/app/src/main/java/org/pjsip/pjsua

    • Property svn:ignore
      •  

        old new  
        11Pjsua*.java 
        22pjsua*.java 
         3SWIG*.java 
         4WindowHandle.java 
         5 
  • 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.