mirror of
https://gitlab.linphone.org/BC/public/linphone-iphone.git
synced 2026-01-17 11:08:06 +00:00
Reworking of the EC calibrator API in order to be automatically wrapped
This commit is contained in:
parent
fe807ccae1
commit
0c9100d573
7 changed files with 120 additions and 8 deletions
|
|
@ -24,7 +24,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
|||
#include "mediastreamer2/dtmfgen.h"
|
||||
|
||||
#include "linphone/lpconfig.h"
|
||||
|
||||
#include "c-wrapper/c-wrapper.h"
|
||||
|
||||
|
||||
static void ecc_init_filters(EcCalibrator *ecc){
|
||||
|
|
@ -325,6 +325,37 @@ int linphone_core_start_echo_calibration(LinphoneCore *lc, LinphoneEcCalibration
|
|||
return 0;
|
||||
}
|
||||
|
||||
static void _ec_calibration_result_cb(LinphoneCore *lc, LinphoneEcCalibratorStatus status, int delay_ms, void *user_data) {
|
||||
linphone_core_notify_ec_calibration_result(lc, status, delay_ms);
|
||||
}
|
||||
|
||||
static void _ec_calibration_audio_init_cb(void *user_data) {
|
||||
LinphoneCore *lc = (LinphoneCore *)user_data;
|
||||
linphone_core_notify_ec_calibration_audio_init(lc);
|
||||
}
|
||||
|
||||
static void _ec_calibration_audio_uninit_cb(void *user_data) {
|
||||
LinphoneCore *lc = (LinphoneCore *)user_data;
|
||||
linphone_core_notify_ec_calibration_audio_uninit(lc);
|
||||
}
|
||||
|
||||
LinphoneStatus linphone_core_start_echo_canceller_calibration(LinphoneCore *lc) {
|
||||
unsigned int rate;
|
||||
|
||||
if (lc->ecc!=NULL){
|
||||
ms_error("Echo calibration is still on going !");
|
||||
return -1;
|
||||
}
|
||||
rate = (unsigned int)lp_config_get_int(lc->config,"sound","echo_cancellation_rate",8000);
|
||||
lc->ecc=ec_calibrator_new(lc->factory, lc->sound_conf.play_sndcard, lc->sound_conf.capt_sndcard, rate,
|
||||
_ec_calibration_result_cb,
|
||||
_ec_calibration_audio_init_cb,
|
||||
_ec_calibration_audio_uninit_cb, lc);
|
||||
lc->ecc->play_cool_tones = !!lp_config_get_int(lc->config, "sound", "ec_calibrator_cool_tones", 0);
|
||||
ec_calibrator_start(lc->ecc);
|
||||
return 0;
|
||||
}
|
||||
|
||||
bool_t linphone_core_has_builtin_echo_canceller(LinphoneCore *lc) {
|
||||
MSFactory * factory = linphone_core_get_ms_factory(lc);
|
||||
MSDevicesInfo *devices = ms_factory_get_devices_info(factory);
|
||||
|
|
|
|||
|
|
@ -436,6 +436,18 @@ void linphone_core_cbs_set_chat_room_instantiated (LinphoneCoreCbs *cbs, Linphon
|
|||
cbs->vtable->chat_room_instantiated = cb;
|
||||
}
|
||||
|
||||
void linphone_core_cbs_set_ec_calibration_result(LinphoneCoreCbs *cbs, LinphoneCoreCbsEcCalibrationResultCb cb) {
|
||||
cbs->vtable->ec_calibration_result = cb;
|
||||
}
|
||||
|
||||
void linphone_core_cbs_set_ec_calibration_audio_init(LinphoneCoreCbs *cbs, LinphoneCoreCbsEcCalibrationAudioInitCb cb) {
|
||||
cbs->vtable->ec_calibration_audio_init = cb;
|
||||
}
|
||||
|
||||
void linphone_core_cbs_set_ec_calibration_audio_uninit(LinphoneCoreCbs *cbs, LinphoneCoreCbsEcCalibrationAudioUninitCb cb) {
|
||||
cbs->vtable->ec_calibration_audio_uninit = cb;
|
||||
}
|
||||
|
||||
|
||||
typedef belle_sip_object_t_vptr_t LinphoneCore_vptr_t;
|
||||
BELLE_SIP_DECLARE_NO_IMPLEMENTED_INTERFACES(LinphoneCore);
|
||||
|
|
@ -2190,7 +2202,6 @@ static void linphone_core_init(LinphoneCore * lc, LinphoneCoreCbs *cbs, LpConfig
|
|||
_linphone_core_add_callbacks(lc, internal_cbs, TRUE);
|
||||
belle_sip_object_unref(internal_cbs);
|
||||
|
||||
|
||||
if (cbs != NULL) {
|
||||
_linphone_core_add_callbacks(lc, cbs, FALSE);
|
||||
} else {
|
||||
|
|
@ -7379,4 +7390,4 @@ bool_t linphone_core_has_crappy_opengl(LinphoneCore *lc) {
|
|||
if (sound_description == NULL) return FALSE;
|
||||
if (sound_description->flags & DEVICE_HAS_CRAPPY_OPENGL) return TRUE;
|
||||
return FALSE;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1475,6 +1475,10 @@ void linphone_core_notify_call_created(LinphoneCore *lc, LinphoneCall *call);
|
|||
void linphone_core_notify_version_update_check_result_received(LinphoneCore *lc, LinphoneVersionUpdateCheckResult result, const char *version, const char *url);
|
||||
void linphone_core_notify_chat_room_instantiated (LinphoneCore *lc, LinphoneChatRoom *cr);
|
||||
|
||||
void linphone_core_notify_ec_calibration_result(LinphoneCore *lc, LinphoneEcCalibratorStatus status, int delay_ms);
|
||||
void linphone_core_notify_ec_calibration_audio_init(LinphoneCore *lc);
|
||||
void linphone_core_notify_ec_calibration_audio_uninit(LinphoneCore *lc);
|
||||
|
||||
void set_playback_gain_db(AudioStream *st, float gain);
|
||||
|
||||
LinphoneMediaDirection media_direction_from_sal_stream_dir(SalStreamDir dir);
|
||||
|
|
|
|||
|
|
@ -292,6 +292,21 @@ void linphone_core_notify_chat_room_instantiated (LinphoneCore *lc, LinphoneChat
|
|||
cleanup_dead_vtable_refs(lc);
|
||||
}
|
||||
|
||||
void linphone_core_notify_ec_calibration_result(LinphoneCore *lc, LinphoneEcCalibratorStatus status, int delay_ms) {
|
||||
NOTIFY_IF_EXIST(ec_calibration_result, lc, status, delay_ms);
|
||||
cleanup_dead_vtable_refs(lc);
|
||||
}
|
||||
|
||||
void linphone_core_notify_ec_calibration_audio_init(LinphoneCore *lc) {
|
||||
NOTIFY_IF_EXIST(ec_calibration_audio_init, lc);
|
||||
cleanup_dead_vtable_refs(lc);
|
||||
}
|
||||
|
||||
void linphone_core_notify_ec_calibration_audio_uninit(LinphoneCore *lc) {
|
||||
NOTIFY_IF_EXIST(ec_calibration_audio_uninit, lc);
|
||||
cleanup_dead_vtable_refs(lc);
|
||||
}
|
||||
|
||||
static VTableReference * v_table_reference_new(LinphoneCoreCbs *cbs, bool_t internal){
|
||||
VTableReference *ref=ms_new0(VTableReference,1);
|
||||
ref->valid=TRUE;
|
||||
|
|
|
|||
|
|
@ -492,6 +492,26 @@ typedef void (*LinphoneFriendListCbsSyncStateChangedCb)(LinphoneFriendList *list
|
|||
* @{
|
||||
*/
|
||||
|
||||
/**
|
||||
* @brief Function prototype used by #linphone_core_cbs_set_ec_calibrator_result().
|
||||
* @param lc The core.
|
||||
* @param status The state of the calibrator.
|
||||
* @param delay_ms The measured delay if available.
|
||||
*/
|
||||
typedef void (*LinphoneCoreCbsEcCalibrationResultCb)(LinphoneCore *lc, LinphoneEcCalibratorStatus status, int delay_ms);
|
||||
|
||||
/**
|
||||
* @brief Function prototype used by #linphone_core_cbs_set_ec_calibrator_audio_init().
|
||||
* @param lc The core.
|
||||
*/
|
||||
typedef void (*LinphoneCoreCbsEcCalibrationAudioInitCb)(LinphoneCore *lc);
|
||||
|
||||
/**
|
||||
* @biref Function prototype used by #linphone_core_cbs_set_ec_calibrator_audio_uninit().
|
||||
* @param lc The core.
|
||||
*/
|
||||
typedef void (*LinphoneCoreCbsEcCalibrationAudioUninitCb)(LinphoneCore *lc);
|
||||
|
||||
/**
|
||||
* Callback to decrypt incoming LinphoneChatMessage
|
||||
* @param engine ImEncryptionEngine object
|
||||
|
|
|
|||
|
|
@ -186,6 +186,9 @@ typedef struct _LinphoneCoreVTable{
|
|||
LinphoneCoreCbsCallCreatedCb call_created;
|
||||
LinphoneCoreCbsVersionUpdateCheckResultReceivedCb version_update_check_result_received;
|
||||
LinphoneCoreCbsChatRoomInstantiatedCb chat_room_instantiated;
|
||||
LinphoneCoreCbsEcCalibrationResultCb ec_calibration_result;
|
||||
LinphoneCoreCbsEcCalibrationAudioInitCb ec_calibration_audio_init;
|
||||
LinphoneCoreCbsEcCalibrationAudioUninitCb ec_calibration_audio_uninit;
|
||||
void *user_data; /**<User data associated with the above callbacks */
|
||||
} LinphoneCoreVTable;
|
||||
|
||||
|
|
@ -672,6 +675,21 @@ LINPHONE_PUBLIC LinphoneCoreCbsChatRoomInstantiatedCb linphone_core_cbs_get_chat
|
|||
*/
|
||||
LINPHONE_PUBLIC void linphone_core_cbs_set_chat_room_instantiated (LinphoneCoreCbs *cbs, LinphoneCoreCbsChatRoomInstantiatedCb cb);
|
||||
|
||||
/**
|
||||
* @brief Sets a callback to call each time the echo-canceler calibration is completed.
|
||||
*/
|
||||
LINPHONE_PUBLIC void linphone_core_cbs_set_ec_calibration_result(LinphoneCoreCbs *cbs, LinphoneCoreCbsEcCalibrationResultCb cb);
|
||||
|
||||
/**
|
||||
* @brief Sets a callback to call when the echo-canceler calibrator has completed its audio graph.
|
||||
*/
|
||||
LINPHONE_PUBLIC void linphone_core_cbs_set_ec_calibration_audio_init(LinphoneCoreCbs *cbs, LinphoneCoreCbsEcCalibrationAudioInitCb cb);
|
||||
|
||||
/**
|
||||
* @brief Sets a callback to call when the echo-canceler calibrator destroys its audio graph.
|
||||
*/
|
||||
LINPHONE_PUBLIC void linphone_core_cbs_set_ec_calibration_audio_uninit(LinphoneCoreCbs *cbs, LinphoneCoreCbsEcCalibrationAudioUninitCb cb);
|
||||
|
||||
/**
|
||||
* @}
|
||||
**/
|
||||
|
|
|
|||
|
|
@ -22,6 +22,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
|||
|
||||
|
||||
#include "linphone/types.h"
|
||||
#include "linphone/callbacks.h"
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
|
|
@ -49,17 +50,29 @@ LINPHONE_PUBLIC void linphone_core_use_sound_daemon(LinphoneCore *lc, LinphoneSo
|
|||
LINPHONE_PUBLIC void linphone_sound_daemon_destroy(LinphoneSoundDaemon *obj);
|
||||
|
||||
|
||||
typedef void (*LinphoneEcCalibrationCallback)(LinphoneCore *lc, LinphoneEcCalibratorStatus status, int delay_ms, void *data);
|
||||
typedef void (*LinphoneEcCalibrationAudioInit)(void *data);
|
||||
typedef void (*LinphoneEcCalibrationAudioUninit)(void *data);
|
||||
LINPHONE_DEPRECATED typedef void (*LinphoneEcCalibrationCallback)(LinphoneCore *lc, LinphoneEcCalibratorStatus status, int delay_ms, void *data);
|
||||
LINPHONE_DEPRECATED typedef void (*LinphoneEcCalibrationAudioInit)(void *data);
|
||||
LINPHONE_DEPRECATED typedef void (*LinphoneEcCalibrationAudioUninit)(void *data);
|
||||
|
||||
/**
|
||||
*
|
||||
* Start an echo calibration of the sound devices, in order to find adequate settings for the echo canceller automatically.
|
||||
* @brief Starts an echo calibration of the sound devices, in order to find adequate settings for the echo canceler automatically.
|
||||
* @deprecated Use #linphone_core_start_echo_canceller_calibration() instead. To set the callbacks create or get an already instantiated
|
||||
* #LinphoneCoreCbs and call #linphone_core_cbs_set_ec_calibration_result(), #linphone_core_cbs_set_ec_calibration_audio_init() and
|
||||
* #linphone_core_cbs_set_ec_callibration_audio_uninit(). Deprecated since 2017-10-16.
|
||||
* @ingroup misc
|
||||
**/
|
||||
LINPHONE_PUBLIC int linphone_core_start_echo_calibration(LinphoneCore *lc, LinphoneEcCalibrationCallback cb,
|
||||
LINPHONE_DEPRECATED LINPHONE_PUBLIC int linphone_core_start_echo_calibration(LinphoneCore *lc, LinphoneEcCalibrationCallback cb,
|
||||
LinphoneEcCalibrationAudioInit audio_init_cb, LinphoneEcCalibrationAudioUninit audio_uninit_cb, void *cb_data);
|
||||
|
||||
/**
|
||||
* @brief Starts an echo calibration of the sound devices, in order to find adequate settings for the echo canceler automatically.
|
||||
* @param[in] lc #LinphoneCore object.
|
||||
* @return #LinphoneStatus whether calibration has started or not.
|
||||
* @ingroup misc
|
||||
**/
|
||||
LINPHONE_PUBLIC LinphoneStatus linphone_core_start_echo_canceller_calibration(LinphoneCore *lc);
|
||||
|
||||
/**
|
||||
* Start the simulation of call to test the latency with an external device
|
||||
* @param lc The core.
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue