Ignore:
Timestamp:
Jul 26, 2013 9:16:37 AM (11 years ago)
Author:
nanang
Message:

JNI projects:

  • separate makefile for Android and desktop/development
  • simplify build process for Android (upload pregenerated SWIG interface)
  • removed main loop for Android sample app
Location:
pjproject/branches/projects/jni/pjsip-apps/src/jni/src/org/pjsip/hello
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • pjproject/branches/projects/jni/pjsip-apps/src/jni/src/org/pjsip/hello/MainActivity.java

    r4574 r4575  
    1212                setContentView(R.layout.activity_main); 
    1313                 
    14                 /* Call test app here 
    15                 String [] args = {"sip:192.168.1.49"}; 
    16                 hello.main(args); 
    17                 */ 
     14                hello.init(); 
    1815        } 
    1916 
  • pjproject/branches/projects/jni/pjsip-apps/src/jni/src/org/pjsip/hello/hello.java

    r4574 r4575  
    1111class app_config { 
    1212        public static int cur_call_id = -1; 
     13        public static int cur_acc_id = -1; 
    1314} 
    1415 
     
    8384                return (app_config.cur_call_id > -1); 
    8485        } 
    85  
    86         public static void main(String[] args) { 
     86         
     87        public static int init() { 
    8788                int[] tp_id = new int[1]; 
    8889                int[] acc_id = new int[1]; 
    89                 int[] call_id = new int[1]; 
    9090                int status; 
    9191 
     
    9898                        if (status != pjsua.PJ_SUCCESS) { 
    9999                                System.out.println("Error creating pjsua: " + status); 
    100                                 System.exit(status); 
     100                                return status; 
    101101                        } 
    102102                } 
     
    115115                        status = pjsua.init(cfg, log_cfg, null); 
    116116                        if (status != pjsua.PJ_SUCCESS) { 
    117                                 pj_error_exit("Error inintializing pjsua", status); 
     117                                System.out.println("Error initializing pjsua: " + status); 
     118                                return status; 
    118119                        } 
    119120                } 
     
    126127                        status = pjsua.transport_create(pjsip_transport_type_e.PJSIP_TRANSPORT_UDP, cfg, tp_id); 
    127128                        if (status != pjsua.PJ_SUCCESS) { 
    128                                 pj_error_exit("Error creating transport", status); 
     129                                System.out.println("Error creating transport: " + status); 
     130                                return status; 
    129131                        } 
    130132                } 
     
    134136                        status = pjsua.acc_add_local(tp_id[0], true, acc_id); 
    135137                        if (status != pjsua.PJ_SUCCESS) { 
    136                                 pj_error_exit("Error creating local UDP account", status); 
    137                         } 
     138                                System.out.println("Error creating local UDP account: " + status); 
     139                                return status; 
     140                        } 
     141                        app_config.cur_acc_id = acc_id[0];  
    138142                } 
    139143                 
     
    142146                        status = pjsua.start(); 
    143147                        if (status != pjsua.PJ_SUCCESS) { 
    144                                 pj_error_exit("Error starting pjsua", status); 
    145                         } 
    146                 } 
    147                  
    148                 /* Make call to the URL. */ 
    149                 if (false) { 
    150                         status = pjsua.call_make_call(acc_id[0], "sip:localhost:6000", null, 0, null, call_id); 
    151                         if (status != pjsua.PJ_SUCCESS) { 
    152                                 pj_error_exit("Error making call", status); 
    153                         } 
    154                         app_config.cur_call_id = call_id[0]; 
     148                                System.out.println("Error starting pjsua: " + status); 
     149                                return status; 
     150                        } 
    155151                } 
    156152                 
     
    165161 
    166162                        pjsua.schedule_timer(timer, tv); 
     163                } 
     164                 
     165                return pjsua.PJ_SUCCESS; 
     166        } 
     167 
     168 
     169        public static void destroy() { 
     170                pjsua.destroy(); 
     171        } 
     172         
     173 
     174        public static void main(String[] args) 
     175        { 
     176                /* Init pjsua */ 
     177                int status = init(); 
     178                if (status != pjsua.PJ_SUCCESS) { 
     179                        pj_error_exit("Failed initializing pjsua", status); 
     180                } 
     181                 
     182                /* Make call to the URL. */ 
     183                if (args.length > 1) { 
     184                        int[] call_id = new int[1]; 
     185                        status = pjsua.call_make_call(app_config.cur_acc_id, args[1], null, 0, null, call_id); 
     186                        if (status != pjsua.PJ_SUCCESS) { 
     187                                pj_error_exit("Error making call", status); 
     188                        } 
     189                        app_config.cur_call_id = call_id[0]; 
    167190                } 
    168191                 
     
    221244                        } 
    222245                } 
    223  
     246                 
    224247                /* Finally, destroy pjsua */ 
    225                 { 
    226                         pjsua.destroy(); 
    227                 } 
    228                  
    229         } 
    230 } 
     248                destroy(); 
     249 
     250        } 
     251} 
Note: See TracChangeset for help on using the changeset viewer.