diff --git a/coreapi/linphonecall.c b/coreapi/linphonecall.c index a0b20ec63..fa024a590 100644 --- a/coreapi/linphonecall.c +++ b/coreapi/linphonecall.c @@ -2929,6 +2929,16 @@ static RtpSession * create_audio_rtp_io_session(LinphoneCall *call) { return rtp_session; } +static void linphone_call_set_on_hold_file(LinphoneCall *call, const char *file){ + if (call->onhold_file){ + ms_free(call->onhold_file); + call->onhold_file = NULL; + } + if (file){ + call->onhold_file = ms_strdup(file); + } +} + static void linphone_call_start_audio_stream(LinphoneCall *call, LinphoneCallState next_state, bool_t use_arc){ LinphoneCore *lc=call->core; int used_pt=-1; @@ -3069,12 +3079,6 @@ static void linphone_call_start_audio_stream(LinphoneCall *call, LinphoneCallSta &io); if (err == 0){ post_configure_audio_streams(call, (call->all_muted || call->audio_muted) && !call->playing_ringbacktone); - if (file_to_play){ - MSFilter *player = audio_stream_open_remote_play(call->audiostream, file_to_play); - if (player){ - ms_filter_call_method_noarg(player, MS_PLAYER_START); - } - } } } @@ -3097,6 +3101,7 @@ static void linphone_call_start_audio_stream(LinphoneCall *call, LinphoneCallSta call->current_params->low_bandwidth=call->params->low_bandwidth; }else ms_warning("No audio stream accepted ?"); } + linphone_call_set_on_hold_file(call, file_to_play); } #ifdef VIDEO_ENABLED @@ -3428,6 +3433,13 @@ void linphone_call_start_media_streams(LinphoneCall *call, LinphoneCallState nex if (call->audiostream) audio_stream_link_video(call->audiostream,call->videostream); linphone_call_start_video_stream(call, next_state); } + /*the onhold file is to be played once both audio and video are ready.*/ + if (call->onhold_file && call->audiostream){ + MSFilter *player = audio_stream_open_remote_play(call->audiostream, call->onhold_file); + if (player){ + ms_filter_call_method_noarg(player, MS_PLAYER_START); + } + } call->up_bw=linphone_core_get_upload_bandwidth(lc); diff --git a/coreapi/private.h b/coreapi/private.h index 6f7e033ea..1a10bed92 100644 --- a/coreapi/private.h +++ b/coreapi/private.h @@ -318,6 +318,7 @@ struct _LinphoneCall{ belle_sip_source_t *dtmfs_timer; /*DTMF timer needed to send a DTMF sequence*/ char *dtls_certificate_fingerprint; /**> This fingerprint is computed during stream init and is stored in call to be used when making local media description */ + char *onhold_file; /*set if a on-hold file is to be played*/ LinphoneChatRoom *chat_room; bool_t refer_pending; bool_t expect_media_in_ack; diff --git a/tools/auto_answer.c b/tools/auto_answer.c index 174d9e235..8cedc9bc0 100644 --- a/tools/auto_answer.c +++ b/tools/auto_answer.c @@ -55,7 +55,7 @@ static void call_state_changed(LinphoneCore *lc, LinphoneCall *call, LinphoneCal LinphoneCallParams * call_params; switch(cstate){ case LinphoneCallIncomingReceived: - ms_message("Incoming call arrive !\n"); + ms_message("Incoming call arriving !\n"); /* accept the incoming call*/ call_params = linphone_core_create_call_params(lc, call); linphone_call_params_enable_video(call_params,TRUE); @@ -63,7 +63,6 @@ static void call_state_changed(LinphoneCore *lc, LinphoneCall *call, LinphoneCal linphone_call_params_set_video_direction(call_params,LinphoneMediaDirectionSendOnly); linphone_core_accept_call_with_params(lc,call,call_params); linphone_call_params_destroy(call_params); - break; default: break; @@ -74,6 +73,7 @@ static void helper(const char *progname) { printf("%s --help\n" "\t\t\t--listening-uri uri to listen on, default [sip:localhost:5060]\n" "\t\t\t--max-call-duration max duration of a call in seconds, default [3600]\n" + "\t\t\t--media-file \n" "\t\t\t--verbose\n", progname); exit(0); } @@ -88,6 +88,7 @@ int main(int argc, char *argv[]){ char * tmp = NULL; LpConfig * lp_config = lp_config_new(NULL); int max_call_duration=3600; + static const char *media_file = NULL; policy.automatically_accept=TRUE; signal(SIGINT,stop); @@ -115,6 +116,11 @@ int main(int argc, char *argv[]){ helper(); break; }*/ + } else if (strcmp(argv[i], "--media-file") == 0){ + i++; + if (i