diff --git a/coreapi/linphonecall.c b/coreapi/linphonecall.c index 8511375ad..cdf6920c4 100644 --- a/coreapi/linphonecall.c +++ b/coreapi/linphonecall.c @@ -1751,6 +1751,23 @@ static void linphone_call_start_audio_stream(LinphoneCall *call, const char *cna audio_stream_mixed_record_open(call->audiostream,call->params.record_file); call->current_params.record_file=ms_strdup(call->params.record_file); } + /* valid local tags are > 0 */ + if (stream->proto == SalProtoRtpSavp) { + local_st_desc=sal_media_description_find_stream(call->localdesc,SalProtoRtpSavp,SalAudio); + crypto_idx = find_crypto_index_from_tag(local_st_desc->crypto, stream->crypto_local_tag); + + if (crypto_idx >= 0) { + audio_stream_enable_srtp( + call->audiostream, + stream->crypto[0].algo, + local_st_desc->crypto[crypto_idx].master_key, + stream->crypto[0].master_key); + call->audiostream_encrypted=TRUE; + } else { + ms_warning("Failed to find local crypto algo with tag: %d", stream->crypto_local_tag); + call->audiostream_encrypted=FALSE; + } + }else call->audiostream_encrypted=FALSE; audio_stream_start_full( call->audiostream, call->audio_profile, @@ -1779,23 +1796,6 @@ static void linphone_call_start_audio_stream(LinphoneCall *call, const char *cna } audio_stream_set_rtcp_information(call->audiostream, cname, rtcp_tool); - /* valid local tags are > 0 */ - if (stream->proto == SalProtoRtpSavp) { - local_st_desc=sal_media_description_find_stream(call->localdesc,SalProtoRtpSavp,SalAudio); - crypto_idx = find_crypto_index_from_tag(local_st_desc->crypto, stream->crypto_local_tag); - - if (crypto_idx >= 0) { - audio_stream_enable_srtp( - call->audiostream, - stream->crypto[0].algo, - local_st_desc->crypto[crypto_idx].master_key, - stream->crypto[0].master_key); - call->audiostream_encrypted=TRUE; - } else { - ms_warning("Failed to find local crypto algo with tag: %d", stream->crypto_local_tag); - call->audiostream_encrypted=FALSE; - } - }else call->audiostream_encrypted=FALSE; if (call->params.in_conference){ /*transform the graph to connect it to the conference filter */ mute=stream->dir==SalStreamRecvOnly; @@ -1811,6 +1811,7 @@ static void linphone_call_start_video_stream(LinphoneCall *call, const char *cna #ifdef VIDEO_ENABLED LinphoneCore *lc=call->core; int used_pt=-1; + /* look for savp stream first */ const SalStreamDescription *vstream=sal_media_description_find_stream(call->resultdesc, SalProtoRtpSavp,SalVideo); @@ -1831,6 +1832,8 @@ static void linphone_call_start_video_stream(LinphoneCall *call, const char *cna if (vstream!=NULL && vstream->dir!=SalStreamInactive && vstream->rtp_port!=0) { const char *rtp_addr=vstream->rtp_addr[0]!='\0' ? vstream->rtp_addr : call->resultdesc->addr; const char *rtcp_addr=vstream->rtcp_addr[0]!='\0' ? vstream->rtcp_addr : call->resultdesc->addr; + const SalStreamDescription *local_st_desc=sal_media_description_find_stream(call->localdesc,vstream->proto,SalVideo); + call->video_profile=make_profile(call,call->resultdesc,vstream,&used_pt); if (used_pt!=-1){ VideoStreamDir dir=VideoStreamSendRecv; @@ -1852,7 +1855,10 @@ static void linphone_call_start_video_stream(LinphoneCall *call, const char *cna video_stream_use_preview_video_window (call->videostream,lc->use_preview_window); if (vstream->dir==SalStreamSendOnly && lc->video_conf.capture ){ - cam=get_nowebcam_device(); + if (local_st_desc->dir==SalStreamSendOnly){ + /* localdesc stream dir to SendOnly is when we want to put on hold, so use nowebcam in this case*/ + cam=get_nowebcam_device(); + } dir=VideoStreamSendOnly; }else if (vstream->dir==SalStreamRecvOnly && lc->video_conf.display ){ dir=VideoStreamRecvOnly; @@ -1872,6 +1878,18 @@ static void linphone_call_start_video_stream(LinphoneCall *call, const char *cna cam=get_nowebcam_device(); } if (!is_inactive){ + if (vstream->proto == SalProtoRtpSavp) { + video_stream_enable_strp( + call->videostream, + 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; + } + call->log->video_enabled = TRUE; video_stream_set_direction (call->videostream, dir); ms_message("%s lc rotation:%d\n", __FUNCTION__, lc->device_rotation); @@ -1883,21 +1901,6 @@ static void linphone_call_start_video_stream(LinphoneCall *call, const char *cna used_pt, linphone_core_get_video_jittcomp(lc), cam); video_stream_set_rtcp_information(call->videostream, cname,rtcp_tool); } - - if (vstream->proto == SalProtoRtpSavp) { - const SalStreamDescription *local_st_desc=sal_media_description_find_stream(call->localdesc, - SalProtoRtpSavp,SalVideo); - - video_stream_enable_strp( - call->videostream, - 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{ ms_warning("No valid video stream defined."); diff --git a/coreapi/linphonecore.c b/coreapi/linphonecore.c index b6f096363..d9eb057e6 100644 --- a/coreapi/linphonecore.c +++ b/coreapi/linphonecore.c @@ -1263,14 +1263,6 @@ static void linphone_core_init (LinphoneCore * lc, const LinphoneCoreVTable *vta linphone_core_assign_payload_type(lc,&payload_type_telephone_event,101,"0-15"); linphone_core_assign_payload_type(lc,&payload_type_g722,9,NULL); -#if defined(ANDROID) || defined (__IPHONE_OS_VERSION_MIN_REQUIRED) - /*shorten the DNS lookup time and send more retransmissions on mobiles: - - to workaround potential packet losses - - to avoid hanging for 30 seconds when the network doesn't work despite the phone thinks it does. - */ - _linphone_core_configure_resolver(); -#endif - #ifdef ENABLE_NONSTANDARD_GSM { PayloadType *pt; @@ -1340,7 +1332,7 @@ static void linphone_core_init (LinphoneCore * lc, const LinphoneCoreVTable *vta net_config_read(lc); rtp_config_read(lc); codecs_config_read(lc); - sip_config_read(lc); /* this will start eXosip*/ + sip_config_read(lc); video_config_read(lc); //autoreplier_config_init(&lc->autoreplier_conf); lc->presence_model=linphone_presence_model_new_with_activity(LinphonePresenceActivityOnline, NULL); @@ -6149,6 +6141,18 @@ void linphone_core_set_srtp_enabled(LinphoneCore *lc, bool_t enabled) { lp_config_set_int(lc->config,"sip","srtp",(int)enabled); } +const char *linphone_media_encryption_to_string(LinphoneMediaEncryption menc){ + switch(menc){ + case LinphoneMediaEncryptionSRTP: + return "LinphoneMediaEncryptionSRTP"; + case LinphoneMediaEncryptionZRTP: + return "LinphoneMediaEncryptionZRTP"; + case LinphoneMediaEncryptionNone: + return "LinphoneMediaEncryptionNone"; + } + return "INVALID"; +} + /** * Returns whether a media encryption scheme is supported by the LinphoneCore engine **/ diff --git a/coreapi/linphonecore.h b/coreapi/linphonecore.h index b71118dd3..fe3dc043c 100644 --- a/coreapi/linphonecore.h +++ b/coreapi/linphonecore.h @@ -316,6 +316,12 @@ enum _LinphoneMediaEncryption { **/ typedef enum _LinphoneMediaEncryption LinphoneMediaEncryption; +/** + * Convert enum member to string. + * @ingroup media_parameters +**/ +LINPHONE_PUBLIC const char *linphone_media_encryption_to_string(LinphoneMediaEncryption menc); + /*public: */ LINPHONE_PUBLIC LinphoneAddress *linphone_call_log_get_from(LinphoneCallLog *cl); LINPHONE_PUBLIC LinphoneAddress *linphone_call_log_get_to(LinphoneCallLog *cl); diff --git a/coreapi/misc.c b/coreapi/misc.c index 1ceb432a0..3a93bf97e 100644 --- a/coreapi/misc.c +++ b/coreapi/misc.c @@ -1093,10 +1093,6 @@ int linphone_core_get_local_ip_for(int type, const char *dest, char *result){ return 0; } - -void _linphone_core_configure_resolver(){ -} - SalReason linphone_reason_to_sal(LinphoneReason reason){ switch(reason){ case LinphoneReasonNone: diff --git a/tester/call_tester.c b/tester/call_tester.c index 34279e8d4..f32d41b02 100644 --- a/tester/call_tester.c +++ b/tester/call_tester.c @@ -945,7 +945,7 @@ static void encrypted_call(LinphoneMediaEncryption mode) { CU_ASSERT_TRUE(wait_for(pauline->lc,marie->lc,&pauline->stat.number_of_LinphoneCallEnd,1)); CU_ASSERT_TRUE(wait_for(pauline->lc,marie->lc,&marie->stat.number_of_LinphoneCallEnd,1)); } else { - ms_warning ("not tested because srtp not available"); + ms_warning ("Not tested because %s not available", linphone_media_encryption_to_string(mode)); } linphone_core_manager_destroy(marie); linphone_core_manager_destroy(pauline);