Changeset 4575
- Timestamp:
- Jul 26, 2013 9:16:37 AM (11 years ago)
- Location:
- pjproject/branches/projects/jni/pjsip-apps/src/jni
- Files:
-
- 5 added
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
pjproject/branches/projects/jni/pjsip-apps/src/jni/Makefile
r4574 r4575 1 include jni/Android.mk 1 # $Id: Makefile 4563 2013-07-15 05:34:14Z bennylp $ 2 3 # Get PJ build settings 4 include ../../../build.mak 5 include $(PJDIR)/build/common.mak 6 7 # Get JDK location 8 ifeq ("$(JAVA_HOME)","") 9 # Get javac location to determine JDK location 10 JAVAC_PATH = $(shell which javac) 11 ifeq ("$(JAVAC_PATH)","") 12 $(error Cannot determine JDK location using 'which' command. Please define JAVA_HOME envvar) 13 endif 14 15 JAVAC_PATH := $(realpath $(JAVAC_PATH)) 16 JAVA_BIN := $(dir $(JAVAC_PATH)) 17 JAVA_HOME := $(patsubst %/bin/,%,$(JAVA_BIN)) 18 endif 19 20 # OS specific 21 ifeq ($(OS),Windows_NT) 22 MY_JNI_LDFLAGS = -L$(MY_JDK)/lib -Wl,--kill-at 23 MY_JNI_LIB = $(MY_PACKAGE_BIN)/pjsua.dll 24 else 25 MY_JNI_LDFLAGS = -L$(MY_JDK)/lib -Wl,-soname,pjsua.so 26 MY_JNI_LIB = $(MY_PACKAGE_BIN)/libpjsua.so 27 MY_JNI_CFLAGS := -fPIC 28 endif 29 30 # Env settings, e.g: path to SWIG, JDK, java(.exe), javac(.exe) 31 MY_SWIG = swig 32 MY_JDK = $(JAVA_HOME) 33 MY_JAVA = $(MY_JDK)/bin/java 34 MY_JAVAC = $(MY_JDK)/bin/javac 35 MY_JNI_CFLAGS := $(MY_JNI_CFLAGS) -I$(MY_JDK)/include -I$(MY_JDK)/include/win32 \ 36 -I$(MY_JDK)/include/linux -I. 37 38 # Build settings 39 MY_CFLAGS = $(PJ_CFLAGS) $(MY_JNI_CFLAGS) 40 MY_LDFLAGS = $(PJ_LDFLAGS) $(PJ_LDLIBS) $(MY_JNI_LDFLAGS) -static-libstdc++ 41 42 # Output/intermediate path settings 43 MY_PACKAGE = org.pjsip.pjsua 44 MY_OUT_DIR = jni/output 45 MY_SWIG_IF = $(MY_OUT_DIR)/pjsua.i 46 MY_SWIG_FLAG = -c++ -I$(MY_OUT_DIR) # -debug-tmsearch -debug-tmused # -Wall 47 MY_SWIG_WRAPPER = $(MY_OUT_DIR)/pjsua_wrap 48 MY_PACKAGE_SRC = src/$(subst .,/,$(MY_PACKAGE)) 49 MY_PACKAGE_BIN = $(MY_OUT_DIR)/bin 50 51 TEST_PACKAGE = org.pjsip.hello 52 TEST_SRC = src/$(subst .,/,$(TEST_PACKAGE)) 53 54 jni: $(MY_JNI_LIB) java 55 56 clean: 57 rm -f $(MY_OUT_DIR)/*.* 58 rm -rf $(MY_PACKAGE_SRC) 59 60 $(MY_SWIG_IF).tmp: jni/swig_gen.py 61 @mkdir -p $(MY_OUT_DIR) 62 python jni/swig_gen.py > $(MY_SWIG_IF).tmp 63 64 $(MY_SWIG_IF): jni/header.i $(MY_SWIG_IF).tmp 65 cat jni/header.i > $(MY_SWIG_IF) 66 cat $(MY_SWIG_IF).tmp >> $(MY_SWIG_IF) 67 68 $(MY_SWIG_WRAPPER).cpp: $(MY_SWIG_IF) jni/callbacks.i jni/my_typemaps.i 69 @# Cleanup java outdir first, to remove any old/deprecated java files 70 rm -rf $(MY_PACKAGE_SRC) 71 @mkdir -p $(MY_PACKAGE_SRC) 72 $(MY_SWIG) $(MY_SWIG_FLAG) -o $(MY_SWIG_WRAPPER).cpp -package $(MY_PACKAGE) \ 73 -outdir $(MY_PACKAGE_SRC) -java $(MY_SWIG_IF) > $(MY_SWIG_WRAPPER)-tm.log 74 75 $(MY_JNI_LIB): $(MY_SWIG_WRAPPER).cpp 76 @mkdir -p $(MY_PACKAGE_BIN) 77 $(PJ_CXX) -shared -o $(MY_JNI_LIB) $(MY_SWIG_WRAPPER).cpp $(MY_OUT_DIR)/callbacks.cpp \ 78 $(MY_CFLAGS) $(MY_LDFLAGS) 79 80 java: $(TEST_SRC)/hello.java 81 @mkdir -p $(MY_PACKAGE_BIN) 82 $(MY_JAVAC) -d $(MY_PACKAGE_BIN) $(MY_PACKAGE_SRC)/*.java 83 $(MY_JAVAC) -d $(MY_PACKAGE_BIN) -classpath "$(MY_PACKAGE_BIN)" $(TEST_SRC)/hello.java 84 85 test: $(MY_PACKAGE_BIN)/hello.class 86 @# Need to specify classpath and library path, alternatively, they can be set via 87 @# CLASSPATH and java.library.path env settings 88 $(MY_JAVA) -cp $(MY_PACKAGE_BIN) -Djava.library.path="$(MY_PACKAGE_BIN)" hello -
pjproject/branches/projects/jni/pjsip-apps/src/jni/jni/Android.mk
r4574 r4575 18 18 endif 19 19 20 # OS specific21 ifeq ($(OS),Windows_NT)22 MY_JNI_LDFLAGS = -L$(MY_JDK)/lib -Wl,--kill-at23 MY_JNI_LIB = $(MY_PACKAGE_BIN)/pjsua.dll24 else25 20 MY_JNI_LDFLAGS = -L$(MY_JDK)/lib -Wl,-soname,pjsua.so 26 21 MY_JNI_LIB = $(MY_PACKAGE_BIN)/libpjsua.so 27 22 MY_JNI_CFLAGS := -fPIC 28 endif29 23 30 24 # Env settings, e.g: path to SWIG, JDK, java(.exe), javac(.exe) … … 44 38 MY_OUT_DIR = jni/output 45 39 MY_SWIG_IF = $(MY_OUT_DIR)/pjsua.i 46 MY_SWIG_FLAG = -c++ -I$(MY_OUT_DIR) # -debug-tmsearch -debug-tmused # -Wall40 MY_SWIG_FLAG = -c++ -I$(MY_OUT_DIR) 47 41 MY_SWIG_WRAPPER = $(MY_OUT_DIR)/pjsua_wrap 48 42 MY_PACKAGE_SRC = src/$(subst .,/,$(MY_PACKAGE)) … … 65 59 66 60 clean: 67 rm -rf $(MY_ OUT_DIR)61 rm -rf $(MY_SWIG_WRAPPER).* 68 62 rm -rf $(MY_PACKAGE_SRC) 69 70 $(MY_SWIG_IF).tmp: jni/swig_gen.py71 @mkdir -p $(MY_OUT_DIR)72 python jni/swig_gen.py > $(MY_SWIG_IF).tmp73 74 $(MY_SWIG_IF): jni/header.i $(MY_SWIG_IF).tmp75 cat jni/header.i > $(MY_SWIG_IF)76 cat $(MY_SWIG_IF).tmp >> $(MY_SWIG_IF)77 63 78 64 $(MY_SWIG_WRAPPER).cpp: $(MY_SWIG_IF) jni/callbacks.i jni/my_typemaps.i … … 81 67 @mkdir -p $(MY_PACKAGE_SRC) 82 68 $(MY_SWIG) $(MY_SWIG_FLAG) -o $(MY_SWIG_WRAPPER).cpp -package $(MY_PACKAGE) \ 83 -outdir $(MY_PACKAGE_SRC) -java $(MY_SWIG_IF) > $(MY_SWIG_WRAPPER)-tm.log69 -outdir $(MY_PACKAGE_SRC) -java $(MY_SWIG_IF) 84 70 85 71 $(MY_JNI_LIB): $(MY_SWIG_WRAPPER).cpp … … 88 74 $(MY_CFLAGS) $(MY_LDFLAGS) 89 75 90 java: $(TEST_SRC)/hello.java91 @mkdir -p $(MY_PACKAGE_BIN)92 $(MY_JAVAC) -d $(MY_PACKAGE_BIN) $(MY_PACKAGE_SRC)/*.java93 $(MY_JAVAC) -d $(MY_PACKAGE_BIN) -classpath "$(MY_PACKAGE_BIN)" $(TEST_SRC)/hello.java94 95 test: $(MY_PACKAGE_BIN)/hello.class96 @# Need to specify classpath and library path, alternatively, they can be set via97 @# CLASSPATH and java.library.path env settings98 $(MY_JAVA) -cp $(MY_PACKAGE_BIN) -Djava.library.path="$(MY_PACKAGE_BIN)" hello99 100 76 $(LOCAL_PATH)/$(MY_SWIG_WRAPPER).cpp: $(MY_SWIG_WRAPPER).cpp 101 77 -
pjproject/branches/projects/jni/pjsip-apps/src/jni/src/org/pjsip/hello/MainActivity.java
r4574 r4575 12 12 setContentView(R.layout.activity_main); 13 13 14 /* Call test app here 15 String [] args = {"sip:192.168.1.49"}; 16 hello.main(args); 17 */ 14 hello.init(); 18 15 } 19 16 -
pjproject/branches/projects/jni/pjsip-apps/src/jni/src/org/pjsip/hello/hello.java
r4574 r4575 11 11 class app_config { 12 12 public static int cur_call_id = -1; 13 public static int cur_acc_id = -1; 13 14 } 14 15 … … 83 84 return (app_config.cur_call_id > -1); 84 85 } 85 86 public static void main(String[] args) {86 87 public static int init() { 87 88 int[] tp_id = new int[1]; 88 89 int[] acc_id = new int[1]; 89 int[] call_id = new int[1];90 90 int status; 91 91 … … 98 98 if (status != pjsua.PJ_SUCCESS) { 99 99 System.out.println("Error creating pjsua: " + status); 100 System.exit(status);100 return status; 101 101 } 102 102 } … … 115 115 status = pjsua.init(cfg, log_cfg, null); 116 116 if (status != pjsua.PJ_SUCCESS) { 117 pj_error_exit("Error inintializing pjsua", status); 117 System.out.println("Error initializing pjsua: " + status); 118 return status; 118 119 } 119 120 } … … 126 127 status = pjsua.transport_create(pjsip_transport_type_e.PJSIP_TRANSPORT_UDP, cfg, tp_id); 127 128 if (status != pjsua.PJ_SUCCESS) { 128 pj_error_exit("Error creating transport", status); 129 System.out.println("Error creating transport: " + status); 130 return status; 129 131 } 130 132 } … … 134 136 status = pjsua.acc_add_local(tp_id[0], true, acc_id); 135 137 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]; 138 142 } 139 143 … … 142 146 status = pjsua.start(); 143 147 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 } 155 151 } 156 152 … … 165 161 166 162 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]; 167 190 } 168 191 … … 221 244 } 222 245 } 223 246 224 247 /* 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.