diff --git a/coreapi/call_params.h b/coreapi/call_params.h index 847b93e68..6b55f7334 100644 --- a/coreapi/call_params.h +++ b/coreapi/call_params.h @@ -290,14 +290,14 @@ LINPHONE_PUBLIC LinphoneMediaDirection linphone_call_params_get_audio_direction LINPHONE_PUBLIC LinphoneMediaDirection linphone_call_params_get_video_direction(const LinphoneCallParams *cp); /** - * Set the audio stream direction. Only relevant for multicast + * Set the audio stream direction. * @param[in] cl LinphoneCallParams object * @param[in] The audio stream direction associated with this call params. **/ LINPHONE_PUBLIC void linphone_call_params_set_audio_direction(LinphoneCallParams *cp, LinphoneMediaDirection dir); /** - * Set the video stream direction. Only relevant for multicast + * Set the video stream direction. * @param[in] cl LinphoneCallParams object * @param[in] The video stream direction associated with this call params. **/ diff --git a/coreapi/linphonecore_jni.cc b/coreapi/linphonecore_jni.cc index bb54de7c9..989074639 100644 --- a/coreapi/linphonecore_jni.cc +++ b/coreapi/linphonecore_jni.cc @@ -3744,6 +3744,23 @@ extern "C" jintArray Java_org_linphone_core_LinphoneCallParamsImpl_getReceivedVi return arr; } +JNIEXPORT jint JNICALL Java_org_linphone_core_LinphoneCallParamsImpl_getAudioDirection(JNIEnv *env, jobject thiz, jlong ptr) { + return (jint)linphone_call_params_get_audio_direction((LinphoneCallParams *)ptr); +} + +JNIEXPORT jint JNICALL Java_org_linphone_core_LinphoneCallParamsImpl_getVideoDirection(JNIEnv *env, jobject thiz, jlong ptr) { + return (jint)linphone_call_params_get_video_direction((LinphoneCallParams *)ptr); +} + +JNIEXPORT void JNICALL Java_org_linphone_core_LinphoneCallParamsImpl_setAudioDirection(JNIEnv *env, jobject thiz, jlong ptr, jint jdir) { + linphone_call_params_set_audio_direction((LinphoneCallParams *)ptr, (LinphoneMediaDirection)jdir); +} + +JNIEXPORT void JNICALL Java_org_linphone_core_LinphoneCallParamsImpl_setVideoDirection(JNIEnv *env, jobject thiz, jlong ptr, jint jdir) { + linphone_call_params_set_video_direction((LinphoneCallParams *)ptr, (LinphoneMediaDirection)jdir); +} + + extern "C" void Java_org_linphone_core_LinphoneCallParamsImpl_destroy(JNIEnv *env, jobject thiz, jlong lc){ return linphone_call_params_destroy((LinphoneCallParams*)lc); } diff --git a/java/common/org/linphone/core/LinphoneCallParams.java b/java/common/org/linphone/core/LinphoneCallParams.java index e0caea75c..ed16ec396 100644 --- a/java/common/org/linphone/core/LinphoneCallParams.java +++ b/java/common/org/linphone/core/LinphoneCallParams.java @@ -17,6 +17,7 @@ along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ package org.linphone.core; +import org.linphone.core.LinphoneCore.MediaDirection; import org.linphone.core.LinphoneCore.MediaEncryption; import org.linphone.core.LinphoneCore.StreamType; /** @@ -201,6 +202,28 @@ public interface LinphoneCallParams { * @returns returns true if call rtt is activated. **/ boolean realTimeTextEnabled(); - - + + /** + * Get the audio stream direction. + * @return The audio stream direction associated with the call params. + **/ + MediaDirection getAudioDirection(); + + /** + * Get the video stream direction. + * @return The video stream direction associated with the call params. + **/ + MediaDirection getVideoDirection(); + + /** + * Set the audio stream direction. + * @param The audio stream direction associated with this call params. + **/ + void setAudioDirection(MediaDirection dir); + + /** + * Set the video stream direction. + * @param The video stream direction associated with this call params. + **/ + void setVideoDirection(MediaDirection dir); } diff --git a/java/common/org/linphone/core/LinphoneCore.java b/java/common/org/linphone/core/LinphoneCore.java index b4d513f13..f562fd582 100644 --- a/java/common/org/linphone/core/LinphoneCore.java +++ b/java/common/org/linphone/core/LinphoneCore.java @@ -292,6 +292,52 @@ public interface LinphoneCore { return mStringValue; } } + /** + * Stream type enum-like. + * + */ + static public final class MediaDirection { + + static private Vector values = new Vector(); + /** + * Invalid + */ + static public final MediaDirection Invalid = new MediaDirection(-1, "Invalid"); + /** + * Inactive + */ + static public final MediaDirection Inactive = new MediaDirection(0, "Inactive"); + /** + * SendOnly + */ + static public final MediaDirection SendOnly = new MediaDirection(1, "SendOnly"); + /** + * RecvOnly + */ + static public final MediaDirection RecvOnly = new MediaDirection(2, "RecvOnly"); + /** + * SendRecv + */ + static public final MediaDirection SendRecv = new MediaDirection(3, "SendRecv"); + protected final int mValue; + private final String mStringValue; + + private MediaDirection(int value, String stringValue) { + mValue = value; + values.addElement(this); + mStringValue = stringValue; + } + public static MediaDirection fromInt(int value) { + for (int i = 0; i < values.size(); i++) { + MediaDirection dir = (MediaDirection) values.elementAt(i); + if (dir.mValue == value) return dir; + } + throw new RuntimeException("MediaDirection not found [" + value + "]"); + } + public String toString() { + return mStringValue; + } + } /** * Media (RTP) encryption enum-like. * diff --git a/java/impl/org/linphone/core/LinphoneCallParamsImpl.java b/java/impl/org/linphone/core/LinphoneCallParamsImpl.java index 83bacb623..df91d4d81 100644 --- a/java/impl/org/linphone/core/LinphoneCallParamsImpl.java +++ b/java/impl/org/linphone/core/LinphoneCallParamsImpl.java @@ -18,6 +18,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ package org.linphone.core; +import org.linphone.core.LinphoneCore.MediaDirection; import org.linphone.core.LinphoneCore.MediaEncryption; import org.linphone.core.LinphoneCore.StreamType; @@ -208,4 +209,28 @@ public class LinphoneCallParamsImpl implements LinphoneCallParams { public boolean realTimeTextEnabled() { return realTimeTextEnabled(nativePtr); } + + private native int getAudioDirection(long nativePtr); + @Override + public MediaDirection getAudioDirection() { + return MediaDirection.fromInt(getAudioDirection(nativePtr)); + } + + private native int getVideoDirection(long nativePtr); + @Override + public MediaDirection getVideoDirection() { + return MediaDirection.fromInt(getVideoDirection(nativePtr)); + } + + private native void setAudioDirection(long nativePtr, int direction); + @Override + public void setAudioDirection(MediaDirection direction) { + setAudioDirection(nativePtr, direction.mValue); + } + + private native void setVideoDirection(long nativePtr, int direction); + @Override + public void setVideoDirection(MediaDirection direction) { + setVideoDirection(nativePtr, direction.mValue); + } }