Commit 62c62711 authored by Ghislain MARY's avatar Ghislain MARY
Browse files

Add JNI for the API to handle custom SDP attributes.

parent fe9b63d2
......@@ -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);
......
......@@ -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);
......
......@@ -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}
......
......@@ -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<StreamType> values = new Vector<StreamType>();
/**
* 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.
*
......
......@@ -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) {
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment