summaryrefslogtreecommitdiffstats
path: root/bindings/java/java.i
diff options
context:
space:
mode:
authorbossiel <bossiel@yahoo.fr>2011-08-10 22:59:15 +0000
committerbossiel <bossiel@yahoo.fr>2011-08-10 22:59:15 +0000
commit1ebf5a5fcda0c9154e22ed02404fd46525a7fd9f (patch)
tree4b6214a7142ab1035cb0e47444e88af38e712421 /bindings/java/java.i
downloaddoubango-1.0.zip
doubango-1.0.tar.gz
Move deprecated v1.0 from trunk to branches1.0
Diffstat (limited to 'bindings/java/java.i')
-rw-r--r--bindings/java/java.i79
1 files changed, 79 insertions, 0 deletions
diff --git a/bindings/java/java.i b/bindings/java/java.i
new file mode 100644
index 0000000..6872e59
--- /dev/null
+++ b/bindings/java/java.i
@@ -0,0 +1,79 @@
+/* File : java.i
+* http://www.swig.org/Doc1.3/Java.html
+*/
+
+// http://www.swig.org/Doc1.3/Java.html#enumerations
+%include "enums.swg"
+%javaconst(1);
+
+
+//================== Mapping void* (Java to C) as ByteBuffer
+%typemap(jni) void * "jbyteArray"
+%typemap(jtype) void * "java.nio.ByteBuffer"
+%typemap(jstype) void * "java.nio.ByteBuffer"
+%typemap(javain) void * "$javainput"
+%typemap(javaout) void * { return $jnicall; }
+
+// (From Java to C)
+%typemap(in) void * %{
+ $1 = jenv->GetDirectBufferAddress($input);
+%}
+
+// (From C to Java)
+//%typemap(out) void * %{
+// $result = $1;
+//%}
+%typemap(javadirectorin) void * "$jniinput"
+//==================
+
+
+%typemap(javacode) SipMessage %{
+ public byte[] getSipContent() {
+ final int clen = (int)this.getSipContentLength();
+ if(clen>0){
+ final java.nio.ByteBuffer buffer = java.nio.ByteBuffer.allocateDirect(clen);
+ final int read = (int)this.getSipContent(buffer, clen);
+ final byte[] bytes = new byte[read];
+ buffer.get(bytes, 0, read);
+ return bytes;
+ }
+ return null;
+ }
+%}
+
+%typemap(javacode) SipSession %{
+ protected java.nio.ByteBuffer getByteBuffer(byte[] bytes) {
+ if(bytes != null){
+ final java.nio.ByteBuffer byteBuffer = java.nio.ByteBuffer.allocateDirect(bytes.length);
+ byteBuffer.put(bytes);
+ return byteBuffer;
+ }
+ return null;
+ }
+%}
+
+%typemap(javacode) PublicationSession %{
+ public boolean Publish(byte[] bytes) {
+ if(bytes != null){
+ final java.nio.ByteBuffer byteBuffer = this.getByteBuffer(bytes);
+ return this.publish(byteBuffer, bytes.length);
+ }
+ return false;
+ }
+%}
+
+%typemap(javacode) XcapMessage %{
+ public byte[] getXcapContent() {
+ final int clen = (int)this.getXcapContentLength();
+ if(clen>0){
+ final java.nio.ByteBuffer buffer = java.nio.ByteBuffer.allocateDirect(clen);
+ final int read = (int)this.getXcapContent(buffer, clen);
+ final byte[] bytes = new byte[read];
+ buffer.get(bytes, 0, read);
+ return bytes;
+ }
+ return null;
+ }
+%}
+
+%include ../_common/tinyWRAP.i
OpenPOWER on IntegriCloud