From ca9738f673d397e1e94f6d217881318ab84b30f7 Mon Sep 17 00:00:00 2001 From: Jehan Monnier Date: Wed, 4 Feb 2015 17:38:14 +0100 Subject: [PATCH] prepare multicast control api java binding --- coreapi/linphonecore_jni.cc | 139 ++++++++++++++++++ .../org/linphone/core/LinphoneCore.java | 13 +- .../org/linphone/core/LinphoneCoreImpl.java | 68 +++++++++ 3 files changed, 214 insertions(+), 6 deletions(-) diff --git a/coreapi/linphonecore_jni.cc b/coreapi/linphonecore_jni.cc index 6bcc51ccc..fb01e6dbe 100644 --- a/coreapi/linphonecore_jni.cc +++ b/coreapi/linphonecore_jni.cc @@ -5603,3 +5603,142 @@ extern "C" jlong Java_org_linphone_core_LinphoneCoreImpl_createLocalPlayer(JNIEn return (jlong)player; } } + + +/* + * Class: org_linphone_core_LinphoneCoreImpl + * Method: setAudioMulticastAddr + * Signature: (JLjava/lang/String;)I + */ +extern "C" jint JNICALL Java_org_linphone_core_LinphoneCoreImpl_setAudioMulticastAddr + (JNIEnv * env , jobject, jlong ptr, jstring value) { + const char *char_value = value ? env->GetStringUTFChars(value, NULL) : NULL; + LinphoneCore *lc=(LinphoneCore*)ptr; + int result = linphone_core_set_audio_multicast_addr(lc,char_value); + if (char_value) env->ReleaseStringUTFChars(value, char_value); + return result; +} + +/* + * Class: org_linphone_core_LinphoneCoreImpl + * Method: setVideoMulticastAddr + * Signature: (JLjava/lang/String;)I + */ +extern "C" jint JNICALL Java_org_linphone_core_LinphoneCoreImpl_setVideoMulticastAddr + (JNIEnv * env, jobject, jlong ptr, jstring value) { + const char *char_value = value ? env->GetStringUTFChars(value, NULL) : NULL; + LinphoneCore *lc=(LinphoneCore*)ptr; + int result = linphone_core_set_video_multicast_addr(lc,char_value); + if (char_value) env->ReleaseStringUTFChars(value, char_value); + return result; +} + +/* + * Class: org_linphone_core_LinphoneCoreImpl + * Method: getAudioMulticastAddr + * Signature: (J)Ljava/lang/String; + */ +extern "C" jstring JNICALL Java_org_linphone_core_LinphoneCoreImpl_getAudioMulticastAddr + (JNIEnv *, jobject, jlong) { + ms_error("Java_org_linphone_core_LinphoneCoreImpl_getAudioMulticastAddr not implemented yet"); + return NULL; +} + +/* + * Class: org_linphone_core_LinphoneCoreImpl + * Method: getVideoMulticastAddr + * Signature: (J)Ljava/lang/String; + */ +extern "C" jstring JNICALL Java_org_linphone_core_LinphoneCoreImpl_getVideoMulticastAddr + (JNIEnv *, jobject, jlong) { + ms_error("Java_org_linphone_core_LinphoneCoreImpl_getVideoMulticastAddr not implemented yet"); + return NULL; +} + +/* + * Class: org_linphone_core_LinphoneCoreImpl + * Method: setAudioMulticastTtl + * Signature: (JI)I + */ +extern "C" jint JNICALL Java_org_linphone_core_LinphoneCoreImpl_setAudioMulticastTtl + (JNIEnv *, jobject, jlong, jint) { + ms_error("Java_org_linphone_core_LinphoneCoreImpl_setAudioMulticastTtl not implemented yet"); + return -1; +} + +/* + * Class: org_linphone_core_LinphoneCoreImpl + * Method: setVideoMulticastTtl + * Signature: (JI)I + */ +extern "C" jint JNICALL Java_org_linphone_core_LinphoneCoreImpl_setVideoMulticastTtl + (JNIEnv *, jobject, jlong, jint) { + ms_error("Java_org_linphone_core_LinphoneCoreImpl_setVideoMulticastTtl not implemented yet"); + return -1; +} + +/* + * Class: org_linphone_core_LinphoneCoreImpl + * Method: getAudioMulticastTtl + * Signature: (J)I + */ +extern "C" jint JNICALL Java_org_linphone_core_LinphoneCoreImpl_getAudioMulticastTtl + (JNIEnv *, jobject, jlong) { + ms_error("Java_org_linphone_core_LinphoneCoreImpl_getAudioMulticastTtl not implemented yet"); + return -1; +} + +/* + * Class: org_linphone_core_LinphoneCoreImpl + * Method: getVideoMulticastTtl + * Signature: (J)I + */ +extern "C" jint JNICALL Java_org_linphone_core_LinphoneCoreImpl_getVideoMulticastTtl + (JNIEnv *, jobject, jlong) { + ms_error("Java_org_linphone_core_LinphoneCoreImpl_getVideoMulticastTtl not implemented yet"); + return -1; +} + +/* + * Class: org_linphone_core_LinphoneCoreImpl + * Method: enableAudioMulticast + * Signature: (JZ)V + */ +extern "C" void JNICALL Java_org_linphone_core_LinphoneCoreImpl_enableAudioMulticast + (JNIEnv *, jobject, jlong, jboolean) { + ms_error("Java_org_linphone_core_LinphoneCoreImpl_enableAudioMulticast not implemented yet"); +} + +/* + * Class: org_linphone_core_LinphoneCoreImpl + * Method: audioMulticastEnabled + * Signature: (J)Z + */ +extern "C" jboolean JNICALL Java_org_linphone_core_LinphoneCoreImpl_audioMulticastEnabled + (JNIEnv *, jobject, jlong) { + ms_error("Java_org_linphone_core_LinphoneCoreImpl_audioMulticastEnabled not implemented yet"); + return false; +} + +/* + * Class: org_linphone_core_LinphoneCoreImpl + * Method: enableVideoMulticast + * Signature: (JZ)V + */ +extern "C" void JNICALL Java_org_linphone_core_LinphoneCoreImpl_enableVideoMulticast + (JNIEnv *, jobject, jlong, jboolean) { + ms_error("Java_org_linphone_core_LinphoneCoreImpl_enableVideoMulticast not implemented yet"); +} + +/* + * Class: org_linphone_core_LinphoneCoreImpl + * Method: videoMulticastEnabled + * Signature: (J)Z + */ +extern "C" jboolean JNICALL Java_org_linphone_core_LinphoneCoreImpl_videoMulticastEnabled + (JNIEnv *, jobject, jlong) { + ms_error("Java_org_linphone_core_LinphoneCoreImpl_videoMulticastEnabled not implemented yet"); + return false; +} + + diff --git a/java/common/org/linphone/core/LinphoneCore.java b/java/common/org/linphone/core/LinphoneCore.java index 9c2a0f34e..98e9226eb 100644 --- a/java/common/org/linphone/core/LinphoneCore.java +++ b/java/common/org/linphone/core/LinphoneCore.java @@ -1884,15 +1884,16 @@ public interface LinphoneCore { /** * Use to set multicast address to be used for audio stream. * @param ip an ipv4/6 multicast address + * @return * @thow LinphoneCoreException **/ - public setAudioMulticastAddr(String ip) throw LinphoneCoreException; + public void setAudioMulticastAddr(String ip) throws LinphoneCoreException; /** * Use to set multicast address to be used for video stream. * @param ip an ipv4/6 multicast address * @thow LinphoneCoreException **/ - public void setVideoMulticastAddr(String ip); + public void setVideoMulticastAddr(String ip) throws LinphoneCoreException; /** * Use to get multicast address to be used for audio stream. @@ -1911,27 +1912,27 @@ public interface LinphoneCore { * @param ttl value or -1 if not used. [0..255] default value is 1 * @thow LinphoneCoreException **/ - public void setAudioMulticastTtl(int ttl); + public void setAudioMulticastTtl(int ttl) throws LinphoneCoreException; /** * Use to set multicast ttl to be used for video stream. * @param ttl value or -1 if not used. [0..255] default value is 1 * @thow LinphoneCoreException **/ - public void setVideoMulticastTtl(int ttl); + public void setVideoMulticastTtl(int ttl) throws LinphoneCoreException; /** * Use to get multicast ttl to be used for audio stream. * @return a time to leave value * @thow LinphoneCoreException * **/ - public void getAudioMulticastTtl(); + public int getAudioMulticastTtl(); /** * Use to get multicast ttl to be used for video stream. * @return a time to leave value * @thow LinphoneCoreException **/ - public void getVideoMulticastTtl(const LinphoneCore *core); + public int getVideoMulticastTtl(); /** diff --git a/java/impl/org/linphone/core/LinphoneCoreImpl.java b/java/impl/org/linphone/core/LinphoneCoreImpl.java index 4b35f4780..11f62619c 100644 --- a/java/impl/org/linphone/core/LinphoneCoreImpl.java +++ b/java/impl/org/linphone/core/LinphoneCoreImpl.java @@ -1364,4 +1364,72 @@ public class LinphoneCoreImpl implements LinphoneCore { public float getPreferredFramerate() { return getPreferredFramerate(nativePtr); } + + + private native int setAudioMulticastAddr(long nativePtr, String ip); + @Override + public void setAudioMulticastAddr(String ip) throws LinphoneCoreException { + if (setAudioMulticastAddr(nativePtr, ip)!=0) + throw new LinphoneCoreException("bad ip address ["+ip+"]"); + } + private native int setVideoMulticastAddr(long nativePtr, String ip); + @Override + public void setVideoMulticastAddr(String ip) throws LinphoneCoreException { + if (setVideoMulticastAddr(nativePtr, ip)!=0) + throw new LinphoneCoreException("bad ip address ["+ip+"]"); + } + private native String getAudioMulticastAddr(long ptr); + @Override + public String getAudioMulticastAddr() { + return getAudioMulticastAddr() ; + } + private native String getVideoMulticastAddr(long ptr); + @Override + public String getVideoMulticastAddr() { + return getVideoMulticastAddr(); + } + private native int setAudioMulticastTtl(long ptr,int ttl); + @Override + public void setAudioMulticastTtl(int ttl) throws LinphoneCoreException { + if (setAudioMulticastTtl(nativePtr, ttl)!=0) + throw new LinphoneCoreException("bad ttl value ["+ttl+"]"); + + } + private native int setVideoMulticastTtl(long ptr,int ttl); + @Override + public void setVideoMulticastTtl(int ttl) throws LinphoneCoreException { + if (setVideoMulticastTtl(nativePtr, ttl)!=0) + throw new LinphoneCoreException("bad ttl value ["+ttl+"]"); + } + private native int getAudioMulticastTtl(long ptr); + @Override + public int getAudioMulticastTtl() { + return getAudioMulticastTtl(nativePtr); + } + private native int getVideoMulticastTtl(long ptr); + @Override + public int getVideoMulticastTtl() { + return getVideoMulticastTtl(nativePtr); + } + private native void enableAudioMulticast(long ptr,boolean yesno); + @Override + public void enableAudioMulticast(boolean yesno) { + enableAudioMulticast(nativePtr,yesno); + } + private native boolean audioMulticastEnabled(long ptr); + @Override + public boolean audioMulticastEnabled() { + return audioMulticastEnabled(nativePtr); + } + private native void enableVideoMulticast(long ptr,boolean yesno); + + @Override + public void enableVideoMulticast(boolean yesno) { + enableVideoMulticast(nativePtr,yesno); + } + private native boolean videoMulticastEnabled(long ptr); + @Override + public boolean videoMulticastEnabled() { + return videoMulticastEnabled(nativePtr); + } }