dtmf_tester.c: stop using static global variables to definitively fix tests when opus not available

parent 73ec6eb8
...@@ -19,10 +19,6 @@ ...@@ -19,10 +19,6 @@
#include "liblinphone_tester.h" #include "liblinphone_tester.h"
#include "private.h" #include "private.h"
LinphoneCoreManager* marie;
LinphoneCoreManager* pauline;
LinphoneCall *marie_call;
void dtmf_received(LinphoneCore *lc, LinphoneCall *call, int dtmf) { void dtmf_received(LinphoneCore *lc, LinphoneCall *call, int dtmf) {
stats* counters = get_stats(lc); stats* counters = get_stats(lc);
char** dst = &counters->dtmf_list_received; char** dst = &counters->dtmf_list_received;
...@@ -32,11 +28,12 @@ void dtmf_received(LinphoneCore *lc, LinphoneCall *call, int dtmf) { ...@@ -32,11 +28,12 @@ void dtmf_received(LinphoneCore *lc, LinphoneCall *call, int dtmf) {
counters->dtmf_count++; counters->dtmf_count++;
} }
void send_dtmf_base(bool_t use_rfc2833, bool_t use_sipinfo, char dtmf, char* dtmf_seq, bool_t use_opus) { void send_dtmf_base(LinphoneCoreManager **pmarie, LinphoneCoreManager **ppauline, bool_t use_rfc2833, bool_t use_sipinfo, char dtmf, char* dtmf_seq, bool_t use_opus) {
char* expected = NULL; char* expected = NULL;
int dtmf_count_prev; int dtmf_count_prev;
marie = linphone_core_manager_new( "marie_rc"); LinphoneCoreManager *marie = *pmarie = linphone_core_manager_new( "marie_rc");
pauline = linphone_core_manager_new( "pauline_tcp_rc"); LinphoneCoreManager *pauline = *ppauline = linphone_core_manager_new( "pauline_tcp_rc");
LinphoneCall *marie_call = NULL;
if (use_opus) { if (use_opus) {
if (!ms_filter_codec_supported("opus")) { if (!ms_filter_codec_supported("opus")) {
...@@ -90,7 +87,8 @@ void send_dtmf_base(bool_t use_rfc2833, bool_t use_sipinfo, char dtmf, char* dtm ...@@ -90,7 +87,8 @@ void send_dtmf_base(bool_t use_rfc2833, bool_t use_sipinfo, char dtmf, char* dtm
} }
} }
void send_dtmf_cleanup() { void send_dtmf_cleanup(LinphoneCoreManager *marie, LinphoneCoreManager *pauline) {
LinphoneCall *marie_call = linphone_core_get_current_call(marie->lc);
if (marie_call) { if (marie_call) {
BC_ASSERT_PTR_NULL(marie_call->dtmfs_timer); BC_ASSERT_PTR_NULL(marie_call->dtmfs_timer);
BC_ASSERT_PTR_NULL(marie_call->dtmf_sequence); BC_ASSERT_PTR_NULL(marie_call->dtmf_sequence);
...@@ -105,52 +103,62 @@ void send_dtmf_cleanup() { ...@@ -105,52 +103,62 @@ void send_dtmf_cleanup() {
} }
static void send_dtmf_rfc2833() { static void send_dtmf_rfc2833() {
send_dtmf_base(TRUE,FALSE,'1',NULL,FALSE); LinphoneCoreManager *marie, *pauline;
send_dtmf_cleanup(); send_dtmf_base(&marie, &pauline, TRUE,FALSE,'1',NULL,FALSE);
send_dtmf_cleanup(marie, pauline);
} }
static void send_dtmf_sip_info() { static void send_dtmf_sip_info() {
send_dtmf_base(FALSE,TRUE,'#',NULL,FALSE); LinphoneCoreManager *marie, *pauline;
send_dtmf_cleanup(); send_dtmf_base(&marie, &pauline, FALSE,TRUE,'#',NULL,FALSE);
send_dtmf_cleanup(marie, pauline);
} }
static void send_dtmfs_sequence_rfc2833() { static void send_dtmfs_sequence_rfc2833() {
send_dtmf_base(TRUE,FALSE,'\0',"1230#",FALSE); LinphoneCoreManager *marie, *pauline;
send_dtmf_cleanup(); send_dtmf_base(&marie, &pauline, TRUE,FALSE,'\0',"1230#",FALSE);
send_dtmf_cleanup(marie, pauline);
} }
static void send_dtmfs_sequence_sip_info() { static void send_dtmfs_sequence_sip_info() {
send_dtmf_base(FALSE,TRUE,'\0',"1230#",FALSE); LinphoneCoreManager *marie, *pauline;
send_dtmf_cleanup(); send_dtmf_base(&marie, &pauline, FALSE,TRUE,'\0',"1230#",FALSE);
send_dtmf_cleanup(marie, pauline);
} }
static void send_dtmfs_sequence_not_ready() { static void send_dtmfs_sequence_not_ready() {
LinphoneCoreManager *marie;
marie = linphone_core_manager_new( "marie_rc"); marie = linphone_core_manager_new( "marie_rc");
BC_ASSERT_EQUAL(linphone_call_send_dtmfs(linphone_core_get_current_call(marie->lc), "123"), -1, int, "%d"); BC_ASSERT_EQUAL(linphone_call_send_dtmfs(linphone_core_get_current_call(marie->lc), "123"), -1, int, "%d");
linphone_core_manager_destroy(marie); linphone_core_manager_destroy(marie);
} }
static void send_dtmfs_sequence_call_state_changed() { static void send_dtmfs_sequence_call_state_changed() {
send_dtmf_base(FALSE,TRUE,'\0',NULL,FALSE); LinphoneCoreManager *marie, *pauline;
LinphoneCall *marie_call = NULL;
send_dtmf_base(&marie, &pauline, FALSE,TRUE,'\0',NULL,FALSE);
/*very long DTMF(around 4 sec to be sent)*/ marie_call = linphone_core_get_current_call(marie->lc);
linphone_call_send_dtmfs(marie_call, "123456789123456789"); if (marie_call) {
/*just after, change call state, and expect DTMF to be canceled*/ /*very long DTMF(around 4 sec to be sent)*/
linphone_core_pause_call(marie_call->core,marie_call); linphone_call_send_dtmfs(marie_call, "123456789123456789");
BC_ASSERT_TRUE(wait_for(marie->lc,pauline->lc,&marie->stat.number_of_LinphoneCallPausing,1)); /*just after, change call state, and expect DTMF to be canceled*/
BC_ASSERT_TRUE(wait_for(marie->lc,pauline->lc,&marie->stat.number_of_LinphoneCallPaused,1)); linphone_core_pause_call(marie_call->core,marie_call);
BC_ASSERT_TRUE(wait_for(marie->lc,pauline->lc,&marie->stat.number_of_LinphoneCallPausing,1));
/*wait a few time to ensure that no DTMF are received*/ BC_ASSERT_TRUE(wait_for(marie->lc,pauline->lc,&marie->stat.number_of_LinphoneCallPaused,1));
wait_for_until(marie->lc, pauline->lc, NULL, 0, 1000);
BC_ASSERT_PTR_NULL(pauline->stat.dtmf_list_received); /*wait a few time to ensure that no DTMF are received*/
wait_for_until(marie->lc, pauline->lc, NULL, 0, 1000);
send_dtmf_cleanup(); BC_ASSERT_PTR_NULL(pauline->stat.dtmf_list_received);
}
send_dtmf_cleanup(marie, pauline);
} }
static void send_dtmf_rfc2833_opus() { static void send_dtmf_rfc2833_opus() {
send_dtmf_base(TRUE,FALSE,'1',NULL,TRUE); LinphoneCoreManager *marie, *pauline;
send_dtmf_cleanup(); send_dtmf_base(&marie, &pauline, TRUE,FALSE,'1',NULL,TRUE);
send_dtmf_cleanup(marie, pauline);
} }
test_t dtmf_tests[] = { test_t dtmf_tests[] = {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment