diff --git a/coreapi/call_params.h b/coreapi/call_params.h index a9e81ee5e..847b93e68 100644 --- a/coreapi/call_params.h +++ b/coreapi/call_params.h @@ -400,6 +400,7 @@ LINPHONE_PUBLIC void linphone_call_params_add_custom_sdp_attribute(LinphoneCallP /** * Add a custom attribute related to a specific stream in the SDP exchanged within SIP messages during a call. * @param[in] params The #LinphoneCallParams to add a custom SDP attribute to. + * @param[in] type The type of the stream to add a custom SDP attribute to. * @param[in] attribute_name The name of the attribute to add. * @param[in] attribute_value The content value of the attribute to add. * @ingroup media_parameters @@ -411,14 +412,17 @@ LINPHONE_PUBLIC void linphone_call_params_add_custom_sdp_media_attribute(Linphon * @param[in] params The #LinphoneCallParams to get the custom SDP attribute from. * @param[in] attribute_name The name of the attribute to get. * @return The content value of the attribute or NULL if not found. + * @ingroup media_parameters **/ LINPHONE_PUBLIC const char * linphone_call_params_get_custom_sdp_attribute(const LinphoneCallParams *params, const char *attribute_name); /** * Get a custom SDP attribute that is related to a specific stream. * @param[in] params The #LinphoneCallParams to get the custom SDP attribute from. + * @param[in] type The type of the stream to add a custom SDP attribute to. * @param[in] attribute_name The name of the attribute to get. * @return The content value of the attribute or NULL if not found. + * @ingroup media_parameters **/ LINPHONE_PUBLIC const char * linphone_call_params_get_custom_sdp_media_attribute(const LinphoneCallParams *params, LinphoneStreamType type, const char *attribute_name); diff --git a/coreapi/linphonecore_jni.cc b/coreapi/linphonecore_jni.cc index 01d63f74b..fbe1bd9e4 100644 --- a/coreapi/linphonecore_jni.cc +++ b/coreapi/linphonecore_jni.cc @@ -3657,6 +3657,36 @@ extern "C" void Java_org_linphone_core_LinphoneCallParamsImpl_addCustomHeader(JN env->ReleaseStringUTFChars(jheader_value, header_value); } +JNIEXPORT void JNICALL Java_org_linphone_core_LinphoneCallParamsImpl_addCustomSdpAttribute(JNIEnv *env, jobject thiz, jlong ptr, jstring jname, jstring jvalue) { + const char *name = env->GetStringUTFChars(jname, NULL); + const char *value = env->GetStringUTFChars(jvalue, NULL); + linphone_call_params_add_custom_sdp_attribute((LinphoneCallParams *)ptr, name, value); + env->ReleaseStringUTFChars(jname, name); + env->ReleaseStringUTFChars(jvalue, value); +} + +JNIEXPORT void JNICALL Java_org_linphone_core_LinphoneCallParamsImpl_addCustomSdpMediaAttribute(JNIEnv *env, jobject thiz, jlong ptr, jint jtype, jstring jname, jstring jvalue) { + const char *name = env->GetStringUTFChars(jname, NULL); + const char *value = env->GetStringUTFChars(jvalue, NULL); + linphone_call_params_add_custom_sdp_media_attribute((LinphoneCallParams *)ptr, (LinphoneStreamType)jtype, name, value); + env->ReleaseStringUTFChars(jname, name); + env->ReleaseStringUTFChars(jvalue, value); +} + +JNIEXPORT jstring JNICALL Java_org_linphone_core_LinphoneCallParamsImpl_getCustomSdpAttribute(JNIEnv *env, jobject thiz, jlong ptr, jstring jname) { + const char *name = env->GetStringUTFChars(jname, NULL); + const char *value = linphone_call_params_get_custom_sdp_attribute((LinphoneCallParams *)ptr, name); + env->ReleaseStringUTFChars(jname, name); + return value ? env->NewStringUTF(value) : NULL; +} + +JNIEXPORT jstring JNICALL Java_org_linphone_core_LinphoneCallParamsImpl_getCustomSdpMediaAttribute(JNIEnv *env, jobject thiz, jlong ptr, jint jtype, jstring jname) { + const char *name = env->GetStringUTFChars(jname, NULL); + const char *value = linphone_call_params_get_custom_sdp_media_attribute((LinphoneCallParams *)ptr, (LinphoneStreamType)jtype, name); + env->ReleaseStringUTFChars(jname, name); + return value ? env->NewStringUTF(value) : NULL; +} + extern "C" void Java_org_linphone_core_LinphoneCallParamsImpl_setRecordFile(JNIEnv *env, jobject thiz, jlong lcp, jstring jrecord_file){ if (jrecord_file){ const char* record_file=env->GetStringUTFChars(jrecord_file, NULL); diff --git a/java/common/org/linphone/core/LinphoneCallParams.java b/java/common/org/linphone/core/LinphoneCallParams.java index f0be37ac4..e0caea75c 100644 --- a/java/common/org/linphone/core/LinphoneCallParams.java +++ b/java/common/org/linphone/core/LinphoneCallParams.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.MediaEncryption; +import org.linphone.core.LinphoneCore.StreamType; /** * The LinphoneCallParams is an object containing various call related parameters. * It can be used to retrieve parameters from a currently running call or modify the call's characteristics @@ -96,7 +97,37 @@ public interface LinphoneCallParams { * @return value for the header, or null if it doesn't exist. */ String getCustomHeader(String name); - + + /** + * Add a custom attribute related to all the streams in the SDP exchanged within SIP messages during a call. + * @param name The name of the attribute to add. + * @param value The content value of the attribute to add. + **/ + void addCustomSdpAttribute(String name, String value); + + /** + * Add a custom attribute related to a specific stream in the SDP exchanged within SIP messages during a call. + * @param type The type of the stream to add a custom SDP attribute to. + * @param name The name of the attribute to add. + * @param value The content value of the attribute to add. + **/ + void addCustomSdpMediaAttribute(StreamType type, String name, String value); + + /** + * Get a custom SDP attribute that is related to all the streams. + * @param name The name of the attribute to get. + * @return The content value of the attribute or null if not found. + **/ + String getCustomSdpAttribute(String name); + + /** + * Get a custom SDP attribute that is related to a specific stream. + * @param type The type of the stream to add a custom SDP attribute to. + * @param name The name of the attribute to get. + * @return The content value of the attribute or null if not found. + **/ + String getCustomSdpMediaAttribute(StreamType type, String name); + /** * Set the privacy for the call. * @param privacy_mask a or'd int of values defined in interface {@link org.linphone.core.Privacy} diff --git a/java/common/org/linphone/core/LinphoneCore.java b/java/common/org/linphone/core/LinphoneCore.java index e668520f9..ea205b87c 100644 --- a/java/common/org/linphone/core/LinphoneCore.java +++ b/java/common/org/linphone/core/LinphoneCore.java @@ -250,6 +250,48 @@ public interface LinphoneCore { return "udp["+udp+"] tcp["+tcp+"] tls["+tls+"]"; } } + /** + * Stream type enum-like. + * + */ + static public final class StreamType { + + static private Vector values = new Vector(); + /** + * Audio + */ + static public final StreamType Audio = new StreamType(0, "Audio"); + /** + * Video + */ + static public final StreamType Video = new StreamType(1, "Video"); + /** + * Text + */ + static public final StreamType Text = new StreamType(2, "Text"); + /** + * Unknown + */ + static public final StreamType Unknown = new StreamType(3, "Unknown"); + protected final int mValue; + private final String mStringValue; + + private StreamType(int value, String stringValue) { + mValue = value; + values.addElement(this); + mStringValue = stringValue; + } + public static StreamType fromInt(int value) { + for (int i = 0; i < values.size(); i++) { + StreamType stype = (StreamType) values.elementAt(i); + if (stype.mValue == value) return stype; + } + throw new RuntimeException("StreamType 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 29e5d5c02..83bacb623 100644 --- a/java/impl/org/linphone/core/LinphoneCallParamsImpl.java +++ b/java/impl/org/linphone/core/LinphoneCallParamsImpl.java @@ -19,6 +19,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. package org.linphone.core; import org.linphone.core.LinphoneCore.MediaEncryption; +import org.linphone.core.LinphoneCore.StreamType; public class LinphoneCallParamsImpl implements LinphoneCallParams { protected final long nativePtr; @@ -107,6 +108,30 @@ public class LinphoneCallParamsImpl implements LinphoneCallParams { return getCustomHeader(nativePtr,name); } + private native void addCustomSdpAttribute(long nativePtr, String name, String value); + @Override + public void addCustomSdpAttribute(String name, String value) { + addCustomSdpAttribute(nativePtr, name, value); + } + + private native void addCustomSdpMediaAttribute(long nativePtr, int type, String name, String value); + @Override + public void addCustomSdpMediaAttribute(StreamType type, String name, String value) { + addCustomSdpMediaAttribute(nativePtr, type.mValue, name, value); + } + + private native String getCustomSdpAttribute(long nativePtr, String name); + @Override + public String getCustomSdpAttribute(String name) { + return getCustomSdpAttribute(nativePtr, name); + } + + private native String getCustomSdpMediaAttribute(long nativePtr, int type, String name); + @Override + public String getCustomSdpMediaAttribute(StreamType type, String name) { + return getCustomSdpMediaAttribute(nativePtr, type.mValue, name); + } + private native void setPrivacy(long nativePtr, int mask); @Override public void setPrivacy(int privacy_mask) {