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

parent 73ec6eb8
......@@ -19,10 +19,6 @@
#include "liblinphone_tester.h"
#include "private.h"
LinphoneCoreManager* marie;
LinphoneCoreManager* pauline;
LinphoneCall *marie_call;
void dtmf_received(LinphoneCore *lc, LinphoneCall *call, int dtmf) {
stats* counters = get_stats(lc);
char** dst = &counters->dtmf_list_received;
......@@ -32,11 +28,12 @@ void dtmf_received(LinphoneCore *lc, LinphoneCall *call, int dtmf) {
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;
int dtmf_count_prev;
marie = linphone_core_manager_new( "marie_rc");
pauline = linphone_core_manager_new( "pauline_tcp_rc");
LinphoneCoreManager *marie = *pmarie = linphone_core_manager_new( "marie_rc");
LinphoneCoreManager *pauline = *ppauline = linphone_core_manager_new( "pauline_tcp_rc");
LinphoneCall *marie_call = NULL;
if (use_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
}
}
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) {
BC_ASSERT_PTR_NULL(marie_call->dtmfs_timer);
BC_ASSERT_PTR_NULL(marie_call->dtmf_sequence);
......@@ -105,34 +103,43 @@ void send_dtmf_cleanup() {
}
static void send_dtmf_rfc2833() {
send_dtmf_base(TRUE,FALSE,'1',NULL,FALSE);
send_dtmf_cleanup();
LinphoneCoreManager *marie, *pauline;
send_dtmf_base(&marie, &pauline, TRUE,FALSE,'1',NULL,FALSE);
send_dtmf_cleanup(marie, pauline);
}
static void send_dtmf_sip_info() {
send_dtmf_base(FALSE,TRUE,'#',NULL,FALSE);
send_dtmf_cleanup();
LinphoneCoreManager *marie, *pauline;
send_dtmf_base(&marie, &pauline, FALSE,TRUE,'#',NULL,FALSE);
send_dtmf_cleanup(marie, pauline);
}
static void send_dtmfs_sequence_rfc2833() {
send_dtmf_base(TRUE,FALSE,'\0',"1230#",FALSE);
send_dtmf_cleanup();
LinphoneCoreManager *marie, *pauline;
send_dtmf_base(&marie, &pauline, TRUE,FALSE,'\0',"1230#",FALSE);
send_dtmf_cleanup(marie, pauline);
}
static void send_dtmfs_sequence_sip_info() {
send_dtmf_base(FALSE,TRUE,'\0',"1230#",FALSE);
send_dtmf_cleanup();
LinphoneCoreManager *marie, *pauline;
send_dtmf_base(&marie, &pauline, FALSE,TRUE,'\0',"1230#",FALSE);
send_dtmf_cleanup(marie, pauline);
}
static void send_dtmfs_sequence_not_ready() {
LinphoneCoreManager *marie;
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");
linphone_core_manager_destroy(marie);
}
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);
marie_call = linphone_core_get_current_call(marie->lc);
if (marie_call) {
/*very long DTMF(around 4 sec to be sent)*/
linphone_call_send_dtmfs(marie_call, "123456789123456789");
/*just after, change call state, and expect DTMF to be canceled*/
......@@ -144,13 +151,14 @@ static void send_dtmfs_sequence_call_state_changed() {
wait_for_until(marie->lc, pauline->lc, NULL, 0, 1000);
BC_ASSERT_PTR_NULL(pauline->stat.dtmf_list_received);
send_dtmf_cleanup();
}
send_dtmf_cleanup(marie, pauline);
}
static void send_dtmf_rfc2833_opus() {
send_dtmf_base(TRUE,FALSE,'1',NULL,TRUE);
send_dtmf_cleanup();
LinphoneCoreManager *marie, *pauline;
send_dtmf_base(&marie, &pauline, TRUE,FALSE,'1',NULL,TRUE);
send_dtmf_cleanup(marie, pauline);
}
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