}
-static enum LinphoneMediaEncryption media_encryption_string_to_enum(const char* menc) {
- if (menc==NULL)
- return LinphoneMediaEncryptionNone;
- else if (strcasecmp(menc, "none")==0)
- return LinphoneMediaEncryptionNone;
- else if (strcasecmp(menc, "srtp")==0)
- return LinphoneMediaEncryptionSRTP;
- else if (strcasecmp(menc, "zrtp")==0)
- return LinphoneMediaEncryptionZRTP;
- else
- return LinphoneMediaEncryptionNone;
-}
-
-static jstring media_encryption_enum_to_jstring(JNIEnv* env, enum LinphoneMediaEncryption enc) {
- switch (enc) {
- case LinphoneMediaEncryptionSRTP:
- return env->NewStringUTF("srtp");
- case LinphoneMediaEncryptionZRTP:
- return env->NewStringUTF("zrtp");
- case LinphoneMediaEncryptionNone:
- return env->NewStringUTF("none");
- default:
- return NULL;
- }
-}
-
-extern "C" jstring Java_org_linphone_core_LinphoneCoreImpl_getMediaEncryption(JNIEnv* env
+extern "C" int Java_org_linphone_core_LinphoneCoreImpl_getMediaEncryption(JNIEnv* env
,jobject thiz
,jlong lc
) {
- return media_encryption_enum_to_jstring(env,
- linphone_core_get_media_encryption((LinphoneCore*)lc));
+ return (int)linphone_core_get_media_encryption((LinphoneCore*)lc);
}
+
extern "C" void Java_org_linphone_core_LinphoneCoreImpl_setMediaEncryption(JNIEnv* env
,jobject thiz
,jlong lc
- ,jstring jmenc) {
- const char* menc = jmenc?env->GetStringUTFChars(jmenc, NULL):NULL;
-
- linphone_core_set_media_encryption((LinphoneCore*)lc,
- media_encryption_string_to_enum(menc));
+ ,int menc) {
+ linphone_core_set_media_encryption((LinphoneCore*)lc,(LinphoneMediaEncryption)menc);
+}
- if (menc) env->ReleaseStringUTFChars(jmenc, menc);
+extern "C" int Java_org_linphone_core_LinphoneCallParamsImpl_getMediaEncryption(JNIEnv* env
+ ,jobject thiz
+ ,jlong cp
+ ) {
+ return (int)linphone_call_params_get_media_encryption((LinphoneCallParams*)cp);
}
-extern "C" jstring Java_org_linphone_core_LinphoneCallParamsImpl_getMediaEncryption(JNIEnv* env
+extern "C" jboolean Java_org_linphone_core_LinphoneCoreImpl_mediaEncryptionSupported(JNIEnv* env
,jobject thiz
- ,jlong lc
+ ,jlong lc, jint menc
) {
- return media_encryption_enum_to_jstring(env,
- linphone_call_params_get_media_encryption((LinphoneCallParams*)lc));
+ return linphone_core_media_encryption_supported((LinphoneCore*)lc,(LinphoneMediaEncryption)menc);
}
+
extern "C" void Java_org_linphone_core_LinphoneCallParamsImpl_setMediaEncryption(JNIEnv* env
,jobject thiz
- ,jlong lc
- ,jstring jmenc) {
- const char* menc = jmenc?env->GetStringUTFChars(jmenc, NULL):NULL;
- linphone_call_params_set_media_encryption((LinphoneCallParams*)lc,
- media_encryption_string_to_enum(menc));
- if (menc) env->ReleaseStringUTFChars(jmenc, menc);
+ ,jlong cp
+ ,int jmenc) {
+ linphone_call_params_set_media_encryption((LinphoneCallParams*)cp,(LinphoneMediaEncryption)jmenc);
}
extern "C" jboolean Java_org_linphone_core_LinphoneCoreImpl_getMediaEncryptionMandatory(JNIEnv* env
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
package org.linphone.core;
-
+import org.linphone.core.LinphoneCore.MediaEncryption;
/**
* 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
/**
* return selected media encryption
- * @return 'none', 'srtp' or 'zrtp'
+ * @return MediaEncryption.None MediaEncryption.SRTP or MediaEncryption.ZRTP
*/
- String getMediaEncryption();
+ MediaEncryption getMediaEncryption();
/**
* set media encryption (rtp) to use
- * @params menc: 'none', 'srtp' or 'zrtp'
+ * @params menc: MediaEncryption.None, MediaEncryption.SRTP or MediaEncryption.ZRTP
*/
- void setMediaEnctyption(String menc);
+ void setMediaEnctyption(MediaEncryption menc);
}
this.tls = t.tls;
}
}
+ /**
+ * Media (RTP) encryption enum-like.
+ *
+ */
+ static public class MediaEncryption {
+ @SuppressWarnings("unchecked")
+ static private Vector values = new Vector();
+ /**
+ * None
+ */
+ static public MediaEncryption None = new MediaEncryption(0,"None");
+ /**
+ * SRTP
+ */
+ static public MediaEncryption SRTP = new MediaEncryption(1,"SRTP");
+ /**
+ * ZRTP
+ */
+ static public MediaEncryption ZRTP = new MediaEncryption(2,"ZRTP");
+ protected final int mValue;
+ private final String mStringValue;
+
+ @SuppressWarnings("unchecked")
+ private MediaEncryption(int value,String stringValue) {
+ mValue = value;
+ values.addElement(this);
+ mStringValue=stringValue;
+ }
+ public static MediaEncryption fromInt(int value) {
+
+ for (int i=0; i<values.size();i++) {
+ MediaEncryption menc = (MediaEncryption) values.elementAt(i);
+ if (menc.mValue == value) return menc;
+ }
+ throw new RuntimeException("MediaEncryption not found ["+value+"]");
+ }
+ public String toString() {
+ return mStringValue;
+ }
+ }
/**
* EC Calibrator Status
*/
* @return
*/
boolean soundResourcesLocked();
+ /**
+ * Returns whether given media encryption is supported by liblinphone.
+ */
+ boolean mediaEncryptionSupported(MediaEncryption menc);
/**
* set media encryption (rtp) to use
- * @params menc: 'none', 'srtp' or 'zrtp'
+ * @params menc: MediaEncryption.None, MediaEncryption.SRTP or MediaEncryption.ZRTP
*/
- void setMediaEncryption(String menc);
+ void setMediaEncryption(MediaEncryption menc);
/**
* return selected media encryption
- * @return 'none', 'srtp' or 'zrtp'
+ * @return MediaEncryption.None, MediaEncryption.SRTP or MediaEncryption.ZRTP
*/
- String getMediaEncryption();
+ MediaEncryption getMediaEncryption();
/**
* Set media encryption required for outgoing calls
*/