From 0c68cdcfbae933c0d6895f05733069cf37f2c547 Mon Sep 17 00:00:00 2001 From: Ghislain MARY Date: Tue, 8 Apr 2014 16:45:23 +0200 Subject: [PATCH 01/23] Update ms2 submodule. --- mediastreamer2 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mediastreamer2 b/mediastreamer2 index da5d1de60..e51c106c7 160000 --- a/mediastreamer2 +++ b/mediastreamer2 @@ -1 +1 @@ -Subproject commit da5d1de606699162f48751f006d9219321069545 +Subproject commit e51c106c7e48cfc961fbd74b5c8d5a0588a21080 From a8176a398de76f82fd4938e235360b26d68efaa3 Mon Sep 17 00:00:00 2001 From: Simon Morlat Date: Tue, 8 Apr 2014 23:38:07 +0200 Subject: [PATCH 02/23] rework SRTP support so that recv and send key can be set and updated independently. --- configure.ac | 64 +++++++++++++++-------------- coreapi/bellesip_sal/sal_sdp.c | 30 +++++++++----- coreapi/linphonecall.c | 74 +++++++++++++++++----------------- coreapi/linphonecore.c | 5 ++- coreapi/remote_provisioning.c | 11 +++-- include/sal/sal.h | 4 +- mediastreamer2 | 2 +- oRTP | 2 +- tester/call_tester.c | 8 ++-- tester/message_tester.c | 4 +- 10 files changed, 112 insertions(+), 92 deletions(-) diff --git a/configure.ac b/configure.ac index 786cb6287..ba4ae31a0 100644 --- a/configure.ac +++ b/configure.ac @@ -680,6 +680,39 @@ AC_SUBST(STRICT_OPTIONS) top_srcdir=`dirname $0` +AC_ARG_ENABLE(external-ortp, + [AS_HELP_STRING([--enable-external-ortp], [Use external oRTP library])], + [case "${enableval}" in + yes) external_ortp=true ;; + no) external_ortp=false ;; + *) AC_MSG_ERROR(bad value ${enableval} for --enable-external-ortp) ;; + esac], + [external_ortp=false] +) + +if test "$external_ortp" = 'true'; then + PKG_CHECK_MODULES([ORTP], [ortp >= 0.23.0]) + ORTP_VERSION=`$PKG_CONFIG --modversion ortp` +else + AC_CONFIG_SUBDIRS( oRTP ) + ORTP_CFLAGS="-I\$(top_srcdir)/oRTP/include" + ORTP_LIBS="\$(top_builddir)/oRTP/src/libortp.la" + if test x$ac_cv_c_bigendian = xyes ; then + ORTP_CFLAGS="$ORTP_CFLAGS -DORTP_BIGENDIAN" + fi + if test x$ntptimestamp = xtrue ; then + ORTP_CFLAGS="$ORTP_CFLAGS -DORTP_TIMESTAMP" + fi + ORTP_DIR=oRTP + changequote(<<, >>) + ORTP_VERSION=`grep -E ^[AC]+_INIT ${top_srcdir}/oRTP/configure.ac | sed -e 's:^.*_INIT(.*,\[\(.*\)\]):\1:g'` + changequote([, ]) +fi +AC_SUBST(ORTP_CFLAGS) +AC_SUBST(ORTP_LIBS) +AC_SUBST([ORTP_VERSION]) +AC_SUBST([ORTP_DIR]) + AC_ARG_ENABLE([external-mediastreamer], [AS_HELP_STRING([--enable-external-mediastreamer],[Use external mediastreamer library])],, [enable_external_mediastreamer=no] @@ -778,38 +811,7 @@ AC_DEFINE_UNQUOTED(LINPHONE_PLUGINS_DIR, "${package_prefix}/lib/liblinphone/plug LINPHONE_PLUGINS_DIR="${package_prefix}/lib/liblinphone/plugins" AC_SUBST(LINPHONE_PLUGINS_DIR) -AC_ARG_ENABLE(external-ortp, - [AS_HELP_STRING([--enable-external-ortp], [Use external oRTP library])], - [case "${enableval}" in - yes) external_ortp=true ;; - no) external_ortp=false ;; - *) AC_MSG_ERROR(bad value ${enableval} for --enable-external-ortp) ;; - esac], - [external_ortp=false] -) -if test "$external_ortp" = 'true'; then - PKG_CHECK_MODULES([ORTP], [ortp >= 0.23.0]) - ORTP_VERSION=`$PKG_CONFIG --modversion ortp` -else - AC_CONFIG_SUBDIRS( oRTP ) - ORTP_CFLAGS="-I\$(top_srcdir)/oRTP/include" - ORTP_LIBS="\$(top_builddir)/oRTP/src/libortp.la" - if test x$ac_cv_c_bigendian = xyes ; then - ORTP_CFLAGS="$ORTP_CFLAGS -DORTP_BIGENDIAN" - fi - if test x$ntptimestamp = xtrue ; then - ORTP_CFLAGS="$ORTP_CFLAGS -DORTP_TIMESTAMP" - fi - ORTP_DIR=oRTP - changequote(<<, >>) - ORTP_VERSION=`grep -E ^[AC]+_INIT ${top_srcdir}/oRTP/configure.ac | sed -e 's:^.*_INIT(.*,\[\(.*\)\]):\1:g'` - changequote([, ]) -fi -AC_SUBST(ORTP_CFLAGS) -AC_SUBST(ORTP_LIBS) -AC_SUBST([ORTP_VERSION]) -AC_SUBST([ORTP_DIR]) AC_ARG_ENABLE(tutorials, [AS_HELP_STRING([--disable-tutorials], [Disable compilation of tutorials])], diff --git a/coreapi/bellesip_sal/sal_sdp.c b/coreapi/bellesip_sal/sal_sdp.c index b2f106cef..2c9411841 100644 --- a/coreapi/bellesip_sal/sal_sdp.c +++ b/coreapi/bellesip_sal/sal_sdp.c @@ -146,17 +146,20 @@ static void stream_description_to_sdp ( belle_sdp_session_description_t *session if ( stream->proto == SalProtoRtpSavp ) { /* add crypto lines */ for ( j=0; jcrypto[j].algo ) { case AES_128_SHA1_80: - snprintf ( buffer, sizeof ( buffer ), "%d %s inline:%s", - stream->crypto[j].tag, "AES_CM_128_HMAC_SHA1_80", stream->crypto[j].master_key ); - belle_sdp_media_description_add_attribute ( media_desc,belle_sdp_attribute_create ( "crypto",buffer ) ); + enc_name="AES_CM_128_HMAC_SHA1_80"; break; case AES_128_SHA1_32: - snprintf ( buffer, sizeof ( buffer ), "%d %s inline:%s", - stream->crypto[j].tag, "AES_CM_128_HMAC_SHA1_32", stream->crypto[j].master_key ); - belle_sdp_media_description_add_attribute ( media_desc,belle_sdp_attribute_create ( "crypto",buffer ) ); + enc_name="AES_CM_128_HMAC_SHA1_32"; + break; + case AES_256_SHA1_32: + enc_name="AES_CM_256_HMAC_SHA1_32"; + break; + case AES_256_SHA1_80: + enc_name="AES_CM_256_HMAC_SHA1_32"; break; case AES_128_NO_AUTH: ms_warning ( "Unsupported crypto suite: AES_128_NO_AUTH" ); @@ -168,6 +171,11 @@ static void stream_description_to_sdp ( belle_sdp_session_description_t *session j = SAL_CRYPTO_ALGO_MAX; /* no break */ } + if (enc_name){ + snprintf ( buffer, sizeof ( buffer )-1, "%d %s inline:%s", + stream->crypto[j].tag, enc_name, stream->crypto[j].master_key ); + belle_sdp_media_description_add_attribute ( media_desc,belle_sdp_attribute_create ( "crypto",buffer ) ); + } } } switch ( stream->dir ) { @@ -342,11 +350,15 @@ static void sdp_parse_media_crypto_parameters(belle_sdp_media_description_t *med tmp, tmp2 ); if ( nb == 3 ) { - if ( keywordcmp ( "AES_CM_128_HMAC_SHA1_80",tmp ) == 0 ) + if ( keywordcmp ( "AES_CM_128_HMAC_SHA1_80",tmp ) == 0 ){ stream->crypto[valid_count].algo = AES_128_SHA1_80; - else if ( keywordcmp ( "AES_CM_128_HMAC_SHA1_32",tmp ) == 0 ) + }else if ( keywordcmp ( "AES_CM_128_HMAC_SHA1_32",tmp ) == 0 ){ stream->crypto[valid_count].algo = AES_128_SHA1_32; - else { + }else if ( keywordcmp ( "AES_CM_256_HMAC_SHA1_32",tmp ) == 0 ){ + stream->crypto[valid_count].algo = AES_256_SHA1_32; + }else if ( keywordcmp ( "AES_CM_256_HMAC_SHA1_80",tmp ) == 0 ){ + stream->crypto[valid_count].algo = AES_256_SHA1_80; + }else { ms_warning ( "Failed to parse crypto-algo: '%s'", tmp ); stream->crypto[valid_count].algo = 0; } diff --git a/coreapi/linphonecall.c b/coreapi/linphonecall.c index c5f3ef3f2..cf69902c7 100644 --- a/coreapi/linphonecall.c +++ b/coreapi/linphonecall.c @@ -1873,11 +1873,8 @@ static void linphone_call_start_audio_stream(LinphoneCall *call, const char *cna 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); + media_stream_set_srtp_recv_key(&call->audiostream->ms,stream->crypto[0].algo,stream->crypto[0].master_key); + media_stream_set_srtp_send_key(&call->audiostream->ms,stream->crypto[0].algo,local_st_desc->crypto[crypto_idx].master_key); call->audiostream_encrypted=TRUE; } else { ms_warning("Failed to find local crypto algo with tag: %d", stream->crypto_local_tag); @@ -1996,13 +1993,13 @@ static void linphone_call_start_video_stream(LinphoneCall *call, const char *cna } 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; + int crypto_idx = find_crypto_index_from_tag(local_st_desc->crypto, vstream->crypto_local_tag); + + if (crypto_idx >= 0) { + media_stream_set_srtp_recv_key(&call->videostream->ms,vstream->crypto[0].algo,vstream->crypto[0].master_key); + media_stream_set_srtp_send_key(&call->videostream->ms,vstream->crypto[0].algo,local_st_desc->crypto[crypto_idx].master_key); + call->videostream_encrypted=TRUE; + }else call->videostream_encrypted=FALSE; }else{ call->videostream_encrypted=FALSE; } @@ -2103,42 +2100,43 @@ void linphone_call_stop_media_streams_for_ice_gathering(LinphoneCall *call){ #endif } +static bool_t update_stream_crypto_params(LinphoneCall *call, const SalStreamDescription *local_st_desc, SalStreamDescription *old_stream, SalStreamDescription *new_stream, MediaStream *ms){ + int crypto_idx = find_crypto_index_from_tag(local_st_desc->crypto, new_stream->crypto_local_tag); + if (crypto_idx >= 0) { + if (call->localdesc_changed & SAL_MEDIA_DESCRIPTION_CRYPTO_CHANGED) + media_stream_set_srtp_send_key(ms,new_stream->crypto[0].algo,local_st_desc->crypto[crypto_idx].master_key); + if (strcmp(old_stream->crypto[0].master_key,new_stream->crypto[0].master_key)!=0){ + media_stream_set_srtp_recv_key(ms,new_stream->crypto[0].algo,new_stream->crypto[0].master_key); + } + return TRUE; + } else { + ms_warning("Failed to find local crypto algo with tag: %d", new_stream->crypto_local_tag); + } + return FALSE; +} + void linphone_call_update_crypto_parameters(LinphoneCall *call, SalMediaDescription *old_md, SalMediaDescription *new_md) { SalStreamDescription *old_stream; SalStreamDescription *new_stream; - + const SalStreamDescription *local_st_desc; + + local_st_desc = sal_media_description_find_stream(call->localdesc, SalProtoRtpSavp, SalAudio); old_stream = sal_media_description_find_stream(old_md, SalProtoRtpSavp, SalAudio); new_stream = sal_media_description_find_stream(new_md, SalProtoRtpSavp, SalAudio); - if (old_stream && new_stream) { - const SalStreamDescription *local_st_desc = sal_media_description_find_stream(call->localdesc, SalProtoRtpSavp, SalAudio); - if (local_st_desc) { - int crypto_idx = find_crypto_index_from_tag(local_st_desc->crypto, new_stream->crypto_local_tag); - if (crypto_idx >= 0) { - audio_stream_enable_srtp(call->audiostream, new_stream->crypto[0].algo, local_st_desc->crypto[crypto_idx].master_key, new_stream->crypto[0].master_key); - call->audiostream_encrypted = TRUE; - } else { - ms_warning("Failed to find local crypto algo with tag: %d", new_stream->crypto_local_tag); - call->audiostream_encrypted = FALSE; - } - } - } + if (call->audiostream && local_st_desc && old_stream && new_stream && + update_stream_crypto_params(call,local_st_desc,old_stream,new_stream,&call->audiostream->ms)){ + call->audiostream_encrypted = TRUE; + }else call->audiostream_encrypted = FALSE; #ifdef VIDEO_ENABLED + local_st_desc = sal_media_description_find_stream(call->localdesc, SalProtoRtpSavp, SalVideo); old_stream = sal_media_description_find_stream(old_md, SalProtoRtpSavp, SalVideo); new_stream = sal_media_description_find_stream(new_md, SalProtoRtpSavp, SalVideo); - if (old_stream && new_stream) { - const SalStreamDescription *local_st_desc = sal_media_description_find_stream(call->localdesc, SalProtoRtpSavp, SalVideo); - if (local_st_desc) { - int crypto_idx = find_crypto_index_from_tag(local_st_desc->crypto, new_stream->crypto_local_tag); - if (crypto_idx >= 0) { - video_stream_enable_strp(call->videostream, new_stream->crypto[0].algo, local_st_desc->crypto[crypto_idx].master_key, new_stream->crypto[0].master_key); - call->videostream_encrypted = TRUE; - } else { - ms_warning("Failed to find local crypto algo with tag: %d", new_stream->crypto_local_tag); - call->videostream_encrypted = FALSE; - } - } + if (call->videostream && local_st_desc && old_stream && new_stream && + update_stream_crypto_params(call,local_st_desc,old_stream,new_stream,&call->videostream->ms)){ + call->videostream_encrypted = TRUE; } + call->videostream_encrypted = FALSE; #endif } diff --git a/coreapi/linphonecore.c b/coreapi/linphonecore.c index 6c609d037..1ac48dff7 100644 --- a/coreapi/linphonecore.c +++ b/coreapi/linphonecore.c @@ -6380,6 +6380,7 @@ const char *linphone_media_encryption_to_string(LinphoneMediaEncryption menc){ case LinphoneMediaEncryptionNone: return "LinphoneMediaEncryptionNone"; } + ms_error("Invalid LinphoneMediaEncryption value %i",(int)menc); return "INVALID"; } @@ -6389,7 +6390,7 @@ const char *linphone_media_encryption_to_string(LinphoneMediaEncryption menc){ bool_t linphone_core_media_encryption_supported(const LinphoneCore *lc, LinphoneMediaEncryption menc){ switch(menc){ case LinphoneMediaEncryptionSRTP: - return ortp_srtp_supported(); + return media_stream_srtp_supported(); case LinphoneMediaEncryptionZRTP: return ortp_zrtp_available(); case LinphoneMediaEncryptionNone: @@ -6402,7 +6403,7 @@ int linphone_core_set_media_encryption(LinphoneCore *lc, LinphoneMediaEncryption const char *type="none"; int ret=0; if (menc == LinphoneMediaEncryptionSRTP){ - if (!ortp_srtp_supported()){ + if (!media_stream_srtp_supported()){ ms_warning("SRTP not supported by library."); type="none"; ret=-1; diff --git a/coreapi/remote_provisioning.c b/coreapi/remote_provisioning.c index 96ee2a6dd..bcae9e798 100644 --- a/coreapi/remote_provisioning.c +++ b/coreapi/remote_provisioning.c @@ -62,10 +62,15 @@ static int linphone_remote_provisioning_load_file( LinphoneCore* lc, const char* fseek(f, 0, SEEK_SET); char* provisioning = ms_malloc(fsize + 1); - fread(provisioning, fsize, 1, f); + if (fread(provisioning, fsize, 1, f)==0){ + ms_error("Could not read xml provisioning file from %s",file_path); + status=-1; + }else{ + linphone_remote_provisioning_apply(lc, provisioning); + status = 0; + } + ms_free(provisioning); fclose(f); - linphone_remote_provisioning_apply(lc, provisioning); - status = 0; } else { ms_error("Couldn't open file %s for provisioning", file_path); } diff --git a/include/sal/sal.h b/include/sal/sal.h index 5bc5264a2..1dba31f90 100644 --- a/include/sal/sal.h +++ b/include/sal/sal.h @@ -166,12 +166,12 @@ typedef struct SalIceRemoteCandidate { #define SAL_MEDIA_DESCRIPTION_MAX_ICE_UFRAG_LEN 256 #define SAL_MEDIA_DESCRIPTION_MAX_ICE_PWD_LEN 256 -#define SAL_SRTP_KEY_SIZE 41 +/*sufficient for 256bit keys encoded in base 64*/ +#define SAL_SRTP_KEY_SIZE 64 typedef struct SalSrtpCryptoAlgo { unsigned int tag; enum ortp_srtp_crypto_suite_t algo; - /* 41= 40 max(key_length for all algo) + '\0' */ char master_key[SAL_SRTP_KEY_SIZE]; } SalSrtpCryptoAlgo; diff --git a/mediastreamer2 b/mediastreamer2 index e51c106c7..8858dc193 160000 --- a/mediastreamer2 +++ b/mediastreamer2 @@ -1 +1 @@ -Subproject commit e51c106c7e48cfc961fbd74b5c8d5a0588a21080 +Subproject commit 8858dc1938b14d2a84773052fa3bc87fd0950800 diff --git a/oRTP b/oRTP index 5008a70e0..daa314ae9 160000 --- a/oRTP +++ b/oRTP @@ -1 +1 @@ -Subproject commit 5008a70e077b3706de4a48374f162f93071b4d08 +Subproject commit daa314ae9c0ba46910299ebc70301897aea7448f diff --git a/tester/call_tester.c b/tester/call_tester.c index be60fd8af..2a18b30d2 100644 --- a/tester/call_tester.c +++ b/tester/call_tester.c @@ -1155,6 +1155,7 @@ static void encrypted_call(LinphoneMediaEncryption mode) { CU_ASSERT_STRING_EQUAL(linphone_call_get_authentication_token(linphone_core_get_current_call(pauline->lc)) ,linphone_call_get_authentication_token(linphone_core_get_current_call(marie->lc))); } + liblinphone_tester_check_rtcp(pauline,marie); /*just to sleep*/ linphone_core_terminate_all_calls(marie->lc); CU_ASSERT_TRUE(wait_for(pauline->lc,marie->lc,&pauline->stat.number_of_LinphoneCallEnd,1)); @@ -1165,13 +1166,14 @@ static void encrypted_call(LinphoneMediaEncryption mode) { linphone_core_manager_destroy(marie); linphone_core_manager_destroy(pauline); } -static void srtp_call(LinphoneMediaEncryptionSRTP) { + +static void srtp_call() { encrypted_call(LinphoneMediaEncryptionSRTP); } /* - * futur work -static void zrtp_call(LinphoneMediaEncryptionSRTP) { + * future work +static void zrtp_call() { encrypted_call(LinphoneMediaEncryptionZRTP); }*/ diff --git a/tester/message_tester.c b/tester/message_tester.c index 259727715..8568492d4 100644 --- a/tester/message_tester.c +++ b/tester/message_tester.c @@ -42,8 +42,8 @@ void message_received(LinphoneCore *lc, LinphoneChatRoom *room, LinphoneChatMess counters = get_stats(lc); counters->number_of_LinphoneMessageReceived++; if (linphone_chat_message_get_external_body_url(message)) { - counters->number_of_LinphoneMessageExtBodyReceived++; - CU_ASSERT_STRING_EQUAL(linphone_chat_message_get_external_body_url(message),message_external_body_url); + counters->number_of_LinphoneMessageExtBodyReceived++; + CU_ASSERT_STRING_EQUAL(linphone_chat_message_get_external_body_url(message),message_external_body_url); } } From 50c60455cec1576308ff3d321c953bf40e448301 Mon Sep 17 00:00:00 2001 From: Simon Morlat Date: Tue, 8 Apr 2014 23:40:55 +0200 Subject: [PATCH 03/23] update ms2 --- mediastreamer2 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mediastreamer2 b/mediastreamer2 index 8858dc193..fd97e9048 160000 --- a/mediastreamer2 +++ b/mediastreamer2 @@ -1 +1 @@ -Subproject commit 8858dc1938b14d2a84773052fa3bc87fd0950800 +Subproject commit fd97e9048e2e5f5b8a2dd972d0d7848294742f89 From bd83f0b7ca66bd600cd4646ce40223d00997aa6d Mon Sep 17 00:00:00 2001 From: Simon Morlat Date: Wed, 9 Apr 2014 00:00:22 +0200 Subject: [PATCH 04/23] fix crash while receiving a SIP message without content-type. --- coreapi/bellesip_sal/sal_op_message.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/coreapi/bellesip_sal/sal_op_message.c b/coreapi/bellesip_sal/sal_op_message.c index c346347d0..2f161c2a6 100644 --- a/coreapi/bellesip_sal/sal_op_message.c +++ b/coreapi/bellesip_sal/sal_op_message.c @@ -130,8 +130,7 @@ void sal_process_incoming_message(SalOp *op,const belle_sip_request_event_t *eve belle_sip_object_unref(address); belle_sip_free(from); } else { - ms_error("Unsupported MESSAGE with content type [%s/%s]",belle_sip_header_content_type_get_type(content_type) - ,belle_sip_header_content_type_get_subtype(content_type)); + ms_error("Unsupported MESSAGE (content-type not recognized)"); resp = belle_sip_response_create_from_request(req,415); add_message_accept((belle_sip_message_t*)resp); belle_sip_server_transaction_send_response(server_transaction,resp); From 756ae1737a0ed61d4daab94636d4b490d83e2fa7 Mon Sep 17 00:00:00 2001 From: Simon Morlat Date: Wed, 9 Apr 2014 11:15:09 +0200 Subject: [PATCH 05/23] fix upnp build --- coreapi/upnp.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/coreapi/upnp.c b/coreapi/upnp.c index 7b1307435..741e44529 100644 --- a/coreapi/upnp.c +++ b/coreapi/upnp.c @@ -698,19 +698,19 @@ int linphone_core_update_upnp_audio_video(LinphoneCall *call, bool_t audio, bool * Audio part */ linphone_upnp_update_port_binding(lupnp, &call->upnp_session->audio->rtp, - UPNP_IGD_IP_PROTOCOL_UDP, (audio)? call->audio_port:0, UPNP_CALL_RETRY_DELAY); + UPNP_IGD_IP_PROTOCOL_UDP, (audio)? call->media_ports[0].rtp_port:0, UPNP_CALL_RETRY_DELAY); linphone_upnp_update_port_binding(lupnp, &call->upnp_session->audio->rtcp, - UPNP_IGD_IP_PROTOCOL_UDP, (audio)? call->audio_port+1:0, UPNP_CALL_RETRY_DELAY); + UPNP_IGD_IP_PROTOCOL_UDP, (audio)? call->media_ports[0].rtcp_port:0, UPNP_CALL_RETRY_DELAY); /* * Video part */ linphone_upnp_update_port_binding(lupnp, &call->upnp_session->video->rtp, - UPNP_IGD_IP_PROTOCOL_UDP, (video)? call->video_port:0, UPNP_CALL_RETRY_DELAY); + UPNP_IGD_IP_PROTOCOL_UDP, (video)? call->media_ports[1].rtp_port:0, UPNP_CALL_RETRY_DELAY); linphone_upnp_update_port_binding(lupnp, &call->upnp_session->video->rtcp, - UPNP_IGD_IP_PROTOCOL_UDP, (video)? call->video_port+1:0, UPNP_CALL_RETRY_DELAY); + UPNP_IGD_IP_PROTOCOL_UDP, (video)? call->media_ports[1].rtcp_port:0, UPNP_CALL_RETRY_DELAY); } ms_mutex_unlock(&lupnp->mutex); From 0868c544d42ba4a7668288f59659ce33c3fffe4f Mon Sep 17 00:00:00 2001 From: Simon Morlat Date: Wed, 9 Apr 2014 16:27:30 +0200 Subject: [PATCH 06/23] fix preview ring bug --- coreapi/linphonecore.c | 14 ++++++++++++-- mediastreamer2 | 2 +- oRTP | 2 +- 3 files changed, 14 insertions(+), 4 deletions(-) diff --git a/coreapi/linphonecore.c b/coreapi/linphonecore.c index 1ac48dff7..d6b3f842c 100644 --- a/coreapi/linphonecore.c +++ b/coreapi/linphonecore.c @@ -2262,7 +2262,15 @@ void linphone_core_iterate(LinphoneCore *lc){ if (lc->ringstream && lc->ringstream_autorelease && lc->dmfs_playing_start_time!=0 && (curtime-lc->dmfs_playing_start_time)>5){ - linphone_core_stop_dtmf_stream(lc); + MSPlayerState state; + bool_t stop=TRUE; + if (lc->ringstream->source && ms_filter_call_method(lc->ringstream->source,MS_PLAYER_GET_STATE,&state)==0){ + if (state==MSPlayerPlaying) stop=FALSE; + } + if (stop) { + ms_message("Releasing inactive tone player."); + linphone_core_stop_dtmf_stream(lc); + } } sal_iterate(lc->sal); @@ -4412,7 +4420,9 @@ void linphone_core_verify_server_cn(LinphoneCore *lc, bool_t yesno){ static void notify_end_of_ring(void *ud, MSFilter *f, unsigned int event, void *arg){ LinphoneCore *lc=(LinphoneCore*)ud; - lc->preview_finished=1; + if (event==MS_PLAYER_EOF){ + lc->preview_finished=1; + } } int linphone_core_preview_ring(LinphoneCore *lc, const char *ring,LinphoneCoreCbFunc func,void * userdata) diff --git a/mediastreamer2 b/mediastreamer2 index fd97e9048..e2a163d31 160000 --- a/mediastreamer2 +++ b/mediastreamer2 @@ -1 +1 @@ -Subproject commit fd97e9048e2e5f5b8a2dd972d0d7848294742f89 +Subproject commit e2a163d31b7e51811dd907a640788c61b24e83b0 diff --git a/oRTP b/oRTP index daa314ae9..550e1e1e4 160000 --- a/oRTP +++ b/oRTP @@ -1 +1 @@ -Subproject commit daa314ae9c0ba46910299ebc70301897aea7448f +Subproject commit 550e1e1e43ec64b3be96c34e0adb618f4752f34a From f64c06a85c8aa3e175f594e6e56ba6116f8f2ff8 Mon Sep 17 00:00:00 2001 From: Simon Morlat Date: Wed, 9 Apr 2014 16:55:09 +0200 Subject: [PATCH 07/23] fix compilation on mac --- mediastreamer2 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mediastreamer2 b/mediastreamer2 index e2a163d31..3053e4fd0 160000 --- a/mediastreamer2 +++ b/mediastreamer2 @@ -1 +1 @@ -Subproject commit e2a163d31b7e51811dd907a640788c61b24e83b0 +Subproject commit 3053e4fd0ec6817213576821ec5e3392b8791904 From cc7d32654a91f3dbf776424d3c02d3548ff00c96 Mon Sep 17 00:00:00 2001 From: Simon Morlat Date: Thu, 10 Apr 2014 11:19:27 +0200 Subject: [PATCH 08/23] add bzrtp in windows setup.exe --- linphone-deps.filelist | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/linphone-deps.filelist b/linphone-deps.filelist index fd8e6da17..53cde44a9 100755 --- a/linphone-deps.filelist +++ b/linphone-deps.filelist @@ -2,8 +2,6 @@ ./bin/libspeex-1.dll ./bin/libspeexdsp-1.dll ./bin/avutil-51.dll -./bin/libeay32.dll -./bin/ssleay32.dll ./bin/libbellesip-0.dll ./bin/libantlr3c.dll ./lib/libpolarssl.dll @@ -17,5 +15,5 @@ ./bin/libgnutls-26.dll ./bin/libtasn1-3.dll ./bin/libsqlite3-0.dll -./bin/zrtpcppcore.dll ./bin/libopus-0.dll +./bin/libbzrtp-0.dll From 28dc28a244f7ad93f953cc44a537d854a9403858 Mon Sep 17 00:00:00 2001 From: Sylvain Berfini Date: Thu, 10 Apr 2014 11:31:02 +0200 Subject: [PATCH 09/23] updated ms2 --- mediastreamer2 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mediastreamer2 b/mediastreamer2 index 3053e4fd0..29b6bbe34 160000 --- a/mediastreamer2 +++ b/mediastreamer2 @@ -1 +1 @@ -Subproject commit 3053e4fd0ec6817213576821ec5e3392b8791904 +Subproject commit 29b6bbe34100e47573c532bf77f9ce6ba2dc30db From b28472af78f9422db2869c48aaaff619ec48d66e Mon Sep 17 00:00:00 2001 From: Ghislain MARY Date: Thu, 10 Apr 2014 16:47:10 +0200 Subject: [PATCH 10/23] Update ms2 and oRTP submodules. --- mediastreamer2 | 2 +- oRTP | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/mediastreamer2 b/mediastreamer2 index 29b6bbe34..6aa698351 160000 --- a/mediastreamer2 +++ b/mediastreamer2 @@ -1 +1 @@ -Subproject commit 29b6bbe34100e47573c532bf77f9ce6ba2dc30db +Subproject commit 6aa6983512e5fa61ccdaaedc79f109993c5de04a diff --git a/oRTP b/oRTP index 550e1e1e4..6330e3d1c 160000 --- a/oRTP +++ b/oRTP @@ -1 +1 @@ -Subproject commit 550e1e1e43ec64b3be96c34e0adb618f4752f34a +Subproject commit 6330e3d1c792515826be7116fb31086284faa430 From 7aec150bf4f0df7d2a84155687e59aff1eee3aa4 Mon Sep 17 00:00:00 2001 From: Simon Morlat Date: Thu, 10 Apr 2014 19:42:42 +0200 Subject: [PATCH 11/23] fix missing custom header processing in generic PUBLISH api --- coreapi/bellesip_sal/sal_op_publish.c | 6 ++++-- coreapi/event.c | 5 ++++- tester/eventapi_tester.c | 16 +++++++++++----- tester/tester.c | 2 +- 4 files changed, 20 insertions(+), 9 deletions(-) diff --git a/coreapi/bellesip_sal/sal_op_publish.c b/coreapi/bellesip_sal/sal_op_publish.c index 81a7ce724..0e2ca3da9 100644 --- a/coreapi/bellesip_sal/sal_op_publish.c +++ b/coreapi/bellesip_sal/sal_op_publish.c @@ -24,18 +24,20 @@ static void publish_refresher_listener (belle_sip_refresher_t* refresher ,unsigned int status_code ,const char* reason_phrase) { SalOp* op = (SalOp*)user_pointer; + const belle_sip_client_transaction_t* last_publish_trans=belle_sip_refresher_get_transaction(op->refresher); + belle_sip_request_t* last_publish=belle_sip_transaction_get_request(BELLE_SIP_TRANSACTION(last_publish_trans)); + belle_sip_response_t *response=belle_sip_transaction_get_response(BELLE_SIP_TRANSACTION(last_publish_trans)); /*belle_sip_response_t* response=belle_sip_transaction_get_response(BELLE_SIP_TRANSACTION(belle_sip_refresher_get_transaction(refresher)));*/ ms_message("Publish refresher [%i] reason [%s] for proxy [%s]",status_code,reason_phrase?reason_phrase:"none",sal_op_get_proxy(op)); if (status_code==412){ /*resubmit the request after removing the SIP-If-Match*/ - const belle_sip_client_transaction_t* last_publish_trans=belle_sip_refresher_get_transaction(op->refresher); - belle_sip_request_t* last_publish=belle_sip_transaction_get_request(BELLE_SIP_TRANSACTION(last_publish_trans)); belle_sip_message_remove_header((belle_sip_message_t*)last_publish,"SIP-If-Match"); belle_sip_refresher_refresh(op->refresher,BELLE_SIP_REFRESHER_REUSE_EXPIRES); }else if (status_code==0){ op->base.root->callbacks.on_expire(op); }else if (status_code>=200){ sal_error_info_set(&op->error_info,SalReasonUnknown,status_code,reason_phrase,NULL); + sal_op_assign_recv_headers(op,(belle_sip_message_t*)response); op->base.root->callbacks.on_publish_response(op); } } diff --git a/coreapi/event.c b/coreapi/event.c index 731412153..28ea5914b 100644 --- a/coreapi/event.c +++ b/coreapi/event.c @@ -234,7 +234,10 @@ static int _linphone_event_send_publish(LinphoneEvent *lev, const LinphoneConten ms_error("linphone_event_update_publish(): this is not a PUBLISH event."); return -1; } - + if (lev->send_custom_headers){ + sal_op_set_sent_custom_header(lev->op,lev->send_custom_headers); + lev->send_custom_headers=NULL; + }else sal_op_set_sent_custom_header(lev->op,NULL); err=sal_publish(lev->op,NULL,NULL,lev->name,lev->expires,sal_body_from_content(&salbody,body)); if (err==0){ linphone_event_set_publish_state(lev,LinphonePublishProgress); diff --git a/tester/eventapi_tester.c b/tester/eventapi_tester.c index 5f10a5183..9d776fa40 100644 --- a/tester/eventapi_tester.c +++ b/tester/eventapi_tester.c @@ -97,7 +97,11 @@ void linphone_publish_state_changed(LinphoneCore *lc, LinphoneEvent *ev, Linphon stats* counters = get_stats(lc); switch(state){ case LinphonePublishProgress: counters->number_of_LinphonePublishProgress++; break; - case LinphonePublishOk: counters->number_of_LinphonePublishOk++; break; + case LinphonePublishOk: + /*make sure custom header access API is working*/ + CU_ASSERT_PTR_NOT_NULL(linphone_event_get_custom_header(ev,"From")); + counters->number_of_LinphonePublishOk++; + break; case LinphonePublishError: counters->number_of_LinphonePublishError++; break; case LinphonePublishExpiring: counters->number_of_LinphonePublishExpiring++; break; case LinphonePublishCleared: counters->number_of_LinphonePublishCleared++;break; @@ -300,24 +304,26 @@ static void publish_test_with_args(bool_t refresh){ lp_config_set_int(marie->lc->config,"sip","refresh_generic_publish",refresh); - lev=linphone_core_publish(marie->lc,pauline->identity,"dodo",5,&content); + lev=linphone_core_create_publish(marie->lc,pauline->identity,"dodo",5); + linphone_event_add_custom_header(lev,"CustomHeader","someValue"); + linphone_event_send_publish(lev,&content); linphone_event_ref(lev); CU_ASSERT_TRUE(wait_for_list(lcs,&marie->stat.number_of_LinphonePublishProgress,1,1000)); - CU_ASSERT_TRUE(wait_for_list(lcs,&marie->stat.number_of_LinphonePublishOk,1,1000)); + CU_ASSERT_TRUE(wait_for_list(lcs,&marie->stat.number_of_LinphonePublishOk,1,3000)); if (!refresh){ CU_ASSERT_TRUE(wait_for_list(lcs,&marie->stat.number_of_LinphonePublishExpiring,1,5000)); linphone_event_update_publish(lev,&content); CU_ASSERT_TRUE(wait_for_list(lcs,&marie->stat.number_of_LinphonePublishProgress,1,1000)); - CU_ASSERT_TRUE(wait_for_list(lcs,&marie->stat.number_of_LinphonePublishOk,1,1000)); + CU_ASSERT_TRUE(wait_for_list(lcs,&marie->stat.number_of_LinphonePublishOk,1,3000)); }else{ } linphone_event_terminate(lev); - CU_ASSERT_TRUE(wait_for_list(lcs,&marie->stat.number_of_LinphonePublishCleared,1,1000)); + CU_ASSERT_TRUE(wait_for_list(lcs,&marie->stat.number_of_LinphonePublishCleared,1,3000)); linphone_event_unref(lev); diff --git a/tester/tester.c b/tester/tester.c index 9eedb0ed1..caeb78009 100644 --- a/tester/tester.c +++ b/tester/tester.c @@ -216,7 +216,7 @@ LinphoneCoreManager* linphone_core_manager_new2(const char* rc_file, int check_f proxy_count=0; if (proxy_count) - wait_for_until(mgr->lc,NULL,&mgr->stat.number_of_LinphoneRegistrationOk,proxy_count,3000*proxy_count); + wait_for_until(mgr->lc,NULL,&mgr->stat.number_of_LinphoneRegistrationOk,proxy_count,5000*proxy_count); CU_ASSERT_EQUAL(mgr->stat.number_of_LinphoneRegistrationOk,proxy_count); enable_codec(mgr->lc,"PCMU",8000); From 39f9ec6a48f850b103b558db0a290a8fd9419c3b Mon Sep 17 00:00:00 2001 From: Simon Morlat Date: Fri, 11 Apr 2014 10:00:13 +0200 Subject: [PATCH 12/23] improve LinphoneEvent api: - better error notification - allow publish without expires --- coreapi/bellesip_sal/sal_op_publish.c | 4 +++- coreapi/callbacks.c | 13 ++++++++++--- coreapi/event.c | 2 +- coreapi/event.h | 7 ++++--- .../common/org/linphone/core/SubscriptionState.java | 4 ++-- tester/eventapi_tester.c | 13 +++++++++---- 6 files changed, 29 insertions(+), 14 deletions(-) diff --git a/coreapi/bellesip_sal/sal_op_publish.c b/coreapi/bellesip_sal/sal_op_publish.c index 0e2ca3da9..2655c58d2 100644 --- a/coreapi/bellesip_sal/sal_op_publish.c +++ b/coreapi/bellesip_sal/sal_op_publish.c @@ -106,7 +106,9 @@ int sal_publish(SalOp *op, const char *from, const char *to, const char *eventna } belle_sip_message_add_header(BELLE_SIP_MESSAGE(req),belle_sip_header_create("Event",eventname)); sal_op_add_body(op,BELLE_SIP_MESSAGE(req),body); - return sal_op_send_and_create_refresher(op,req,expires,publish_refresher_listener); + if (expires!=-1) + return sal_op_send_and_create_refresher(op,req,expires,publish_refresher_listener); + else return sal_op_send_request(op,req); } else { /*update status*/ const belle_sip_client_transaction_t* last_publish_trans=belle_sip_refresher_get_transaction(op->refresher); diff --git a/coreapi/callbacks.c b/coreapi/callbacks.c index efd17aab6..2bbea45b2 100644 --- a/coreapi/callbacks.c +++ b/coreapi/callbacks.c @@ -1052,6 +1052,7 @@ static void info_received(SalOp *op, const SalBody *body){ static void subscribe_response(SalOp *op, SalSubscribeStatus status){ LinphoneEvent *lev=(LinphoneEvent*)sal_op_get_user_pointer(op); + const SalErrorInfo *ei=sal_op_get_error_info(op); if (lev==NULL) return; @@ -1060,7 +1061,10 @@ static void subscribe_response(SalOp *op, SalSubscribeStatus status){ }else if (status==SalSubscribePending){ linphone_event_set_state(lev,LinphoneSubscriptionPending); }else{ - linphone_event_set_state(lev,LinphoneSubscriptionError); + if (lev->subscription_state==LinphoneSubscriptionActive && ei->reason==SalReasonIOError){ + linphone_event_set_state(lev,LinphoneSubscriptionOutgoingProgress); + } + else linphone_event_set_state(lev,LinphoneSubscriptionError); } } @@ -1111,9 +1115,12 @@ static void on_publish_response(SalOp* op){ linphone_event_set_publish_state(lev,LinphonePublishOk); else linphone_event_set_publish_state(lev,LinphonePublishCleared); - }else{ - linphone_event_set_publish_state(lev,LinphonePublishError); + if (lev->publish_state==LinphonePublishOk){ + linphone_event_set_publish_state(lev,LinphonePublishProgress); + }else{ + linphone_event_set_publish_state(lev,LinphonePublishError); + } } } diff --git a/coreapi/event.c b/coreapi/event.c index 28ea5914b..e95f7d454 100644 --- a/coreapi/event.c +++ b/coreapi/event.c @@ -295,7 +295,7 @@ void linphone_event_terminate(LinphoneEvent *lev){ } if (lev->publish_state!=LinphonePublishNone){ - if (lev->publish_state==LinphonePublishOk){ + if (lev->publish_state==LinphonePublishOk && lev->expires!=-1){ sal_publish(lev->op,NULL,NULL,NULL,0,NULL); }else sal_op_stop_refreshing(lev->op); linphone_event_set_publish_state(lev,LinphonePublishCleared); diff --git a/coreapi/event.h b/coreapi/event.h index 5985d1c96..2b0e2bf0d 100644 --- a/coreapi/event.h +++ b/coreapi/event.h @@ -52,7 +52,7 @@ typedef enum _LinphoneSubscriptionDir LinphoneSubscriptionDir; **/ enum _LinphoneSubscriptionState{ LinphoneSubscriptionNone, /**< Initial state, should not be used.**/ - LinphoneSubscriptionOutgoingInit, /**lc->config,"sip","refresh_generic_publish",refresh); - lev=linphone_core_create_publish(marie->lc,pauline->identity,"dodo",5); + lev=linphone_core_create_publish(marie->lc,pauline->identity,"dodo",expires); linphone_event_add_custom_header(lev,"CustomHeader","someValue"); linphone_event_send_publish(lev,&content); linphone_event_ref(lev); @@ -332,11 +332,15 @@ static void publish_test_with_args(bool_t refresh){ } static void publish_test(){ - publish_test_with_args(TRUE); + publish_test_with_args(TRUE,5); } static void publish_no_auto_test(){ - publish_test_with_args(FALSE); + publish_test_with_args(FALSE,5); +} + +static void publish_without_expires(){ + publish_test_with_args(TRUE,-1); } test_t event_tests[] = { @@ -347,6 +351,7 @@ test_t event_tests[] = { { "Subscribe manually refreshed", subscribe_test_manually_refreshed }, { "Subscribe terminated by notifier", subscribe_test_terminated_by_notifier }, { "Publish", publish_test }, + { "Publish without expires", publish_without_expires }, { "Publish without automatic refresh",publish_no_auto_test } }; From 643d39637bb0130d35275fbaaeb0b24d31122345 Mon Sep 17 00:00:00 2001 From: Simon Morlat Date: Fri, 11 Apr 2014 11:10:56 +0200 Subject: [PATCH 13/23] repair android build, serialize proxy configs. --- coreapi/linphonecore_jni.cc | 21 ++++++++++++++++--- .../linphone/core/LinphoneCoreListener.java | 2 +- .../org/linphone/core/LinphoneCoreImpl.java | 8 ++++--- .../core/LinphoneProxyConfigImpl.java | 14 ++++++++++--- mediastreamer2 | 2 +- 5 files changed, 36 insertions(+), 11 deletions(-) diff --git a/coreapi/linphonecore_jni.cc b/coreapi/linphonecore_jni.cc index 824852418..2b0c79897 100644 --- a/coreapi/linphonecore_jni.cc +++ b/coreapi/linphonecore_jni.cc @@ -224,6 +224,8 @@ public: /*void newSubscriptionRequest(LinphoneCore lc, LinphoneFriend lf, String url)*/ newSubscriptionRequestId = env->GetMethodID(listenerClass,"newSubscriptionRequest","(Lorg/linphone/core/LinphoneCore;Lorg/linphone/core/LinphoneFriend;Ljava/lang/String;)V"); + + authInfoRequestedId = env->GetMethodID(listenerClass,"authInfoRequested","(Lorg/linphone/core/LinphoneCore;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;)V"); /*void notifyPresenceReceived(LinphoneCore lc, LinphoneFriend lf);*/ notifyPresenceReceivedId = env->GetMethodID(listenerClass,"notifyPresenceReceived","(Lorg/linphone/core/LinphoneCore;Lorg/linphone/core/LinphoneFriend;)V"); @@ -245,7 +247,7 @@ public: proxyClass = (jclass)env->NewGlobalRef(env->FindClass("org/linphone/core/LinphoneProxyConfigImpl")); - proxyCtrId = env->GetMethodID(proxyClass,"", "(J)V"); + proxyCtrId = env->GetMethodID(proxyClass,"", "(Lorg/linphone/core/LinphoneCoreImpl;J)V"); callClass = (jclass)env->NewGlobalRef(env->FindClass("org/linphone/core/LinphoneCallImpl")); callCtrId = env->GetMethodID(callClass,"", "(J)V"); @@ -325,6 +327,7 @@ public: jmethodID transferStateId; jmethodID infoReceivedId; jmethodID subscriptionStateId; + jmethodID authInfoRequestedId; jmethodID publishStateId; jmethodID notifyRecvId; @@ -413,7 +416,19 @@ public: } static void authInfoRequested(LinphoneCore *lc, const char *realm, const char *username, const char *domain) { - + JNIEnv *env = 0; + jint result = jvm->AttachCurrentThread(&env,NULL); + if (result != 0) { + ms_error("cannot attach VM"); + return; + } + LinphoneCoreData* lcData = (LinphoneCoreData*)linphone_core_get_user_data(lc); + env->CallVoidMethod(lcData->listener, + lcData->authInfoRequestedId, + lcData->core, + realm ? env->NewStringUTF(realm):NULL, + username ? env->NewStringUTF(username) : NULL, + domain ? env->NewStringUTF(domain) : NULL); } static void globalStateChange(LinphoneCore *lc, LinphoneGlobalState gstate,const char* message) { JNIEnv *env = 0; @@ -440,7 +455,7 @@ public: env->CallVoidMethod(lcData->listener ,lcData->registrationStateId ,lcData->core - ,env->NewObject(lcData->proxyClass,lcData->proxyCtrId,(jlong)proxy) + ,env->NewObject(lcData->proxyClass,lcData->proxyCtrId,lcData->core,(jlong)proxy) ,env->CallStaticObjectMethod(lcData->registrationStateClass,lcData->registrationStateFromIntId,(jint)state), message ? env->NewStringUTF(message) : NULL); } diff --git a/java/common/org/linphone/core/LinphoneCoreListener.java b/java/common/org/linphone/core/LinphoneCoreListener.java index 5d2ac5f5f..bd83172a9 100644 --- a/java/common/org/linphone/core/LinphoneCoreListener.java +++ b/java/common/org/linphone/core/LinphoneCoreListener.java @@ -28,7 +28,7 @@ import org.linphone.core.LinphoneCore.RemoteProvisioningState; public interface LinphoneCoreListener { /**< Ask the application some authentication information * @return */ - void authInfoRequested(LinphoneCore lc,String realm,String username); + void authInfoRequested(LinphoneCore lc, String realm, String username, String Domain); /** General State notification * @param state LinphoneCore.State diff --git a/java/impl/org/linphone/core/LinphoneCoreImpl.java b/java/impl/org/linphone/core/LinphoneCoreImpl.java index 7a28a0867..66597ca81 100644 --- a/java/impl/org/linphone/core/LinphoneCoreImpl.java +++ b/java/impl/org/linphone/core/LinphoneCoreImpl.java @@ -192,7 +192,7 @@ class LinphoneCoreImpl implements LinphoneCore { isValid(); long lNativePtr = getDefaultProxyConfig(nativePtr); if (lNativePtr!=0) { - return new LinphoneProxyConfigImpl(lNativePtr); + return new LinphoneProxyConfigImpl(this,lNativePtr); } else { return null; } @@ -218,10 +218,12 @@ class LinphoneCoreImpl implements LinphoneCore { if (addProxyConfig(proxyCfg,nativePtr,((LinphoneProxyConfigImpl)proxyCfg).nativePtr) !=0) { throw new LinphoneCoreException("bad proxy config"); } + ((LinphoneProxyConfigImpl)proxyCfg).mCore=this; } public synchronized void removeProxyConfig(LinphoneProxyConfig proxyCfg) { isValid(); removeProxyConfig(nativePtr, ((LinphoneProxyConfigImpl)proxyCfg).nativePtr); + ((LinphoneProxyConfigImpl)proxyCfg).mCore=null; } public synchronized void clearAuthInfos() { isValid(); @@ -517,7 +519,7 @@ class LinphoneCoreImpl implements LinphoneCore { LinphoneProxyConfig[] proxies = new LinphoneProxyConfig[typesPtr.length]; for (int i=0; i < proxies.length; i++) { - proxies[i] = new LinphoneProxyConfigImpl(typesPtr[i]); + proxies[i] = new LinphoneProxyConfigImpl(this,typesPtr[i]); } return proxies; @@ -1137,7 +1139,7 @@ class LinphoneCoreImpl implements LinphoneCore { } @Override public synchronized LinphoneProxyConfig createProxyConfig() { - return new LinphoneProxyConfigImpl(createProxyConfig(nativePtr)); + return new LinphoneProxyConfigImpl(this,createProxyConfig(nativePtr)); } @Override public synchronized void setCallErrorTone(Reason reason, String path) { diff --git a/java/impl/org/linphone/core/LinphoneProxyConfigImpl.java b/java/impl/org/linphone/core/LinphoneProxyConfigImpl.java index 96b153733..a78819075 100644 --- a/java/impl/org/linphone/core/LinphoneProxyConfigImpl.java +++ b/java/impl/org/linphone/core/LinphoneProxyConfigImpl.java @@ -27,6 +27,7 @@ import org.linphone.core.LinphoneCore.RegistrationState; class LinphoneProxyConfigImpl implements LinphoneProxyConfig { protected final long nativePtr; + protected LinphoneCoreImpl mCore; private native int getState(long nativePtr); private native void setExpires(long nativePtr, int delay); @@ -41,9 +42,10 @@ class LinphoneProxyConfigImpl implements LinphoneProxyConfig { enableRegister(enableRegister); ownPtr=true; } - protected LinphoneProxyConfigImpl(long aNativePtr) { + protected LinphoneProxyConfigImpl(LinphoneCoreImpl core, long aNativePtr) { nativePtr = aNativePtr; ownPtr=false; + mCore=core; } protected void finalize() throws Throwable { //Log.e(LinphoneService.TAG,"fixme, should release underlying proxy config"); @@ -90,11 +92,17 @@ class LinphoneProxyConfigImpl implements LinphoneProxyConfig { } public void done() { - done(nativePtr); + Object mutex=mCore!=null ? mCore : this; + synchronized(mutex){ + done(nativePtr); + } } public LinphoneProxyConfig edit() { - edit(nativePtr); + Object mutex=mCore!=null ? mCore : this; + synchronized(mutex){ + edit(nativePtr); + } return this; } diff --git a/mediastreamer2 b/mediastreamer2 index 6aa698351..b76e3dde1 160000 --- a/mediastreamer2 +++ b/mediastreamer2 @@ -1 +1 @@ -Subproject commit 6aa6983512e5fa61ccdaaedc79f109993c5de04a +Subproject commit b76e3dde111af0d24be4ac5f1d4f633361e654c1 From 5e3ff318d97f2f5eecaa57958858f3b0a91dae87 Mon Sep 17 00:00:00 2001 From: Simon Morlat Date: Fri, 11 Apr 2014 11:51:12 +0200 Subject: [PATCH 14/23] add ref count to LinphoneChatMessage --- coreapi/chat.c | 46 ++++++++++++++++++++++++++++++++++++++---- coreapi/linphonecore.h | 2 ++ coreapi/private.h | 6 +++++- 3 files changed, 49 insertions(+), 5 deletions(-) diff --git a/coreapi/chat.c b/coreapi/chat.c index ef01b8b11..fe0370afe 100644 --- a/coreapi/chat.c +++ b/coreapi/chat.c @@ -32,6 +32,18 @@ #define COMPOSING_DEFAULT_REFRESH_TIMEOUT 60 #define COMPOSING_DEFAULT_REMOTE_REFRESH_TIMEOUT 120 +static void _linphone_chat_message_destroy(LinphoneChatMessage* msg); + +BELLE_SIP_DECLARE_NO_IMPLEMENTED_INTERFACES(LinphoneChatMessage); + +BELLE_SIP_INSTANCIATE_VPTR(LinphoneChatMessage,belle_sip_object_t, + (belle_sip_object_destroy_t)_linphone_chat_message_destroy, + NULL, // clone + NULL, // marshal + FALSE +); + + /** * @addtogroup chatroom * @{ @@ -406,7 +418,7 @@ const LinphoneAddress* linphone_chat_room_get_peer_address(LinphoneChatRoom *cr) * @return a new #LinphoneChatMessage */ LinphoneChatMessage* linphone_chat_room_create_message(LinphoneChatRoom *cr, const char* message) { - LinphoneChatMessage* msg = ms_new0(LinphoneChatMessage,1); + LinphoneChatMessage* msg = belle_sip_object_new(LinphoneChatMessage); msg->chat_room=(LinphoneChatRoom*)cr; msg->message=message?ms_strdup(message):NULL; msg->is_read=TRUE; @@ -429,7 +441,7 @@ LinphoneChatMessage* linphone_chat_room_create_message_2( LinphoneChatMessageState state, time_t time, bool_t is_read, bool_t is_incoming) { LinphoneCore *lc=linphone_chat_room_get_lc(cr); - LinphoneChatMessage* msg = ms_new0(LinphoneChatMessage,1); + LinphoneChatMessage* msg = belle_sip_object_new(LinphoneChatMessage); msg->chat_room=(LinphoneChatRoom*)cr; msg->message=message?ms_strdup(message):NULL; msg->external_body_url=external_body_url?ms_strdup(external_body_url):NULL; @@ -803,14 +815,40 @@ LinphoneChatMessage* linphone_chat_message_clone(const LinphoneChatMessage* msg) /** * Destroys a LinphoneChatMessage. **/ -void linphone_chat_message_destroy(LinphoneChatMessage* msg) { +void linphone_chat_message_destroy(LinphoneChatMessage* msg){ + belle_sip_object_unref(msg); +} + + +/** + * Destroys a LinphoneChatMessage. +**/ +static void _linphone_chat_message_destroy(LinphoneChatMessage* msg) { if (msg->op) sal_op_release(msg->op); if (msg->message) ms_free(msg->message); if (msg->external_body_url) ms_free(msg->external_body_url); if (msg->from) linphone_address_destroy(msg->from); if (msg->to) linphone_address_destroy(msg->to); if (msg->custom_headers) sal_custom_header_free(msg->custom_headers); - ms_free(msg); +} + + +/** + * Acquire a reference to the chat message. + * @param msg the chat message + * @return the same chat message +**/ +LinphoneChatMessage * linphone_chat_message_ref(LinphoneChatMessage *msg){ + belle_sip_object_ref(msg); + return msg; +} + +/** + * Release reference to the chat message. + * @param msg the chat message. +**/ +void linphone_chat_message_unref(LinphoneChatMessage *msg){ + belle_sip_object_unref(msg); } /** diff --git a/coreapi/linphonecore.h b/coreapi/linphonecore.h index f4f34b8c6..7448341aa 100644 --- a/coreapi/linphonecore.h +++ b/coreapi/linphonecore.h @@ -1067,6 +1067,8 @@ LINPHONE_PUBLIC unsigned int linphone_chat_message_store(LinphoneChatMessage *ms LINPHONE_PUBLIC const char* linphone_chat_message_state_to_string(const LinphoneChatMessageState state); LINPHONE_PUBLIC LinphoneChatMessageState linphone_chat_message_get_state(const LinphoneChatMessage* message); LINPHONE_PUBLIC LinphoneChatMessage* linphone_chat_message_clone(const LinphoneChatMessage* message); +LINPHONE_PUBLIC LinphoneChatMessage * linphone_chat_message_ref(LinphoneChatMessage *msg); +LINPHONE_PUBLIC void linphone_chat_message_unref(LinphoneChatMessage *msg); LINPHONE_PUBLIC void linphone_chat_message_destroy(LinphoneChatMessage* msg); LINPHONE_PUBLIC void linphone_chat_message_set_from(LinphoneChatMessage* message, const LinphoneAddress* from); LINPHONE_PUBLIC const LinphoneAddress* linphone_chat_message_get_from(const LinphoneChatMessage* message); diff --git a/coreapi/private.h b/coreapi/private.h index 9fa89dd3a..69ca8c728 100644 --- a/coreapi/private.h +++ b/coreapi/private.h @@ -132,6 +132,7 @@ typedef enum _LinphoneChatMessageDir{ } LinphoneChatMessageDir; struct _LinphoneChatMessage { + belle_sip_object_t base; LinphoneChatRoom* chat_room; LinphoneChatMessageDir dir; char* message; @@ -149,6 +150,8 @@ struct _LinphoneChatMessage { SalOp *op; }; +BELLE_SIP_DECLARE_VPTR(LinphoneChatMessage); + typedef struct StunCandidate{ char addr[64]; int port; @@ -862,7 +865,8 @@ BELLE_SIP_DECLARE_TYPES_BEGIN(linphone,10000) BELLE_SIP_TYPE_ID(LinphoneContactSearch), BELLE_SIP_TYPE_ID(LinphoneContactProvider), BELLE_SIP_TYPE_ID(LinphoneLDAPContactProvider), -BELLE_SIP_TYPE_ID(LinphoneLDAPContactSearch) +BELLE_SIP_TYPE_ID(LinphoneLDAPContactSearch), +BELLE_SIP_TYPE_ID(LinphoneChatMessage) BELLE_SIP_DECLARE_TYPES_END From fd813601605e2f4e2cbd70e2cdb96806e3e78e41 Mon Sep 17 00:00:00 2001 From: Simon Morlat Date: Fri, 11 Apr 2014 14:46:21 +0200 Subject: [PATCH 15/23] fix management of LinphoneChatMessage in android glue add authInfoRequested implementation. --- .../core/tutorials/TutorialBuddyStatus.java | 8 ++++- .../core/tutorials/TutorialChatRoom.java | 2 +- .../core/tutorials/TutorialHelloWorld.java | 2 +- .../core/tutorials/TutorialRegistration.java | 2 +- coreapi/linphonecore_jni.cc | 31 +++++++++-------- .../linphone/core/LinphoneChatMessage.java | 5 --- .../core/LinphoneChatMessageImpl.java | 33 +++++++------------ .../linphone/core/LinphoneChatRoomImpl.java | 8 ++--- 8 files changed, 44 insertions(+), 47 deletions(-) diff --git a/coreapi/help/java/org/linphone/core/tutorials/TutorialBuddyStatus.java b/coreapi/help/java/org/linphone/core/tutorials/TutorialBuddyStatus.java index c9ccb9105..6424442e7 100644 --- a/coreapi/help/java/org/linphone/core/tutorials/TutorialBuddyStatus.java +++ b/coreapi/help/java/org/linphone/core/tutorials/TutorialBuddyStatus.java @@ -97,7 +97,6 @@ public class TutorialBuddyStatus implements LinphoneCoreListener { } public void show(LinphoneCore lc) {} public void byeReceived(LinphoneCore lc, String from) {} - public void authInfoRequested(LinphoneCore lc, String realm, String username) {} public void displayStatus(LinphoneCore lc, String message) {} public void displayMessage(LinphoneCore lc, String message) {} public void displayWarning(LinphoneCore lc, String message) {} @@ -294,5 +293,12 @@ public class TutorialBuddyStatus implements LinphoneCoreListener { } + @Override + public void authInfoRequested(LinphoneCore lc, String realm, + String username, String Domain) { + // TODO Auto-generated method stub + + } + } diff --git a/coreapi/help/java/org/linphone/core/tutorials/TutorialChatRoom.java b/coreapi/help/java/org/linphone/core/tutorials/TutorialChatRoom.java index e2dc10d34..bf1d93d6d 100644 --- a/coreapi/help/java/org/linphone/core/tutorials/TutorialChatRoom.java +++ b/coreapi/help/java/org/linphone/core/tutorials/TutorialChatRoom.java @@ -73,7 +73,7 @@ public class TutorialChatRoom implements LinphoneCoreListener, LinphoneChatMessa public void show(LinphoneCore lc) {} public void byeReceived(LinphoneCore lc, String from) {} - public void authInfoRequested(LinphoneCore lc, String realm, String username) {} + public void authInfoRequested(LinphoneCore lc, String realm, String username, String domain) {} public void displayStatus(LinphoneCore lc, String message) {} public void displayMessage(LinphoneCore lc, String message) {} public void displayWarning(LinphoneCore lc, String message) {} diff --git a/coreapi/help/java/org/linphone/core/tutorials/TutorialHelloWorld.java b/coreapi/help/java/org/linphone/core/tutorials/TutorialHelloWorld.java index e0faf9d92..8c1eeafb4 100644 --- a/coreapi/help/java/org/linphone/core/tutorials/TutorialHelloWorld.java +++ b/coreapi/help/java/org/linphone/core/tutorials/TutorialHelloWorld.java @@ -67,7 +67,7 @@ public class TutorialHelloWorld implements LinphoneCoreListener { public void show(LinphoneCore lc) {} public void byeReceived(LinphoneCore lc, String from) {} - public void authInfoRequested(LinphoneCore lc, String realm, String username) {} + public void authInfoRequested(LinphoneCore lc, String realm, String username, String domain) {} public void displayStatus(LinphoneCore lc, String message) {} public void displayMessage(LinphoneCore lc, String message) {} public void displayWarning(LinphoneCore lc, String message) {} diff --git a/coreapi/help/java/org/linphone/core/tutorials/TutorialRegistration.java b/coreapi/help/java/org/linphone/core/tutorials/TutorialRegistration.java index c3aebd307..91a778feb 100644 --- a/coreapi/help/java/org/linphone/core/tutorials/TutorialRegistration.java +++ b/coreapi/help/java/org/linphone/core/tutorials/TutorialRegistration.java @@ -78,7 +78,7 @@ public class TutorialRegistration implements LinphoneCoreListener { public void show(LinphoneCore lc) {} public void byeReceived(LinphoneCore lc, String from) {} - public void authInfoRequested(LinphoneCore lc, String realm, String username) {} + public void authInfoRequested(LinphoneCore lc, String realm, String username, String domain) {} public void displayStatus(LinphoneCore lc, String message) {} public void displayMessage(LinphoneCore lc, String message) {} public void displayWarning(LinphoneCore lc, String message) {} diff --git a/coreapi/linphonecore_jni.cc b/coreapi/linphonecore_jni.cc index 2b0c79897..bb94573f5 100644 --- a/coreapi/linphonecore_jni.cc +++ b/coreapi/linphonecore_jni.cc @@ -2447,13 +2447,6 @@ extern "C" void Java_org_linphone_core_LinphoneChatRoomImpl_destroy(JNIEnv* env linphone_chat_room_destroy((LinphoneChatRoom*)ptr); } -extern "C" void Java_org_linphone_core_LinphoneChatMessageImpl_setUserData(JNIEnv* env - ,jobject thiz - ,jlong ptr) { - jobject ud = env->NewGlobalRef(thiz); - linphone_chat_message_set_user_data((LinphoneChatMessage*)ptr,(void*) ud); -} - extern "C" void Java_org_linphone_core_LinphoneChatMessageImpl_store(JNIEnv* env ,jobject thiz ,jlong ptr) { @@ -2554,6 +2547,12 @@ extern "C" jint Java_org_linphone_core_LinphoneChatMessageImpl_getStorageId(JNIE return (jint) linphone_chat_message_get_storage_id((LinphoneChatMessage*)ptr); } +extern "C" void Java_org_linphone_core_LinphoneChatMessageImpl_unref(JNIEnv* env + ,jobject thiz + ,jlong ptr) { + linphone_chat_message_unref((LinphoneChatMessage*)ptr); +} + extern "C" jlongArray Java_org_linphone_core_LinphoneCoreImpl_getChatRooms(JNIEnv* env ,jobject thiz ,jlong ptr) { @@ -2592,26 +2591,32 @@ static void chat_room_impl_callback(LinphoneChatMessage* msg, LinphoneChatMessag jobject listener = (jobject) ud; jclass clazz = (jclass) env->GetObjectClass(listener); jmethodID method = env->GetMethodID(clazz, "onLinphoneChatMessageStateChanged","(Lorg/linphone/core/LinphoneChatMessage;Lorg/linphone/core/LinphoneChatMessage$State;)V"); - + jobject jmessage=(jobject)linphone_chat_message_get_user_data(msg); LinphoneCore *lc = linphone_chat_room_get_lc(linphone_chat_message_get_chat_room(msg)); LinphoneCoreData* lcData = (LinphoneCoreData*)linphone_core_get_user_data(lc); env->CallVoidMethod( listener, method, - (jobject)linphone_chat_message_get_user_data(msg), + jmessage, env->CallStaticObjectMethod(lcData->chatMessageStateClass,lcData->chatMessageStateFromIntId,(jint)state)); - + if (state == LinphoneChatMessageStateDelivered || state == LinphoneChatMessageStateNotDelivered) { env->DeleteGlobalRef(listener); + env->DeleteGlobalRef(jmessage); + linphone_chat_message_set_user_data(msg,NULL); } } extern "C" void Java_org_linphone_core_LinphoneChatRoomImpl_sendMessage2(JNIEnv* env ,jobject thiz - ,jlong ptr - ,jlong jmessage + ,jlong chatroom_ptr + ,jobject message + ,jlong messagePtr ,jobject jlistener) { jobject listener = env->NewGlobalRef(jlistener); - linphone_chat_room_send_message2((LinphoneChatRoom*)ptr, (LinphoneChatMessage*)jmessage, chat_room_impl_callback, (void*)listener); + message = env->NewGlobalRef(message); + linphone_chat_message_ref((LinphoneChatMessage*)messagePtr); + linphone_chat_message_set_user_data((LinphoneChatMessage*)messagePtr, message); + linphone_chat_room_send_message2((LinphoneChatRoom*)chatroom_ptr, (LinphoneChatMessage*)messagePtr, chat_room_impl_callback, (void*)listener); } extern "C" void Java_org_linphone_core_LinphoneCoreImpl_setVideoWindowId(JNIEnv* env diff --git a/java/common/org/linphone/core/LinphoneChatMessage.java b/java/common/org/linphone/core/LinphoneChatMessage.java index 356294102..d51a19251 100644 --- a/java/common/org/linphone/core/LinphoneChatMessage.java +++ b/java/common/org/linphone/core/LinphoneChatMessage.java @@ -52,11 +52,6 @@ public interface LinphoneChatMessage { } } - long getNativePtr(); - - Object getUserData(); - - void setUserData(); /** * get text associated to this LinphoneChatMessage diff --git a/java/impl/org/linphone/core/LinphoneChatMessageImpl.java b/java/impl/org/linphone/core/LinphoneChatMessageImpl.java index a891cad8b..c48c8a5cc 100644 --- a/java/impl/org/linphone/core/LinphoneChatMessageImpl.java +++ b/java/impl/org/linphone/core/LinphoneChatMessageImpl.java @@ -2,7 +2,6 @@ package org.linphone.core; public class LinphoneChatMessageImpl implements LinphoneChatMessage { protected final long nativePtr; - private native void setUserData(long ptr); private native String getText(long ptr); private native long getPeerAddress(long ptr); private native String getExternalBodyUrl(long ptr); @@ -14,27 +13,16 @@ public class LinphoneChatMessageImpl implements LinphoneChatMessage { private native boolean isOutgoing(long ptr); private native void store(long ptr); private native int getStorageId(long ptr); + private native void unref(long ptr); protected LinphoneChatMessageImpl(long aNativePtr) { nativePtr = aNativePtr; - setUserData(); } public long getNativePtr() { return nativePtr; } - @Override - public Object getUserData() { - // TODO Auto-generated method stub - return null; - } - - @Override - public void setUserData() { - setUserData(nativePtr); - } - @Override public String getText() { return getText(nativePtr); @@ -97,12 +85,15 @@ public class LinphoneChatMessageImpl implements LinphoneChatMessage { private native int getReason(long ptr); - public Reason getReason() { - return Reason.fromInt(getReason(nativePtr)); - } - private native long getErrorInfo(long nativePtr); - @Override - public ErrorInfo getErrorInfo() { - return new ErrorInfoImpl(getErrorInfo(nativePtr)); - } + public Reason getReason() { + return Reason.fromInt(getReason(nativePtr)); + } + private native long getErrorInfo(long nativePtr); + @Override + public ErrorInfo getErrorInfo() { + return new ErrorInfoImpl(getErrorInfo(nativePtr)); + } + protected void finalize(){ + unref(nativePtr); + } } diff --git a/java/impl/org/linphone/core/LinphoneChatRoomImpl.java b/java/impl/org/linphone/core/LinphoneChatRoomImpl.java index c2021e379..7901272c9 100644 --- a/java/impl/org/linphone/core/LinphoneChatRoomImpl.java +++ b/java/impl/org/linphone/core/LinphoneChatRoomImpl.java @@ -26,7 +26,7 @@ class LinphoneChatRoomImpl implements LinphoneChatRoom { private native long createLinphoneChatMessage(long ptr, String message); private native long getPeerAddress(long ptr); private native void sendMessage(long ptr, String message); - private native void sendMessage2(long ptr, long message, StateListener listener); + private native void sendMessage2(long ptr, Object msg, long messagePtr, StateListener listener); private native long[] getHistory(long ptr, int limit); private native void destroy(long ptr); private native int getUnreadMessagesCount(long ptr); @@ -54,7 +54,7 @@ class LinphoneChatRoomImpl implements LinphoneChatRoom { @Override public void sendMessage(LinphoneChatMessage message, StateListener listener) { - sendMessage2(nativePtr, message.getNativePtr(), listener); + sendMessage2(nativePtr, message, ((LinphoneChatMessageImpl)message).getNativePtr(), listener); } @Override @@ -104,12 +104,12 @@ class LinphoneChatRoomImpl implements LinphoneChatRoom { public void deleteMessage(LinphoneChatMessage message) { if (message != null) - deleteMessage(nativePtr, message.getNativePtr()); + deleteMessage(nativePtr, ((LinphoneChatMessageImpl)message).getNativePtr()); } public void updateUrl(LinphoneChatMessage message) { if (message != null) - updateUrl(nativePtr, message.getNativePtr()); + updateUrl(nativePtr, ((LinphoneChatMessageImpl)message).getNativePtr()); } @Override From 08645f8eeaa60f1b8c6bd30d9871389ad18196bf Mon Sep 17 00:00:00 2001 From: Guillaume BIENKOWSKI Date: Fri, 11 Apr 2014 16:20:05 +0200 Subject: [PATCH 16/23] Add lp_config_new_from_buffer --- coreapi/lpconfig.c | 206 +++++++++++++++++++++++------------------- coreapi/lpconfig.h | 40 +++++--- tester/setup_tester.c | 45 ++++++--- 3 files changed, 171 insertions(+), 120 deletions(-) diff --git a/coreapi/lpconfig.c b/coreapi/lpconfig.c index 8df196df2..6e51d257c 100644 --- a/coreapi/lpconfig.c +++ b/coreapi/lpconfig.c @@ -177,101 +177,107 @@ LpItem *lp_section_find_item(const LpSection *sec, const char *name){ return NULL; } -void lp_config_parse(LpConfig *lpconfig, FILE *file){ - char tmp[MAX_LEN]= {'\0'}; - LpSection *cur=NULL; +static LpSection* lp_config_parse_line(LpConfig* lpconfig, const char* line, LpSection* cur) { LpSectionParam *params = NULL; char *pos1,*pos2; int nbs; - char secname[MAX_LEN]; - char key[MAX_LEN]; - char value[MAX_LEN]; + static char secname[MAX_LEN]; + static char key[MAX_LEN]; + static char value[MAX_LEN]; LpItem *item; + pos1=strchr(line,'['); + if (pos1!=NULL && is_first_char(line,pos1) ){ + pos2=strchr(pos1,']'); + if (pos2!=NULL){ + secname[0]='\0'; + /* found section */ + *pos2='\0'; + nbs = sscanf(pos1+1, "%s", secname); + if (nbs >= 1) { + if (strlen(secname) > 0) { + cur = lp_config_find_section (lpconfig,secname); + if (cur == NULL) { + cur = lp_section_new(secname); + lp_config_add_section(lpconfig, cur); + } + + if (pos2 > pos1 + 1 + strlen(secname)) { + /* found at least one section param */ + pos2 = pos1 + 1 + strlen(secname) + 1; // Remove the white space after the secname + pos1 = strchr(pos2, '='); + while (pos1 != NULL) { + /* for each section param */ + key[0] = '\0'; + value[0] = '\0'; + *pos1 = ' '; + if (sscanf(pos2, "%s %s", key, value) == 2) { + params = lp_section_param_new(key, value); + lp_config_add_section_param(cur, params); + + pos2 += strlen(key) + strlen(value) + 2; // Remove the = sign + the white space after each param + pos1 = strchr(pos2, '='); + } else { + ms_warning("parse section params error !"); + pos1 = NULL; + } + } + } + } + } else { + ms_warning("parse error!"); + } + } + }else { + pos1=strchr(line,'='); + if (pos1!=NULL){ + key[0]='\0'; + + *pos1='\0'; + if (sscanf(line,"%s",key)>0){ + + pos1++; + pos2=strchr(pos1,'\r'); + if (pos2==NULL) + pos2=strchr(pos1,'\n'); + if (pos2==NULL) pos2=pos1+strlen(pos1); + else { + *pos2='\0'; /*replace the '\n' */ + } + /* remove ending white spaces */ + for (; pos2>pos1 && pos2[-1]==' ';pos2--) pos2[-1]='\0'; + + if (pos2-pos1>=0){ + /* found a pair key,value */ + + if (cur!=NULL){ + item=lp_section_find_item(cur,key); + if (item==NULL){ + lp_section_add_item(cur,lp_item_new(key,pos1)); + }else{ + ortp_free(item->value); + item->value=ortp_strdup(pos1); + } + /*ms_message("Found %s=%s",key,pos1);*/ + }else{ + ms_warning("found key,item but no sections"); + } + } + } + } + } + return cur; +} + +void lp_config_parse(LpConfig *lpconfig, FILE *file){ + char tmp[MAX_LEN]= {'\0'}; + LpSection* current_section = NULL; + if (file==NULL) return; while(fgets(tmp,MAX_LEN,file)!=NULL){ tmp[sizeof(tmp) -1] = '\0'; - pos1=strchr(tmp,'['); - if (pos1!=NULL && is_first_char(tmp,pos1) ){ - pos2=strchr(pos1,']'); - if (pos2!=NULL){ - secname[0]='\0'; - /* found section */ - *pos2='\0'; - nbs = sscanf(pos1+1, "%s", secname); - if (nbs >= 1) { - if (strlen(secname) > 0) { - cur = lp_config_find_section (lpconfig,secname); - if (cur == NULL) { - cur = lp_section_new(secname); - lp_config_add_section(lpconfig, cur); - } - - if (pos2 > pos1 + 1 + strlen(secname)) { - /* found at least one section param */ - pos2 = pos1 + 1 + strlen(secname) + 1; // Remove the white space after the secname - pos1 = strchr(pos2, '='); - while (pos1 != NULL) { - /* for each section param */ - key[0] = '\0'; - value[0] = '\0'; - *pos1 = ' '; - if (sscanf(pos2, "%s %s", key, value) == 2) { - params = lp_section_param_new(key, value); - lp_config_add_section_param(cur, params); - - pos2 += strlen(key) + strlen(value) + 2; // Remove the = sign + the white space after each param - pos1 = strchr(pos2, '='); - } else { - ms_warning("parse section params error !"); - pos1 = NULL; - } - } - } - } - } else { - ms_warning("parse error!"); - } - } - }else { - pos1=strchr(tmp,'='); - if (pos1!=NULL){ - key[0]='\0'; - - *pos1='\0'; - if (sscanf(tmp,"%s",key)>0){ - - pos1++; - pos2=strchr(pos1,'\r'); - if (pos2==NULL) - pos2=strchr(pos1,'\n'); - if (pos2==NULL) pos2=pos1+strlen(pos1); - else { - *pos2='\0'; /*replace the '\n' */ - } - /* remove ending white spaces */ - for (; pos2>pos1 && pos2[-1]==' ';pos2--) pos2[-1]='\0'; - - if (pos2-pos1>=0){ - /* found a pair key,value */ - - if (cur!=NULL){ - item=lp_section_find_item(cur,key); - if (item==NULL){ - lp_section_add_item(cur,lp_item_new(key,pos1)); - }else{ - ortp_free(item->value); - item->value=ortp_strdup(pos1); - } - /*ms_message("Found %s=%s",key,pos1);*/ - }else{ - ms_warning("found key,item but no sections"); - } - } - } - } - } + current_section = lp_config_parse_line(lpconfig, tmp, current_section); } } @@ -279,9 +285,27 @@ LpConfig * lp_config_new(const char *filename){ return lp_config_new_with_factory(filename, NULL); } +LpConfig * lp_config_new_from_buffer(const char *buffer){ + LpConfig* conf = lp_new0(LpConfig,1); + LpSection* current_section = NULL; + + char* ptr = ms_strdup(buffer); + char* strtok_storage = NULL; + char* line = strtok_r(ptr, "\n", &strtok_storage); + + while( line != NULL ){ + current_section = lp_config_parse_line(conf,line,current_section); + line = strtok_r(NULL, "\n", &strtok_storage); + } + + ms_free(ptr); + + return conf; +} + LpConfig *lp_config_new_with_factory(const char *config_filename, const char *factory_config_filename) { LpConfig *lpconfig=lp_new0(LpConfig,1); - + if (config_filename!=NULL){ ms_message("Using (r/w) config information from %s", config_filename); lpconfig->filename=ortp_strdup(config_filename); @@ -547,7 +571,7 @@ int lp_config_get_default_int(const LpConfig *lpconfig, const char *section, con char default_section[MAX_LEN]; strcpy(default_section, section); strcat(default_section, DEFAULT_VALUES_SUFFIX); - + return lp_config_get_int(lpconfig, default_section, key, default_value); } @@ -555,7 +579,7 @@ int64_t lp_config_get_default_int64(const LpConfig *lpconfig, const char *sectio char default_section[MAX_LEN]; strcpy(default_section, section); strcat(default_section, DEFAULT_VALUES_SUFFIX); - + return lp_config_get_int64(lpconfig, default_section, key, default_value); } @@ -563,7 +587,7 @@ float lp_config_get_default_float(const LpConfig *lpconfig, const char *section, char default_section[MAX_LEN]; strcpy(default_section, section); strcat(default_section, DEFAULT_VALUES_SUFFIX); - + return lp_config_get_float(lpconfig, default_section, key, default_value); } @@ -571,6 +595,6 @@ const char* lp_config_get_default_string(const LpConfig *lpconfig, const char *s char default_section[MAX_LEN]; strcpy(default_section, section); strcat(default_section, DEFAULT_VALUES_SUFFIX); - + return lp_config_get_string(lpconfig, default_section, key, default_value); } diff --git a/coreapi/lpconfig.h b/coreapi/lpconfig.h index 0e735c1a7..f0f330c18 100644 --- a/coreapi/lpconfig.h +++ b/coreapi/lpconfig.h @@ -21,7 +21,7 @@ * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ - + #ifndef LPCONFIG_H #define LPCONFIG_H #include @@ -33,7 +33,7 @@ /** * The LpConfig object is used to manipulate a configuration file. - * + * * @ingroup misc * The format of the configuration file is a .ini like format: * - sections are defined in [] @@ -64,6 +64,16 @@ extern "C" { */ LINPHONE_PUBLIC LpConfig * lp_config_new(const char *filename); +/** + * Instantiates a LpConfig object from a user provided buffer. + * + * @ingroup misc + * @param buffer the buffer from which the lpconfig will be retrieved. We expect the buffer to be null-terminated. + * @see lp_config_new_with_factory + * @see lp_config_new + */ +LINPHONE_PUBLIC LpConfig * lp_config_new_from_buffer(const char *buffer); + /** * Instantiates a LpConfig object from a user config file and a factory config file. * @@ -88,7 +98,7 @@ LINPHONE_PUBLIC int lp_config_read_file(LpConfig *lpconfig, const char *filename /** * Retrieves a configuration item as a string, given its section, key, and default value. - * + * * @ingroup misc * The default value string is returned if the config item isn't found. **/ @@ -105,7 +115,7 @@ LINPHONE_PUBLIC bool_t lp_config_get_range(const LpConfig *lpconfig, const char /** * Retrieves a configuration item as an integer, given its section, key, and default value. - * + * * @ingroup misc * The default integer value is returned if the config item isn't found. **/ @@ -113,7 +123,7 @@ LINPHONE_PUBLIC int lp_config_get_int(const LpConfig *lpconfig,const char *secti /** * Retrieves a configuration item as a 64 bit integer, given its section, key, and default value. - * + * * @ingroup misc * The default integer value is returned if the config item isn't found. **/ @@ -121,14 +131,14 @@ LINPHONE_PUBLIC int64_t lp_config_get_int64(const LpConfig *lpconfig,const char /** * Retrieves a configuration item as a float, given its section, key, and default value. - * + * * @ingroup misc * The default float value is returned if the config item isn't found. **/ LINPHONE_PUBLIC float lp_config_get_float(const LpConfig *lpconfig,const char *section, const char *key, float default_value); /** - * Sets a string config item + * Sets a string config item * * @ingroup misc **/ @@ -167,11 +177,11 @@ LINPHONE_PUBLIC void lp_config_set_int64(LpConfig *lpconfig,const char *section, * * @ingroup misc **/ -LINPHONE_PUBLIC void lp_config_set_float(LpConfig *lpconfig,const char *section, const char *key, float value); +LINPHONE_PUBLIC void lp_config_set_float(LpConfig *lpconfig,const char *section, const char *key, float value); /** * Writes the config file to disk. - * + * * @ingroup misc **/ LINPHONE_PUBLIC int lp_config_sync(LpConfig *lpconfig); @@ -211,7 +221,7 @@ LINPHONE_PUBLIC void lp_config_destroy(LpConfig *cfg); /** * Retrieves a default configuration item as an integer, given its section, key, and default value. - * + * * @ingroup misc * The default integer value is returned if the config item isn't found. **/ @@ -219,7 +229,7 @@ LINPHONE_PUBLIC int lp_config_get_default_int(const LpConfig *lpconfig, const ch /** * Retrieves a default configuration item as a 64 bit integer, given its section, key, and default value. - * + * * @ingroup misc * The default integer value is returned if the config item isn't found. **/ @@ -227,7 +237,7 @@ LINPHONE_PUBLIC int64_t lp_config_get_default_int64(const LpConfig *lpconfig, co /** * Retrieves a default configuration item as a float, given its section, key, and default value. - * + * * @ingroup misc * The default float value is returned if the config item isn't found. **/ @@ -235,7 +245,7 @@ LINPHONE_PUBLIC float lp_config_get_default_float(const LpConfig *lpconfig, cons /** * Retrieves a default configuration item as a string, given its section, key, and default value. - * + * * @ingroup misc * The default value string is returned if the config item isn't found. **/ @@ -243,12 +253,12 @@ LINPHONE_PUBLIC const char* lp_config_get_default_string(const LpConfig *lpconfi /** * Retrieves a section parameter item as a string, given its section and key. - * + * * @ingroup misc * The default value string is returned if the config item isn't found. **/ LINPHONE_PUBLIC const char* lp_config_get_section_param_string(const LpConfig *lpconfig, const char *section, const char *key, const char *default_value); - + #ifdef __cplusplus } #endif diff --git a/tester/setup_tester.c b/tester/setup_tester.c index 0e4299dbc..dc30e058e 100644 --- a/tester/setup_tester.c +++ b/tester/setup_tester.c @@ -1,19 +1,19 @@ /* - liblinphone_tester - liblinphone test suite - Copyright (C) 2013 Belledonne Communications SARL + liblinphone_tester - liblinphone test suite + Copyright (C) 2013 Belledonne Communications SARL - This program is free software: you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation, either version 2 of the License, or - (at your option) any later version. + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 2 of the License, or + (at your option) any later version. - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. - You should have received a copy of the GNU General Public License - along with this program. If not, see . + You should have received a copy of the GNU General Public License + along with this program. If not, see . */ #include @@ -72,7 +72,7 @@ static void linphone_interpret_url_test() LinphoneCore* lc; const char* sips_address = "sips:margaux@sip.linphone.org"; LinphoneAddress* address; - + memset ( &v_table,0,sizeof ( v_table ) ); lc = linphone_core_new ( &v_table,NULL,NULL,NULL ); CU_ASSERT_PTR_NOT_NULL_FATAL ( lc ); @@ -89,12 +89,29 @@ static void linphone_interpret_url_test() linphone_core_destroy ( lc ); } +static void linphone_lpconfig_from_buffer(){ + + static const char* buffer = "[buffer]\ntest=ok"; + static const char* buffer_linebreaks = "[buffer_linebreaks]\n\n\n\r\n\n\r\ntest=ok"; + LpConfig* conf; + + conf = lp_config_new_from_buffer(buffer); + CU_ASSERT_STRING_EQUAL(lp_config_get_string(conf,"buffer","test",""),"ok"); + lp_config_destroy(conf); + + conf = lp_config_new_from_buffer(buffer_linebreaks); + CU_ASSERT_STRING_EQUAL(lp_config_get_string(conf,"buffer_linebreaks","test",""),"ok"); + lp_config_destroy(conf); + +} + test_t setup_tests[] = { { "Linphone Address", linphone_address_test }, { "Linphone core init/uninit", core_init_test }, { "Linphone random transport port",core_sip_transport_test}, - { "Linphone interpret url", linphone_interpret_url_test } + { "Linphone interpret url", linphone_interpret_url_test }, + { "LPConfig from buffer", linphone_lpconfig_from_buffer } }; test_suite_t setup_test_suite = { From 7427b281693eeaa2483725e225967cf6cf4772e8 Mon Sep 17 00:00:00 2001 From: Guillaume Beraudo Date: Mon, 14 Apr 2014 10:19:43 +0200 Subject: [PATCH 17/23] Fix real early media command line. --- console/linphonec.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/console/linphonec.c b/console/linphonec.c index f08c0f94d..ca7d6cafa 100644 --- a/console/linphonec.c +++ b/console/linphonec.c @@ -914,7 +914,7 @@ print_usage (int exit_status) " -l logfile specify the log file for your SIP phone\n" " -s sipaddress specify the sip call to do at startup\n" " -a enable auto answering for incoming calls\n" -" --real-early-media enable sending early media using real audio/video (beware of privacy issue)\n" +" --real-early-media enable sending early media using real audio/video (beware of privacy issue)\n" " -V enable video features globally (disabled by default)\n" " -C enable video capture only (disabled by default)\n" " -D enable video display only (disabled by default)\n" @@ -1238,7 +1238,7 @@ linphonec_parse_cmdline(int argc, char **argv) { auto_answer = TRUE; } - else if (strncmp ("--real-early-media", argv[arg_num], 2) == 0) + else if (strncmp ("--real-early-media", argv[arg_num], strlen("--real-early-media")) == 0) { real_early_media_sending = TRUE; } From 162f121348d175e217d18141bbb2839f73b8dbb3 Mon Sep 17 00:00:00 2001 From: Jehan Monnier Date: Fri, 11 Apr 2014 17:16:29 +0200 Subject: [PATCH 18/23] better mgt of refresher in case of registration error --- coreapi/proxy.c | 6 ++++++ tester/register_tester.c | 28 ++++++++++++++++++++++++---- 2 files changed, 30 insertions(+), 4 deletions(-) diff --git a/coreapi/proxy.c b/coreapi/proxy.c index 74c8a7730..a526f337b 100644 --- a/coreapi/proxy.c +++ b/coreapi/proxy.c @@ -270,6 +270,9 @@ void linphone_proxy_config_edit(LinphoneProxyConfig *obj){ if (obj->state == LinphoneRegistrationOk || obj->state == LinphoneRegistrationProgress) { sal_unregister(obj->op); + } else { + /*stop refresher*/ + if (obj->op) sal_op_stop_refreshing(obj->op); } } } @@ -351,6 +354,9 @@ static void linphone_proxy_config_register(LinphoneProxyConfig *obj){ linphone_proxy_config_set_state(obj,LinphoneRegistrationFailed,"Registration failed"); } ms_free(proxy_string); + } else { + /*stop refresher, just in case*/ + if (obj->op) sal_op_stop_refreshing(obj->op); } } diff --git a/tester/register_tester.c b/tester/register_tester.c index 28850e141..a0d63e278 100644 --- a/tester/register_tester.c +++ b/tester/register_tester.c @@ -332,8 +332,7 @@ static void authenticated_register_with_wrong_late_credentials(){ linphone_core_manager_destroy(mgr); } -static void authenticated_register_with_wrong_credentials_with_params(const char* user_agent) { - LinphoneCoreManager *mgr; +static void authenticated_register_with_wrong_credentials_with_params_base(const char* user_agent,LinphoneCoreManager *mgr) { stats* counters; LCSipTransports transport = {5070,5070,0,5071}; LinphoneAuthInfo *info=linphone_auth_info_new(test_username,NULL,"wrong passwd",NULL,auth_domain,NULL); /*create authentication structure from identity*/ @@ -341,8 +340,6 @@ static void authenticated_register_with_wrong_credentials_with_params(const char sprintf(route,"sip:%s",test_route); - mgr=linphone_core_manager_new(NULL); - mgr->lc->vtable.auth_info_requested=auth_info_requested2; sal_set_refresher_retry_after(mgr->lc->sal,500); @@ -372,11 +369,33 @@ static void authenticated_register_with_wrong_credentials_with_params(const char } } + } +static void authenticated_register_with_wrong_credentials_with_params(const char* user_agent) { + LinphoneCoreManager *mgr = linphone_core_manager_new(NULL); + authenticated_register_with_wrong_credentials_with_params_base(user_agent,mgr); linphone_core_manager_destroy(mgr); } static void authenticated_register_with_wrong_credentials() { authenticated_register_with_wrong_credentials_with_params(NULL); } +static void authenticated_register_with_wrong_credentials_2() { + LinphoneCoreManager *mgr = linphone_core_manager_new(NULL); + stats* counters = get_stats(mgr->lc); + int current_in_progress; + LinphoneProxyConfig* proxy; + + authenticated_register_with_wrong_credentials_with_params_base(NULL,mgr); + + linphone_core_get_default_proxy(mgr->lc,&proxy); + /*Make sure registration attempts are stopped*/ + linphone_proxy_config_edit(proxy); + linphone_proxy_config_enable_register(proxy,FALSE); + linphone_proxy_config_done(proxy); + current_in_progress=counters->number_of_LinphoneRegistrationProgress; + CU_ASSERT_FALSE(wait_for(mgr->lc,mgr->lc,&counters->number_of_LinphoneRegistrationProgress,current_in_progress+1)); + + linphone_core_manager_destroy(mgr); +} static void authenticated_register_with_wrong_credentials_without_403() { authenticated_register_with_wrong_credentials_with_params("tester-no-403"); } @@ -655,6 +674,7 @@ test_t register_tests[] = { { "Ha1 authenticated register", ha1_authenticated_register }, { "Digest auth without initial credentials", authenticated_register_with_no_initial_credentials }, { "Digest auth with wrong credentials", authenticated_register_with_wrong_credentials }, + { "Digest auth with wrong credentials, check if registration attempts are stopped", authenticated_register_with_wrong_credentials_2 }, { "Digest auth with wrong credentials without 403", authenticated_register_with_wrong_credentials_without_403}, { "Authenticated register with wrong late credentials", authenticated_register_with_wrong_late_credentials}, { "Authenticated register with late credentials", authenticated_register_with_late_credentials }, From 2ae4719376dad8ae54106cfd2ab6357d1b110993 Mon Sep 17 00:00:00 2001 From: Jehan Monnier Date: Mon, 14 Apr 2014 10:38:03 +0200 Subject: [PATCH 19/23] change some registration test to wait until registration cleared to arive --- mediastreamer2 | 2 +- tester/register_tester.c | 8 +++++++- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/mediastreamer2 b/mediastreamer2 index b76e3dde1..34ced9269 160000 --- a/mediastreamer2 +++ b/mediastreamer2 @@ -1 +1 @@ -Subproject commit b76e3dde111af0d24be4ac5f1d4f633361e654c1 +Subproject commit 34ced9269b1e8f8272b25f627db37dc12ce05317 diff --git a/tester/register_tester.c b/tester/register_tester.c index a0d63e278..0798bd61f 100644 --- a/tester/register_tester.c +++ b/tester/register_tester.c @@ -567,11 +567,17 @@ static void io_recv_error_without_active_register(){ for (proxys=ms_list_copy(linphone_core_get_proxy_config_list(lc));proxys!=NULL;proxys=proxys->next) { LinphoneProxyConfig* proxy_cfg=(LinphoneProxyConfig*)proxys->data; linphone_proxy_config_edit(proxy_cfg); + } + ms_list_free(proxys); + /*wait for unregistrations*/ + CU_ASSERT_TRUE(wait_for(lc,lc,&counters->number_of_LinphoneRegistrationCleared,register_ok /*because 1 udp*/)); + + for (proxys=ms_list_copy(linphone_core_get_proxy_config_list(lc));proxys!=NULL;proxys=proxys->next) { + LinphoneProxyConfig* proxy_cfg=(LinphoneProxyConfig*)proxys->data; linphone_proxy_config_enable_register(proxy_cfg,FALSE); linphone_proxy_config_done(proxy_cfg); } ms_list_free(proxys); - CU_ASSERT_TRUE(wait_for(lc,lc,&counters->number_of_LinphoneRegistrationCleared,register_ok /*because 1 udp*/)); sal_set_recv_error(lc->sal, 0); From 28f4a815f6be83516748a2af610d69629f0ab593 Mon Sep 17 00:00:00 2001 From: Simon Morlat Date: Mon, 14 Apr 2014 15:25:28 +0200 Subject: [PATCH 20/23] prevent concurrent registers using linphone_core_refresh_registers() being called multiple times. --- coreapi/proxy.c | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/coreapi/proxy.c b/coreapi/proxy.c index a526f337b..466c77b93 100644 --- a/coreapi/proxy.c +++ b/coreapi/proxy.c @@ -365,7 +365,7 @@ static void linphone_proxy_config_register(LinphoneProxyConfig *obj){ * This is useful if for example you resuming from suspend, thus IP address may have changed. **/ void linphone_proxy_config_refresh_register(LinphoneProxyConfig *obj){ - if (obj->reg_sendregister && obj->op){ + if (obj->reg_sendregister && obj->op && obj->state!=LinphoneRegistrationProgress){ if (sal_register_refresh(obj->op,obj->expires) == 0) { linphone_proxy_config_set_state(obj,LinphoneRegistrationProgress, "Refresh registration"); } @@ -1326,15 +1326,16 @@ void * linphone_proxy_config_get_user_data(LinphoneProxyConfig *cr) { void linphone_proxy_config_set_state(LinphoneProxyConfig *cfg, LinphoneRegistrationState state, const char *message){ LinphoneCore *lc=cfg->lc; bool_t update_friends=FALSE; - if (linphone_core_should_subscribe_friends_only_when_registered(lc)){ - update_friends=(state==LinphoneRegistrationOk && cfg->state!=LinphoneRegistrationOk) - || (state!=LinphoneRegistrationOk && cfg->state==LinphoneRegistrationOk); - } - ms_message("Proxy config [%p] for identity [%s] moving from state [%s] to [%s]" , cfg, + + if (cfg->state!=state || state==LinphoneRegistrationOk) { /*allow multiple notification of LinphoneRegistrationOk for refreshing*/ + ms_message("Proxy config [%p] for identity [%s] moving from state [%s] to [%s]" , cfg, linphone_proxy_config_get_identity(cfg), linphone_registration_state_to_string(cfg->state), linphone_registration_state_to_string(state)); - if (cfg->state!=state || state==LinphoneRegistrationOk) { /*allow multiple notification of LinphoneRegistrationOk for refreshing*/ + if (linphone_core_should_subscribe_friends_only_when_registered(lc)){ + update_friends=(state==LinphoneRegistrationOk && cfg->state!=LinphoneRegistrationOk) + || (state!=LinphoneRegistrationOk && cfg->state==LinphoneRegistrationOk); + } cfg->state=state; if (update_friends){ From 80c1f93b9575c9871ea9f7e78a90680dfc22f536 Mon Sep 17 00:00:00 2001 From: Simon Morlat Date: Mon, 14 Apr 2014 16:10:56 +0200 Subject: [PATCH 21/23] fix crash with RTCP xr --- coreapi/linphonecall.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/coreapi/linphonecall.c b/coreapi/linphonecall.c index cf69902c7..e3127a3e6 100644 --- a/coreapi/linphonecall.c +++ b/coreapi/linphonecall.c @@ -2222,6 +2222,11 @@ void linphone_call_stop_video_stream(LinphoneCall *call) { #endif } +static void unset_rtp_profile(LinphoneCall *call, int i){ + if (call->sessions[i].rtp_session) + rtp_session_set_profile(call->sessions[i].rtp_session,&av_profile); +} + void linphone_call_stop_media_streams(LinphoneCall *call){ if (call->audiostream || call->videostream) { linphone_call_stop_audio_stream(call); @@ -2235,10 +2240,12 @@ void linphone_call_stop_media_streams(LinphoneCall *call){ if (call->audio_profile){ rtp_profile_destroy(call->audio_profile); call->audio_profile=NULL; + unset_rtp_profile(call,0); } if (call->video_profile){ rtp_profile_destroy(call->video_profile); call->video_profile=NULL; + unset_rtp_profile(call,1); } } From a32c864292e147b769bc6f2b19735593cf84f41e Mon Sep 17 00:00:00 2001 From: Jehan Monnier Date: Mon, 14 Apr 2014 16:28:57 +0200 Subject: [PATCH 22/23] fix invalid read in gtk app call log management --- gtk/calllogs.c | 8 +++++--- tester/call_tester.c | 2 +- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/gtk/calllogs.c b/gtk/calllogs.c index 2f7e8f769..7a4840aa8 100644 --- a/gtk/calllogs.c +++ b/gtk/calllogs.c @@ -293,7 +293,10 @@ void linphone_gtk_call_log_update(GtkWidget *w){ #endif lf=linphone_core_get_friend_by_address(linphone_gtk_get_core(),addr); if(lf != NULL){ - display=linphone_address_get_display_name(linphone_friend_get_address(lf)); + if ((display=linphone_address_get_display_name(linphone_friend_get_address(lf)))) { + /*update display name from friend*/ + linphone_address_set_display_name(la,display); + } } else { display=linphone_address_get_display_name(la); } @@ -302,9 +305,8 @@ void linphone_gtk_call_log_update(GtkWidget *w){ if (display==NULL){ display=linphone_address_get_domain (la); } - } else { - linphone_address_set_display_name(la,display); } + if (linphone_call_log_get_quality(cl)!=-1){ snprintf(quality,sizeof(quality),"%.1f",linphone_call_log_get_quality(cl)); }else snprintf(quality,sizeof(quality)-1,"%s",_("n/a")); diff --git a/tester/call_tester.c b/tester/call_tester.c index 2a18b30d2..c655e4b88 100644 --- a/tester/call_tester.c +++ b/tester/call_tester.c @@ -355,7 +355,7 @@ static void call_with_dns_time_out(void) { linphone_core_set_sip_transports(marie->lc,&transport); linphone_core_iterate(marie->lc); sal_set_dns_timeout(marie->lc->sal,0); - linphone_core_invite(marie->lc,"sip:toto@toto.com"); + linphone_core_invite(marie->lc,"\"t\x8et\x8e\" sip:toto@toto.com"); /*just to use non ascii values*/ for(i=0;i<10;i++){ ms_usleep(200000); linphone_core_iterate(marie->lc); From e5d8ff817a5de726d75a6a69791d6a9603fe6460 Mon Sep 17 00:00:00 2001 From: Simon Morlat Date: Mon, 14 Apr 2014 19:13:13 +0200 Subject: [PATCH 23/23] update ms2 --- mediastreamer2 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mediastreamer2 b/mediastreamer2 index 34ced9269..13d0cee33 160000 --- a/mediastreamer2 +++ b/mediastreamer2 @@ -1 +1 @@ -Subproject commit 34ced9269b1e8f8272b25f627db37dc12ce05317 +Subproject commit 13d0cee33672690daca1a7252c9f3a7022da95bd