Commit 0039298e authored by Paul Cartier's avatar Paul Cartier
Browse files

Tones refactor

- Move and refactor all tone related code to ToneManager class
- Add tone testing in Single Call and Multi Call test suites
parent c1dc3298
......@@ -1319,7 +1319,7 @@ static void sound_config_read(LinphoneCore *lc) {
/*just parse requested stream feature once at start to print out eventual errors*/
linphone_core_get_audio_features(lc);
_linphone_core_set_tone(lc,LinphoneReasonBusy,LinphoneToneBusy,NULL);
L_GET_PRIVATE_FROM_C_OBJECT(lc)->getToneManager()->setTone(LinphoneReasonBusy, LinphoneToneBusy, NULL);
}
static int _linphone_core_tls_postcheck_callback(void *data, const bctbx_x509_certificate_t *peer_cert){
......@@ -2438,7 +2438,6 @@ static void linphone_core_init(LinphoneCore * lc, LinphoneCoreCbs *cbs, LpConfig
lc->is_unreffing = FALSE;
lc->config=lp_config_ref(config);
lc->data=userdata;
lc->ringstream_autorelease=TRUE;
// We need the Sal on the Android platform helper init
lc->sal=new Sal(NULL);
......@@ -3580,19 +3579,6 @@ void linphone_core_iterate(LinphoneCore *lc){
lc_callback_obj_invoke(&lc->preview_finished_cb,lc);
}
if (lc->ringstream && lc->ringstream_autorelease && lc->dmfs_playing_start_time!=0
&& (curtime_ms/1000 - (uint64_t)lc->dmfs_playing_start_time)>5){
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);
}
}
lc->sal->iterate();
if (lc->msevq) ms_event_queue_pump(lc->msevq);
if (linphone_core_get_global_state(lc) == LinphoneGlobalConfiguring)
......@@ -3983,25 +3969,6 @@ bool_t linphone_core_incompatible_security(LinphoneCore *lc, SalMediaDescription
return linphone_core_is_media_encryption_mandatory(lc) && linphone_core_get_media_encryption(lc)==LinphoneMediaEncryptionSRTP && !sal_media_description_has_srtp(md);
}
void linphone_core_notify_incoming_call(LinphoneCore *lc, LinphoneCall *call){
/* Play the ring if this is the only call*/
if (linphone_core_get_calls_nb(lc)==1){
MSSndCard *ringcard=lc->sound_conf.lsd_card ?lc->sound_conf.lsd_card : lc->sound_conf.ring_sndcard;
L_GET_PRIVATE_FROM_C_OBJECT(lc)->setCurrentCall(L_GET_CPP_PTR_FROM_C_OBJECT(call));
if (lc->ringstream && lc->dmfs_playing_start_time!=0){
linphone_core_stop_dtmf_stream(lc);
}
if (ringcard) {
ms_snd_card_set_stream_type(ringcard, MS_SND_CARD_STREAM_RING);
linphone_ringtoneplayer_start(lc->factory, lc->ringtoneplayer, ringcard, lc->sound_conf.local_ring, 2000);
}
}else{
/* else play a tone within the context of the current call */
L_GET_PRIVATE_FROM_C_OBJECT(call)->setRingingBeep(true);
linphone_core_play_named_tone(lc,LinphoneToneCallWaiting);
}
}
LinphoneStatus linphone_core_accept_early_media_with_params(LinphoneCore *lc, LinphoneCall *call, const LinphoneCallParams *params) {
return linphone_call_accept_early_media_with_params(call, params);
}
......@@ -4112,9 +4079,6 @@ int linphone_core_preempt_sound_resources(LinphoneCore *lc){
ms_message("Pausing automatically the current call.");
err = L_GET_CPP_PTR_FROM_C_OBJECT(current_call)->pause();
}
if (lc->ringstream){
linphone_core_stop_ringing(lc);
}
return err;
}
......@@ -6029,152 +5993,16 @@ void linphone_core_set_record_file(LinphoneCore *lc, const char *file){
}
}
typedef enum{
LinphoneToneGenerator,
LinphoneLocalPlayer
}LinphoneAudioResourceType;
static MSFilter *get_audio_resource(LinphoneCore *lc, LinphoneAudioResourceType rtype, MSSndCard *card, bool_t create) {
LinphoneCall *call=linphone_core_get_current_call(lc);
AudioStream *stream=NULL;
RingStream *ringstream;
if (call){
stream=reinterpret_cast<AudioStream *>(linphone_call_get_stream(call, LinphoneStreamTypeAudio));
}else if (linphone_core_is_in_conference(lc)){
stream=linphone_conference_get_audio_stream(lc->conf_ctx);
}
if (stream){
if (rtype==LinphoneToneGenerator) return stream->dtmfgen;
if (rtype==LinphoneLocalPlayer) return stream->local_player;
return NULL;
}
if (card && lc->ringstream && card != lc->ringstream->card){
ring_stop(lc->ringstream);
lc->ringstream = NULL;
}
if (lc->ringstream == NULL) {
float amp=lp_config_get_float(lc->config,"sound","dtmf_player_amp",0.1f);
MSSndCard *ringcard=lc->sound_conf.lsd_card
? lc->sound_conf.lsd_card
: card
? card
: lc->sound_conf.ring_sndcard;
if (ringcard == NULL)
return NULL;
if (!create) return NULL;
ringstream=lc->ringstream=ring_start(lc->factory, NULL,0,ringcard);
ms_filter_call_method(lc->ringstream->gendtmf,MS_DTMF_GEN_SET_DEFAULT_AMPLITUDE,&amp);
lc->dmfs_playing_start_time = (time_t)ms_get_cur_time_ms()/1000;
}else{
ringstream=lc->ringstream;
if (lc->dmfs_playing_start_time!=0)
lc->dmfs_playing_start_time = (time_t)ms_get_cur_time_ms()/1000;
}
if (rtype==LinphoneToneGenerator) return ringstream->gendtmf;
if (rtype==LinphoneLocalPlayer) return ringstream->source;
return NULL;
}
static MSFilter *get_dtmf_gen(LinphoneCore *lc, MSSndCard *card) {
return get_audio_resource(lc,LinphoneToneGenerator, card, TRUE);
}
void linphone_core_play_dtmf(LinphoneCore *lc, char dtmf, int duration_ms){
MSSndCard *card = linphone_core_in_call(lc)
? lc->sound_conf.play_sndcard
: lc->sound_conf.ring_sndcard;
MSFilter *f=get_dtmf_gen(lc, card);
if (f==NULL){
ms_error("No dtmf generator at this time !");
return;
}
if (duration_ms > 0)
ms_filter_call_method(f, MS_DTMF_GEN_PLAY, &dtmf);
else ms_filter_call_method(f, MS_DTMF_GEN_START, &dtmf);
}
LinphoneStatus _linphone_core_play_local(LinphoneCore *lc, const char *audiofile, MSSndCard *card) {
MSFilter *f=get_audio_resource(lc,LinphoneLocalPlayer, card, TRUE);
int loopms=-1;
if (!f) return -1;
ms_filter_call_method(f,MS_PLAYER_SET_LOOP,&loopms);
if (ms_filter_call_method(f,MS_PLAYER_OPEN,(void*)audiofile)!=0){
return -1;
}
ms_filter_call_method_noarg(f,MS_PLAYER_START);
return 0;
L_GET_PRIVATE_FROM_C_OBJECT(lc)->getToneManager()->linphoneCorePlayDtmf(dtmf, duration_ms);
}
LinphoneStatus linphone_core_play_local(LinphoneCore *lc, const char *audiofile) {
return _linphone_core_play_local(lc, audiofile, NULL);
}
void linphone_core_play_named_tone(LinphoneCore *lc, LinphoneToneID toneid){
if (linphone_core_tone_indications_enabled(lc)){
const char *audiofile=linphone_core_get_tone_file(lc,toneid);
if (!audiofile){
MSFilter *f=get_dtmf_gen(lc, lc->sound_conf.play_sndcard);
MSDtmfGenCustomTone def;
if (f==NULL){
ms_error("No dtmf generator at this time !");
return;
}
memset(&def,0,sizeof(def));
def.amplitude=1;
/*these are french tones, excepted the failed one, which is USA congestion tone (does not exist in France)*/
switch(toneid){
case LinphoneToneCallOnHold:
case LinphoneToneCallWaiting:
def.duration=300;
def.frequencies[0]=440;
def.interval=2000;
break;
case LinphoneToneBusy:
def.duration=500;
def.frequencies[0]=440;
def.interval=500;
def.repeat_count=3;
break;
case LinphoneToneCallLost:
def.duration=250;
def.frequencies[0]=480;
def.frequencies[0]=620;
def.interval=250;
def.repeat_count=3;
break;
default:
ms_warning("Unhandled tone id.");
}
if (def.duration>0)
ms_filter_call_method(f, MS_DTMF_GEN_PLAY_CUSTOM,&def);
}else{
_linphone_core_play_local(lc,audiofile, lc->sound_conf.play_sndcard);
}
}
}
void linphone_core_play_call_error_tone(LinphoneCore *lc, LinphoneReason reason){
if (linphone_core_tone_indications_enabled(lc)){
LinphoneToneDescription *tone=linphone_core_get_call_error_tone(lc,reason);
if (tone){
if (tone->audiofile){
_linphone_core_play_local(lc, tone->audiofile, lc->sound_conf.play_sndcard);
}else if (tone->toneid != LinphoneToneUndefined){
linphone_core_play_named_tone(lc, tone->toneid);
}
}
}
return L_GET_PRIVATE_FROM_C_OBJECT(lc)->getToneManager()->linphoneCorePlayLocal(audiofile);
}
void linphone_core_stop_dtmf(LinphoneCore *lc){
MSFilter *f=get_audio_resource(lc, LinphoneToneGenerator, NULL, FALSE);
if (f!=NULL)
ms_filter_call_method_noarg (f, MS_DTMF_GEN_STOP);
L_GET_PRIVATE_FROM_C_OBJECT(lc)->getToneManager()->linphoneCoreStopDtmf();
}
void *linphone_core_get_user_data(const LinphoneCore *lc){
......@@ -6892,31 +6720,15 @@ bool_t linphone_core_keep_alive_enabled(LinphoneCore* lc) {
}
void linphone_core_start_dtmf_stream(LinphoneCore* lc) {
get_dtmf_gen(lc, lc->sound_conf.ring_sndcard); /*make sure ring stream is started*/
lc->ringstream_autorelease=FALSE; /*disable autorelease mode*/
L_GET_PRIVATE_FROM_C_OBJECT(lc)->getToneManager()->linphoneCoreStartDtmfStream();
}
void linphone_core_stop_ringing(LinphoneCore* lc) {
LinphoneCall *call=linphone_core_get_current_call(lc);
if (linphone_ringtoneplayer_is_started(lc->ringtoneplayer)) {
linphone_ringtoneplayer_stop(lc->ringtoneplayer);
}
if (lc->ringstream) {
ring_stop(lc->ringstream);
lc->ringstream=NULL;
lc->dmfs_playing_start_time=0;
lc->ringstream_autorelease=TRUE;
}
if (call && L_GET_PRIVATE_FROM_C_OBJECT(call)->getRingingBeep()) {
linphone_core_stop_dtmf(lc);
L_GET_PRIVATE_FROM_C_OBJECT(call)->setRingingBeep(false);
}
L_GET_PRIVATE_FROM_C_OBJECT(lc)->getToneManager()->linphoneCoreStopRinging();
}
void linphone_core_stop_dtmf_stream(LinphoneCore* lc) {
if (lc->dmfs_playing_start_time!=0) {
linphone_core_stop_ringing(lc);
}
L_GET_PRIVATE_FROM_C_OBJECT(lc)->getToneManager()->linphoneCoreStopDtmfStream();
}
int linphone_core_get_max_calls(LinphoneCore *lc) {
......
......@@ -21,6 +21,7 @@
#include "linphone/lpconfig.h"
#include "linphone/wrapper_utils.h"
#include "mediastreamer2/mediastream.h"
#include "core/core-p.h"
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
......@@ -574,44 +575,12 @@ void linphone_tone_description_destroy(LinphoneToneDescription *obj){
ms_free(obj);
}
static LinphoneToneDescription *linphone_core_lookup_tone(const LinphoneCore *lc, LinphoneReason reason, LinphoneToneID id){
const bctbx_list_t *elem;
for (elem=lc->tones;elem!=NULL;elem=elem->next){
LinphoneToneDescription *tone=(LinphoneToneDescription*)elem->data;
if (reason == LinphoneReasonNone){
if (tone->toneid == id && tone->reason == LinphoneReasonNone) return tone;
}else{
if (tone->reason==reason) return tone;
}
}
return NULL;
}
LinphoneToneDescription *linphone_core_get_call_error_tone(const LinphoneCore *lc, LinphoneReason reason){
return linphone_core_lookup_tone(lc, reason, LinphoneToneUndefined);
}
const char *linphone_core_get_tone_file(const LinphoneCore *lc, LinphoneToneID id){
LinphoneToneDescription *tone = linphone_core_lookup_tone(lc, LinphoneReasonNone, id);
return tone ? tone->audiofile : NULL;
}
void _linphone_core_set_tone(LinphoneCore *lc, LinphoneReason reason, LinphoneToneID id, const char *audiofile){
LinphoneToneDescription *tone = linphone_core_lookup_tone(lc,reason, id);
if (tone){
lc->tones=bctbx_list_remove(lc->tones,tone);
linphone_tone_description_destroy(tone);
}
tone=linphone_tone_description_new(reason,id,audiofile);
lc->tones=bctbx_list_append(lc->tones,tone);
}
void linphone_core_set_call_error_tone(LinphoneCore *lc, LinphoneReason reason, const char *audiofile){
_linphone_core_set_tone(lc,reason,LinphoneToneUndefined, audiofile);
L_GET_PRIVATE_FROM_C_OBJECT(lc)->getToneManager()->setTone(reason, LinphoneToneUndefined, audiofile);
}
void linphone_core_set_tone(LinphoneCore *lc, LinphoneToneID id, const char *audiofile){
_linphone_core_set_tone(lc, LinphoneReasonNone, id, audiofile);
L_GET_PRIVATE_FROM_C_OBJECT(lc)->getToneManager()->setTone(LinphoneReasonNone, id, audiofile);
}
const MSCryptoSuite * linphone_core_get_srtp_crypto_suites(LinphoneCore *lc){
......
......@@ -287,7 +287,6 @@ void linphone_core_start_waiting(LinphoneCore *lc, const char *purpose);
void linphone_core_update_progress(LinphoneCore *lc, const char *purpose, float progresses);
void linphone_core_stop_waiting(LinphoneCore *lc);
void linphone_core_notify_incoming_call(LinphoneCore *lc, LinphoneCall *call);
bool_t linphone_core_incompatible_security(LinphoneCore *lc, SalMediaDescription *md);
extern LinphonePrivate::Sal::Callbacks linphone_sal_callbacks;
LINPHONE_PUBLIC bool_t linphone_core_rtcp_enabled(const LinphoneCore *lc);
......@@ -345,10 +344,6 @@ const LinphoneParticipantImdnState *_linphone_participant_imdn_state_from_cpp_ob
LinphoneToneDescription * linphone_tone_description_new(LinphoneReason reason, LinphoneToneID id, const char *audiofile);
void linphone_tone_description_destroy(LinphoneToneDescription *obj);
LinphoneToneDescription *linphone_core_get_call_error_tone(const LinphoneCore *lc, LinphoneReason reason);
void linphone_core_play_call_error_tone(LinphoneCore *lc, LinphoneReason reason);
void _linphone_core_set_tone(LinphoneCore *lc, LinphoneReason reason, LinphoneToneID id, const char *audiofile);
LINPHONE_PUBLIC const char *linphone_core_get_tone_file(const LinphoneCore *lc, LinphoneToneID id);
void linphone_task_list_init(LinphoneTaskList *t);
void linphone_task_list_add(LinphoneTaskList *t, LinphoneCoreIterateHook hook, void *hook_data);
......@@ -419,7 +414,6 @@ void linphone_chat_message_set_message_state_changed_cb_user_data(LinphoneChatMe
void * linphone_chat_message_get_message_state_changed_cb_user_data(LinphoneChatMessage* msg);
LinphoneChatRoom *_linphone_core_create_chat_room_from_call(LinphoneCall *call);
void linphone_core_play_named_tone(LinphoneCore *lc, LinphoneToneID id);
bool_t linphone_core_tone_indications_enabled(LinphoneCore*lc);
const char *linphone_core_create_uuid(LinphoneCore *lc);
void linphone_configure_op(LinphoneCore *lc, LinphonePrivate::SalOp *op, const LinphoneAddress *dest, SalCustomHeader *headers, bool_t with_contact);
......
......@@ -762,7 +762,6 @@ namespace LinphonePrivate {
MSList *friends_lists; \
MSList *auth_info; \
struct _RingStream *ringstream; \
time_t dmfs_playing_start_time; \
LCCallbackObj preview_finished_cb; \
MSList *queued_calls; \
MSList *call_logs; \
......@@ -805,7 +804,6 @@ namespace LinphonePrivate {
bool_t network_reachable_to_be_notified; \
bool_t use_preview_window; \
bool_t network_last_status; \
bool_t ringstream_autorelease; \
bool_t vtables_running; \
bool_t send_call_stats_periodical_updates; \
bool_t forced_ice_relay; \
......
......@@ -199,4 +199,15 @@ char * linphone_core_get_device_identity(LinphoneCore *lc) {
return identity;
}
LinphoneCoreToneManagerStats *linphone_core_get_tone_manager_stats(LinphoneCore *lc) {
return L_GET_PRIVATE_FROM_C_OBJECT(lc)->getToneManager()->getStats();
}
void linphone_core_reset_tone_manager_stats(LinphoneCore *lc) {
L_GET_PRIVATE_FROM_C_OBJECT(lc)->getToneManager()->resetStats();
}
const char *linphone_core_get_tone_file(LinphoneCore *lc, LinphoneToneID id){
LinphoneToneDescription *tone = L_GET_PRIVATE_FROM_C_OBJECT(lc)->getToneManager()->getToneFromId(id);
return tone ? tone->audiofile : NULL;
}
......@@ -42,6 +42,16 @@ typedef enum _LinphoneProxyConfigAddressComparisonResult{
LinphoneProxyConfigAddressWeakEqual
} LinphoneProxyConfigAddressComparisonResult;
typedef struct _LinphoneCoreToneManagerStats {
int number_of_startRingbackTone;
int number_of_startRingtone;
int number_of_startErrorTone;
int number_of_startNamedTone;
int number_of_stopRingbackTone;
int number_of_stopRingtone;
int number_of_stopTone;
} LinphoneCoreToneManagerStats;
#ifdef __cplusplus
extern "C" {
#endif
......@@ -53,7 +63,6 @@ LINPHONE_PUBLIC int linphone_core_get_local_ip_for(int type, const char *dest, c
LINPHONE_PUBLIC void linphone_core_enable_forced_ice_relay(LinphoneCore *lc, bool_t enable);
LINPHONE_PUBLIC void linphone_core_set_zrtp_not_available_simulation(LinphoneCore *lc, bool_t enabled);
LINPHONE_PUBLIC belle_http_provider_t *linphone_core_get_http_provider(const LinphoneCore *lc);
LINPHONE_PUBLIC const char *linphone_core_get_tone_file(const LinphoneCore *lc, LinphoneToneID id);
LINPHONE_PUBLIC IceSession * linphone_call_get_ice_session(const LinphoneCall *call);
LINPHONE_PUBLIC const struct addrinfo *linphone_core_get_stun_server_addrinfo(LinphoneCore *lc);
LINPHONE_PUBLIC void linphone_core_enable_send_call_stats_periodical_updates(LinphoneCore *lc, bool_t enabled);
......@@ -129,6 +138,10 @@ LINPHONE_PUBLIC int linphone_remote_provisioning_load_file( LinphoneCore* lc, co
LINPHONE_PUBLIC char *linphone_core_get_device_identity(LinphoneCore *lc);
LINPHONE_PUBLIC LinphoneCoreToneManagerStats *linphone_core_get_tone_manager_stats(LinphoneCore *lc);
LINPHONE_PUBLIC void linphone_core_reset_tone_manager_stats(LinphoneCore *lc);
LINPHONE_PUBLIC const char *linphone_core_get_tone_file(LinphoneCore *lc, LinphoneToneID id);
/**
* Send an XML-RPC request to delete a Linphone account.
* @param[in] creator LinphoneAccountCreator object
......
......@@ -165,6 +165,7 @@ set(LINPHONE_CXX_OBJECTS_PRIVATE_HEADER_FILES
conference/session/call-session.h
conference/session/media-session.h
conference/session/port-config.h
conference/session/tone-manager.h
containers/lru-cache.h
content/content-disposition.h
content/content-manager.h
......@@ -330,6 +331,7 @@ set(LINPHONE_CXX_OBJECTS_SOURCE_FILES
conference/remote-conference.cpp
conference/session/call-session.cpp
conference/session/media-session.cpp
conference/session/tone-manager.cpp
content/content-disposition.cpp
content/content-manager.cpp
content/content-type.cpp
......
......@@ -58,9 +58,6 @@ public:
MediaStream *getMediaStream (LinphoneStreamType type) const;
SalCallOp *getOp () const;
bool getRingingBeep () const { return ringingBeep; }
void setRingingBeep (bool value) { ringingBeep = value; }
bool getSpeakerMuted () const;
void setSpeakerMuted (bool muted);
......@@ -109,12 +106,7 @@ private:
void onSetCurrentSession (const std::shared_ptr<CallSession> &session) override;
void onFirstVideoFrameDecoded (const std::shared_ptr<CallSession> &session) override;
void onResetFirstVideoFrameDecoded (const std::shared_ptr<CallSession> &session) override;
void onPlayErrorTone (const std::shared_ptr<CallSession> &session, LinphoneReason reason) override;
void onRingbackToneRequested (const std::shared_ptr<CallSession> &session, bool requested) override;
void onStartRinging (const std::shared_ptr<CallSession> &session) override;
void onStopRinging (const std::shared_ptr<CallSession> &session) override;
void onStopRingingIfInCall (const std::shared_ptr<CallSession> &session) override;
void onStopRingingIfNeeded (const std::shared_ptr<CallSession> &session) override;
bool areSoundResourcesAvailable (const std::shared_ptr<CallSession> &session) override;
bool isPlayingRingbackTone (const std::shared_ptr<CallSession> &session) override;
void onRealTimeTextCharacterReceived (const std::shared_ptr<CallSession> &session, RealtimeTextReceivedCharacter *character) override;
......@@ -125,7 +117,6 @@ private:
CallCallbackObj nextVideoFrameDecoded;
bool ringingBeep = false;
bool playingRingbackTone = false;
BackgroundTask bgTask;
......
......@@ -190,7 +190,7 @@ void CallPrivate::terminateBecauseOfLostMedia () {
lInfo() << "Call [" << q << "]: Media connectivity with " << q->getRemoteAddress().asString()
<< " is lost, call is going to be terminated";
static_pointer_cast<MediaSession>(getActiveSession())->terminateBecauseOfLostMedia();
linphone_core_play_named_tone(q->getCore()->getCCore(), LinphoneToneCallLost);
q->getCore()->getPrivate()->getToneManager()->startNamedTone(getActiveSession(), LinphoneToneCallLost);
}
// -----------------------------------------------------------------------------
......@@ -222,16 +222,6 @@ bool CallPrivate::onCallSessionAccepted (const shared_ptr<CallSession> &session)
if (q->getCore()->getCurrentCall() != q->getSharedFromThis())
linphone_core_preempt_sound_resources(lc);
// Stop ringing
if (linphone_ringtoneplayer_is_started(lc->ringtoneplayer)) {
lInfo() << "Stop ringing";
linphone_core_stop_ringing(lc);
wasRinging = true;
}
if (ringingBeep) {
linphone_core_stop_dtmf(lc);
ringingBeep = false;
}
return wasRinging;
}
......@@ -276,10 +266,6 @@ void CallPrivate::onCallSessionSetTerminated (const shared_ptr<CallSession> &ses
lError() << "Could not remove the call from the list!!!";
if (core->conf_ctx)
linphone_conference_on_call_terminating(core->conf_ctx, L_GET_C_BACK_PTR(q));
if (ringingBeep) {
linphone_core_stop_dtmf(core);
ringingBeep = false;
}
#if 0
if (lcall->chat_room)
linphone_chat_room_set_call(lcall->chat_room, nullptr);
......@@ -294,6 +280,8 @@ void CallPrivate::onCallSessionStartReferred (const shared_ptr<CallSession> &ses
void CallPrivate::onCallSessionStateChanged (const shared_ptr<CallSession> &session, CallSession::State state, const string &message) {
L_Q();
q->getCore()->getPrivate()->getToneManager()->update(session);
switch(state){
case CallSession::State::OutgoingInit:
case CallSession::State::IncomingReceived:
......@@ -352,7 +340,10 @@ void CallPrivate::onIncomingCallSessionNotified (const shared_ptr<CallSession> &
void CallPrivate::onIncomingCallSessionStarted (const shared_ptr<CallSession> &session) {
L_Q();
linphone_core_notify_incoming_call(q->getCore()->getCCore(), L_GET_C_BACK_PTR(q));
if (linphone_core_get_calls_nb(q->getCore()->getCCore())==1) {
L_GET_PRIVATE_FROM_C_OBJECT(q->getCore()->getCCore())->setCurrentCall(q->getSharedFromThis());
}
q->getCore()->getPrivate()->getToneManager()->startRingtone(session);
}
void CallPrivate::onIncomingCallSessionTimeoutCheck (const shared_ptr<CallSession> &session, int elapsed, bool oneSecondElapsed) {
......@@ -442,11 +433,6 @@ void CallPrivate::requestNotifyNextVideoFrameDecoded(){
static_pointer_cast<MediaSession>(getActiveSession())->requestNotifyNextVideoFrameDecoded();
}
void CallPrivate::onPlayErrorTone (const shared_ptr<CallSession> &session, LinphoneReason reason) {
L_Q();
linphone_core_play_call_error_tone(q->getCore()->getCCore(), reason);
}
void CallPrivate::onRingbackToneRequested (const shared_ptr<CallSession> &session, bool requested) {
L_Q();
if (requested && linphone_core_get_remote_ringback_tone(q->getCore()->getCCore()))
......@@ -455,44 +441,6 @@ void CallPrivate::onRingbackToneRequested (const shared_ptr<CallSession> &sessio
playingRingbackTone = false;
}
void CallPrivate::onStartRinging (const shared_ptr<CallSession> &session) {
L_Q();
LinphoneCore *lc = q->getCore()->getCCore();
if (lc->ringstream)
return; // Already ringing!
startRemoteRing();
}
void CallPrivate::onStopRinging (const shared_ptr<CallSession> &session) {
L_Q();
linphone_core_stop_ringing(q->getCore()->getCCore());
}
void CallPrivate::onStopRingingIfInCall (const shared_ptr<CallSession> &session) {
L_Q();
LinphoneCore *lc = q->getCore()->getCCore();
// We stop the ring only if we have this current call or if we are in call
if ((q->getCore()->getCallCount() == 1) || linphone_core_in_call(lc)) {
linphone_core_stop_ringing(lc);
}
}
void CallPrivate::onStopRingingIfNeeded (const shared_ptr<CallSession> &session) {
L_Q();
LinphoneCore *lc = q->getCore()->getCCore();
bool stopRinging = true;
bool ringDuringEarlyMedia = !!linphone_core_get_ring_during_incoming_early_media(lc);
for (const auto &call : q->getCore()->getCalls()) {
if ((call->getState() == CallSession::State::IncomingReceived)
|| (ringDuringEarlyMedia && call->getState() == CallSession::State::IncomingEarlyMedia)) {
stopRinging = false;
break;
}
}
if (stopRinging)
linphone_core_stop_ringing(lc);
}
bool CallPrivate::areSoundResourcesAvailable (const shared_ptr<CallSession> &session) {
L_Q();
LinphoneCore *lc = q->getCore()->getCCore();
......
......@@ -70,12 +70,7 @@ public:
virtual void onFirstVideoFrameDecoded (const std::shared_ptr<CallSession> &session) {}
virtual void onResetFirstVideoFrameDecoded (const std::shared_ptr<CallSession> &session) {}
virtual void onPlayErrorTone (const std::shared_ptr<CallSession> &session, LinphoneReason reason) {}
virtual void onRingbackToneRequested (const std::shared_ptr<CallSession> &session, bool requested) {}
virtual void onStartRinging (const std::shared_ptr<CallSession> &session) {}
virtual void onStopRinging (const std::shared_ptr<CallSession> &session) {}
virtual void onStopRingingIfInCall (const std::shared_ptr<CallSession> &session) {}
virtual void onStopRingingIfNeeded (const std::shared_ptr<CallSession> &session) {}
virtual bool areSoundResourcesAvailable (const std::shared_ptr<CallSession> &session) { return true; }
virtual bool isPlayingRingbackTone (const std::shared_ptr<CallSession> &session) { return false; }
......
......@@ -301,8 +301,6 @@ bool CallSessionPrivate::failure () {
else
setState(CallSession::State::End, ei->full_string ? ei->full_string : "");
}
if ((ei->reason != SalReasonNone) && listener)
listener->onPlayErrorTone(q->getSharedFromThis(), linphone_reason_from_sal(ei->reason));
}
if (referer) {
// Notify referer of the failure
......@@ -344,12 +342,8 @@ void CallSessionPrivate::referred (const Address &referToAddr) {
}