]> sjero.net Git - linphone/blobdiff - coreapi/linphonecore.c
Merge branch 'upnp'
[linphone] / coreapi / linphonecore.c
index 9545af23ffc2cdfec817f7769838e70c1360133d..c6a2857fcc48eadc74c8838d44b78be9c5ae3cf6 100644 (file)
@@ -634,7 +634,8 @@ static void sip_config_read(LinphoneCore *lc)
        lc->sip_conf.ping_with_options=lp_config_get_int(lc->config,"sip","ping_with_options",1);
        lc->sip_conf.auto_net_state_mon=lp_config_get_int(lc->config,"sip","auto_net_state_mon",1);
        lc->sip_conf.keepalive_period=lp_config_get_int(lc->config,"sip","keepalive_period",10000);
-       sal_set_keepalive_period(lc->sal,lc->sip_conf.keepalive_period);
+       lc->sip_conf.tcp_tls_keepalive=lp_config_get_int(lc->config,"sip","tcp_tls_keepalive",0);
+       linphone_core_enable_keep_alive(lc, (lc->sip_conf.keepalive_period > 0));
        sal_use_one_matching_codec_policy(lc->sal,lp_config_get_int(lc->config,"sip","only_one_codec",0));
        sal_use_double_registrations(lc->sal,lp_config_get_int(lc->config,"sip","use_double_registrations",1));
        sal_use_dates(lc->sal,lp_config_get_int(lc->config,"sip","put_date",0));
