From 523ad425a5b29b1ae0b0a85a2de2d1147eb6d2df Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fran=C3=A7ois=20Grisez?= Date: Wed, 13 Jan 2016 11:52:30 +0100 Subject: [PATCH 01/10] Add a class storing conference parameters --- CMakeLists.txt | 1 + coreapi/conference.cc | 88 ++++++++++++++++++++++++++++++------ coreapi/conference.h | 84 ++++++++++++++++++++-------------- coreapi/conference_private.h | 74 ++++++++++++++++++++++++++++++ coreapi/linphonecall.c | 1 + coreapi/linphonecore.c | 23 +++++++--- coreapi/linphonecore.h | 62 ++++++++++++------------- tester/multi_call_tester.c | 4 +- 8 files changed, 249 insertions(+), 88 deletions(-) create mode 100644 coreapi/conference_private.h diff --git a/CMakeLists.txt b/CMakeLists.txt index f4f45d39b..7e86c8270 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -216,6 +216,7 @@ endif() set(STRICT_OPTIONS_CPP ) set(STRICT_OPTIONS_C ) +set(STRICT_OPTIONS_CXX "-std=c++11") set(STRICT_OPTIONS_OBJC ) if(NOT MSVC) list(APPEND STRICT_OPTIONS_CPP "-Wall" "-Wuninitialized" "-Wno-error=deprecated-declarations") diff --git a/coreapi/conference.cc b/coreapi/conference.cc index 9defb80d3..72fe4ff4e 100644 --- a/coreapi/conference.cc +++ b/coreapi/conference.cc @@ -24,7 +24,7 @@ */ #include "private.h" -#include "conference.h" +#include "conference_private.h" #include #include #include @@ -49,9 +49,21 @@ private: class Conference { public: - Conference(LinphoneCore *core); + class Params { + public: + Params(const LinphoneCore *core = NULL); + void enableVideo(bool enable) {m_enableVideo = enable;} + bool videoRequested() const {return m_enableVideo;} + + private: + bool m_enableVideo; + }; + + Conference(LinphoneCore *core, const Params *params = NULL); virtual ~Conference() {}; + const Params &getCurrentParams() const {return m_currentParams;} + virtual int addParticipant(LinphoneCall *call) = 0; virtual int removeParticipant(LinphoneCall *call) = 0; virtual int removeParticipant(const LinphoneAddress *uri) = 0; @@ -83,11 +95,12 @@ protected: AudioStream *m_localParticipantStream; bool m_isMuted; std::list m_participants; + Params m_currentParams; }; class LocalConference: public Conference { public: - LocalConference(LinphoneCore *core); + LocalConference(LinphoneCore *core, const Params *params = NULL); virtual ~LocalConference(); virtual int addParticipant(LinphoneCall *call); @@ -103,9 +116,9 @@ public: virtual int startRecording(const char *path); virtual int stopRecording(); - void onCallStreamStarting(LinphoneCall *call, bool isPausedByRemote); - void onCallStreamStopping(LinphoneCall *call); - void onCallTerminating(LinphoneCall *call); + virtual void onCallStreamStarting(LinphoneCall *call, bool isPausedByRemote); + virtual void onCallStreamStopping(LinphoneCall *call); + virtual void onCallTerminating(LinphoneCall *call); private: void addLocalEndpoint(); @@ -124,7 +137,7 @@ private: class RemoteConference: public Conference { public: - RemoteConference(LinphoneCore *core); + RemoteConference(LinphoneCore *core, const Params *params = NULL); virtual ~RemoteConference(); virtual int addParticipant(LinphoneCall *call); @@ -190,10 +203,20 @@ bool Participant::operator==(const Participant &src) const { -Conference::Conference(LinphoneCore *core) : +Conference::Params::Params(const LinphoneCore *core): m_enableVideo(false) { + if(core) { + const LinphoneVideoPolicy *policy = linphone_core_get_video_policy(core); + if(policy->automatically_initiate) m_enableVideo = true; + } +} + + + +Conference::Conference(LinphoneCore *core, const Conference::Params *params): m_core(core), m_localParticipantStream(NULL), m_isMuted(false) { + if(params) m_currentParams = *params; } int Conference::addParticipant(LinphoneCall *call) { @@ -255,15 +278,16 @@ Participant *Conference::find_participant(const LinphoneAddress *uri) { -LocalConference::LocalConference(LinphoneCore *core): Conference(core), +LocalConference::LocalConference(LinphoneCore *core, const Conference::Params *params): + Conference(core, params), m_conf(NULL), m_localEndpoint(NULL), m_recordEndpoint(NULL), m_localDummyProfile(NULL), m_terminated(FALSE) { - MSAudioConferenceParams params; - params.samplerate = lp_config_get_int(m_core->config, "sound","conference_rate",16000); - m_conf=ms_audio_conference_new(¶ms); + MSAudioConferenceParams ms_conf_params; + ms_conf_params.samplerate = lp_config_get_int(m_core->config, "sound","conference_rate",16000); + m_conf=ms_audio_conference_new(&ms_conf_params); } LocalConference::~LocalConference() { @@ -548,8 +572,8 @@ void LocalConference::onCallTerminating(LinphoneCall *call) { -RemoteConference::RemoteConference(LinphoneCore *core): - Conference(core), +RemoteConference::RemoteConference(LinphoneCore *core, const Conference::Params *params): + Conference(core, params), m_focusAddr(NULL), m_focusContact(NULL), m_focusCall(NULL), @@ -573,6 +597,7 @@ RemoteConference::~RemoteConference() { int RemoteConference::addParticipant(LinphoneCall *call) { LinphoneAddress *addr; + LinphoneCallParams *params; switch(m_state) { case NotConnectedToFocus: @@ -580,12 +605,15 @@ int RemoteConference::addParticipant(LinphoneCall *call) { ms_message("Calling the conference focus (%s)", m_focusAddr); addr = linphone_address_new(m_focusAddr); if(addr) { - m_focusCall = linphone_call_ref(linphone_core_invite_address(m_core, addr)); + params = linphone_core_create_call_params(m_core, NULL); + linphone_call_params_enable_video(params, m_currentParams.videoRequested()); + m_focusCall = linphone_call_ref(linphone_core_invite_address_with_params(m_core, addr, params)); m_localParticipantStream = m_focusCall->audiostream; m_pendingCalls = ms_list_append(m_pendingCalls, linphone_call_ref(call)); m_state = ConnectingToFocus; linphone_address_unref(addr); call->conf_ref = (LinphoneConference *)this; + linphone_call_params_unref(params); return 0; } else return -1; @@ -784,14 +812,44 @@ void RemoteConference::transferStateChanged(LinphoneCore *lc, LinphoneCall *tran +LinphoneConferenceParams *linphone_conference_params_new(const LinphoneCore *core) { + return (LinphoneConferenceParams *)new Conference::Params(core); +} + +void linphone_conference_params_free(LinphoneConferenceParams *params) { + delete (Conference::Params *)params; +} + +LinphoneConferenceParams *linphone_conference_params_clone(const LinphoneConferenceParams *params) { + return (LinphoneConferenceParams *)new Conference::Params(*(Conference::Params *)params); +} + +void linphone_conference_params_enable_video(LinphoneConferenceParams *params, bool_t enable) { + ((Conference::Params *)params)->enableVideo(enable); +} + +bool_t linphone_conference_params_video_requested(const LinphoneConferenceParams *params) { + return ((Conference::Params *)params)->videoRequested(); +} + + + LinphoneConference *linphone_local_conference_new(LinphoneCore *core) { return (LinphoneConference *) new LocalConference(core); } +LinphoneConference *linphone_local_conference_new_with_params(LinphoneCore *core, const LinphoneConferenceParams *params) { + return (LinphoneConference *) new LocalConference(core, (Conference::Params *)params); +} + LinphoneConference *linphone_remote_conference_new(LinphoneCore *core) { return (LinphoneConference *) new RemoteConference(core); } +LinphoneConference *linphone_remote_conference_new_with_params(LinphoneCore *core, const LinphoneConferenceParams *params) { + return (LinphoneConference *) new RemoteConference(core, (Conference::Params *)params); +} + void linphone_conference_free(LinphoneConference *obj) { delete (Conference *)obj; } diff --git a/coreapi/conference.h b/coreapi/conference.h index 6192850a3..90da4b0b7 100644 --- a/coreapi/conference.h +++ b/coreapi/conference.h @@ -1,5 +1,5 @@ /******************************************************************************* - * conference.cc + * conference.h * * Thu Nov 26, 2015 * Copyright 2015 Belledonne Communications @@ -25,49 +25,67 @@ #ifndef CONFERENCE_H #define CONFERENCE_H + +#include "linphonecore.h" #ifdef __cplusplus extern "C" { #endif - -#include "linphonecore.h" -//typedef struct _LinphoneConference LinphoneConference; +/** + * @addtogroup call_control + * @{ + */ -typedef enum { - LinphoneConferenceClassLocal, - LinphoneConferenceClassRemote -} LinphoneConferenceClass; +/** + * Create a #LinphoneConferenceParams with default parameters set. + * @param core #LinphoneCore to use to find out the default parameters. Can be NULL. + * @return A freshly allocated #LinphoneConferenceParams + */ +LINPHONE_PUBLIC LinphoneConferenceParams *linphone_conference_params_new(const LinphoneCore *core); +/** + * Free a #LinphoneConferenceParams + * @param params #LinphoneConferenceParams to free + */ +LINPHONE_PUBLIC void linphone_conference_params_free(LinphoneConferenceParams *params); +/** + * Clone a #LinphoneConferenceParams + * @param params The #LinphoneConfrenceParams to clone + * @return An allocated #LinphoneConferenceParams with the same parameters than params + */ +LINPHONE_PUBLIC LinphoneConferenceParams *linphone_conference_params_clone(const LinphoneConferenceParams *params); +/** + * Enable video when starting a conference + * @param params A #LinphoneConnferenceParams + * @param enable If true, video will be enabled during conference + */ +LINPHONE_PUBLIC void linphone_conference_params_enable_video(LinphoneConferenceParams *params, bool_t enable); +/** + * Check whether video will be enable at conference starting + * @return if true, the video will be enable at conference starting + */ +LINPHONE_PUBLIC bool_t linphone_conference_params_video_requested(const LinphoneConferenceParams *params); -LinphoneConference *linphone_local_conference_new(LinphoneCore *core); -LinphoneConference *linphone_remote_conference_new(LinphoneCore *core); -void linphone_conference_free(LinphoneConference *obj); -int linphone_conference_add_participant(LinphoneConference *obj, LinphoneCall *call); -int linphone_conference_remove_participant_with_call(LinphoneConference *obj, LinphoneCall *call); +/** + * Remove a participant from a conference + * @param obj A #LinphoneConference + * @param uri SIP URI of the participant to remove + * @return 0 if succeeded, -1 if failed + */ LINPHONE_PUBLIC int linphone_conference_remove_participant(LinphoneConference *obj, const LinphoneAddress *uri); -int linphone_conference_terminate(LinphoneConference *obj); - -int linphone_conference_enter(LinphoneConference *obj); -int linphone_conference_leave(LinphoneConference *obj); -LINPHONE_PUBLIC bool_t linphone_conference_is_in(const LinphoneConference *obj); -AudioStream *linphone_conference_get_audio_stream(const LinphoneConference *obj); - -int linphone_conference_mute_microphone(LinphoneConference *obj, bool_t val); -bool_t linphone_conference_microphone_is_muted(const LinphoneConference *obj); -float linphone_conference_get_input_volume(const LinphoneConference *obj); - -LINPHONE_PUBLIC int linphone_conference_get_size(const LinphoneConference *obj); +/** + * Get URIs of all participants of one conference + * The returned MSList contains URIs of all participant. That list must be + * freed after use and each URI must be unref with linphone_address_unref() + * @param obj A #LinphoneConference + * @return \mslist{LinphoneAddress} + */ LINPHONE_PUBLIC MSList *linphone_conference_get_participants(const LinphoneConference *obj); -int linphone_conference_start_recording(LinphoneConference *obj, const char *path); -int linphone_conference_stop_recording(LinphoneConference *obj); - -void linphone_conference_on_call_stream_starting(LinphoneConference *obj, LinphoneCall *call, bool_t is_paused_by_remote); -void linphone_conference_on_call_stream_stopping(LinphoneConference *obj, LinphoneCall *call); -void linphone_conference_on_call_terminating(LinphoneConference *obj, LinphoneCall *call); - -bool_t linphone_conference_check_class(LinphoneConference *obj, LinphoneConferenceClass _class); +/** + * @} + */ #ifdef __cplusplus } diff --git a/coreapi/conference_private.h b/coreapi/conference_private.h new file mode 100644 index 000000000..3147cfd9a --- /dev/null +++ b/coreapi/conference_private.h @@ -0,0 +1,74 @@ +/******************************************************************************* + * conference_private.h + * + * Tue Jan 12, 2015 + * Copyright 2015 Belledonne Communications + * Author: Linphone's team + * Email info@belledonne-communications.com + ******************************************************************************/ + +/* + * 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. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + */ +#ifndef CONFERENCE_PRIVATE_H +#define CONFERENCE_PRIVATE_H + +#include "linphonecore.h" +#include "conference.h" + +#ifdef __cplusplus +extern "C" { +#endif + +typedef enum { + LinphoneConferenceClassLocal, + LinphoneConferenceClassRemote +} LinphoneConferenceClass; + +LinphoneConference *linphone_local_conference_new(LinphoneCore *core); +LinphoneConference *linphone_local_conference_new_with_params(LinphoneCore *core, const LinphoneConferenceParams *params); +LinphoneConference *linphone_remote_conference_new(LinphoneCore *core); +LinphoneConference *linphone_remote_conference_new_with_params(LinphoneCore *core, const LinphoneConferenceParams *params); +void linphone_conference_free(LinphoneConference *obj); + +int linphone_conference_add_participant(LinphoneConference *obj, LinphoneCall *call); +int linphone_conference_remove_participant_with_call(LinphoneConference *obj, LinphoneCall *call); +int linphone_conference_terminate(LinphoneConference *obj); +int linphone_conference_get_size(const LinphoneConference *obj); + +int linphone_conference_enter(LinphoneConference *obj); +int linphone_conference_leave(LinphoneConference *obj); +bool_t linphone_conference_is_in(const LinphoneConference *obj); + +AudioStream *linphone_conference_get_audio_stream(const LinphoneConference *obj); + +int linphone_conference_mute_microphone(LinphoneConference *obj, bool_t val); +bool_t linphone_conference_microphone_is_muted(const LinphoneConference *obj); +float linphone_conference_get_input_volume(const LinphoneConference *obj); + +int linphone_conference_start_recording(LinphoneConference *obj, const char *path); +int linphone_conference_stop_recording(LinphoneConference *obj); + +void linphone_conference_on_call_stream_starting(LinphoneConference *obj, LinphoneCall *call, bool_t is_paused_by_remote); +void linphone_conference_on_call_stream_stopping(LinphoneConference *obj, LinphoneCall *call); +void linphone_conference_on_call_terminating(LinphoneConference *obj, LinphoneCall *call); + +LINPHONE_PUBLIC bool_t linphone_conference_check_class(LinphoneConference *obj, LinphoneConferenceClass _class); + +#ifdef __cplusplus +} +#endif + +#endif //CONFERENCE_PRIVATE_H diff --git a/coreapi/linphonecall.c b/coreapi/linphonecall.c index 1eff5f2da..0d7635b8c 100644 --- a/coreapi/linphonecall.c +++ b/coreapi/linphonecall.c @@ -25,6 +25,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. #include "sipsetup.h" #include "lpconfig.h" #include "private.h" +#include "conference_private.h" #include #include #include diff --git a/coreapi/linphonecore.c b/coreapi/linphonecore.c index 086a55350..18cc6d2fe 100644 --- a/coreapi/linphonecore.c +++ b/coreapi/linphonecore.c @@ -24,6 +24,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. #include "private.h" #include "quality_reporting.h" #include "lime.h" +#include "conference_private.h" #include #include @@ -5350,7 +5351,7 @@ void linphone_core_set_video_policy(LinphoneCore *lc, const LinphoneVideoPolicy * See linphone_core_set_video_policy() for more details. * @ingroup media_parameters **/ -const LinphoneVideoPolicy *linphone_core_get_video_policy(LinphoneCore *lc){ +const LinphoneVideoPolicy *linphone_core_get_video_policy(const LinphoneCore *lc){ return &lc->video_policy; } @@ -7433,20 +7434,30 @@ LinphoneRingtonePlayer *linphone_core_get_ringtoneplayer(LinphoneCore *lc) { return lc->ringtoneplayer; } -int linphone_core_add_to_conference(LinphoneCore *lc, LinphoneCall *call) { +LinphoneConference *linphone_core_create_conference_with_params(LinphoneCore *lc, const LinphoneConferenceParams *params) { const char *conf_method_name; if(lc->conf_ctx == NULL) { conf_method_name = lp_config_get_string(lc->config, "misc", "conference_type", "local"); if(strcasecmp(conf_method_name, "local") == 0) { - lc->conf_ctx = linphone_local_conference_new(lc); + lc->conf_ctx = linphone_local_conference_new_with_params(lc, params); } else if(strcasecmp(conf_method_name, "remote") == 0) { - lc->conf_ctx = linphone_remote_conference_new(lc); + lc->conf_ctx = linphone_remote_conference_new_with_params(lc, params); } else { ms_error("'%s' is not a valid conference method", conf_method_name); - return -1; + return NULL; } + } else { + ms_error("Could not create a conference: a conference instance already exists"); + return NULL; } - return linphone_conference_add_participant(lc->conf_ctx, call); + return lc->conf_ctx; +} + +int linphone_core_add_to_conference(LinphoneCore *lc, LinphoneCall *call) { + LinphoneConference *conference = linphone_core_get_conference(lc); + if(conference == NULL) conference = linphone_core_create_conference_with_params(lc, NULL); + if(conference) return linphone_conference_add_participant(lc->conf_ctx, call); + else return -1; } int linphone_core_add_all_to_conference(LinphoneCore *lc) { diff --git a/coreapi/linphonecore.h b/coreapi/linphonecore.h index 3c334be22..07ce58813 100644 --- a/coreapi/linphonecore.h +++ b/coreapi/linphonecore.h @@ -66,6 +66,18 @@ struct _LinphoneInfoMessage; */ typedef struct _LinphoneCore LinphoneCore; +/** + * Internal object of LinphoneCore representing a conference + * @ingroup call_control + */ +typedef struct _LinphoneConference LinphoneConference; + +/** + * Parameters for initialization of conferences + * @ingroup call_control + */ +typedef struct _LinphoneCorferenceParams LinphoneConferenceParams; + /** * Disable a sip transport @@ -140,12 +152,6 @@ enum _LinphoneStreamType { **/ typedef enum _LinphoneStreamType LinphoneStreamType; -/** - * Internal object of LinphoneCore representing a conference - * @ingroup call_control - */ -typedef struct _LinphoneConference LinphoneConference; - /** * Function returning a human readable value for LinphoneStreamType. * @ingroup initializing @@ -3443,7 +3449,7 @@ LINPHONE_PUBLIC bool_t linphone_core_video_capture_enabled(LinphoneCore *lc); LINPHONE_PUBLIC bool_t linphone_core_video_display_enabled(LinphoneCore *lc); LINPHONE_PUBLIC void linphone_core_set_video_policy(LinphoneCore *lc, const LinphoneVideoPolicy *policy); -LINPHONE_PUBLIC const LinphoneVideoPolicy *linphone_core_get_video_policy(LinphoneCore *lc); +LINPHONE_PUBLIC const LinphoneVideoPolicy *linphone_core_get_video_policy(const LinphoneCore *lc); typedef struct MSVideoSizeDef{ MSVideoSize vsize; @@ -3828,6 +3834,14 @@ LINPHONE_PUBLIC LinphoneCall* linphone_core_find_call_from_uri(const LinphoneCor * @{ */ +/** + * Create a conference + * @param lc The #LinphoneCore instance where the conference will be created inside. + * @param params Parameters of the conference. See #LinphoneConferenceParms. + * @return A pointer on the freshly created conference. That object will be automatically + * freed by the core after calling linphone_core_terminate_conference(). + */ +LINPHONE_PUBLIC LinphoneConference *linphone_core_create_conference_with_params(LinphoneCore *lc, const LinphoneConferenceParams *params); /** * Add a participant to the conference. If no conference is going on * a new internal conference context is created and the participant is @@ -3836,7 +3850,7 @@ LINPHONE_PUBLIC LinphoneCall* linphone_core_find_call_from_uri(const LinphoneCor * @param call The current call with the participant to add * @return 0 if succeeded. Negative number if failed */ -LINPHONE_PUBLIC int linphone_core_add_to_conference(LinphoneCore *lc, LinphoneCall *call); +LINPHONE_PUBLIC int linphone_core_add_to_conference(LinphoneCore *lc, LinphoneCall *call); /** * Add all current calls into the conference. If no conference is running * a new internal conference context is created and all current calls @@ -3844,7 +3858,7 @@ LINPHONE_PUBLIC int linphone_core_add_to_conference(LinphoneCore *lc, LinphoneCa * @param lc #LinphoneCore * @return 0 if succeeded. Negative number if failed */ -LINPHONE_PUBLIC int linphone_core_add_all_to_conference(LinphoneCore *lc); +LINPHONE_PUBLIC int linphone_core_add_all_to_conference(LinphoneCore *lc); /** * Remove a call from the conference. * @param lc the linphone core @@ -3860,7 +3874,7 @@ LINPHONE_PUBLIC int linphone_core_add_all_to_conference(LinphoneCore *lc); * * @return 0 if successful, -1 otherwise. **/ - LINPHONE_PUBLIC int linphone_core_remove_from_conference(LinphoneCore *lc, LinphoneCall *call); + LINPHONE_PUBLIC int linphone_core_remove_from_conference(LinphoneCore *lc, LinphoneCall *call); /** * Indicates whether the local participant is part of a conference. * @warning That function automatically fails in the case of conferences using a @@ -3869,25 +3883,25 @@ LINPHONE_PUBLIC int linphone_core_add_all_to_conference(LinphoneCore *lc); * @param lc the linphone core * @return TRUE if the local participant is in a conference, FALSE otherwise. */ -LINPHONE_PUBLIC bool_t linphone_core_is_in_conference(const LinphoneCore *lc); +LINPHONE_PUBLIC bool_t linphone_core_is_in_conference(const LinphoneCore *lc); /** * Join the local participant to the running conference * @param lc #LinphoneCore * @return 0 if succeeded. Negative number if failed */ -LINPHONE_PUBLIC int linphone_core_enter_conference(LinphoneCore *lc); +LINPHONE_PUBLIC int linphone_core_enter_conference(LinphoneCore *lc); /** * Make the local participant leave the running conference * @param lc #LinphoneCore * @return 0 if succeeded. Negative number if failed */ -LINPHONE_PUBLIC int linphone_core_leave_conference(LinphoneCore *lc); +LINPHONE_PUBLIC int linphone_core_leave_conference(LinphoneCore *lc); /** * Get the set input volume of the local participant * @param lc #LinphoneCore * @return A value inside [0.0 ; 1.0] */ -LINPHONE_PUBLIC float linphone_core_get_conference_local_input_volume(LinphoneCore *lc); +LINPHONE_PUBLIC float linphone_core_get_conference_local_input_volume(LinphoneCore *lc); /** * Terminate the running conference. If it is a local conference, all calls * inside it will become back separate calls and will be put in #LinphoneCallPaused state. @@ -3896,14 +3910,14 @@ LINPHONE_PUBLIC float linphone_core_get_conference_local_input_volume(LinphoneCo * @param lc #LinphoneCore * @return 0 if succeeded. Negative number if failed */ -LINPHONE_PUBLIC int linphone_core_terminate_conference(LinphoneCore *lc); +LINPHONE_PUBLIC int linphone_core_terminate_conference(LinphoneCore *lc); /** * Get the number of participant in the running conference. The local * participant is included in the count only if it is in the conference. * @param lc #LinphoneCore * @return The number of participant */ -LINPHONE_PUBLIC int linphone_core_get_conference_size(LinphoneCore *lc); +LINPHONE_PUBLIC int linphone_core_get_conference_size(LinphoneCore *lc); /** * Start recording the running conference * @param lc #LinphoneCore @@ -3923,21 +3937,7 @@ LINPHONE_PUBLIC int linphone_core_stop_conference_recording(LinphoneCore *lc); * @return A pointer on #LinphoneConference or NULL if no conference are going on */ LINPHONE_PUBLIC LinphoneConference *linphone_core_get_conference(LinphoneCore *lc); -/** - * Get URIs of all participants of one conference - * The returned MSList contains URIs of all participant. That list must be - * freed after use and each URI must be unref with linphone_address_unref() - * @param obj A #LinphoneConference - * @return \mslist{LinphoneAddress} - */ -LINPHONE_PUBLIC MSList *linphone_conference_get_participants(const LinphoneConference *obj); -/** - * Remove a participant from a conference - * @param obj A #LinphoneConference - * @param uri SIP URI of the participant to remove - * @return 0 if succeeded, -1 if failed - */ -LINPHONE_PUBLIC int linphone_conference_remove_participant(LinphoneConference *obj, const LinphoneAddress *uri); + /** * @} diff --git a/tester/multi_call_tester.c b/tester/multi_call_tester.c index bd4fc2d9d..8a6d9aff6 100644 --- a/tester/multi_call_tester.c +++ b/tester/multi_call_tester.c @@ -262,9 +262,7 @@ static void simple_conference_base(LinphoneCoreManager* marie, LinphoneCoreManag BC_ASSERT_PTR_NOT_NULL(conference = linphone_core_get_conference(marie->lc)); if(conference) { MSList *participants = linphone_conference_get_participants(conference); - BC_ASSERT_EQUAL(linphone_conference_get_size(conference), linphone_core_get_conference_size(marie->lc), int, "%d"); - BC_ASSERT_EQUAL(linphone_conference_get_size(conference), ms_list_size(participants)+(linphone_conference_is_in(conference)?1:0), int, "%d"); - BC_ASSERT_TRUE(linphone_conference_is_in(conference)); + BC_ASSERT_EQUAL(ms_list_size(participants), 2, int, "%d"); ms_list_free_with_data(participants, (void(*)(void *))linphone_address_destroy); } From 9eced02408170884cb847938ea4488c49e7d40cb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fran=C3=A7ois=20Grisez?= Date: Wed, 13 Jan 2016 15:07:08 +0100 Subject: [PATCH 02/10] Wraps LinphoneConferenceParams into Java --- coreapi/linphonecore_jni.cc | 41 +++++++++++++++ .../core/LinphoneConferenceParams.java | 25 +++++++++ .../org/linphone/core/LinphoneCore.java | 21 +++++--- .../core/LinphoneConferenceParamsImpl.java | 51 +++++++++++++++++++ .../org/linphone/core/LinphoneCoreImpl.java | 24 +++++---- 5 files changed, 144 insertions(+), 18 deletions(-) create mode 100644 java/common/org/linphone/core/LinphoneConferenceParams.java create mode 100644 java/impl/org/linphone/core/LinphoneConferenceParamsImpl.java diff --git a/coreapi/linphonecore_jni.cc b/coreapi/linphonecore_jni.cc index 0bc48f880..38e7fa8a2 100644 --- a/coreapi/linphonecore_jni.cc +++ b/coreapi/linphonecore_jni.cc @@ -4315,6 +4315,21 @@ extern "C" jint Java_org_linphone_core_LinphoneCoreImpl_getConferenceSize(JNIEnv return (jint)linphone_core_get_conference_size((LinphoneCore *) pCore); } +extern "C" jobject Java_org_linphone_core_LinphoneCoreImpl_createConference(JNIEnv *env, jobject thiz, jlong corePtr, jobject jparams) { + jclass params_class = env->FindClass("org/linphone/core/LinphoneConferenceParamsImpl"); + jclass conference_class = env->FindClass("org/linphone/core/LinphoneConferenceImpl"); + jfieldID params_native_ptr_attr = env->GetFieldID(params_class, "nativePtr", "J"); + jmethodID conference_constructor = env->GetMethodID(conference_class, "", "(J)V"); + LinphoneConferenceParams *params = NULL; + LinphoneConference *conference; + jobject jconference; + + if(jparams) params = (LinphoneConferenceParams *)env->GetLongField(params_class, params_native_ptr_attr); + conference = linphone_core_create_conference_with_params((LinphoneCore *)corePtr, params); + if(conference) return env->NewObject(conference_class, conference_constructor, (jlong)conference); + else return NULL; +} + extern "C" jobject Java_org_linphone_core_LinphoneCoreImpl_getConference(JNIEnv *env, jobject thiz, jlong pCore) { jclass conference_class = env->FindClass("org/linphone/core/LinphoneConferenceImpl"); jmethodID conference_constructor = env->GetMethodID(conference_class, "", "(J)V"); @@ -6746,6 +6761,32 @@ JNIEXPORT jint JNICALL Java_org_linphone_core_LinphoneCoreImpl_getNortpTimeout(J +extern "C" jlong Java_org_linphone_core_LinphoneConferenceParamsImpl_createInstance(JNIEnv *env, jobject thiz, jobject jcore) { + jclass core_class = env->FindClass("org/linphone/core/LinphoneCoreImpl"); + jfieldID native_ptr_attr = env->GetFieldID(core_class, "nativePtr", "J"); + LinphoneCore *core = NULL; + if(jcore) core = (LinphoneCore *)env->GetLongField(jcore, native_ptr_attr); + return (jlong)linphone_conference_params_new(core); +} + +extern "C" jlong Java_org_linphone_core_LinphoneConferenceParamsImpl_copyInstance(JNIEnv *env, jobject thiz, jlong paramsPtr) { + return (jlong)linphone_conference_params_clone((LinphoneConferenceParams *)paramsPtr); +} + +extern "C" void Java_org_linphone_core_LinphoneConferenceParamsImpl_destroyInstance(JNIEnv *env, jobject thiz, jlong paramsPtr) { + linphone_conference_params_free((LinphoneConferenceParams *)paramsPtr); +} + +extern "C" void Java_org_linphone_core_LinphoneConferenceParamsImpl_enableVideo(JNIEnv *env, jobject thiz, jlong paramsPtr, jboolean enable) { + linphone_conference_params_enable_video((LinphoneConferenceParams *)paramsPtr, enable); +} + +extern "C" jboolean Java_org_linphone_core_LinphoneConferenceParamsImpl_isVideoEnabled(JNIEnv *env, jobject thiz, jlong paramsPtr) { + return linphone_conference_params_video_requested((LinphoneConferenceParams *)paramsPtr); +} + + + extern "C" jobjectArray Java_org_linphone_core_LinphoneConferenceImpl_getParticipants(JNIEnv *env, jobject thiz, jlong pconference) { MSList *participants, *it; jclass addr_class = env->FindClass("org/linphone/core/LinphoneAddressImpl"); diff --git a/java/common/org/linphone/core/LinphoneConferenceParams.java b/java/common/org/linphone/core/LinphoneConferenceParams.java new file mode 100644 index 000000000..ee67ddd9b --- /dev/null +++ b/java/common/org/linphone/core/LinphoneConferenceParams.java @@ -0,0 +1,25 @@ +/* +LinphoneConferenceParams.java +Copyright (C) 2015 Belledonne Communications, Grenoble, France + +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. + +You should have received a copy of the GNU General Public License +along with this program; if not, write to the Free Software +Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. +*/ + +package org.linphone.core; + +public interface LinphoneConferenceParams { + public void enableVideo(boolean enable); + public boolean isVideoRequested(); +} diff --git a/java/common/org/linphone/core/LinphoneCore.java b/java/common/org/linphone/core/LinphoneCore.java index ef5112622..4c5c8bc0f 100644 --- a/java/common/org/linphone/core/LinphoneCore.java +++ b/java/common/org/linphone/core/LinphoneCore.java @@ -1348,6 +1348,19 @@ public interface LinphoneCore { void setZrtpSecretsCache(String file); void enableEchoLimiter(boolean val); + /** + * Create a conference + * @param params Parameters of the conference. Can be null + * @return The new conference or null if the creation has failed + */ + LinphoneConference createConference(LinphoneConferenceParams params); + /** + * Return the value of the C pointer on the conference instance. + * + * That function can be used to test whether a conference is running. + * @return A positive value if a conference is running, 0 if not. + **/ + LinphoneConference getConference(); /** * Indicates whether the local user is part of the conference. **/ @@ -1368,7 +1381,6 @@ public interface LinphoneCore { * When the local participant is out of the conference, the remote participants can continue to talk normally. **/ void leaveConference(); - /** * Merge a call into a conference. * @@ -1417,13 +1429,6 @@ public interface LinphoneCore { * @returns the number of participants to the conference **/ int getConferenceSize(); - /** - * Return the value of the C pointer on the conference instance. - * - * That function can be used to test whether a conference is running. - * @return A positive value if a conference is running, 0 if not. - **/ - LinphoneConference getConference(); /** * Request recording of the conference into a supplied file path. diff --git a/java/impl/org/linphone/core/LinphoneConferenceParamsImpl.java b/java/impl/org/linphone/core/LinphoneConferenceParamsImpl.java new file mode 100644 index 000000000..7210dfa8f --- /dev/null +++ b/java/impl/org/linphone/core/LinphoneConferenceParamsImpl.java @@ -0,0 +1,51 @@ +/* +LinphoneConferenceParamsImpl.java +Copyright (C) 2015 Belledonne Communications, Grenoble, France + +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. + +You should have received a copy of the GNU General Public License +along with this program; if not, write to the Free Software +Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. +*/ + +package org.linphone.core; + +public class LinphoneConferenceParamsImpl implements LinphoneConferenceParams { + private long nativePtr = 0; + + private native long createInstance(LinphoneCoreImpl core); + public LinphoneConferenceParamsImpl(LinphoneCore core) { + this.nativePtr = createInstance((LinphoneCoreImpl)core); + } + + private native long copyInstance(long paramsPtr); + public LinphoneConferenceParamsImpl(LinphoneConferenceParamsImpl params) { + nativePtr = copyInstance(params.nativePtr); + } + + private native void destroyInstance(long nativePtr); + public void finalize() { + destroyInstance(this.nativePtr); + } + + private native void enableVideo(long paramsPtr, boolean enable); + @Override + public void enableVideo(boolean enable) { + enableVideo(this.nativePtr, enable); + } + + private native boolean isVideoRequested(long paramsPtr); + @Override + public boolean isVideoRequested() { + return isVideoRequested(this.nativePtr); + } +} \ No newline at end of file diff --git a/java/impl/org/linphone/core/LinphoneCoreImpl.java b/java/impl/org/linphone/core/LinphoneCoreImpl.java index 1147305b2..ab09f7e06 100644 --- a/java/impl/org/linphone/core/LinphoneCoreImpl.java +++ b/java/impl/org/linphone/core/LinphoneCoreImpl.java @@ -322,7 +322,7 @@ class LinphoneCoreImpl implements LinphoneCore { setNetworkStateReachable(nativePtr,isReachable); } public synchronized void setPlaybackGain(float gain) { - setPlaybackGain(nativePtr,gain); + setPlaybackGain(nativePtr, gain); } public synchronized float getPlaybackGain() { @@ -382,7 +382,7 @@ class LinphoneCoreImpl implements LinphoneCore { public synchronized boolean payloadTypeIsVbr(PayloadType pt) { isValid(); - return payloadTypeIsVbr(nativePtr, ((PayloadTypeImpl)pt).nativePtr); + return payloadTypeIsVbr(nativePtr, ((PayloadTypeImpl) pt).nativePtr); } public synchronized void enableEchoCancellation(boolean enable) { @@ -449,7 +449,7 @@ class LinphoneCoreImpl implements LinphoneCore { } public synchronized void addFriend(LinphoneFriend lf) throws LinphoneCoreException { - addFriend(nativePtr,((LinphoneFriendImpl)lf).nativePtr); + addFriend(nativePtr, ((LinphoneFriendImpl) lf).nativePtr); } @@ -484,7 +484,7 @@ class LinphoneCoreImpl implements LinphoneCore { return new LinphoneChatRoomImpl(getOrCreateChatRoom(nativePtr,to)); } public synchronized LinphoneChatRoom getChatRoom(LinphoneAddress to) { - return new LinphoneChatRoomImpl(getChatRoom(nativePtr,((LinphoneAddressImpl)to).nativePtr)); + return new LinphoneChatRoomImpl(getChatRoom(nativePtr, ((LinphoneAddressImpl) to).nativePtr)); } public synchronized void setPreviewWindow(Object w) { setPreviewWindowId(nativePtr,w); @@ -497,7 +497,7 @@ class LinphoneCoreImpl implements LinphoneCore { } public synchronized void enableVideo(boolean vcap_enabled, boolean display_enabled) { - enableVideo(nativePtr,vcap_enabled, display_enabled); + enableVideo(nativePtr, vcap_enabled, display_enabled); } public synchronized boolean isVideoEnabled() { return isVideoEnabled(nativePtr); @@ -515,7 +515,7 @@ class LinphoneCoreImpl implements LinphoneCore { setFirewallPolicy(nativePtr,pol.value()); } public synchronized void setStunServer(String stunServer) { - setStunServer(nativePtr,stunServer); + setStunServer(nativePtr, stunServer); } public synchronized LinphoneCall inviteAddressWithParams(LinphoneAddress to, LinphoneCallParams params) throws LinphoneCoreException { @@ -655,7 +655,7 @@ class LinphoneCoreImpl implements LinphoneCore { } public synchronized void enableIpv6(boolean enable) { - enableIpv6(nativePtr,enable); + enableIpv6(nativePtr, enable); } public synchronized boolean isIpv6Enabled() { return isIpv6Enabled(nativePtr); @@ -678,14 +678,14 @@ class LinphoneCoreImpl implements LinphoneCore { } public synchronized void setUploadPtime(int ptime) { - setUploadPtime(nativePtr,ptime); + setUploadPtime(nativePtr, ptime); } public synchronized void setZrtpSecretsCache(String file) { - setZrtpSecretsCache(nativePtr,file); + setZrtpSecretsCache(nativePtr, file); } public synchronized void enableEchoLimiter(boolean val) { - enableEchoLimiter(nativePtr,val); + enableEchoLimiter(nativePtr, val); } public synchronized void setVideoDevice(int id) { Log.i("Setting camera id :", id); @@ -721,6 +721,10 @@ class LinphoneCoreImpl implements LinphoneCore { public synchronized int getConferenceSize() { return getConferenceSize(nativePtr); } + private native LinphoneConference createConference(long corePtr, LinphoneConferenceParams params); + public synchronized LinphoneConference createConference(LinphoneConferenceParams params) { + return createConference(this.nativePtr, params); + } private native LinphoneConference getConference(long nativePtr); public synchronized LinphoneConference getConference() { return getConference(nativePtr); From fc9dc6093bc7055feacec45986eaac95e4383de8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fran=C3=A7ois=20Grisez?= Date: Thu, 14 Jan 2016 17:00:06 +0100 Subject: [PATCH 03/10] Add a method to LinphoneCallLog to check whether a call was a call to a conference server --- coreapi/call_log.c | 4 ++++ coreapi/call_log.h | 7 +++++++ coreapi/conference.cc | 4 +++- coreapi/linphonecore_jni.cc | 4 ++++ coreapi/private.h | 1 + java/common/org/linphone/core/LinphoneCallLog.java | 5 +++++ java/impl/org/linphone/core/LinphoneCallLogImpl.java | 4 ++++ 7 files changed, 28 insertions(+), 1 deletion(-) diff --git a/coreapi/call_log.c b/coreapi/call_log.c index 2bf8d5b9f..a9ecf0149 100644 --- a/coreapi/call_log.c +++ b/coreapi/call_log.c @@ -248,6 +248,10 @@ bool_t linphone_call_log_video_enabled(LinphoneCallLog *cl) { return cl->video_enabled; } +bool_t linphone_call_log_was_conference(LinphoneCallLog *cl) { + return cl->was_conference; +} + /******************************************************************************* * Reference and user data handling functions * diff --git a/coreapi/call_log.h b/coreapi/call_log.h index 6a3ec8dab..8cae77d24 100644 --- a/coreapi/call_log.h +++ b/coreapi/call_log.h @@ -179,6 +179,13 @@ LINPHONE_PUBLIC bool_t linphone_call_log_video_enabled(LinphoneCallLog *cl); **/ LINPHONE_PUBLIC char * linphone_call_log_to_str(LinphoneCallLog *cl); +/** + * Tells whether that call was a call to a conference server + * @param[in] cl #LinphoneCallLog object + * @return TRUE if the call was a call to a conference server + */ +LINPHONE_PUBLIC bool_t linphone_call_log_was_conference(LinphoneCallLog *cl); + /******************************************************************************* * Reference and user data handling functions * diff --git a/coreapi/conference.cc b/coreapi/conference.cc index 72fe4ff4e..121114a64 100644 --- a/coreapi/conference.cc +++ b/coreapi/conference.cc @@ -611,8 +611,10 @@ int RemoteConference::addParticipant(LinphoneCall *call) { m_localParticipantStream = m_focusCall->audiostream; m_pendingCalls = ms_list_append(m_pendingCalls, linphone_call_ref(call)); m_state = ConnectingToFocus; - linphone_address_unref(addr); call->conf_ref = (LinphoneConference *)this; + LinphoneCallLog *callLog = linphone_call_get_call_log(m_focusCall); + callLog->was_conference = TRUE; + linphone_address_unref(addr); linphone_call_params_unref(params); return 0; } else return -1; diff --git a/coreapi/linphonecore_jni.cc b/coreapi/linphonecore_jni.cc index 38e7fa8a2..6212991e6 100644 --- a/coreapi/linphonecore_jni.cc +++ b/coreapi/linphonecore_jni.cc @@ -2790,6 +2790,10 @@ extern "C" jint Java_org_linphone_core_LinphoneCallLogImpl_getCallDuration(JNIEn return (jint)((LinphoneCallLog*)ptr)->duration; } +extern "C" jboolean Java_org_linphone_core_LinphoneCallLogImpl_wasConference(JNIEnv *env, jobject thiz, jlong ptr) { + return linphone_call_log_was_conference((LinphoneCallLog *)ptr); +} + /* CallStats */ extern "C" jint Java_org_linphone_core_LinphoneCallStatsImpl_getMediaType(JNIEnv *env, jobject thiz, jlong stats_ptr) { return (jint)((LinphoneCallStats *)stats_ptr)->type; diff --git a/coreapi/private.h b/coreapi/private.h index 5e63ff151..de115f84f 100644 --- a/coreapi/private.h +++ b/coreapi/private.h @@ -194,6 +194,7 @@ struct _LinphoneCallLog{ char* call_id; /**unique id of a call*/ struct _LinphoneQualityReporting reporting; bool_t video_enabled; + bool_t was_conference; /** Date: Fri, 15 Jan 2016 09:21:31 +0100 Subject: [PATCH 04/10] add logs to track RtpEndpoint enablement --- coreapi/TunnelManager.cc | 1 + coreapi/linphonecall.c | 2 ++ 2 files changed, 3 insertions(+) diff --git a/coreapi/TunnelManager.cc b/coreapi/TunnelManager.cc index 128707a12..859394f17 100644 --- a/coreapi/TunnelManager.cc +++ b/coreapi/TunnelManager.cc @@ -89,6 +89,7 @@ RtpTransport *TunnelManager::createRtpTransport(int port){ t->t_close=sCloseRtpTransport; t->t_destroy=sDestroyRtpTransport; t->data=socket; + ms_message("Creating tunnel RTP transport for local virtual port %i", port); return t; } diff --git a/coreapi/linphonecall.c b/coreapi/linphonecall.c index df3624ebe..5429fe377 100644 --- a/coreapi/linphonecall.c +++ b/coreapi/linphonecall.c @@ -2398,6 +2398,7 @@ void linphone_call_init_audio_stream(LinphoneCall *call){ rtp_session_get_transports(audiostream->ms.sessions.rtp_session,&meta_rtp,&meta_rtcp); if (meta_rtp_transport_get_endpoint(meta_rtp) == NULL) { + ms_message("LinphoneCall[%p]: using custom audio RTP transport endpoint.", call); meta_rtp_transport_set_endpoint(meta_rtp,lc->rtptf->audio_rtp_func(lc->rtptf->audio_rtp_func_data, call->media_ports[call->main_audio_stream_index].rtp_port)); } if (meta_rtp_transport_get_endpoint(meta_rtcp) == NULL) { @@ -2466,6 +2467,7 @@ void linphone_call_init_video_stream(LinphoneCall *call){ rtp_session_get_transports(call->videostream->ms.sessions.rtp_session,&meta_rtp,&meta_rtcp); if (meta_rtp_transport_get_endpoint(meta_rtp) == NULL) { + ms_message("LinphoneCall[%p]: using custom video RTP transport endpoint.", call); meta_rtp_transport_set_endpoint(meta_rtp,lc->rtptf->video_rtp_func(lc->rtptf->video_rtp_func_data, call->media_ports[call->main_video_stream_index].rtp_port)); } if (meta_rtp_transport_get_endpoint(meta_rtcp) == NULL) { From afd3c2f705c4fd88410ac4922b9e72ab93601abd Mon Sep 17 00:00:00 2001 From: Simon Morlat Date: Fri, 15 Jan 2016 10:29:29 +0100 Subject: [PATCH 05/10] fix makedistckeck --- coreapi/Makefile.am | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/coreapi/Makefile.am b/coreapi/Makefile.am index 79300d538..0dd8febe0 100644 --- a/coreapi/Makefile.am +++ b/coreapi/Makefile.am @@ -42,7 +42,8 @@ linphone_include_HEADERS=\ lpconfig.h \ sipsetup.h \ xml2lpc.h \ - xmlrpc.h + xmlrpc.h \ + conference.h lib_LTLIBRARIES=liblinphone.la @@ -56,7 +57,7 @@ liblinphone_la_SOURCES=\ call_params.c \ chat.c \ chat_file_transfer.c \ - conference.cc conference.h \ + conference.cc conference.h conference_private.h \ contactprovider.c contactprovider.h contact_providers_priv.h \ content.c \ dict.c \ From ddb37ca75e4f736c7401bd40c0a8bb9956a478dd Mon Sep 17 00:00:00 2001 From: Gautier Pelloux-Prayer Date: Fri, 15 Jan 2016 11:01:46 +0100 Subject: [PATCH 06/10] gtk: disable encryption mandatory requirement if encryption is disabled --- gtk/propertybox.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/gtk/propertybox.c b/gtk/propertybox.c index b996a5378..974542075 100644 --- a/gtk/propertybox.c +++ b/gtk/propertybox.c @@ -1285,19 +1285,21 @@ static void linphone_gtk_media_encryption_changed(GtkWidget *combo){ char *selected=gtk_combo_box_get_active_text(GTK_COMBO_BOX(combo)); LinphoneCore *lc=linphone_gtk_get_core(); GtkWidget *toplevel=gtk_widget_get_toplevel(combo); + GtkWidget *mandatory_box = linphone_gtk_get_widget(toplevel,"media_encryption_mandatory"); if (selected!=NULL){ if (strcasecmp(selected,"SRTP")==0){ linphone_core_set_media_encryption(lc,LinphoneMediaEncryptionSRTP); - linphone_gtk_set_media_encryption_mandatory_sensitive(toplevel,TRUE); + gtk_widget_set_sensitive(mandatory_box,TRUE); }else if (strcasecmp(selected,"DTLS")==0){ linphone_core_set_media_encryption(lc,LinphoneMediaEncryptionDTLS); - linphone_gtk_set_media_encryption_mandatory_sensitive(toplevel,FALSE); + gtk_widget_set_sensitive(mandatory_box,FALSE); }else if (strcasecmp(selected,"ZRTP")==0){ linphone_core_set_media_encryption(lc,LinphoneMediaEncryptionZRTP); - linphone_gtk_set_media_encryption_mandatory_sensitive(toplevel,FALSE); + gtk_widget_set_sensitive(mandatory_box,FALSE); } else { linphone_core_set_media_encryption(lc,LinphoneMediaEncryptionNone); - linphone_gtk_set_media_encryption_mandatory_sensitive(toplevel,FALSE); + gtk_widget_set_sensitive(mandatory_box,FALSE); + gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(mandatory_box), FALSE); } g_free(selected); }else g_warning("gtk_combo_box_get_active_text() returned NULL"); From a1c8d9f99ce8c092e1a3bdc9ff7d23cf16224f90 Mon Sep 17 00:00:00 2001 From: Jehan Monnier Date: Fri, 15 Jan 2016 15:36:13 +0100 Subject: [PATCH 07/10] make sure in case of SRTP DTLS enabled, ice reinvite is disabled & mandatory encryption is activated --- coreapi/bellesip_sal/sal_op_impl.c | 1 - coreapi/linphonecall.c | 40 +++++++++++++++++++----------- coreapi/linphonecore.c | 2 ++ coreapi/private.h | 2 ++ coreapi/sal.c | 4 ++- gtk/incall_view.c | 2 ++ include/sal/sal.h | 2 ++ mediastreamer2 | 2 +- oRTP | 2 +- tester/call_tester.c | 17 ++++++++++++- tester/flexisip_tester.c | 15 ++++++++--- tester/message_tester.c | 2 +- 12 files changed, 67 insertions(+), 24 deletions(-) diff --git a/coreapi/bellesip_sal/sal_op_impl.c b/coreapi/bellesip_sal/sal_op_impl.c index 9f654902c..345501b84 100644 --- a/coreapi/bellesip_sal/sal_op_impl.c +++ b/coreapi/bellesip_sal/sal_op_impl.c @@ -701,7 +701,6 @@ void sal_op_assign_recv_headers(SalOp *op, belle_sip_message_t *incoming){ const char *sal_op_get_remote_contact(const SalOp *op){ /* * remote contact is filled in process_response - * return sal_custom_header_find(op->base.recv_custom_headers,"Contact"); */ return op->base.remote_contact; } diff --git a/coreapi/linphonecall.c b/coreapi/linphonecall.c index 5429fe377..5718782ed 100644 --- a/coreapi/linphonecall.c +++ b/coreapi/linphonecall.c @@ -1092,7 +1092,9 @@ LinphoneCall * linphone_call_new_outgoing(struct _LinphoneCore *lc, LinphoneAddr linphone_call_get_local_ip(call, to); call->params = linphone_call_params_copy(params); linphone_call_init_common(call, from, to); - + + call->current_params->update_call_when_ice_completed = call->params->update_call_when_ice_completed; /*copy param*/ + linphone_call_fill_media_multicast_addr(call); if (linphone_core_get_firewall_policy(call->core) == LinphonePolicyUseIce) { @@ -1300,6 +1302,9 @@ LinphoneCall * linphone_call_new_incoming(LinphoneCore *lc, LinphoneAddress *fro */ /*set privacy*/ call->current_params->privacy=(LinphonePrivacyMask)sal_op_get_privacy(call->op); + /*config params*/ + call->current_params->update_call_when_ice_completed = call->params->update_call_when_ice_completed; /*copy config params*/ + /*set video support */ call->params->has_video = linphone_core_video_enabled(lc) && lc->video_policy.automatically_accept; if (md) { @@ -1754,7 +1759,8 @@ const LinphoneCallParams * linphone_call_get_current_params(LinphoneCall *call){ if ((all_streams_encrypted = linphone_call_all_streams_encrypted(call)) && linphone_call_get_authentication_token(call)) { call->current_params->media_encryption=LinphoneMediaEncryptionZRTP; } else { - ms_message("Encryption was requested to be %s, but isn't effective (all_streams_encrypted=%i, auth_token=%s)", + /*to avoid to many traces*/ + ms_debug("Encryption was requested to be %s, but isn't effective (all_streams_encrypted=%i, auth_token=%s)", linphone_media_encryption_to_string(call->params->media_encryption), all_streams_encrypted, call->auth_token == NULL ? "" : call->auth_token); call->current_params->media_encryption=LinphoneMediaEncryptionNone; } @@ -1766,7 +1772,8 @@ const LinphoneCallParams * linphone_call_get_current_params(LinphoneCall *call){ if (linphone_call_get_n_active_streams(call)==0 || (all_streams_encrypted = linphone_call_all_streams_encrypted(call))) { call->current_params->media_encryption = call->params->media_encryption; } else { - ms_message("Encryption was requested to be %s, but isn't effective (all_streams_encrypted=%i)", + /*to avoid to many traces*/ + ms_debug("Encryption was requested to be %s, but isn't effective (all_streams_encrypted=%i)", linphone_media_encryption_to_string(call->params->media_encryption), all_streams_encrypted); call->current_params->media_encryption=LinphoneMediaEncryptionNone; } @@ -1982,12 +1989,9 @@ const char *linphone_call_get_remote_user_agent(LinphoneCall *call){ * Returns the far end's sip contact as a string, if available. **/ const char *linphone_call_get_remote_contact(LinphoneCall *call){ - const LinphoneCallParams* lcp = linphone_call_get_remote_params(call); - if( lcp ){ - // we're not using sal_op_get_remote_contact() here because the returned value is stripped from - // params that we need, like the instanceid. Getting it from the headers will make sure we - // get everything - return linphone_call_params_get_custom_header(lcp, "Contact"); + if( call->op ){ + /*sal_op_get_remote_contact preserves header params*/ + return sal_op_get_remote_contact(call->op); } return NULL; } @@ -3101,7 +3105,7 @@ static void linphone_call_start_audio_stream(LinphoneCall *call, LinphoneCallSta } } - ms_media_stream_sessions_set_encryption_mandatory(&call->audiostream->ms.sessions,linphone_core_is_media_encryption_mandatory(call->core)); + ms_media_stream_sessions_set_encryption_mandatory(&call->audiostream->ms.sessions,call->current_params->encryption_mandatory); if (next_state == LinphoneCallPaused && captcard == NULL && playfile != NULL){ int pause_time=500; @@ -3280,7 +3284,7 @@ static void linphone_call_start_video_stream(LinphoneCall *call, LinphoneCallSta used_pt, &io); } } - ms_media_stream_sessions_set_encryption_mandatory(&call->videostream->ms.sessions,linphone_core_is_media_encryption_mandatory(call->core)); + ms_media_stream_sessions_set_encryption_mandatory(&call->videostream->ms.sessions,call->current_params->encryption_mandatory); _linphone_call_set_next_video_frame_decoded_trigger(call); } }else ms_warning("No video stream accepted."); @@ -3338,7 +3342,7 @@ static void linphone_call_start_text_stream(LinphoneCall *call) { text_stream_start(call->textstream, call->text_profile, rtp_addr, tstream->rtp_port, rtcp_addr, (linphone_core_rtcp_enabled(lc) && !is_multicast) ? (tstream->rtcp_port ? tstream->rtcp_port : tstream->rtp_port + 1) : 0, used_pt); ms_filter_add_notify_callback(call->textstream->rttsink, real_time_text_character_received, call, FALSE); - ms_media_stream_sessions_set_encryption_mandatory(&call->textstream->ms.sessions,linphone_core_is_media_encryption_mandatory(call->core)); + ms_media_stream_sessions_set_encryption_mandatory(&call->textstream->ms.sessions,call->current_params->encryption_mandatory); } else ms_warning("No text stream accepted."); } else { ms_message("No valid text stream defined."); @@ -3431,6 +3435,10 @@ void linphone_call_start_media_streams(LinphoneCall *call, LinphoneCallState nex ms_fatal("start_media_stream() called without prior init !"); return; } + if (call->params->media_encryption==LinphoneMediaEncryptionDTLS) { + call->current_params->encryption_mandatory = TRUE; + ms_message("Forcing encryption mandatory on call [%p]",call); + } call->nb_media_starts++; #if defined(VIDEO_ENABLED) @@ -3487,6 +3495,10 @@ void linphone_call_start_media_streams(LinphoneCall *call, LinphoneCallState nex set_dtls_fingerprint_on_all_streams(call); if ((call->ice_session != NULL) && (ice_session_state(call->ice_session) != IS_Completed)) { + if (call->params->media_encryption==LinphoneMediaEncryptionDTLS) { + call->current_params->update_call_when_ice_completed = FALSE; + ms_message("Disabling update call when ice completed on call [%p]",call); + } ice_session_start_connectivity_checks(call->ice_session); } else { /*should not start dtls until ice is completed*/ @@ -3913,7 +3925,7 @@ static bool_t ice_in_progress(LinphoneCallStats *stats){ /** * Indicates whether an operation is in progress at the media side. - * It can a bad idea to initiate signaling operations (adding video, pausing the call, removing video, changing video parameters) while + * It can be a bad idea to initiate signaling operations (adding video, pausing the call, removing video, changing video parameters) while * the media is busy in establishing the connection (typically ICE connectivity checks). It can result in failures generating loss of time * in future operations in the call. * Applications are invited to check this function after each call state change to decide whether certain operations are permitted or not. @@ -4266,7 +4278,7 @@ static void handle_ice_events(LinphoneCall *call, OrtpEvent *ev){ case IS_Completed: ice_session_select_candidates(call->ice_session); if (ice_session_role(call->ice_session) == IR_Controlling - && lp_config_get_int(call->core->config, "sip", "update_call_when_ice_completed", TRUE)) { + && params->update_call_when_ice_completed) { params->internal_call_update = TRUE; linphone_core_update_call(call->core, call, params); } diff --git a/coreapi/linphonecore.c b/coreapi/linphonecore.c index 18cc6d2fe..27965a84e 100644 --- a/coreapi/linphonecore.c +++ b/coreapi/linphonecore.c @@ -7060,6 +7060,8 @@ void linphone_core_init_default_params(LinphoneCore*lc, LinphoneCallParams *para params->real_early_media=lp_config_get_int(lc->config,"misc","real_early_media",FALSE); params->audio_multicast_enabled=linphone_core_audio_multicast_enabled(lc); params->video_multicast_enabled=linphone_core_video_multicast_enabled(lc); + params->update_call_when_ice_completed = lp_config_get_int(lc->config, "sip", "update_call_when_ice_completed", TRUE); + params->encryption_mandatory = linphone_core_is_media_encryption_mandatory(lc); } void linphone_core_set_device_identifier(LinphoneCore *lc,const char* device_id) { diff --git a/coreapi/private.h b/coreapi/private.h index de115f84f..3ed87ca78 100644 --- a/coreapi/private.h +++ b/coreapi/private.h @@ -164,6 +164,8 @@ struct _LinphoneCallParams{ bool_t video_multicast_enabled; bool_t audio_multicast_enabled; bool_t realtimetext_enabled; + bool_t update_call_when_ice_completed; + bool_t encryption_mandatory; }; BELLE_SIP_DECLARE_VPTR(LinphoneCallParams); diff --git a/coreapi/sal.c b/coreapi/sal.c index b2c4c97b1..701d68b90 100644 --- a/coreapi/sal.c +++ b/coreapi/sal.c @@ -613,7 +613,9 @@ void __sal_op_set_network_origin(SalOp *op, const char *origin){ } void __sal_op_set_remote_contact(SalOp *op, const char* remote_contact){ - SET_PARAM(op,remote_contact); + assign_address(&((SalOpBase*)op)->remote_contact_address,remote_contact);\ + /*to preserve header params*/ + assign_string(&((SalOpBase*)op)->remote_contact,remote_contact); \ } void __sal_op_set_network_origin_address(SalOp *op, SalAddress *origin){ diff --git a/gtk/incall_view.c b/gtk/incall_view.c index d37602201..cf97b5d53 100644 --- a/gtk/incall_view.c +++ b/gtk/incall_view.c @@ -635,6 +635,8 @@ static gboolean linphone_gtk_in_call_view_refresh(LinphoneCall *call){ } rating_to_color(rating,&color); gtk_widget_modify_bg(qi,GTK_STATE_NORMAL,&color); + + linphone_gtk_update_video_button(call); /*in case of no ice re-invite, video button status shall be checked by polling*/ return TRUE; } diff --git a/include/sal/sal.h b/include/sal/sal.h index d8106f6b7..721cefbea 100644 --- a/include/sal/sal.h +++ b/include/sal/sal.h @@ -656,7 +656,9 @@ const SalAddress *sal_op_get_contact_address(const SalOp *op); const char *sal_op_get_route(const SalOp *op); const MSList* sal_op_get_route_addresses(const SalOp *op); const char *sal_op_get_proxy(const SalOp *op); +/*raw contact header value with header params*/ const char *sal_op_get_remote_contact(const SalOp *op); +/*contact header address only (I.E without header params*/ const SalAddress* sal_op_get_remote_contact_address(const SalOp *op); /*for incoming requests, returns the origin of the packet as a sip uri*/ const char *sal_op_get_network_origin(const SalOp *op); diff --git a/mediastreamer2 b/mediastreamer2 index 66ad948e8..005c28b9f 160000 --- a/mediastreamer2 +++ b/mediastreamer2 @@ -1 +1 @@ -Subproject commit 66ad948e85e77f1d92545bb5e12823cd5a489d6a +Subproject commit 005c28b9fc0321957a8b339000272b4cb5de8cc0 diff --git a/oRTP b/oRTP index 3c0e10e3a..35b2e7354 160000 --- a/oRTP +++ b/oRTP @@ -1 +1 @@ -Subproject commit 3c0e10e3a4ec3e6b69820f890012db8fe3cba6f7 +Subproject commit 35b2e735421bcbaedd4422b637256987893368bc diff --git a/tester/call_tester.c b/tester/call_tester.c index c0e5858c7..996a0e974 100644 --- a/tester/call_tester.c +++ b/tester/call_tester.c @@ -321,10 +321,25 @@ bool_t call_with_params2(LinphoneCoreManager* caller_mgr && linphone_core_get_firewall_policy(callee_mgr->lc) == LinphonePolicyUseIce && !linphone_core_sdp_200_ack_enabled(caller_mgr->lc) /*ice does not work with sdp less invite*/ && lp_config_get_int(callee_mgr->lc->config, "sip", "update_call_when_ice_completed", TRUE) - && lp_config_get_int(caller_mgr->lc->config, "sip", "update_call_when_ice_completed", TRUE)) { + && lp_config_get_int(caller_mgr->lc->config, "sip", "update_call_when_ice_completed", TRUE) + && linphone_core_get_media_encryption(caller_mgr->lc) != LinphoneMediaEncryptionDTLS /*no ice-reinvite with DTLS*/) { BC_ASSERT_TRUE(wait_for(callee_mgr->lc,caller_mgr->lc,&caller_mgr->stat.number_of_LinphoneCallStreamsRunning,initial_caller.number_of_LinphoneCallStreamsRunning+2)); BC_ASSERT_TRUE(wait_for(callee_mgr->lc,caller_mgr->lc,&callee_mgr->stat.number_of_LinphoneCallStreamsRunning,initial_callee.number_of_LinphoneCallStreamsRunning+2)); + } else if (linphone_core_get_firewall_policy(caller_mgr->lc) == LinphonePolicyUseIce) { + /* check no ice re-invite received*/ + BC_ASSERT_FALSE(wait_for_until(callee_mgr->lc,caller_mgr->lc,&caller_mgr->stat.number_of_LinphoneCallStreamsRunning,initial_caller.number_of_LinphoneCallStreamsRunning+2,2000)); + BC_ASSERT_FALSE(wait_for_until(callee_mgr->lc,caller_mgr->lc,&callee_mgr->stat.number_of_LinphoneCallStreamsRunning,initial_callee.number_of_LinphoneCallStreamsRunning+2,2000)); + + } + if (linphone_core_get_media_encryption(caller_mgr->lc) == LinphoneMediaEncryptionDTLS ) { + if (linphone_core_get_current_call(caller_mgr->lc)->audiostream) + BC_ASSERT_TRUE(ms_media_stream_sessions_get_encryption_mandatory(&linphone_core_get_current_call(caller_mgr->lc)->audiostream->ms.sessions)); +#ifdef VIDEO_ENABLED + if (linphone_core_get_current_call(caller_mgr->lc)->videostream && video_stream_started(linphone_core_get_current_call(caller_mgr->lc)->videostream)) + BC_ASSERT_TRUE(ms_media_stream_sessions_get_encryption_mandatory(&linphone_core_get_current_call(caller_mgr->lc)->videostream->ms.sessions)); +#endif + } return result; } diff --git a/tester/flexisip_tester.c b/tester/flexisip_tester.c index c77655532..b75bd04f2 100644 --- a/tester/flexisip_tester.c +++ b/tester/flexisip_tester.c @@ -876,6 +876,7 @@ static void dos_module_trigger(void) { int i = 0; const char* passmsg = "This one should pass through"; int number_of_messge_to_send = 100; + LinphoneChatMessage * chat_msg = NULL; LinphoneCoreManager* marie = linphone_core_manager_new("marie_rc"); LinphoneCoreManager* pauline = linphone_core_manager_new(transport_supported(LinphoneTransportTls) ? "pauline_rc" : "pauline_tcp_rc"); @@ -887,7 +888,8 @@ static void dos_module_trigger(void) { do { char msg[128]; sprintf(msg, "Flood message number %i", i); - linphone_chat_room_send_message(chat_room, msg); + chat_msg = linphone_chat_room_create_message(chat_room, msg); + linphone_chat_room_send_chat_message(chat_room, chat_msg); ms_usleep(10000); i++; } while (i < number_of_messge_to_send); @@ -898,8 +900,8 @@ static void dos_module_trigger(void) { reset_counters(&marie->stat); reset_counters(&pauline->stat); - - linphone_chat_room_send_message(chat_room, passmsg); + chat_msg = linphone_chat_room_create_message(chat_room, passmsg); + linphone_chat_room_send_chat_message(chat_room, chat_msg); BC_ASSERT_TRUE(wait_for(pauline->lc,marie->lc,&marie->stat.number_of_LinphoneMessageReceived, 1)); BC_ASSERT_EQUAL(marie->stat.number_of_LinphoneMessageReceived, 1, int, "%d"); if (marie->stat.last_received_chat_message) { @@ -909,8 +911,9 @@ static void dos_module_trigger(void) { linphone_core_manager_destroy(pauline); } - +#define USE_PRESENCE_SERVER 0 static void test_subscribe_notify_with_sipp_publisher(void) { +#if USE_PRESENCE_SERVER char *scen; FILE * sipp_out; LinphoneCoreManager* pauline = linphone_core_manager_new( "pauline_rc"); @@ -943,8 +946,10 @@ static void test_subscribe_notify_with_sipp_publisher(void) { linphone_core_manager_destroy(marie); linphone_core_manager_destroy(pauline); +#endif } static void test_subscribe_notify_with_sipp_publisher_double_publish(void) { +#if USE_PRESENCE_SERVER char *scen; FILE * sipp_out; LinphoneCoreManager* pauline = linphone_core_manager_new( "pauline_rc"); @@ -977,6 +982,7 @@ static void test_subscribe_notify_with_sipp_publisher_double_publish(void) { linphone_core_manager_destroy(marie); linphone_core_manager_destroy(pauline); +#endif } static void test_publish_unpublish(void) { @@ -1035,6 +1041,7 @@ static void test_list_subscribe (void) { linphone_event_add_custom_header(lev,"Supported","eventlist"); linphone_event_add_custom_header(lev,"Accept","application/pidf+xml, application/rlmi+xml"); linphone_event_add_custom_header(lev,"Content-Disposition", "recipient-list"); + linphone_event_add_custom_header(lev,"Require", "recipient-list-subscribe"); linphone_event_send_subscribe(lev,content); diff --git a/tester/message_tester.c b/tester/message_tester.c index 78aeb0b69..e49d97979 100644 --- a/tester/message_tester.c +++ b/tester/message_tester.c @@ -1394,7 +1394,7 @@ static void real_time_text(bool_t audio_stream_enabled, bool_t srtp_enabled, boo LinphoneChatRoom *marie_chat_room = linphone_call_get_chat_room(marie_call); for (i = 0; i < strlen(message); i++) { - linphone_chat_message_put_char(rtt_message, message[i]); + BC_ASSERT_FALSE(linphone_chat_message_put_char(rtt_message, message[i])); BC_ASSERT_TRUE(wait_for_until(pauline->lc, marie->lc, &marie->stat.number_of_LinphoneIsComposingActiveReceived, i+1, 1000)); BC_ASSERT_EQUAL(linphone_chat_room_get_char(marie_chat_room), message[i], char, "%c"); } From b86952810c53a4b6249d7f891ac3403df91d760c Mon Sep 17 00:00:00 2001 From: Simon Morlat Date: Fri, 15 Jan 2016 14:47:10 +0100 Subject: [PATCH 08/10] improve loggin of an error case --- coreapi/misc.c | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) diff --git a/coreapi/misc.c b/coreapi/misc.c index 297371680..dff4c026f 100644 --- a/coreapi/misc.c +++ b/coreapi/misc.c @@ -1178,6 +1178,16 @@ static int get_local_ip_with_getifaddrs(int type, char *address, int size){ } #endif +static const char *ai_family_to_string(int af){ + switch(af){ + case AF_INET: return "AF_INET"; + case AF_INET6: return "AF_INET6"; + case AF_UNSPEC: return "AF_UNSPEC"; + default: + return "invalid address family"; + } + return ""; +} static int get_local_ip_for_with_connect(int type, const char *dest, char *result){ int err,tmp; @@ -1202,13 +1212,18 @@ static int get_local_ip_for_with_connect(int type, const char *dest, char *resul return -1; } sock=socket(res->ai_family,SOCK_DGRAM,0); + if (sock == (ortp_socket_t)-1){ + ms_error("get_local_ip_for_with_connect() could not create [%s] socket: %s", + ai_family_to_string(res->ai_family), getSocketError()); + return -1; + } tmp=1; err=setsockopt(sock,SOL_SOCKET,SO_REUSEADDR,(SOCKET_OPTION_VALUE)&tmp,sizeof(int)); - if (err<0){ + if (err == -1){ ms_warning("Error in setsockopt: %s",strerror(errno)); } err=connect(sock,res->ai_addr,(int)res->ai_addrlen); - if (err<0) { + if (err == -1) { /*the network isn't reachable*/ if (getSocketErrorCode()!=ENETUNREACH) ms_error("Error in connect: %s",strerror(errno)); freeaddrinfo(res); From 2a6213d90c4bda8a2758a1102257ea55a24afdf9 Mon Sep 17 00:00:00 2001 From: Simon Morlat Date: Fri, 15 Jan 2016 21:58:21 +0100 Subject: [PATCH 09/10] prepare the removal of a=nortpproxy attribute for ICE reINVITE. --- coreapi/bellesip_sal/sal_sdp.c | 4 ++-- coreapi/linphonecall.c | 5 ++++- coreapi/misc.c | 10 +++++----- coreapi/offeranswer.c | 4 ++-- coreapi/private.h | 2 +- include/sal/sal.h | 8 ++++---- 6 files changed, 18 insertions(+), 15 deletions(-) diff --git a/coreapi/bellesip_sal/sal_sdp.c b/coreapi/bellesip_sal/sal_sdp.c index 126aca340..80cfb032b 100644 --- a/coreapi/bellesip_sal/sal_sdp.c +++ b/coreapi/bellesip_sal/sal_sdp.c @@ -320,7 +320,7 @@ static void stream_description_to_sdp ( belle_sdp_session_description_t *session belle_sdp_media_description_add_attribute(media_desc,belle_sdp_attribute_create ("rtcp",buffer)); } } - if (stream->ice_completed == TRUE) { + if (stream->set_nortpproxy == TRUE) { belle_sdp_media_description_add_attribute(media_desc,belle_sdp_attribute_create ("nortpproxy","yes")); } if (stream->ice_mismatch == TRUE) { @@ -423,7 +423,7 @@ belle_sdp_session_description_t * media_description_to_sdp ( const SalMediaDescr belle_sdp_session_description_set_bandwidth ( session_desc,"AS",desc->bandwidth ); } - if (desc->ice_completed == TRUE) belle_sdp_session_description_add_attribute(session_desc, belle_sdp_attribute_create("nortpproxy","yes")); + if (desc->set_nortpproxy == TRUE) belle_sdp_session_description_add_attribute(session_desc, belle_sdp_attribute_create("nortpproxy","yes")); if (desc->ice_pwd[0] != '\0') belle_sdp_session_description_add_attribute(session_desc, belle_sdp_attribute_create("ice-pwd",desc->ice_pwd)); if (desc->ice_ufrag[0] != '\0') belle_sdp_session_description_add_attribute(session_desc, belle_sdp_attribute_create("ice-ufrag",desc->ice_ufrag)); diff --git a/coreapi/linphonecall.c b/coreapi/linphonecall.c index 5718782ed..e051789c3 100644 --- a/coreapi/linphonecall.c +++ b/coreapi/linphonecall.c @@ -579,8 +579,11 @@ void linphone_call_increment_local_media_description(LinphoneCall *call){ } void linphone_call_update_local_media_description_from_ice_or_upnp(LinphoneCall *call){ + LinphoneCore *lc = call->core; if (call->ice_session != NULL) { - _update_local_media_description_from_ice(call->localdesc, call->ice_session); + /*set this to FALSE once flexisip are updated*/ + bool_t use_nortpproxy = lp_config_get_int(lc->config, "sip", "ice_uses_nortpproxy", TRUE); + _update_local_media_description_from_ice(call->localdesc, call->ice_session, use_nortpproxy); linphone_core_update_ice_state_in_call_stats(call); } #ifdef BUILD_UPNP diff --git a/coreapi/misc.c b/coreapi/misc.c index dff4c026f..df32829dc 100644 --- a/coreapi/misc.c +++ b/coreapi/misc.c @@ -806,7 +806,7 @@ void linphone_call_stop_ice_for_inactive_streams(LinphoneCall *call, SalMediaDes linphone_core_update_ice_state_in_call_stats(call); } -void _update_local_media_description_from_ice(SalMediaDescription *desc, IceSession *session) { +void _update_local_media_description_from_ice(SalMediaDescription *desc, IceSession *session, bool_t use_nortpproxy) { const char *rtp_addr, *rtcp_addr; IceSessionState session_state = ice_session_state(session); int nb_candidates; @@ -814,7 +814,7 @@ void _update_local_media_description_from_ice(SalMediaDescription *desc, IceSess bool_t result; if (session_state == IS_Completed) { - desc->ice_completed = TRUE; + if (use_nortpproxy) desc->set_nortpproxy = TRUE; result = ice_check_list_selected_valid_local_candidate(ice_session_check_list(session, 0), &rtp_addr, NULL, NULL, NULL); if (result == TRUE) { strncpy(desc->addr, rtp_addr, sizeof(desc->addr)); @@ -823,7 +823,7 @@ void _update_local_media_description_from_ice(SalMediaDescription *desc, IceSess } } else { - desc->ice_completed = FALSE; + desc->set_nortpproxy = FALSE; } strncpy(desc->ice_pwd, ice_session_local_pwd(session), sizeof(desc->ice_pwd)); strncpy(desc->ice_ufrag, ice_session_local_ufrag(session), sizeof(desc->ice_ufrag)); @@ -833,10 +833,10 @@ void _update_local_media_description_from_ice(SalMediaDescription *desc, IceSess nb_candidates = 0; if (!sal_stream_description_active(stream) || (cl == NULL)) continue; if (ice_check_list_state(cl) == ICL_Completed) { - stream->ice_completed = TRUE; + if (use_nortpproxy) stream->set_nortpproxy = TRUE; result = ice_check_list_selected_valid_local_candidate(ice_session_check_list(session, i), &rtp_addr, &stream->rtp_port, &rtcp_addr, &stream->rtcp_port); } else { - stream->ice_completed = FALSE; + stream->set_nortpproxy = FALSE; result = ice_check_list_default_local_candidate(ice_session_check_list(session, i), &rtp_addr, &stream->rtp_port, &rtcp_addr, &stream->rtcp_port); } if (result == TRUE) { diff --git a/coreapi/offeranswer.c b/coreapi/offeranswer.c index 7616b3499..bc115001a 100644 --- a/coreapi/offeranswer.c +++ b/coreapi/offeranswer.c @@ -485,7 +485,7 @@ static void initiate_incoming(const SalStreamDescription *local_cap, strcpy(result->ice_pwd, local_cap->ice_pwd); strcpy(result->ice_ufrag, local_cap->ice_ufrag); result->ice_mismatch = local_cap->ice_mismatch; - result->ice_completed = local_cap->ice_completed; + result->set_nortpproxy = local_cap->set_nortpproxy; memcpy(result->ice_candidates, local_cap->ice_candidates, sizeof(result->ice_candidates)); memcpy(result->ice_remote_candidates, local_cap->ice_remote_candidates, sizeof(result->ice_remote_candidates)); strcpy(result->name,local_cap->name); @@ -603,7 +603,7 @@ int offer_answer_initiate_incoming(const SalMediaDescription *local_capabilities strcpy(result->ice_pwd, local_capabilities->ice_pwd); strcpy(result->ice_ufrag, local_capabilities->ice_ufrag); result->ice_lite = local_capabilities->ice_lite; - result->ice_completed = local_capabilities->ice_completed; + result->set_nortpproxy = local_capabilities->set_nortpproxy; result->custom_sdp_attributes = sal_custom_sdp_attribute_clone(local_capabilities->custom_sdp_attributes); strcpy(result->name,local_capabilities->name); diff --git a/coreapi/private.h b/coreapi/private.h index 3ed87ca78..d6b683041 100644 --- a/coreapi/private.h +++ b/coreapi/private.h @@ -485,7 +485,7 @@ int linphone_core_gather_ice_candidates(LinphoneCore *lc, LinphoneCall *call); void linphone_core_update_ice_state_in_call_stats(LinphoneCall *call); void linphone_call_stats_fill(LinphoneCallStats *stats, MediaStream *ms, OrtpEvent *ev); void linphone_call_stop_ice_for_inactive_streams(LinphoneCall *call, SalMediaDescription *result); -void _update_local_media_description_from_ice(SalMediaDescription *desc, IceSession *session); +void _update_local_media_description_from_ice(SalMediaDescription *desc, IceSession *session, bool_t use_nortpproxy); void linphone_call_update_local_media_description_from_ice_or_upnp(LinphoneCall *call); void linphone_call_update_ice_from_remote_media_description(LinphoneCall *call, const SalMediaDescription *md); void linphone_call_clear_unused_ice_candidates(LinphoneCall *call, const SalMediaDescription *md); diff --git a/include/sal/sal.h b/include/sal/sal.h index 721cefbea..58c63f0c5 100644 --- a/include/sal/sal.h +++ b/include/sal/sal.h @@ -246,8 +246,8 @@ typedef struct SalStreamDescription{ SalSrtpCryptoAlgo crypto[SAL_CRYPTO_ALGO_MAX]; unsigned int crypto_local_tag; int max_rate; - bool_t implicit_rtcp_fb; - OrtpRtcpFbConfiguration rtcp_fb; + bool_t implicit_rtcp_fb; + OrtpRtcpFbConfiguration rtcp_fb; OrtpRtcpXrConfiguration rtcp_xr; SalCustomSdpAttribute *custom_sdp_attributes; SalIceCandidate ice_candidates[SAL_MEDIA_DESCRIPTION_MAX_ICE_CANDIDATES]; @@ -255,7 +255,7 @@ typedef struct SalStreamDescription{ char ice_ufrag[SAL_MEDIA_DESCRIPTION_MAX_ICE_UFRAG_LEN]; char ice_pwd[SAL_MEDIA_DESCRIPTION_MAX_ICE_PWD_LEN]; bool_t ice_mismatch; - bool_t ice_completed; + bool_t set_nortpproxy; /*Formely set by ICE to indicate to the proxy that it has nothing to do*/ bool_t rtcp_mux; bool_t pad[1]; char dtls_fingerprint[256]; @@ -285,7 +285,7 @@ typedef struct SalMediaDescription{ char ice_ufrag[SAL_MEDIA_DESCRIPTION_MAX_ICE_UFRAG_LEN]; char ice_pwd[SAL_MEDIA_DESCRIPTION_MAX_ICE_PWD_LEN]; bool_t ice_lite; - bool_t ice_completed; + bool_t set_nortpproxy; bool_t pad[2]; } SalMediaDescription; From d0e27e4e1ae1ce7ed0750f85a13d675737f4d31d Mon Sep 17 00:00:00 2001 From: Simon Morlat Date: Fri, 15 Jan 2016 22:04:41 +0100 Subject: [PATCH 10/10] update ms2 and ortp --- mediastreamer2 | 2 +- oRTP | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/mediastreamer2 b/mediastreamer2 index 005c28b9f..b6f83b3d7 160000 --- a/mediastreamer2 +++ b/mediastreamer2 @@ -1 +1 @@ -Subproject commit 005c28b9fc0321957a8b339000272b4cb5de8cc0 +Subproject commit b6f83b3d7048caf6660c7a163f74e0df89abf8ca diff --git a/oRTP b/oRTP index 35b2e7354..3ac1cac88 160000 --- a/oRTP +++ b/oRTP @@ -1 +1 @@ -Subproject commit 35b2e735421bcbaedd4422b637256987893368bc +Subproject commit 3ac1cac8859d4774ee993a1da6f0058e59a31ef4