- Timestamp:
- Jun 29, 2013 1:14:27 AM (10 years ago)
- Location:
- pjproject/branches/projects/jni/pjsip-apps/src/jni
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
pjproject/branches/projects/jni/pjsip-apps/src/jni
-
Property
svn:ignore
set to
output
yacctab.py
lextab.py
*.log
-
Property
svn:ignore
set to
-
pjproject/branches/projects/jni/pjsip-apps/src/jni/header.i
r4541 r4549 1 %module pjsua 1 /* $Id$ */ 2 2 3 %include "typemaps.i" 3 %module (directors="1") pjsua 4 4 5 %include "enums.swg" 5 %include " arrays_java.i"6 %include "../my_typemaps.i" 6 7 7 8 %header %{ 8 9 #include <pjsua-lib/pjsua.h> 9 extern pjsua_callback* PJSUA_CALLBACK_PROXY;10 10 %} 11 11 12 /* 'void *' shall be handled as byte arrays */ 13 %typemap(jni) void * "void *" 14 %typemap(jtype) void * "byte[]" 15 %typemap(jstype) void * "byte[]" 16 %typemap(javain) void * "$javainput" 17 %typemap(javadirectorin) void * "$jniinput" 18 %typemap(in) void * { $1 = $input; } 19 %typemap(out) void * { $result = $1; } 20 %typemap(javaout) void * { return $jnicall; } 12 /* Strip "pjsua_" prefix from pjsua functions, for better compatibility with 13 * pjsip-jni & csipsimple. 14 */ 15 %rename("%(strip:[pjsua_])s", %$isfunction) ""; 21 16 22 /* Apply output args */ 23 %apply unsigned *INOUT { unsigned *count }; 24 %apply unsigned *OUTPUT { unsigned *tx_level }; 25 %apply unsigned *OUTPUT { unsigned *rx_level }; 26 %apply unsigned *OUTPUT { unsigned *p_tail_ms }; 27 %apply int *OUTPUT { pjsua_acc_id *p_acc_id }; 28 %apply int *OUTPUT { pjsua_call_id *p_call_id }; 29 %apply int *OUTPUT { pjsua_transport_id *p_id }; 30 %apply int *OUTPUT { pjsua_recorder_id *p_id }; 31 %apply int *OUTPUT { pjsua_player_id *p_id }; 32 %apply int *OUTPUT { pjsua_buddy_id *p_buddy_id }; 33 %apply int *OUTPUT { pjsua_conf_port_id *p_id }; 34 %apply int *OUTPUT { int *capture_dev }; 35 %apply int *OUTPUT { int *playback_dev }; 36 %apply int *OUTPUT { pj_stun_nat_type * }; 37 %apply int[ANY] { pjmedia_format_id dec_fmt_id[8] }; 17 /* Map 'void *' simply as long, app can use this "long" as index of its real user data */ 18 %apply long { void * }; 38 19 39 /* Array of pj_str_t */ 20 /* Handle void *[ANY], e.g: pjsip_tx_data::mod_data, pjsip_transaction::mod_data */ 21 //%ignore pjsip_tx_data::mod_data; 22 //%ignore pjsip_transaction::mod_data; 23 %apply long[ANY] { void *[ANY] }; 24 25 /* Map "int*" & "unsigned*" as input & output */ 26 %apply unsigned *INOUT { unsigned * }; 27 %apply int *INOUT { int * }; 28 29 /* Map the following args as input & output */ 30 %apply int *INOUT { pj_stun_nat_type * }; 31 %apply int *INOUT { pjsip_status_code * }; 32 %apply int[ANY] { pjmedia_format_id dec_fmt_id[ANY] }; 33 34 /* Handle array of pj_str_t */ 40 35 JAVA_ARRAYSOFCLASSES(pj_str_t) 41 #ifndef __cplusplus42 /* On C target, pj_str_t::cArrayWrap/Unwrap Java code are missing, this somehow 'fixes' it. */43 JAVA_ARRAYSOFCLASSES(struct pj_str_t)44 #endif45 36 46 /* Array of pj_ssl_cipher in pjsip_tls_setting. Warning: this breaks JAVA_ARRAYS_TYPEMAPS(int)! */ 47 %typemap(out) int[] %{$result = SWIG_JavaArrayOutInt(jenv, (int*)$1, arg1->ciphers_num); %} 48 %apply int[] { pj_ssl_cipher* }; 49 %ignore pjsip_tls_setting::ciphers; 50 %ignore pjsip_tls_setting::ciphers_num; 51 %extend pjsip_tls_setting { 52 void setCiphers(pj_ssl_cipher *ciphers, int num) { 53 int i; 54 $self->ciphers = (pj_ssl_cipher*)calloc(num, sizeof(pj_ssl_cipher)); 55 for (i=0; i<num; ++i) $self->ciphers[i] = ciphers[i]; 56 $self->ciphers_num = num; 57 } 58 pj_ssl_cipher* getCiphers() { 59 return $self->ciphers; 60 } 61 }; 37 /* Handle pointer-to-pointer-to-object as input & output */ 38 MY_JAVA_CLASS_INOUT(pjmedia_port, p_port) 39 MY_JAVA_CLASS_INOUT(pjsip_tx_data, p_tdata) 62 40 41 /* Handle array of pj_ssl_cipher in pjsip_tls_setting. */ 42 MY_JAVA_MEMBER_ARRAY_OF_ENUM(pjsip_tls_setting, pj_ssl_cipher, ciphers, ciphers_num) 63 43 64 /* C++ SWIG target doesn't support nested class (C version does though). 44 /* Handle array of pointer in struct/class member */ 45 MY_JAVA_MEMBER_ARRAY_OF_POINTER(pjsip_regc_cbparam, pjsip_contact_hdr, contact, contact_cnt) 46 MY_JAVA_MEMBER_ARRAY_OF_POINTER(pjmedia_sdp_session, pjmedia_sdp_media, media, media_count) 47 MY_JAVA_MEMBER_ARRAY_OF_POINTER(pjmedia_sdp_media, pjmedia_sdp_bandw, bandw, bandw_count) 48 MY_JAVA_MEMBER_ARRAY_OF_POINTER(pjmedia_sdp_media, pjmedia_sdp_attr, attr, attr_count) 49 50 /* C++ SWIG target doesn't support nested class (C version does though!). 65 51 * This is minimal workaround, ignore nested class as if it is not there. 66 52 * TODO: proper workaround will be moving out inner classes to global scope. … … 72 58 #endif 73 59 74 /* Typemaps for marshalling pjmedia_port ** */ 75 %typemap(jni) pjmedia_port **p_port "jobject" 76 %typemap(jtype) pjmedia_port **p_port "pjmedia_port" 77 %typemap(jstype) pjmedia_port **p_port "pjmedia_port" 78 79 /* Typemaps for pjmedia_port ** as a parameter output type */ 80 %typemap(in) pjmedia_port **p_port (pjmedia_port *ppMediaPort = 0) %{ $1 = &ppMediaPort; %} 81 %typemap(argout) pjmedia_port **p_port { 82 // Give Java proxy the C pointer (of newly created object) 83 jclass clazz = JCALL1(FindClass, jenv, "org/pjsip/pjsua/pjmedia_port"); 84 jfieldID fid = JCALL3(GetFieldID, jenv, clazz, "swigCPtr", "J"); 85 jlong cPtr = 0; 86 *(pjmedia_port **)&cPtr = *$1; 87 JCALL3(SetLongField, jenv, $input, fid, cPtr); 88 } 89 %typemap(javain) pjmedia_port **p_port "$javainput" 90 91 92 /* Strip "pjsua_" prefix from pjsua functions, for better compatibility with 93 * pjsip-jni & csipsimple. 94 */ 95 %rename("%(strip:[pjsua_])s", %$isfunction) ""; 96 97 /* Automatically init pjsua_config::cb to cb proxy via pjsua_config_default() */ 98 /* 1. Hide 'cb' from 'pjsua_config' */ 99 %ignore pjsua_config::cb; 100 /* 2. Ignore original pjsua_config_default() */ 101 %ignore pjsua_config_default; 102 /* 3. Optional, put back "pjsua_" prefix, if stripping is not preferred */ 103 //%rename(pjsua_config_default) config_default; 104 /* 4. Put custom implementation */ 105 %inline %{ 106 void config_default(pjsua_config *cfg) { 107 pjsua_config_default(cfg); 108 cfg->cb = *PJSUA_CALLBACK_PROXY; 109 } 110 %} 60 %include "../callbacks.i" 111 61 112 62 /* Global constants */
Note: See TracChangeset
for help on using the changeset viewer.