@@ -920,11 +921,14 @@ bool_t linphone_core_tunnel_available(void){
 }
 
 /**
- * Enable adaptive rate control (experimental feature, audio-only).
+ * Enable adaptive rate control.
+ * 
+ * @ingroup media_parameters
  *
  * Adaptive rate control consists in using RTCP feedback provided information to dynamically
- * control the output bitrate of the encoders, so that we can adapt to the network conditions and
- * available bandwidth.
+ * control the output bitrate of the audio and video encoders, so that we can adapt to the network conditions and
+ * available bandwidth. Control of the audio encoder is done in case of audio-only call, and control of the video encoder is done for audio & video calls.
+ * Adaptive rate control feature is enabled by default.
 **/
 void linphone_core_enable_adaptive_rate_control(LinphoneCore *lc, bool_t enabled){
        lp_config_set_int(lc->config,"net","adaptive_rate_control",(int)enabled);
@@ -932,6 +936,8 @@ void linphone_core_enable_adaptive_rate_control(LinphoneCore *lc, bool_t enabled
 
 /**
  * Returns whether adaptive rate control is enabled.
+ * 
+ * @ingroup media_parameters
  *
  * See linphone_core_enable_adaptive_rate_control().
 **/
@@ -1004,14 +1010,18 @@ int linphone_core_get_upload_bandwidth(const LinphoneCore *lc){
        return lc->net_conf.upload_bw;
 }
 /**
- * Set audio packetization time linphone expects to receive from peer
+ * Set audio packetization time linphone expects to receive from peer.
+ * A value of zero means that ptime is not specified.
+ * @ingroup media_parameters
  */
 void linphone_core_set_download_ptime(LinphoneCore *lc, int ptime) {
        lp_config_set_int(lc->config,"rtp","download_ptime",ptime);
 }
 
 /**
- * Get audio packetization time linphone expects to receive from peer
+ * Get audio packetization time linphone expects to receive from peer.
+ * A value of zero means that ptime is not specified.
+ * @ingroup media_parameters
  */
 int linphone_core_get_download_ptime(LinphoneCore *lc) {
        return lp_config_get_int(lc->config,"rtp","download_ptime",0);
@@ -1021,6 +1031,7 @@ int linphone_core_get_download_ptime(LinphoneCore *lc) {
  * Set audio packetization time linphone will send (in absence of requirement from peer)
  * A value of 0 stands for the current codec default packetization time.
  *
+ * @ingroup media_parameters
 **/
 void linphone_core_set_upload_ptime(LinphoneCore *lc, int ptime){
        lp_config_set_int(lc->config,"rtp","upload_ptime",ptime);
@@ -1030,6 +1041,8 @@ void linphone_core_set_upload_ptime(LinphoneCore *lc, int ptime){
  * Set audio packetization time linphone will send (in absence of requirement from peer)
  * A value of 0 stands for the current codec default packetization time.
  *
+ * 
+ * @ingroup media_parameters
 **/
 int linphone_core_get_upload_ptime(LinphoneCore *lc){
        return lp_config_get_int(lc->config,"rtp","upload_ptime",0);
@@ -1266,6 +1279,7 @@ LinphoneCore *linphone_core_new(const LinphoneCoreVTable *vtable,
  * structure holding the codec information.
  * It is possible to make copy of the list with ms_list_copy() in order to modify it
  * (such as the order of codecs).
+ * @ingroup media_parameters
 **/
 const MSList *linphone_core_get_audio_codecs(const LinphoneCore *lc)
 {
@@ -1279,6 +1293,7 @@ const MSList *linphone_core_get_audio_codecs(const LinphoneCore *lc)
  * structure holding the codec information.
  * It is possible to make copy of the list with ms_list_copy() in order to modify it
  * (such as the order of codecs).
+ * @ingroup media_parameters
 **/
 const MSList *linphone_core_get_video_codecs(const LinphoneCore *lc)
 {
@@ -1576,6 +1591,7 @@ void linphone_core_set_audio_port(LinphoneCore *lc, int port)
 
 /**
  * Sets the UDP port range from which to randomly select the port used for audio streaming.
+ * @ingroup media_parameters
  */
 void linphone_core_set_audio_port_range(LinphoneCore *lc, int min_port, int max_port)
 {
@@ -1594,6 +1610,7 @@ void linphone_core_set_video_port(LinphoneCore *lc, int port){
 
 /**
  * Sets the UDP port range from which to randomly select the port used for video streaming.
+ * @ingroup media_parameters
  */
 void linphone_core_set_video_port_range(LinphoneCore *lc, int min_port, int max_port)
 {
@@ -2069,6 +2086,8 @@ void linphone_core_iterate(LinphoneCore *lc){
 /**
  * Interpret a call destination as supplied by the user, and returns a fully qualified
  * LinphoneAddress.
+ * 
+ * @ingroup call_control
  *
  * A sip address should look like DisplayName <sip:username@domain:port> .
  * Basically this function performs the following tasks
@@ -2533,6 +2552,7 @@ LinphoneCall * linphone_core_invite_address_with_params(LinphoneCore *lc, const
 /**
  * Performs a simple call transfer to the specified destination.
  *
+ * @ingroup call_control
  * The remote endpoint is expected to issue a new call to the specified destination.
  * The current call remains active and thus can be later paused or terminated.
 **/
@@ -2563,6 +2583,8 @@ int linphone_core_transfer_call(LinphoneCore *lc, LinphoneCall *call, const char
  * @param lc linphone core object
  * @param call a running call you want to transfer
  * @param dest a running call whose remote person will receive the transfer
+ * 
+ * @ingroup call_control
  *
  * The transfered call is supposed to be in paused state, so that it is able to accept the transfer immediately.
  * The destination call is a call previously established to introduce the transfered person.
@@ -2590,7 +2612,7 @@ bool_t linphone_core_inc_invite_pending(LinphoneCore*lc){
 bool_t linphone_core_incompatible_security(LinphoneCore *lc, SalMediaDescription *md){
        if (linphone_core_is_media_encryption_mandatory(lc) && linphone_core_get_media_encryption(lc)==LinphoneMediaEncryptionSRTP){
                int i;
-               for(i=0;i<md->nstreams;i++){
+               for(i=0;i<md->n_active_streams;i++){
                        SalStreamDescription *sd=&md->streams[i];
                        if (sd->proto!=SalProtoRtpSavp){
                                return TRUE;
@@ -2817,6 +2839,7 @@ int linphone_core_start_accept_call_update(LinphoneCore *lc, LinphoneCall *call)
                linphone_core_update_local_media_description_from_upnp(call->localdesc, call->upnp_session);
        }
 #endif //BUILD_UPNP
+       linphone_call_update_remote_session_id_and_ver(call);
        sal_call_set_local_media_description(call->op,call->localdesc);
        sal_call_accept(call->op);
        md=sal_call_get_final_media_description(call->op);
@@ -2846,6 +2869,8 @@ int linphone_core_start_accept_call_update(LinphoneCore *lc, LinphoneCall *call)
  * @return 0 if sucessful, -1 otherwise (actually when this function call is performed outside ot #LinphoneCallUpdatedByRemote state).
 **/
 int linphone_core_accept_call_update(LinphoneCore *lc, LinphoneCall *call, const LinphoneCallParams *params){
+       SalMediaDescription *remote_desc;
+       bool_t keep_sdp_version;
 #ifdef VIDEO_ENABLED
        bool_t old_has_video = call->params.has_video;
 #endif
@@ -2854,6 +2879,15 @@ int linphone_core_accept_call_update(LinphoneCore *lc, LinphoneCall *call, const
                         linphone_call_state_to_string(call->state));
                return -1;
        }
+       remote_desc = sal_call_get_remote_media_description(call->op);
+       keep_sdp_version = lp_config_get_int(lc->config, "sip", "keep_sdp_version", 0);
+       if (keep_sdp_version &&(remote_desc->session_id == call->remote_session_id) && (remote_desc->session_ver == call->remote_session_ver)) {
+               /* Remote has sent an INVITE with the same SDP as before, so send a 200 OK with the same SDP as before. */
+               ms_warning("SDP version has not changed, send same SDP as before.");
+               sal_call_accept(call->op);
+               linphone_call_set_state(call,LinphoneCallStreamsRunning,"Connected (streams running)");
+               return 0;
+       }
        if (params==NULL){
                call->params.has_video=lc->video_policy.automatically_accept || call->current_params.has_video;
        }else
@@ -2867,11 +2901,11 @@ int linphone_core_accept_call_update(LinphoneCore *lc, LinphoneCall *call, const
                ms_warning("Video isn't supported in conference");
                call->params.has_video = FALSE;
        }
-       call->params.has_video &= linphone_core_media_description_contains_video_stream(sal_call_get_remote_media_description(call->op));
+       call->params.has_video &= linphone_core_media_description_contains_video_stream(remote_desc);
        call->camera_active=call->params.has_video;
        linphone_call_make_local_media_description(lc,call);
        if (call->ice_session != NULL) {
-               linphone_core_update_ice_from_remote_media_description(call, sal_call_get_remote_media_description(call->op));
+               linphone_core_update_ice_from_remote_media_description(call, remote_desc);
 #ifdef VIDEO_ENABLED
                if ((call->ice_session != NULL) &&!ice_session_candidates_gathered(call->ice_session)) {
                        if ((call->params.has_video) && (call->params.has_video != old_has_video)) {
@@ -3015,6 +3049,7 @@ int linphone_core_accept_call_with_params(LinphoneCore *lc, LinphoneCall *call,
                audio_stream_prepare_sound(call->audiostream,lc->sound_conf.play_sndcard,lc->sound_conf.capt_sndcard);
        }
 
+       linphone_call_update_remote_session_id_and_ver(call);
        sal_call_accept(call->op);
        if (lc->vtable.display_status!=NULL)
                lc->vtable.display_status(lc,_("Connected."));
@@ -3115,6 +3150,9 @@ int linphone_core_terminate_call(LinphoneCore *lc, LinphoneCall *the_call)
 
 /**
  * Decline a pending incoming call, with a reason.
+ * 
+ * @ingroup call_control
+ * 
  * @param lc the linphone core
  * @param call the LinphoneCall, must be in the IncomingReceived state.
  * @param reason the reason for rejecting the call: LinphoneReasonDeclined or LinphoneReasonBusy
@@ -3240,6 +3278,7 @@ int linphone_core_pause_call(LinphoneCore *lc, LinphoneCall *call)
 
 /**
  * Pause all currently running calls.
+ * @ingroup call_control
 **/
 int linphone_core_pause_all_calls(LinphoneCore *lc){
        const MSList *elem;
@@ -3322,6 +3361,8 @@ static int remote_address_compare(LinphoneCall *call, const LinphoneAddress *rad
  * @param lc
  * @param remote_address
  * @return the LinphoneCall of the call if found
+ * 
+ * @ingroup call_control
  */
 LinphoneCall *linphone_core_get_call_by_remote_address(LinphoneCore *lc, const char *remote_address){
        LinphoneAddress *raddr=linphone_address_new(remote_address);
@@ -3795,18 +3836,18 @@ const char *linphone_core_get_ring(const LinphoneCore *lc){
  * @param path
  * @param lc The LinphoneCore object
  *
- * @ingroup media_parameters
+ * @ingroup initializing
 **/
 void linphone_core_set_root_ca(LinphoneCore *lc,const char *path){
        sal_set_root_ca(lc->sal, path);
 }
 
 /**
- * Gets the path to a file or folder containing trusted root CAs (PEM format)
+ * Gets the path to a file or folder containing the trusted root CAs (PEM format)
  *
  * @param lc The LinphoneCore object
  *
- * @ingroup media_parameters
+ * @ingroup initializing
 **/
 const char *linphone_core_get_root_ca(LinphoneCore *lc){
        return sal_get_root_ca(lc->sal);
@@ -3814,6 +3855,8 @@ const char *linphone_core_get_root_ca(LinphoneCore *lc){
 
 /**
  * Specify whether the tls server certificate must be verified when connecting to a SIP/TLS server.
+ * 
+ * @ingroup initializing
 **/
 void linphone_core_verify_server_certificates(LinphoneCore *lc, bool_t yesno){
        sal_verify_server_certificates(lc->sal,yesno);
@@ -3821,6 +3864,7 @@ void linphone_core_verify_server_certificates(LinphoneCore *lc, bool_t yesno){
 
 /**
  * Specify whether the tls server certificate common name must be verified when connecting to a SIP/TLS server.
+ * @ingroup initializing
 **/
 void linphone_core_verify_server_cn(LinphoneCore *lc, bool_t yesno){
        sal_verify_server_cn(lc->sal,yesno);
@@ -4744,6 +4788,12 @@ void *linphone_core_get_user_data(LinphoneCore *lc){
        return lc->data;
 }
 
+
+/**
+ * Associate a user pointer to the linphone core.
+ *
+ * @ingroup initializing
+**/
 void linphone_core_set_user_data(LinphoneCore *lc, void *userdata){
        lc->data=userdata;
 }
@@ -4752,6 +4802,13 @@ int linphone_core_get_mtu(const LinphoneCore *lc){
        return lc->net_conf.mtu;
 }
 
+/**
+ * Sets the maximum transmission unit size in bytes.
+ * This information is useful for sending RTP packets.
+ * Default value is 1500.
+ * 
+ * @ingroup media_parameters
+**/
 void linphone_core_set_mtu(LinphoneCore *lc, int mtu){
        lc->net_conf.mtu=mtu;
        if (mtu>0){
@@ -5280,6 +5337,7 @@ const char *linphone_error_to_string(LinphoneReason err){
  */
 void linphone_core_enable_keep_alive(LinphoneCore* lc,bool_t enable) {
        if (enable > 0) {
+               sal_use_tcp_tls_keepalive(lc->sal,lc->sip_conf.tcp_tls_keepalive);
                sal_set_keepalive_period(lc->sal,lc->sip_conf.keepalive_period);
        } else {
                sal_set_keepalive_period(lc->sal,0);