mirror of
https://gitlab.linphone.org/BC/public/linphone-iphone.git
synced 2026-01-28 08:39:20 +00:00
dtmf_tester.c: stop using static global variables to definitively fix tests when opus not available
This commit is contained in:
parent
73ec6eb8d9
commit
fcbbbd1979
1 changed files with 38 additions and 30 deletions
|
|
@ -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,52 +103,62 @@ 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);
|
||||
|
||||
/*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*/
|
||||
linphone_core_pause_call(marie_call->core,marie_call);
|
||||
BC_ASSERT_TRUE(wait_for(marie->lc,pauline->lc,&marie->stat.number_of_LinphoneCallPausing,1));
|
||||
BC_ASSERT_TRUE(wait_for(marie->lc,pauline->lc,&marie->stat.number_of_LinphoneCallPaused,1));
|
||||
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*/
|
||||
linphone_core_pause_call(marie_call->core,marie_call);
|
||||
BC_ASSERT_TRUE(wait_for(marie->lc,pauline->lc,&marie->stat.number_of_LinphoneCallPausing,1));
|
||||
BC_ASSERT_TRUE(wait_for(marie->lc,pauline->lc,&marie->stat.number_of_LinphoneCallPaused,1));
|
||||
|
||||
/*wait a few time to ensure that no DTMF are received*/
|
||||
wait_for_until(marie->lc, pauline->lc, NULL, 0, 1000);
|
||||
/*wait a few time to ensure that no DTMF are received*/
|
||||
wait_for_until(marie->lc, pauline->lc, NULL, 0, 1000);
|
||||
|
||||
BC_ASSERT_PTR_NULL(pauline->stat.dtmf_list_received);
|
||||
|
||||
send_dtmf_cleanup();
|
||||
BC_ASSERT_PTR_NULL(pauline->stat.dtmf_list_received);
|
||||
}
|
||||
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[] = {
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue