mirror of
https://gitlab.linphone.org/BC/public/linphone-iphone.git
synced 2026-01-26 23:58:17 +00:00
add function to override common telephony tones by wav files
This commit is contained in:
parent
c73d5d5fc5
commit
a7aab35b4f
5 changed files with 87 additions and 47 deletions
|
|
@ -2525,7 +2525,7 @@ static void linphone_core_disconnected(LinphoneCore *lc, LinphoneCall *call){
|
|||
if (lc->vtable.display_warning!=NULL)
|
||||
lc->vtable.display_warning(lc,temp);
|
||||
linphone_core_terminate_call(lc,call);
|
||||
linphone_core_play_named_tone(lc,LinphoneToneCallFailed);
|
||||
linphone_core_play_named_tone(lc,LinphoneToneCallLost);
|
||||
}
|
||||
|
||||
static void handle_ice_events(LinphoneCall *call, OrtpEvent *ev){
|
||||
|
|
|
|||
|
|
@ -610,7 +610,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_call_error_tone(lc,LinphoneReasonBusy,LinphoneToneBusy,NULL);
|
||||
_linphone_core_set_tone(lc,LinphoneReasonBusy,LinphoneToneBusy,NULL);
|
||||
}
|
||||
|
||||
static void certificates_config_read(LinphoneCore *lc)
|
||||
|
|
@ -5441,41 +5441,46 @@ int linphone_core_play_local(LinphoneCore *lc, const char *audiofile){
|
|||
|
||||
void linphone_core_play_named_tone(LinphoneCore *lc, LinphoneToneID toneid){
|
||||
if (linphone_core_tone_indications_enabled(lc)){
|
||||
MSFilter *f=get_dtmf_gen(lc);
|
||||
MSDtmfGenCustomTone def;
|
||||
if (f==NULL){
|
||||
ms_error("No dtmf generator at this time !");
|
||||
return;
|
||||
const char *audiofile=linphone_core_get_tone_file(lc,toneid);
|
||||
if (!audiofile){
|
||||
MSFilter *f=get_dtmf_gen(lc);
|
||||
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);
|
||||
}
|
||||
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 LinphoneToneCallFailed:
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -2328,7 +2328,27 @@ LINPHONE_PUBLIC bool_t linphone_core_is_provisioning_transient(LinphoneCore *lc)
|
|||
|
||||
LINPHONE_PUBLIC int linphone_core_migrate_to_multi_transport(LinphoneCore *lc);
|
||||
|
||||
|
||||
/**
|
||||
* Enum listing frequent telephony tones.
|
||||
**/
|
||||
enum _LinphoneToneID{
|
||||
LinphoneToneUndefined, /**<Not a tone */
|
||||
LinphoneToneBusy, /**<Busy tone */
|
||||
LinphoneToneCallWaiting, /**Call waiting tone */
|
||||
LinphoneToneCallOnHold, /**Call on hold tone */
|
||||
LinphoneToneCallLost /**Tone played when call is abruptly disconnected (media lost)*/
|
||||
};
|
||||
|
||||
/**
|
||||
* Enum typedef for representing frequent telephony tones.
|
||||
**/
|
||||
typedef enum _LinphoneToneID LinphoneToneID;
|
||||
|
||||
|
||||
LINPHONE_PUBLIC void linphone_core_set_call_error_tone(LinphoneCore *lc, LinphoneReason reason, const char *audiofile);
|
||||
|
||||
LINPHONE_PUBLIC void linphone_core_set_tone(LinphoneCore *lc, LinphoneToneID id, const char *audiofile);
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
|
|
|||
|
|
@ -1339,7 +1339,16 @@ LinphoneToneDescription *linphone_core_get_call_error_tone(const LinphoneCore *l
|
|||
return NULL;
|
||||
}
|
||||
|
||||
void _linphone_core_set_call_error_tone(LinphoneCore *lc, LinphoneReason reason, LinphoneToneID id, const char *audiofile){
|
||||
const char *linphone_core_get_tone_file(const LinphoneCore *lc, LinphoneToneID id){
|
||||
const MSList *elem;
|
||||
for (elem=lc->tones;elem!=NULL;elem=elem->next){
|
||||
LinphoneToneDescription *tone=(LinphoneToneDescription*)elem->data;
|
||||
if (tone->toneid==id && tone->reason==LinphoneReasonNone && tone->audiofile!=NULL) return tone->audiofile;
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
void _linphone_core_set_tone(LinphoneCore *lc, LinphoneReason reason, LinphoneToneID id, const char *audiofile){
|
||||
LinphoneToneDescription *tone=linphone_core_get_call_error_tone(lc,reason);
|
||||
if (tone){
|
||||
lc->tones=ms_list_remove(lc->tones,tone);
|
||||
|
|
@ -1350,12 +1359,24 @@ void _linphone_core_set_call_error_tone(LinphoneCore *lc, LinphoneReason reason,
|
|||
}
|
||||
|
||||
/**
|
||||
* Assign an audio file to played locally upon call failure, for a given reason.
|
||||
* Assign an audio file to be played locally upon call failure, for a given reason.
|
||||
* @param lc the core
|
||||
* @param reason the #LinphoneReason representing the failure error code.
|
||||
* @param audiofile a wav file to be played when such call failure happens.
|
||||
* @ingroup misc
|
||||
**/
|
||||
void linphone_core_set_call_error_tone(LinphoneCore *lc, LinphoneReason reason, const char *audiofile){
|
||||
_linphone_core_set_call_error_tone(lc,reason,LinphoneToneUndefined, audiofile);
|
||||
_linphone_core_set_tone(lc,reason,LinphoneToneUndefined, audiofile);
|
||||
}
|
||||
|
||||
/**
|
||||
* Assign an audio file to be played as a specific tone id.
|
||||
* This function typically allows to customize telephony tones per country.
|
||||
* @param lc the core
|
||||
* @param id the tone id
|
||||
* @param audiofile a wav file to be played.
|
||||
**/
|
||||
void linphone_core_set_tone(LinphoneCore *lc, LinphoneToneID id, const char *audiofile){
|
||||
_linphone_core_set_tone(lc, LinphoneReasonNone, id, audiofile);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -586,13 +586,6 @@ struct _LinphoneConference{
|
|||
bool_t local_muted;
|
||||
};
|
||||
|
||||
typedef enum _LinphoneToneID{
|
||||
LinphoneToneUndefined,
|
||||
LinphoneToneBusy,
|
||||
LinphoneToneCallWaiting,
|
||||
LinphoneToneCallOnHold,
|
||||
LinphoneToneCallFailed
|
||||
}LinphoneToneID;
|
||||
|
||||
typedef struct _LinphoneToneDescription{
|
||||
LinphoneReason reason;
|
||||
|
|
@ -604,7 +597,8 @@ LinphoneToneDescription * linphone_tone_description_new(LinphoneReason reason, L
|
|||
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_call_error_tone(LinphoneCore *lc, LinphoneReason reason, LinphoneToneID id, const char *audiofile);
|
||||
void _linphone_core_set_tone(LinphoneCore *lc, LinphoneReason reason, LinphoneToneID id, const char *audiofile);
|
||||
const char *linphone_core_get_tone_file(const LinphoneCore *lc, LinphoneToneID id);
|
||||
|
||||
typedef struct _LinphoneConference LinphoneConference;
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue