]> sjero.net Git - linphone/commitdiff
Merge branch 'master' of git.linphone.org:linphone
authorSimon Morlat <simon.morlat@linphone.org>
Fri, 4 Nov 2011 09:32:28 +0000 (10:32 +0100)
committerSimon Morlat <simon.morlat@linphone.org>
Fri, 4 Nov 2011 09:32:28 +0000 (10:32 +0100)
1  2 
coreapi/linphonecore.c
coreapi/linphonecore.h
coreapi/linphonecore_jni.cc
java/common/org/linphone/core/LinphoneCore.java

diff --combined coreapi/linphonecore.c
index c4b5dbb6e91ea720f2a5234a7d3716b7495ff6be,afdcf01b3b2773e90ab7816c907fb83cc33714da..3398bf82219122b7048bd31d7e4def234fd938d4
@@@ -23,7 -23,6 +23,7 @@@ Foundation, Inc., 59 Temple Place - Sui
  #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"
@@@ -528,7 -523,7 +528,7 @@@ static void sip_config_read(LinphoneCor
  #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);
  
@@@ -4265,7 -4260,7 +4265,7 @@@ LinphoneGlobalState linphone_core_get_g
  
  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;
  }
  
@@@ -4316,7 -4311,9 +4316,9 @@@ void linphone_core_stop_dtmf_stream(Lin
  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;
@@@ -4368,6 -4365,7 +4370,6 @@@ void linphone_core_set_zrtp_secrets_fil
        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;
@@@ -4414,59 -4412,3 +4416,59 @@@ bool_t linphone_core_sound_resources_lo
        }
        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;
 +}
 +
diff --combined coreapi/linphonecore.h
index f4bb368c61240e1c40ed9ee7b10e1e69fa41ffe8,245bd899b18367965c1955d910bf1ebba337270c..8b747659e2929203c6a284f4250772e2f72204ac
@@@ -156,13 -156,7 +156,13 @@@ typedef struct _LinphoneCallLog
        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);
@@@ -185,8 -179,6 +185,8 @@@ typedef struct _LinphoneCallParams Linp
  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);
@@@ -267,10 -259,6 +267,10 @@@ float linphone_call_get_play_volume(Lin
  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);
  /**
@@@ -1019,9 -1007,15 +1019,9 @@@ LinphoneGlobalState linphone_core_get_g
   */
  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);
  
@@@ -1037,28 -1031,10 +1037,30 @@@ int linphone_core_terminate_conference(
  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
index 4dab0d0a84ca2cf505cafc0b252b62306136ce23,fdd035de48114c0862ebf4dbd433590ed853020f..1bd7d091287a4528d3b5b3701829fac4a4ddfe7b
@@@ -775,82 -775,7 +775,82 @@@ extern "C" jint Java_org_linphone_core_
  
  }
  
 +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
  
@@@ -1598,3 -1523,6 +1598,6 @@@ extern "C" void Java_org_linphone_Linph
  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);
+ }
index 0bea6f60c4d1ffefcf2d611b90b29a466c31600c,249dff5587774f8860fe9160fa6caf34926f5a87..944fa026d2f5f3956ab6c7fd7442733b550edfba
@@@ -623,6 -623,7 +623,7 @@@ public interface LinphoneCore 
        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();
  }