Ignore:
Timestamp:
Mar 22, 2015 8:53:03 AM (10 years ago)
Author:
nanang
Message:

Re #1790:

  • Removed android_opengl_get_surface() for renderer view setup, Java application can directly supply Surface object as renderer window.
  • Added renderer view on pjsua CLI app sample.
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

    r4496 r5014  
    44#include "pjsua_app_callback.h" 
    55#include "../../pjsua_app.h" 
     6#include <android/native_window_jni.h> 
    67 
    78#ifdef __cplusplus 
     
    1718%} 
    1819 
    19 int pjsuaStart(); 
    20 void pjsuaDestroy(); 
    21 int pjsuaRestart(); 
    22  
    23 /* turn on director wrapping PjsuaAppCallback */ 
     20/* Turn on director wrapping PjsuaAppCallback */ 
    2421%feature("director") PjsuaAppCallback; 
    2522 
     23/* Convert Surface object to ANativeWindow for setIncomingVideoRenderer() */ 
     24%typemap(in) jobject surface { 
     25    $1 = (jobject)ANativeWindow_fromSurface(jenv, $input); 
     26} 
     27 
    2628%include "pjsua_app_callback.h" 
    27  
    28 void setCallbackObject(PjsuaAppCallback* callback); 
    29  
  • pjproject/trunk/pjsip-apps/src/pjsua/android/jni/pjsua_app_callback.cpp

    r5005 r5014  
    3030static int restart_argc; 
    3131static char **restart_argv; 
     32static pjsua_callback pjsua_cb_orig; 
     33static jobject callVideoSurface; 
    3234 
    3335extern const char *pjsua_app_def_argv[]; 
     
    4244} 
    4345 
     46static void on_call_media_state(pjsua_call_id call_id) 
     47{ 
     48    pjsua_call_info call_info; 
     49    unsigned mi; 
     50    pj_bool_t has_error = PJ_FALSE; 
     51 
     52    pjsua_call_get_info(call_id, &call_info); 
     53 
     54    for (mi=0; mi<call_info.media_cnt; ++mi) { 
     55        pjsua_call_media_info *med_info = &call_info.media[mi]; 
     56        if (med_info->type == PJMEDIA_TYPE_VIDEO && 
     57            med_info->status == PJSUA_CALL_MEDIA_ACTIVE && 
     58            med_info->stream.vid.win_in != PJSUA_INVALID_ID) 
     59        { 
     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); 
     67            break; 
     68        } 
     69    } 
     70     
     71    /* Forward to original callback */ 
     72    if (pjsua_cb_orig.on_call_media_state) 
     73        (*pjsua_cb_orig.on_call_media_state)(call_id); 
     74} 
    4475 
    4576/** Callback wrapper **/ 
    4677static void on_cli_config(pjsua_app_config *cfg) 
    4778{ 
     79    pjsua_cb_orig = cfg->cfg.cb; 
    4880    cfg->log_cfg.cb = &log_writer; 
     81     
     82    /* Override pjsua callback, e.g: to install renderer view */ 
     83    cfg->cfg.cb.on_call_media_state = &on_call_media_state; 
    4984} 
    5085 
     
    127162} 
    128163 
     164 
     165void setIncomingVideoRenderer(jobject surface) 
     166{ 
     167    callVideoSurface = surface; 
     168} 
     169 
    129170#endif 
  • pjproject/trunk/pjsip-apps/src/pjsua/android/jni/pjsua_app_callback.h

    r4496 r5014  
    2020#define __PJSUA_APP_CALLBACK_H__ 
    2121 
     22#include <jni.h> 
     23 
    2224class PjsuaAppCallback { 
    2325public: 
     
    3234int pjsuaRestart(); 
    3335void setCallbackObject(PjsuaAppCallback* callback); 
     36void setIncomingVideoRenderer(jobject surface); 
    3437} 
    3538 
Note: See TracChangeset for help on using the changeset viewer.