Commit 04c43a9f authored by Gautier Pelloux-Prayer's avatar Gautier Pelloux-Prayer
Browse files

quality_reporting: avoid crash if hanging up too soon in LinphoneCallOutgoingInit state

parent 41aaa916
......@@ -22,7 +22,7 @@
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
#include "private.h"
#include "lpconfig.h"
......@@ -87,7 +87,7 @@ void linphone_core_conference_check_uninit(LinphoneCore *lc){
ctx->record_endpoint=NULL;
}
}
if (ms_audio_conference_get_size(ctx->conf)==0){
ms_audio_conference_destroy(ctx->conf);
ctx->conf=NULL;
......@@ -110,7 +110,7 @@ void linphone_call_add_to_conf(LinphoneCall *call, bool_t muted){
void linphone_call_remove_from_conf(LinphoneCall *call){
LinphoneCore *lc=call->core;
LinphoneConference *conf=&lc->conf_ctx;
ms_audio_conference_remove_member(conf->conf,call->endpoint);
ms_audio_endpoint_release_from_stream(call->endpoint);
call->endpoint=NULL;
......@@ -128,12 +128,12 @@ static void add_local_endpoint(LinphoneConference *conf,LinphoneCore *lc){
/*create a dummy audiostream in order to extract the local part of it */
/* network address and ports have no meaning and are not used here. */
AudioStream *st=audio_stream_new(65000,65001,FALSE);
MSSndCard *playcard=lc->sound_conf.lsd_card ?
MSSndCard *playcard=lc->sound_conf.lsd_card ?
lc->sound_conf.lsd_card : lc->sound_conf.play_sndcard;
MSSndCard *captcard=lc->sound_conf.capt_sndcard;
const MSAudioConferenceParams *params=ms_audio_conference_get_params(conf->conf);
conf->local_dummy_profile=make_dummy_profile(params->samplerate);
audio_stream_start_full(st, conf->local_dummy_profile,
"127.0.0.1",
65000,
......@@ -151,7 +151,7 @@ static void add_local_endpoint(LinphoneConference *conf,LinphoneCore *lc){
conf->local_participant=st;
conf->local_endpoint=ms_audio_endpoint_get_from_stream(st,FALSE);
ms_audio_conference_add_member(conf->conf,conf->local_endpoint);
}
/**
......@@ -166,7 +166,7 @@ float linphone_core_get_conference_local_input_volume(LinphoneCore *lc){
float vol=0;
ms_filter_call_method(st->volsend,MS_VOLUME_GET,&vol);
return vol;
}
return LINPHONE_VOLUME_DB_LOWEST;
}
......@@ -175,22 +175,22 @@ float linphone_core_get_conference_local_input_volume(LinphoneCore *lc){
* Merge a call into a conference.
* @param lc the linphone core
* @param call an established call, either in LinphoneCallStreamsRunning or LinphoneCallPaused state.
*
*
* If this is the first call that enters the conference, the virtual conference will be created automatically.
* If the local user was actively part of the call (ie not in paused state), then the local user is automatically entered into the conference.
* If the call was in paused state, then it is automatically resumed when entering into the conference.
*
*
* @return 0 if successful, -1 otherwise.
**/
int linphone_core_add_to_conference(LinphoneCore *lc, LinphoneCall *call){
LinphoneConference *conf=&lc->conf_ctx;
if (call->current_params->in_conference){
ms_error("Already in conference");
return -1;
}
conference_check_init(&lc->conf_ctx, lp_config_get_int(lc->config, "sound","conference_rate",16000));
if (call->state==LinphoneCallPaused){
call->params->in_conference=TRUE;
call->params->has_video=FALSE;
......@@ -199,7 +199,7 @@ int linphone_core_add_to_conference(LinphoneCore *lc, LinphoneCall *call){
LinphoneCallParams *params=linphone_call_params_copy(linphone_call_get_current_params(call));
params->in_conference=TRUE;
params->has_video=FALSE;
if (call->audiostream || call->videostream){
linphone_call_stop_media_streams(call); /*free the audio & video local resources*/
linphone_call_init_media_streams(call);
......@@ -280,15 +280,15 @@ static int convert_conference_to_call(LinphoneCore *lc){
* Remove a call from the conference.
* @param lc the linphone core
* @param call a call that has been previously merged into the conference.
*
*
* After removing the remote participant belonging to the supplied call, the call becomes a normal call in paused state.
* If one single remote participant is left alone together with the local user in the conference after the removal, then the conference is
* automatically transformed into a simple call in StreamsRunning state.
* The conference's resources are then automatically destroyed.
*
*
* In other words, unless linphone_core_leave_conference() is explicitely called, the last remote participant of a conference is automatically
* put in a simple call in running state.
*
*
* @return 0 if successful, -1 otherwise.
**/
int linphone_core_remove_from_conference(LinphoneCore *lc, LinphoneCall *call){
......@@ -311,11 +311,6 @@ int linphone_core_remove_from_conference(LinphoneCore *lc, LinphoneCall *call){
return err;
}
/**
* Indicates whether the local participant is part of the conference.
* @param lc the linphone core
* @return TRUE if the local participant is in the conference, FALSE otherwise.
**/
bool_t linphone_core_is_in_conference(const LinphoneCore *lc){
return lc->conf_ctx.local_participant!=NULL;
}
......@@ -336,12 +331,12 @@ int linphone_core_leave_conference(LinphoneCore *lc){
/**
* Moves the local participant inside the conference.
* @param lc the linphone core
*
* Makes the local participant to join the conference.
*
* Makes the local participant to join the conference.
* Typically, the local participant is by default always part of the conference when joining an active call into a conference.
* However, by calling linphone_core_leave_conference() and linphone_core_enter_conference() the application can decide to temporarily
* move out and in the local participant from the conference.
*
*
* @return 0 if successful, -1 otherwise
**/
int linphone_core_enter_conference(LinphoneCore *lc){
......@@ -360,9 +355,9 @@ int linphone_core_enter_conference(LinphoneCore *lc){
/**
* Add all calls into a conference.
* @param lc the linphone core
*
*
* Merge all established calls (either in LinphoneCallStreamsRunning or LinphoneCallPaused) into a conference.
*
*
* @return 0 if successful, -1 otherwise
**/
int linphone_core_add_all_to_conference(LinphoneCore *lc) {
......@@ -381,9 +376,9 @@ int linphone_core_add_all_to_conference(LinphoneCore *lc) {
/**
* Terminates the conference and the calls associated with it.
* @param lc the linphone core
*
*
* All the calls that were merged to the conference are terminated, and the conference resources are destroyed.
*
*
* @return 0 if successful, -1 otherwise
**/
int linphone_core_terminate_conference(LinphoneCore *lc) {
......@@ -404,10 +399,10 @@ int linphone_core_terminate_conference(LinphoneCore *lc) {
/**
* Returns the number of participants to the conference, including the local participant.
* @param lc the linphone core
*
*
* Typically, after merging two calls into the conference, there is total of 3 participants:
* the local participant (or local user), and two remote participants that were the destinations of the two previously establised calls.
*
*
* @return the number of participants to the conference
**/
int linphone_core_get_conference_size(LinphoneCore *lc) {
......
......@@ -3797,6 +3797,11 @@ LINPHONE_PUBLIC LinphoneCall* linphone_core_find_call_from_uri(const LinphoneCor
LINPHONE_PUBLIC int linphone_core_add_to_conference(LinphoneCore *lc, LinphoneCall *call);
LINPHONE_PUBLIC int linphone_core_add_all_to_conference(LinphoneCore *lc);
LINPHONE_PUBLIC int linphone_core_remove_from_conference(LinphoneCore *lc, LinphoneCall *call);
/**
* Indicates whether the local participant is part of a conference.
* @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 int linphone_core_enter_conference(LinphoneCore *lc);
LINPHONE_PUBLIC int linphone_core_leave_conference(LinphoneCore *lc);
......
......@@ -481,7 +481,8 @@ void linphone_reporting_update_media_info(LinphoneCall * call, int stats_type) {
reporting_session_report_t * report = call->log->reporting.reports[stats_type];
char * dialog_id;
if (!media_report_enabled(call, stats_type))
// call->op might be already released if hanging up in state LinphoneCallOutgoingInit
if (!media_report_enabled(call, stats_type) || call->op == NULL)
return;
dialog_id = sal_op_get_dialog_id(call->op);
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment