Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
BC
public
liblinphone
Commits
e1830ee3
Commit
e1830ee3
authored
Apr 23, 2013
by
Ghislain MARY
Browse files
Add callbacks for audio (un)initialization in the echo canceller calibrator.
parent
14082270
Changes
5
Hide whitespace changes
Inline
Side-by-side
coreapi/ec-calibrator.c
View file @
e1830ee3
...
...
@@ -77,10 +77,17 @@ static void ecc_init_filters(EcCalibrator *ecc){
ms_ticker_attach
(
ecc
->
ticker
,
ecc
->
sndread
);
ms_ticker_attach
(
ecc
->
ticker
,
ecc
->
play
);
if
(
ecc
->
audio_init_cb
!=
NULL
)
{
(
*
ecc
->
audio_init_cb
)(
ecc
->
cb_data
);
}
}
static
void
ecc_deinit_filters
(
EcCalibrator
*
ecc
){
if
(
ecc
->
audio_uninit_cb
!=
NULL
)
{
(
*
ecc
->
audio_uninit_cb
)(
ecc
->
cb_data
);
}
ms_ticker_detach
(
ecc
->
ticker
,
ecc
->
sndread
);
ms_ticker_detach
(
ecc
->
ticker
,
ecc
->
play
);
...
...
@@ -232,12 +239,15 @@ static void * ecc_thread(void *p){
return
NULL
;
}
EcCalibrator
*
ec_calibrator_new
(
MSSndCard
*
play_card
,
MSSndCard
*
capt_card
,
unsigned
int
rate
,
LinphoneEcCalibrationCallback
cb
,
void
*
cb_data
){
EcCalibrator
*
ec_calibrator_new
(
MSSndCard
*
play_card
,
MSSndCard
*
capt_card
,
unsigned
int
rate
,
LinphoneEcCalibrationCallback
cb
,
LinphoneEcCalibrationAudioInit
audio_init_cb
,
LinphoneEcCalibrationAudioUninit
audio_uninit_cb
,
void
*
cb_data
){
EcCalibrator
*
ecc
=
ms_new0
(
EcCalibrator
,
1
);
ecc
->
rate
=
rate
;
ecc
->
cb
=
cb
;
ecc
->
cb_data
=
cb_data
;
ecc
->
audio_init_cb
=
audio_init_cb
;
ecc
->
audio_uninit_cb
=
audio_uninit_cb
;
ecc
->
capt_card
=
capt_card
;
ecc
->
play_card
=
play_card
;
ms_thread_create
(
&
ecc
->
thread
,
NULL
,
ecc_thread
,
ecc
);
...
...
@@ -253,13 +263,14 @@ void ec_calibrator_destroy(EcCalibrator *ecc){
ms_free
(
ecc
);
}
int
linphone_core_start_echo_calibration
(
LinphoneCore
*
lc
,
LinphoneEcCalibrationCallback
cb
,
void
*
cb_data
){
int
linphone_core_start_echo_calibration
(
LinphoneCore
*
lc
,
LinphoneEcCalibrationCallback
cb
,
LinphoneEcCalibrationAudioInit
audio_init_cb
,
LinphoneEcCalibrationAudioUninit
audio_uninit_cb
,
void
*
cb_data
){
if
(
lc
->
ecc
!=
NULL
){
ms_error
(
"Echo calibration is still on going !"
);
return
-
1
;
}
unsigned
int
rate
=
lp_config_get_int
(
lc
->
config
,
"sound"
,
"echo_cancellation_rate"
,
8000
);
lc
->
ecc
=
ec_calibrator_new
(
lc
->
sound_conf
.
play_sndcard
,
lc
->
sound_conf
.
capt_sndcard
,
rate
,
cb
,
cb_data
);
lc
->
ecc
=
ec_calibrator_new
(
lc
->
sound_conf
.
play_sndcard
,
lc
->
sound_conf
.
capt_sndcard
,
rate
,
cb
,
audio_init_cb
,
audio_uninit_cb
,
cb_data
);
return
0
;
}
coreapi/linphonecore_jni.cc
View file @
e1830ee3
...
...
@@ -996,6 +996,8 @@ extern "C" jint Java_org_linphone_core_LinphoneCoreImpl_startEchoCalibration(JNI
,
jobject
data
)
{
return
(
jint
)
linphone_core_start_echo_calibration
((
LinphoneCore
*
)
lc
,
LinphoneCoreData
::
ecCalibrationStatus
,
NULL
,
NULL
,
data
?
env
->
NewGlobalRef
(
data
)
:
NULL
);
}
...
...
coreapi/linphonecore_utils.h
View file @
e1830ee3
...
...
@@ -64,12 +64,15 @@ typedef enum {
typedef
void
(
*
LinphoneEcCalibrationCallback
)(
LinphoneCore
*
lc
,
LinphoneEcCalibratorStatus
status
,
int
delay_ms
,
void
*
data
);
typedef
void
(
*
LinphoneEcCalibrationAudioInit
)(
void
*
data
);
typedef
void
(
*
LinphoneEcCalibrationAudioUninit
)(
void
*
data
);
/**
*
* Start an echo calibration of the sound devices, in order to find adequate settings for the echo canceller automatically.
**/
int
linphone_core_start_echo_calibration
(
LinphoneCore
*
lc
,
LinphoneEcCalibrationCallback
cb
,
void
*
cb_data
);
int
linphone_core_start_echo_calibration
(
LinphoneCore
*
lc
,
LinphoneEcCalibrationCallback
cb
,
LinphoneEcCalibrationAudioInit
audio_init_cb
,
LinphoneEcCalibrationAudioUninit
audio_uninit_cb
,
void
*
cb_data
);
/**
* @ingroup IOS
* Special function to warm up dtmf feeback stream. #linphone_core_stop_dtmf_stream must() be called before entering FG mode
...
...
coreapi/private.h
View file @
e1830ee3
...
...
@@ -662,6 +662,8 @@ struct _EcCalibrator{
MSTicker
*
ticker
;
LinphoneEcCalibrationCallback
cb
;
void
*
cb_data
;
LinphoneEcCalibrationAudioInit
audio_init_cb
;
LinphoneEcCalibrationAudioUninit
audio_uninit_cb
;
int64_t
acc
;
int
delay
;
unsigned
int
rate
;
...
...
coreapi/test_ecc.c
View file @
e1830ee3
...
...
@@ -45,7 +45,7 @@ int main(int argc, char *argv[]){
linphone_core_enable_logs
(
NULL
);
linphone_core_start_echo_calibration
(
lc
,
calibration_finished
,
NULL
);
linphone_core_start_echo_calibration
(
lc
,
calibration_finished
,
NULL
,
NULL
,
NULL
);
while
(
count
++<
1000
){
linphone_core_iterate
(
lc
);
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment