From 7c514d326b4bff5d472e695e48ea712e1a2c1d94 Mon Sep 17 00:00:00 2001 From: Simon Morlat Date: Mon, 21 Nov 2011 22:25:23 +0100 Subject: [PATCH] fixes for sRTP support --- coreapi/linphonecall.c | 24 +++++++++++++++++------- coreapi/linphonecore.c | 5 +++-- coreapi/offeranswer.c | 1 + gtk/incall_view.c | 4 ++-- 4 files changed, 23 insertions(+), 11 deletions(-) diff --git a/coreapi/linphonecall.c b/coreapi/linphonecall.c index 31270f99c..205f84415 100644 --- a/coreapi/linphonecall.c +++ b/coreapi/linphonecall.c @@ -1126,10 +1126,6 @@ static void linphone_call_start_audio_stream(LinphoneCall *call, const char *cna setup_ring_player(lc,call); } audio_stream_set_rtcp_information(call->audiostream, cname, LINPHONE_RTCP_SDES_TOOL); - if (call->params.in_conference){ - /*transform the graph to connect it to the conference filter */ - linphone_call_add_to_conf(call); - } if (stream->proto == SalProtoRtpSavp) { const SalStreamDescription *local_st_desc=sal_media_description_find_stream(call->localdesc, @@ -1139,8 +1135,14 @@ static void linphone_call_start_audio_stream(LinphoneCall *call, const char *cna call->audiostream, stream->crypto[0].algo, local_st_desc->crypto[0].master_key, - stream->crypto[0].master_key); + stream->crypto[0].master_key); + call->audiostream_encrypted=TRUE; + }else call->audiostream_encrypted=FALSE; + if (call->params.in_conference){ + /*transform the graph to connect it to the conference filter */ + linphone_call_add_to_conf(call); } + call->current_params.in_conference=call->params.in_conference; }else ms_warning("No audio stream accepted ?"); } } @@ -1223,7 +1225,10 @@ static void linphone_call_start_video_stream(LinphoneCall *call, const char *cna vstream->crypto[0].algo, local_st_desc->crypto[0].master_key, vstream->crypto[0].master_key - ); + ); + call->videostream_encrypted=TRUE; + }else{ + call->videostream_encrypted=FALSE; } }else ms_warning("No video stream accepted."); }else{ @@ -1247,7 +1252,6 @@ void linphone_call_start_media_streams(LinphoneCall *call, bool_t all_inputs_mut ms_fatal("start_media_stream() called without prior init !"); return; } - call->current_params = call->params; cname=linphone_address_as_string_uri_only(me); #if defined(VIDEO_ENABLED) @@ -1272,6 +1276,12 @@ void linphone_call_start_media_streams(LinphoneCall *call, bool_t all_inputs_mut params.zid_file=lc->zrtp_secrets_cache; audio_stream_enable_zrtp(call->audiostream,¶ms); + }else if (call->params.media_encryption==LinphoneMediaEncryptionSRTP){ + call->current_params.media_encryption=linphone_call_are_all_streams_encrypted(call) ? + LinphoneMediaEncryptionSRTP : LinphoneMediaEncryptionNone; + /*also reflect the change if the "wished" params, in order to avoid to propose SAVP again + * further in the call, for example during pause,resume, conferencing reINVITEs*/ + call->params.media_encryption=call->current_params.media_encryption; } goto end; diff --git a/coreapi/linphonecore.c b/coreapi/linphonecore.c index 22b33d0aa..d53026ad9 100644 --- a/coreapi/linphonecore.c +++ b/coreapi/linphonecore.c @@ -2498,15 +2498,15 @@ LinphoneCall *linphone_core_get_current_call(const LinphoneCore *lc) * * @ingroup call_control **/ -int linphone_core_pause_call(LinphoneCore *lc, LinphoneCall *the_call) +int linphone_core_pause_call(LinphoneCore *lc, LinphoneCall *call) { - LinphoneCall *call = the_call; const char *subject=NULL; if (call->state!=LinphoneCallStreamsRunning && call->state!=LinphoneCallPausedByRemote){ ms_warning("Cannot pause this call, it is not active."); return -1; } + update_local_media_description(lc,call,&call->localdesc); if (sal_media_description_has_dir(call->resultdesc,SalStreamSendRecv)){ sal_media_description_set_dir(call->localdesc,SalStreamSendOnly); subject="Call on hold"; @@ -2517,6 +2517,7 @@ int linphone_core_pause_call(LinphoneCore *lc, LinphoneCall *the_call) ms_error("No reason to pause this call, it is already paused or inactive."); return -1; } + sal_call_set_local_media_description(call->op,call->localdesc); if (sal_call_update(call->op,subject) != 0){ if (lc->vtable.display_warning) lc->vtable.display_warning(lc,_("Could not pause the call")); diff --git a/coreapi/offeranswer.c b/coreapi/offeranswer.c index ab213a239..ae0fda94a 100644 --- a/coreapi/offeranswer.c +++ b/coreapi/offeranswer.c @@ -301,6 +301,7 @@ int offer_answer_initiate_incoming(const SalMediaDescription *local_capabilities result->streams[i].dir=SalStreamInactive; result->streams[i].port=0; result->streams[i].type=rs->type; + result->streams[i].proto=rs->proto; if (rs->type==SalOther){ strncpy(result->streams[i].typeother,rs->typeother,sizeof(rs->typeother)-1); } diff --git a/gtk/incall_view.c b/gtk/incall_view.c index 1dc9d47e4..75060da9a 100644 --- a/gtk/incall_view.c +++ b/gtk/incall_view.c @@ -443,10 +443,10 @@ void linphone_gtk_in_call_view_show_encryption(LinphoneCall *call){ bool_t verified=linphone_call_get_authentication_token_verified(call); switch(me){ case LinphoneMediaEncryptionSRTP: + gtk_widget_show_all(encryption_box); gtk_label_set_markup(GTK_LABEL(label),_("Secured by SRTP")); gtk_widget_hide(status_icon); gtk_widget_hide(verify_button); - gtk_widget_show_all(encryption_box); break; case LinphoneMediaEncryptionZRTP: { @@ -461,7 +461,7 @@ void linphone_gtk_in_call_view_show_encryption(LinphoneCall *call){ } break; default: - gtk_widget_hide(encryption_box); + gtk_widget_hide_all(encryption_box); } }