#include "private.h"
#include <ortp/telephonyevents.h>
+#include <ortp/zrtp.h>
#include "mediastreamer2/mediastream.h"
#include "mediastreamer2/mseventqueue.h"
#include "mediastreamer2/msvolume.h"
#endif
#endif
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
/*#define UNSTANDART_GSM_11K 1*/
#define ROOT_CA_FILE PACKAGE_DATA_DIR "/linphone/rootca.pem"
#else
sal_root_ca(lc->sal, lp_config_get_string(lc->config,"sip","root_ca", ROOT_CA_FILE));
#endif
-
+
tmp=lp_config_get_int(lc->config,"sip","guess_hostname",1);
linphone_core_set_guess_hostname(lc,tmp);
LinphoneCallParams *linphone_core_create_default_call_parameters(LinphoneCore *lc){
LinphoneCallParams *p=ms_new0(LinphoneCallParams,1);
- p->has_video=linphone_core_video_enabled(lc);
+ linphone_core_init_default_params(lc, p);
return p;
}
int linphone_core_get_max_calls(LinphoneCore *lc) {
return lc->max_calls;
}
-
+ void linphone_core_set_max_calls(LinphoneCore *lc, int max) {
+ lc->max_calls=max;
+ }
typedef struct Hook{
LinphoneCoreIterateHook fun;
lc->zrtp_secrets_cache=file ? ms_strdup(file) : NULL;
}
-// if (stringUri.equals(call.getRemoteAddress().asStringUriOnly())) {
const LinphoneCall* linphone_core_find_call_from_uri(LinphoneCore *lc, const char *uri) {
if (uri == NULL) return NULL;
MSList *calls=lc->calls;
}
return FALSE;
}
+
+void linphone_core_set_srtp_enabled(LinphoneCore *lc, bool_t enabled) {
+ lp_config_set_int(lc->config,"sip","srtp",(int)enabled);
+}
+
+/**
+ * Returns whether a media encryption scheme is supported by the LinphoneCore engine
+**/
+bool_t linphone_core_media_encryption_supported(const LinphoneCore *lc, LinphoneMediaEncryption menc){
+ switch(menc){
+ case LinphoneMediaEncryptionSRTP:
+ return ortp_srtp_supported();
+ case LinphoneMediaEncryptionZRTP:
+ return ortp_zrtp_available();
+ case LinphoneMediaEncryptionNone:
+ return TRUE;
+ }
+ return FALSE;
+}
+
+void linphone_core_set_media_encryption(LinphoneCore *lc, enum LinphoneMediaEncryption menc) {
+ if (menc == LinphoneMediaEncryptionSRTP)
+ lp_config_set_string(lc->config,"sip","media_encryption","srtp");
+ else if (menc == LinphoneMediaEncryptionZRTP)
+ lp_config_set_string(lc->config,"sip","media_encryption","zrtp");
+ else
+ lp_config_set_string(lc->config,"sip","media_encryption","none");
+}
+
+LinphoneMediaEncryption linphone_core_get_media_encryption(LinphoneCore *lc) {
+ const char* menc = lp_config_get_string(lc->config, "sip", "media_encryption", NULL);
+
+ if (menc == NULL)
+ return LinphoneMediaEncryptionNone;
+ else if (strcmp(menc, "srtp")==0)
+ return LinphoneMediaEncryptionSRTP;
+ else if (strcmp(menc, "zrtp")==0)
+ return LinphoneMediaEncryptionZRTP;
+ else
+ return LinphoneMediaEncryptionNone;
+}
+
+bool_t linphone_core_is_media_encryption_mandatory(LinphoneCore *lc) {
+ return (bool_t)lp_config_get_int(lc->config, "sip", "media_encryption_mandatory", 0);
+}
+
+void linphone_core_set_media_encryption_mandatory(LinphoneCore *lc, bool_t m) {
+ lp_config_set_int(lc->config, "sip", "media_encryption_mandatory", (int)m);
+}
+
+void linphone_core_init_default_params(LinphoneCore*lc, LinphoneCallParams *params) {
+ params->has_video=linphone_core_video_enabled(lc);
+ params->media_encryption=linphone_core_get_media_encryption(lc);
+ params->in_conference=FALSE;
+}
+
struct _LinphoneCore *lc;
} LinphoneCallLog;
+enum LinphoneMediaEncryption {
+ LinphoneMediaEncryptionNone,
+ LinphoneMediaEncryptionSRTP,
+ LinphoneMediaEncryptionZRTP
+};
+typedef enum LinphoneMediaEncryption LinphoneMediaEncryption;
/*public: */
void linphone_call_log_set_user_pointer(LinphoneCallLog *cl, void *up);
LinphoneCallParams * linphone_call_params_copy(const LinphoneCallParams *cp);
void linphone_call_params_enable_video(LinphoneCallParams *cp, bool_t enabled);
bool_t linphone_call_params_video_enabled(const LinphoneCallParams *cp);
+enum LinphoneMediaEncryption linphone_call_params_get_media_encryption(LinphoneCallParams *cp);
+void linphone_call_params_set_media_encryption(LinphoneCallParams *cp, enum LinphoneMediaEncryption e);
void linphone_call_params_enable_early_media_sending(LinphoneCallParams *cp, bool_t enabled);
bool_t linphone_call_params_early_media_sending_enabled(const LinphoneCallParams *cp);
bool_t linphone_call_params_local_conference_mode(const LinphoneCallParams *cp);
float linphone_call_get_record_volume(LinphoneCall *call);
float linphone_call_get_current_quality(LinphoneCall *call);
float linphone_call_get_average_quality(LinphoneCall *call);
+bool_t linphone_call_are_all_streams_encrypted(LinphoneCall *call);
+const char* linphone_call_get_authentication_token(LinphoneCall *call);
+bool_t linphone_call_get_authentication_token_verified(LinphoneCall *call);
+void linphone_call_send_vfu_request(LinphoneCall *call);
void *linphone_call_get_user_pointer(LinphoneCall *call);
void linphone_call_set_user_pointer(LinphoneCall *call, void *user_pointer);
/**
*/
void linphone_core_refresh_registers(LinphoneCore* lc);
-
-void linphone_call_send_vfu_request(LinphoneCall *call);
-
/* Path to the file storing secrets cache */
void linphone_core_set_zrtp_secrets_file(LinphoneCore *lc, const char* file);
-bool_t linphone_call_are_all_streams_encrypted(LinphoneCall *call);
-const char* linphone_call_get_authentication_token(LinphoneCall *call);
-bool_t linphone_call_get_authentication_token_verified(LinphoneCall *call);
const LinphoneCall* linphone_core_find_call_from_uri(LinphoneCore *lc, const char *uri);
int linphone_core_get_conference_size(LinphoneCore *lc);
int linphone_core_get_max_calls(LinphoneCore *lc);
+ void linphone_core_set_max_calls(LinphoneCore *lc, int max);
+
bool_t linphone_core_sound_resources_locked(LinphoneCore *lc);
+bool_t linphone_core_media_encryption_supported(const LinphoneCore *lc, LinphoneMediaEncryption menc);
+
+/**
+ * Choose media encryption policy to be used for RTP packets
+ */
+void linphone_core_set_media_encryption(LinphoneCore *lc, enum LinphoneMediaEncryption menc);
+enum LinphoneMediaEncryption linphone_core_get_media_encryption(LinphoneCore *lc);
+
+bool_t linphone_core_is_media_encryption_mandatory(LinphoneCore *lc);
+/**
+ * Defines Linphone behaviour when encryption parameters negociation fails on outoing call.
+ * If set to TRUE call will fail; if set to FALSE will resend an INVITE with encryption disabled
+ */
+void linphone_core_set_media_encryption_mandatory(LinphoneCore *lc, bool_t m);
+
+/**
+ * Init call params using LinphoneCore's current configuration
+ */
+void linphone_core_init_default_params(LinphoneCore*lc, LinphoneCallParams *params);
+
#ifdef __cplusplus
}
#endif
}
+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
+ ,jobject thiz
+ ,jlong lc
+ ) {
+ return media_encryption_enum_to_jstring(env,
+ 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));
+
+ if (menc) env->ReleaseStringUTFChars(jmenc, menc);
+}
+
+extern "C" jstring Java_org_linphone_core_LinphoneCallParamsImpl_getMediaEncryption(JNIEnv* env
+ ,jobject thiz
+ ,jlong lc
+ ) {
+ return media_encryption_enum_to_jstring(env,
+ linphone_call_params_get_media_encryption((LinphoneCallParams*)lc));
+}
+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);
+}
+
+extern "C" jboolean Java_org_linphone_core_LinphoneCoreImpl_getMediaEncryptionMandatory(JNIEnv* env
+ ,jobject thiz
+ ,jlong lc
+ ) {
+ return linphone_core_is_media_encryption_mandatory((LinphoneCore*)lc);
+}
+
+extern "C" void Java_org_linphone_core_LinphoneCoreImpl_setMediaEncryptionMandatory(JNIEnv* env
+ ,jobject thiz
+ ,jlong lc
+ , jboolean yesno
+ ) {
+ linphone_core_set_media_encryption_mandatory((LinphoneCore*)lc, yesno);
+}
//ProxyConfig
extern "C" jint Java_org_linphone_core_LinphoneCoreImpl_getMaxCalls(JNIEnv *env,jobject thiz,jlong pCore) {
return (jint) linphone_core_get_max_calls((LinphoneCore *) pCore);
}
+ extern "C" void Java_org_linphone_core_LinphoneCoreImpl_setMaxCalls(JNIEnv *env,jobject thiz,jlong pCore, jint max) {
+ linphone_core_set_max_calls((LinphoneCore *) pCore, (int) max);
+ }
LinphoneCall findCallFromUri(String uri);
int getMaxCalls();
+ void setMaxCalls(int max);
boolean isMyself(String uri);
/**
* @return
*/
boolean soundResourcesLocked();
+ /**
+ * set media encryption (rtp) to use
+ * @params menc: 'none', 'srtp' or 'zrtp'
+ */
+ void setMediaEncryption(String menc);
+ /**
+ * return selected media encryption
+ * @return 'none', 'srtp' or 'zrtp'
+ */
+ String getMediaEncryption();
+/**
+ * Set media encryption required for outgoing calls
+ */
+ void setMediaEncryptionMandatory(boolean yesno);
+ /**
+ * @return if media encryption is required for ougtoing calls
+ */
+ boolean isMediaEncryptionMandatory();
}