#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);
break;
}
}
+ /*this is to filter out unsupported encryption schemes*/
+ linphone_core_set_media_encryption(lc,linphone_core_get_media_encryption(lc));
/*for tuning or test*/
lc->sip_conf.sdp_200_ack=lp_config_get_int(lc->config,"sip","sdp_200_ack",0);
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 NULL;
}
+
+
+/**
+ * Check if a call will need the sound resources.
+ *
+ * @ingroup call_control
+ * @param lc The LinphoneCore
+**/
+bool_t linphone_core_sound_resources_locked(LinphoneCore *lc){
+ MSList *calls=lc->calls;
+ while(calls) {
+ LinphoneCall *c=(LinphoneCall*)calls->data;
+ calls=calls->next;
+ switch (c->state) {
+ case LinphoneCallOutgoingInit:
+ case LinphoneCallOutgoingProgress:
+ case LinphoneCallOutgoingRinging:
+ case LinphoneCallOutgoingEarlyMedia:
+ case LinphoneCallConnected:
+ case LinphoneCallRefered:
+ case LinphoneCallIncomingEarlyMedia:
+ case LinphoneCallUpdated:
+ return TRUE;
+ default:
+ break;
+ }
+ }
+ 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;
+}
+
+int linphone_core_set_media_encryption(LinphoneCore *lc, enum LinphoneMediaEncryption menc) {
+ const char *type="none";
+ int ret=0;
+ if (menc == LinphoneMediaEncryptionSRTP){
+ if (!ortp_srtp_supported()){
+ ms_warning("SRTP not supported by library.");
+ type="none";
+ ret=-1;
+ }else type="srtp";
+ }else if (menc == LinphoneMediaEncryptionZRTP){
+ if (!ortp_zrtp_available()){
+ ms_warning("ZRTP not supported by library.");
+ type="none";
+ ret=-1;
+ }else type="zrtp";
+ }
+ lp_config_set_string(lc->config,"sip","media_encryption",type);
+ return ret;
+}
+
+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;
+}
+