Commit d46bdda7 authored by Ghislain MARY's avatar Ghislain MARY

Reorganize unit tests.

parent e24d78e2
......@@ -5,8 +5,8 @@ noinst_PROGRAMS=mediastreamer2_tester
TESTS=mediastreamer2_tester
mediastreamer2_tester_SOURCES= \
mediastreamer2_tester.c mediastreamer2_tester.h\
mediastreamer2_dtmfgen_tester.c
mediastreamer2_tester.c mediastreamer2_tester.h mediastreamer2_tester_private.c mediastreamer2_tester_private.h \
mediastreamer2_basic_audio_tester.c mediastreamer2_sound_card_tester.c
mediastreamer2_tester_CFLAGS=$(CUNIT_CFLAGS) $(STRICT_OPTIONS) $(ORTP_CFLAGS)
......
/*
mediastreamer2 library - modular sound and video processing and streaming
Copyright (C) 2006-2013 Belledonne Communications, Grenoble
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; either version 2
of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
#include "mediastreamer2/mediastream.h"
#include "mediastreamer2/dtmfgen.h"
#include "mediastreamer2/msfileplayer.h"
#include "mediastreamer2/msfilerec.h"
#include "mediastreamer2/msrtp.h"
#include "mediastreamer2/mstonedetector.h"
#include "private.h"
#include "mediastreamer2_tester.h"
#include "mediastreamer2_tester_private.h"
#include <stdio.h>
#include "CUnit/Basic.h"
#ifdef _MSC_VER
#define unlink _unlink
#endif
static int basic_audio_tester_init(void) {
ms_init();
ms_filter_enable_statistics(TRUE);
ortp_init();
return 0;
}
static int basic_audio_tester_cleanup(void) {
ms_exit();
return 0;
}
static void tone_detected_cb(void *data, MSFilter *f, unsigned int event_id, MSToneDetectorEvent *ev) {
MS_UNUSED(data), MS_UNUSED(f), MS_UNUSED(event_id), MS_UNUSED(ev);
ms_tester_tone_detected = TRUE;
}
static void dtmfgen_tonedet(void) {
MSConnectionHelper h;
unsigned int filter_mask = FILTER_MASK_VOIDSOURCE | FILTER_MASK_DTMFGEN | FILTER_MASK_TONEDET | FILTER_MASK_VOIDSINK;
ms_filter_reset_statistics();
ms_tester_create_ticker();
ms_tester_create_filters(filter_mask);
ms_filter_set_notify_callback(ms_tester_tonedet, (MSFilterNotifyFunc)tone_detected_cb, NULL);
ms_connection_helper_start(&h);
ms_connection_helper_link(&h, ms_tester_voidsource, -1, 0);
ms_connection_helper_link(&h, ms_tester_dtmfgen, 0, 0);
ms_connection_helper_link(&h, ms_tester_tonedet, 0, 0);
ms_connection_helper_link(&h, ms_tester_voidsink, 0, -1);
ms_ticker_attach(ms_tester_ticker, ms_tester_voidsource);
ms_tester_tone_generation_and_detection_loop();
ms_ticker_detach(ms_tester_ticker, ms_tester_voidsource);
ms_connection_helper_start(&h);
ms_connection_helper_unlink(&h, ms_tester_voidsource, -1, 0);
ms_connection_helper_unlink(&h, ms_tester_dtmfgen, 0, 0);
ms_connection_helper_unlink(&h, ms_tester_tonedet, 0, 0);
ms_connection_helper_unlink(&h, ms_tester_voidsink, 0, -1);
ms_filter_log_statistics();
ms_tester_destroy_filters(filter_mask);
ms_tester_destroy_ticker();
}
static void dtmfgen_enc_dec_tonedet(void) {
MSConnectionHelper h;
unsigned int filter_mask = FILTER_MASK_VOIDSOURCE | FILTER_MASK_DTMFGEN | FILTER_MASK_ENCODER
| FILTER_MASK_DECODER | FILTER_MASK_TONEDET | FILTER_MASK_VOIDSINK;
ms_filter_reset_statistics();
ms_tester_create_ticker();
ms_tester_create_filters(filter_mask);
ms_filter_set_notify_callback(ms_tester_tonedet, (MSFilterNotifyFunc)tone_detected_cb, NULL);
ms_connection_helper_start(&h);
ms_connection_helper_link(&h, ms_tester_voidsource, -1, 0);
ms_connection_helper_link(&h, ms_tester_dtmfgen, 0, 0);
ms_connection_helper_link(&h, ms_tester_encoder, 0, 0);
ms_connection_helper_link(&h, ms_tester_decoder, 0, 0);
ms_connection_helper_link(&h, ms_tester_tonedet, 0, 0);
ms_connection_helper_link(&h, ms_tester_voidsink, 0, -1);
ms_ticker_attach(ms_tester_ticker, ms_tester_voidsource);
ms_tester_tone_generation_and_detection_loop();
ms_ticker_detach(ms_tester_ticker, ms_tester_voidsource);
ms_connection_helper_start(&h);
ms_connection_helper_unlink(&h, ms_tester_voidsource, -1, 0);
ms_connection_helper_unlink(&h, ms_tester_dtmfgen, 0, 0);
ms_connection_helper_unlink(&h, ms_tester_encoder, 0, 0);
ms_connection_helper_unlink(&h, ms_tester_decoder, 0, 0);
ms_connection_helper_unlink(&h, ms_tester_tonedet, 0, 0);
ms_connection_helper_unlink(&h, ms_tester_voidsink, 0, -1);
ms_filter_log_statistics();
ms_tester_destroy_filters(filter_mask);
ms_tester_destroy_ticker();
}
static void dtmfgen_enc_rtp_dec_tonedet(void) {
MSConnectionHelper h;
RtpSession *rtps;
unsigned int filter_mask = FILTER_MASK_VOIDSOURCE | FILTER_MASK_DTMFGEN | FILTER_MASK_ENCODER
| FILTER_MASK_RTPSEND | FILTER_MASK_RTPRECV | FILTER_MASK_DECODER | FILTER_MASK_TONEDET | FILTER_MASK_VOIDSINK;
ms_filter_reset_statistics();
ms_tester_create_ticker();
ms_tester_create_filters(filter_mask);
ms_filter_set_notify_callback(ms_tester_tonedet, (MSFilterNotifyFunc)tone_detected_cb, NULL);
rtps = create_duplex_rtpsession(50060, 0, FALSE);
rtp_session_set_remote_addr_full(rtps, "127.0.0.1", 50060, NULL, 0);
rtp_session_set_payload_type(rtps, 8);
rtp_session_enable_rtcp(rtps,FALSE);
ms_filter_call_method(ms_tester_rtprecv, MS_RTP_RECV_SET_SESSION, rtps);
ms_filter_call_method(ms_tester_rtpsend, MS_RTP_SEND_SET_SESSION, rtps);
ms_connection_helper_start(&h);
ms_connection_helper_link(&h, ms_tester_voidsource, -1, 0);
ms_connection_helper_link(&h, ms_tester_dtmfgen, 0, 0);
ms_connection_helper_link(&h, ms_tester_encoder, 0, 0);
ms_connection_helper_link(&h, ms_tester_rtpsend, 0, -1);
ms_connection_helper_start(&h);
ms_connection_helper_link(&h, ms_tester_rtprecv, -1, 0);
ms_connection_helper_link(&h, ms_tester_decoder, 0, 0);
ms_connection_helper_link(&h, ms_tester_tonedet, 0, 0);
ms_connection_helper_link(&h, ms_tester_voidsink, 0, -1);
ms_ticker_attach_multiple(ms_tester_ticker, ms_tester_voidsource, ms_tester_rtprecv, NULL);
ms_tester_tone_generation_and_detection_loop();
ms_ticker_detach(ms_tester_ticker, ms_tester_voidsource);
ms_ticker_detach(ms_tester_ticker, ms_tester_rtprecv);
ms_connection_helper_start(&h);
ms_connection_helper_unlink(&h, ms_tester_voidsource, -1, 0);
ms_connection_helper_unlink(&h, ms_tester_dtmfgen, 0, 0);
ms_connection_helper_unlink(&h, ms_tester_encoder, 0, 0);
ms_connection_helper_unlink(&h, ms_tester_rtpsend, 0, -1);
ms_connection_helper_start(&h);
ms_connection_helper_unlink(&h, ms_tester_rtprecv, -1, 0);
ms_connection_helper_unlink(&h, ms_tester_decoder, 0, 0);
ms_connection_helper_unlink(&h, ms_tester_tonedet, 0, 0);
ms_connection_helper_unlink(&h, ms_tester_voidsink, 0, -1);
ms_filter_log_statistics();
ms_tester_destroy_filters(filter_mask);
ms_tester_destroy_ticker();
rtp_session_destroy(rtps);
}
#define DTMFGEN_FILE_NAME "dtmfgen_file.raw"
static void dtmfgen_filerec_fileplay_tonedet(void) {
MSConnectionHelper h;
unsigned int filter_mask = FILTER_MASK_VOIDSOURCE | FILTER_MASK_DTMFGEN | FILTER_MASK_FILEREC
| FILTER_MASK_FILEPLAY | FILTER_MASK_TONEDET | FILTER_MASK_VOIDSINK;
ms_filter_reset_statistics();
ms_tester_create_ticker();
ms_tester_create_filters(filter_mask);
ms_filter_set_notify_callback(ms_tester_tonedet, (MSFilterNotifyFunc)tone_detected_cb, NULL);
// Generate tones and save them to a file
ms_filter_call_method_noarg(ms_tester_filerec, MS_FILE_REC_CLOSE);
ms_filter_call_method(ms_tester_filerec, MS_FILE_REC_OPEN, DTMFGEN_FILE_NAME);
ms_filter_call_method_noarg(ms_tester_filerec, MS_FILE_REC_START);
ms_connection_helper_start(&h);
ms_connection_helper_link(&h, ms_tester_voidsource, -1, 0);
ms_connection_helper_link(&h, ms_tester_dtmfgen, 0, 0);
ms_connection_helper_link(&h, ms_tester_filerec, 0, -1);
ms_ticker_attach(ms_tester_ticker, ms_tester_voidsource);
ms_tester_tone_generation_loop();
ms_filter_call_method_noarg(ms_tester_filerec, MS_FILE_REC_CLOSE);
ms_ticker_detach(ms_tester_ticker, ms_tester_voidsource);
ms_connection_helper_start(&h);
ms_connection_helper_unlink(&h, ms_tester_voidsource, -1, 0);
ms_connection_helper_unlink(&h, ms_tester_dtmfgen, 0, 0);
ms_connection_helper_unlink(&h, ms_tester_filerec, 0, -1);
// Read the previous file and detect the tones
ms_filter_call_method_noarg(ms_tester_fileplay, MS_FILE_PLAYER_CLOSE);
ms_filter_call_method(ms_tester_fileplay, MS_FILE_PLAYER_OPEN, DTMFGEN_FILE_NAME);
ms_filter_call_method_noarg(ms_tester_fileplay, MS_FILE_PLAYER_START);
ms_connection_helper_start(&h);
ms_connection_helper_link(&h, ms_tester_fileplay, -1, 0);
ms_connection_helper_link(&h, ms_tester_tonedet, 0, 0);
ms_connection_helper_link(&h, ms_tester_voidsink, 0, -1);
ms_ticker_attach(ms_tester_ticker, ms_tester_fileplay);
ms_tester_tone_detection_loop();
ms_filter_call_method_noarg(ms_tester_fileplay, MS_FILE_PLAYER_CLOSE);
ms_ticker_detach(ms_tester_ticker, ms_tester_fileplay);
ms_connection_helper_start(&h);
ms_connection_helper_unlink(&h, ms_tester_fileplay, -1, 0);
ms_connection_helper_unlink(&h, ms_tester_tonedet, 0, 0);
ms_connection_helper_unlink(&h, ms_tester_voidsink, 0, -1);
ms_filter_log_statistics();
ms_tester_destroy_filters(filter_mask);
ms_tester_destroy_ticker();
unlink(DTMFGEN_FILE_NAME);
}
test_t basic_audio_tests[] = {
{ "dtmfgen-tonedet", dtmfgen_tonedet },
{ "dtmfgen-enc-dec-tonedet", dtmfgen_enc_dec_tonedet },
{ "dtmfgen-enc-rtp-dec-tonedet", dtmfgen_enc_rtp_dec_tonedet },
{ "dtmfgen-filerec-fileplay-tonedet", dtmfgen_filerec_fileplay_tonedet }
};
test_suite_t basic_audio_test_suite = {
"Basic Audio",
basic_audio_tester_init,
basic_audio_tester_cleanup,
sizeof(basic_audio_tests) / sizeof(basic_audio_tests[0]),
basic_audio_tests
};
This diff is collapsed.
/*
mediastreamer2 library - modular sound and video processing and streaming
Copyright (C) 2006-2013 Belledonne Communications, Grenoble
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; either version 2
of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
#include "mediastreamer2/mediastream.h"
#include "mediastreamer2/dtmfgen.h"
#include "mediastreamer2/msfileplayer.h"
#include "mediastreamer2/msfilerec.h"
#include "mediastreamer2/msrtp.h"
#include "mediastreamer2/mstonedetector.h"
#include "private.h"
#include "mediastreamer2_tester.h"
#include "mediastreamer2_tester_private.h"
#include <stdio.h>
#include "CUnit/Basic.h"
static int sound_card_tester_init(void) {
ms_init();
ms_filter_enable_statistics(TRUE);
return 0;
}
static int sound_card_tester_cleanup(void) {
ms_exit();
return 0;
}
static void configure_resampler(MSFilter *resampler, MSFilter *from, MSFilter *to) {
int from_rate = 0, to_rate = 0;
int from_channels = 0, to_channels = 0;
ms_filter_call_method(from, MS_FILTER_GET_SAMPLE_RATE, &from_rate);
ms_filter_call_method(to, MS_FILTER_GET_SAMPLE_RATE, &to_rate);
ms_filter_call_method(resampler, MS_FILTER_SET_SAMPLE_RATE, &from_rate);
ms_filter_call_method(resampler, MS_FILTER_SET_OUTPUT_SAMPLE_RATE, &to_rate);
ms_filter_call_method(from, MS_FILTER_GET_NCHANNELS, &from_channels);
ms_filter_call_method(to, MS_FILTER_GET_NCHANNELS, &to_channels);
ms_filter_call_method(resampler, MS_FILTER_SET_NCHANNELS, &from_channels);
ms_filter_call_method(resampler, MS_FILTER_SET_OUTPUT_NCHANNELS, &to_channels);
}
static void dtmfgen_soundwrite(void) {
MSConnectionHelper h;
bool_t need_resampler = FALSE;
unsigned int filter_mask = FILTER_MASK_VOIDSOURCE | FILTER_MASK_DTMFGEN | FILTER_MASK_SOUNDWRITE;
int sample_rate = 8000;
int nchannels = 1;
ms_filter_reset_statistics();
ms_tester_create_ticker();
ms_tester_create_filters(filter_mask);
ms_filter_call_method(ms_tester_voidsource, MS_FILTER_SET_BITRATE, &sample_rate);
ms_filter_call_method(ms_tester_voidsource, MS_FILTER_SET_NCHANNELS, &nchannels);
ms_filter_call_method(ms_tester_dtmfgen, MS_FILTER_SET_BITRATE, &sample_rate);
ms_filter_call_method(ms_tester_dtmfgen, MS_FILTER_SET_NCHANNELS, &nchannels);
if (ms_filter_call_method(ms_tester_soundwrite, MS_FILTER_SET_BITRATE, &sample_rate) != 0) {
need_resampler = TRUE;
}
if (ms_filter_call_method(ms_tester_soundwrite, MS_FILTER_SET_NCHANNELS, &nchannels) != 0) {
need_resampler = TRUE;
}
if (need_resampler == TRUE) {
ms_tester_create_filters(FILTER_MASK_RESAMPLER);
configure_resampler(ms_tester_resampler, ms_tester_dtmfgen, ms_tester_soundwrite);
}
ms_connection_helper_start(&h);
ms_connection_helper_link(&h, ms_tester_voidsource, -1, 0);
ms_connection_helper_link(&h, ms_tester_dtmfgen, 0, 0);
if (need_resampler == TRUE) {
ms_connection_helper_link(&h, ms_tester_resampler, 0, 0);
}
ms_connection_helper_link(&h, ms_tester_soundwrite, 0, -1);
ms_ticker_attach(ms_tester_ticker, ms_tester_voidsource);
ms_tester_tone_generation_loop();
ms_ticker_detach(ms_tester_ticker, ms_tester_voidsource);
ms_connection_helper_start(&h);
ms_connection_helper_unlink(&h, ms_tester_voidsource, -1, 0);
ms_connection_helper_unlink(&h, ms_tester_dtmfgen, 0, 0);
if (need_resampler == TRUE) {
ms_connection_helper_unlink(&h, ms_tester_resampler, 0, 0);
}
ms_connection_helper_unlink(&h, ms_tester_soundwrite, 0, -1);
if (need_resampler == TRUE) {
ms_tester_destroy_filters(FILTER_MASK_RESAMPLER);
}
ms_filter_log_statistics();
ms_tester_destroy_filters(filter_mask);
ms_tester_destroy_ticker();
}
test_t sound_card_tests[] = {
{ "dtmfgen-soundwrite", dtmfgen_soundwrite }
};
test_suite_t sound_card_test_suite = {
"Sound Card",
sound_card_tester_init,
sound_card_tester_cleanup,
sizeof(sound_card_tests) / sizeof(sound_card_tests[0]),
sound_card_tests
};
......@@ -99,7 +99,8 @@ const char * mediastreamer2_tester_test_name(const char *suite_name, int test_in
}
void mediastreamer2_tester_init(void) {
add_test_suite(&dtmfgen_test_suite);
add_test_suite(&basic_audio_test_suite);
add_test_suite(&sound_card_test_suite);
}
void mediastreamer2_tester_uninit(void) {
......
......@@ -45,7 +45,8 @@ typedef struct {
extern "C" {
#endif
extern test_suite_t dtmfgen_test_suite;
extern test_suite_t basic_audio_test_suite;
extern test_suite_t sound_card_test_suite;
extern int mediastreamer2_tester_nb_test_suites(void);
......
/*
mediastreamer2 library - modular sound and video processing and streaming
Copyright (C) 2006-2013 Belledonne Communications, Grenoble
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; either version 2
of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
#include "CUnit/Basic.h"
#include "mediastreamer2_tester_private.h"
#include "mediastreamer2/dtmfgen.h"
#include "mediastreamer2/msfileplayer.h"
#include "mediastreamer2/msfilerec.h"
#include "mediastreamer2/msrtp.h"
#include "mediastreamer2/mssndcard.h"
#include "mediastreamer2/mstonedetector.h"
typedef struct {
MSDtmfGenCustomTone generated_tone;
MSToneDetectorDef expected_tone;
} tone_test_def_t;
static tone_test_def_t tone_definition[] = {
{ { 400, 2000, 0.6f, 0 }, { "", 2000, 300, 0.5f } },
{ { 600, 1500, 1.0f, 0 }, { "", 1500, 500, 0.9f } },
{ { 500, 941, 0.8f, 0 }, { "", 941, 400, 0.7f } }
};
MSTicker *ms_tester_ticker = NULL;
MSFilter *ms_tester_fileplay = NULL;
MSFilter *ms_tester_filerec = NULL;
MSFilter *ms_tester_dtmfgen = NULL;
MSFilter *ms_tester_tonedet = NULL;
MSFilter *ms_tester_voidsource = NULL;
MSFilter *ms_tester_voidsink = NULL;
MSFilter *ms_tester_encoder = NULL;
MSFilter *ms_tester_decoder = NULL;
MSFilter *ms_tester_rtprecv = NULL;
MSFilter *ms_tester_rtpsend = NULL;
MSFilter *ms_tester_resampler = NULL;
MSFilter *ms_tester_soundwrite = NULL;
unsigned char ms_tester_tone_detected;
static MSTicker * create_ticker(void) {
MSTickerParams params;
params.name = "Tester MSTicker";
params.prio = MS_TICKER_PRIO_NORMAL;
return ms_ticker_new_with_params(&params);
}
void ms_tester_create_ticker(void) {
CU_ASSERT_PTR_NULL(ms_tester_ticker);
ms_tester_ticker = create_ticker();
CU_ASSERT_PTR_NOT_NULL_FATAL(ms_tester_ticker);
}
void ms_tester_destroy_ticker(void) {
if (ms_tester_ticker) {
ms_ticker_destroy(ms_tester_ticker);
ms_tester_ticker = NULL;
}
}
#define CREATE_FILTER(mask, filter, id) \
if (filter_mask & mask) { \
CU_ASSERT_PTR_NULL(filter); \
filter = ms_filter_new(id); \
CU_ASSERT_PTR_NOT_NULL_FATAL(filter); \
}
void ms_tester_create_filters(unsigned int filter_mask) {
MSSndCardManager *manager;
MSSndCard *playcard;
CREATE_FILTER(FILTER_MASK_FILEPLAY, ms_tester_fileplay, MS_FILE_PLAYER_ID);
CREATE_FILTER(FILTER_MASK_FILEREC, ms_tester_filerec, MS_FILE_REC_ID);
CREATE_FILTER(FILTER_MASK_DTMFGEN, ms_tester_dtmfgen, MS_DTMF_GEN_ID);
CREATE_FILTER(FILTER_MASK_TONEDET, ms_tester_tonedet, MS_TONE_DETECTOR_ID);
CREATE_FILTER(FILTER_MASK_VOIDSOURCE, ms_tester_voidsource, MS_VOID_SOURCE_ID);
CREATE_FILTER(FILTER_MASK_VOIDSINK, ms_tester_voidsink, MS_VOID_SINK_ID);
CREATE_FILTER(FILTER_MASK_ENCODER, ms_tester_encoder, MS_ALAW_ENC_ID);
CREATE_FILTER(FILTER_MASK_DECODER, ms_tester_decoder, MS_ALAW_DEC_ID);
CREATE_FILTER(FILTER_MASK_RTPRECV, ms_tester_rtprecv, MS_RTP_RECV_ID);
CREATE_FILTER(FILTER_MASK_RTPSEND, ms_tester_rtpsend, MS_RTP_SEND_ID);
CREATE_FILTER(FILTER_MASK_RESAMPLER, ms_tester_resampler, MS_RESAMPLE_ID);
if (filter_mask & FILTER_MASK_SOUNDWRITE) {
CU_ASSERT_PTR_NULL(ms_tester_soundwrite);
manager = ms_snd_card_manager_get();
playcard = ms_snd_card_manager_get_default_playback_card(manager);
CU_ASSERT_PTR_NOT_NULL_FATAL(playcard);
ms_tester_soundwrite = ms_snd_card_create_writer(playcard);
CU_ASSERT_PTR_NOT_NULL_FATAL(ms_tester_soundwrite);
}
}
#define DESTROY_FILTER(mask, filter) \
if ((filter_mask & mask) & (filter != NULL)) { \
ms_filter_destroy(filter); \
} \
filter = NULL
void ms_tester_destroy_filters(unsigned int filter_mask) {
DESTROY_FILTER(FILTER_MASK_FILEPLAY, ms_tester_fileplay);
DESTROY_FILTER(FILTER_MASK_FILEREC, ms_tester_filerec);
DESTROY_FILTER(FILTER_MASK_DTMFGEN, ms_tester_dtmfgen);
DESTROY_FILTER(FILTER_MASK_TONEDET, ms_tester_tonedet);
DESTROY_FILTER(FILTER_MASK_VOIDSOURCE, ms_tester_voidsource);
DESTROY_FILTER(FILTER_MASK_VOIDSINK, ms_tester_voidsink);
DESTROY_FILTER(FILTER_MASK_ENCODER, ms_tester_encoder);
DESTROY_FILTER(FILTER_MASK_DECODER, ms_tester_decoder);
DESTROY_FILTER(FILTER_MASK_RTPRECV, ms_tester_rtprecv);
DESTROY_FILTER(FILTER_MASK_RTPSEND, ms_tester_rtpsend);
DESTROY_FILTER(FILTER_MASK_RESAMPLER, ms_tester_resampler);
DESTROY_FILTER(FILTER_MASK_SOUNDWRITE, ms_tester_soundwrite);
}
void ms_tester_tone_generation_loop(void) {
unsigned int i;
for (i = 0; i < (sizeof(tone_definition) / sizeof(tone_definition[0])); i++) {
ms_filter_call_method(ms_tester_dtmfgen, MS_DTMF_GEN_PLAY_CUSTOM, &tone_definition[i].generated_tone);
ms_sleep(1);
}
}
void ms_tester_tone_detection_loop(void) {
unsigned int i;
for (i = 0; i < (sizeof(tone_definition) / sizeof(tone_definition[0])); i++) {
ms_tester_tone_detected = FALSE;
ms_filter_call_method(ms_tester_tonedet, MS_TONE_DETECTOR_CLEAR_SCANS, NULL);
ms_filter_call_method(ms_tester_tonedet, MS_TONE_DETECTOR_ADD_SCAN, &tone_definition[i].expected_tone);
ms_sleep(1);
CU_ASSERT_EQUAL(ms_tester_tone_detected, TRUE);
}
}
void ms_tester_tone_generation_and_detection_loop(void) {
unsigned int i;
for (i = 0; i < (sizeof(tone_definition) / sizeof(tone_definition[0])); i++) {
ms_tester_tone_detected = FALSE;
ms_filter_call_method(ms_tester_tonedet, MS_TONE_DETECTOR_CLEAR_SCANS, NULL);
ms_filter_call_method(ms_tester_tonedet, MS_TONE_DETECTOR_ADD_SCAN, &tone_definition[i].expected_tone);
ms_filter_call_method(ms_tester_dtmfgen, MS_DTMF_GEN_PLAY_CUSTOM, &tone_definition[i].generated_tone);
ms_sleep(1);
CU_ASSERT_EQUAL(ms_tester_tone_detected, TRUE);
}
}
/*
mediastreamer2 library - modular sound and video processing and streaming
Copyright (C) 2006-2013 Belledonne Communications, Grenoble
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; either version 2
of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
#ifndef _MEDIASTREAMER2_TESTER_PRIVATE_H
#define _MEDIASTREAMER2_TESTER_PRIVATE_H
#include "mediastreamer2/msfilter.h"
#include "mediastreamer2/msticker.h"
extern MSTicker *ms_tester_ticker;
extern MSFilter *ms_tester_fileplay;
extern MSFilter *ms_tester_filerec;
extern MSFilter *ms_tester_dtmfgen;
extern MSFilter *ms_tester_tonedet;
extern MSFilter *ms_tester_voidsource;
extern MSFilter *ms_tester_voidsink;
extern MSFilter *ms_tester_encoder;
extern MSFilter *ms_tester_decoder;
extern MSFilter *ms_tester_rtprecv;
extern MSFilter *ms_tester_rtpsend;
extern MSFilter *ms_tester_resampler;
extern MSFilter *ms_tester_soundwrite;
enum {
FILTER_MASK_FILEPLAY = (1 << 0),
FILTER_MASK_FILEREC = (1 << 1),
FILTER_MASK_DTMFGEN = (1 << 2),
FILTER_MASK_TONEDET = (1 << 3),
FILTER_MASK_VOIDSOURCE = (1 << 4),
FILTER_MASK_VOIDSINK = (1 << 5),
FILTER_MASK_ENCODER = (1 << 6),
FILTER_MASK_DECODER = (1 << 7),
FILTER_MASK_RTPRECV = (1 << 8),
FILTER_MASK_RTPSEND = (1 << 9),
FILTER_MASK_RESAMPLER = (1 << 10),
FILTER_MASK_SOUNDWRITE = (1 << 11)
} filter_mask_enum;
extern unsigned char ms_tester_tone_detected;
void ms_tester_create_ticker(void);
void ms_tester_destroy_ticker(void);
void ms_tester_create_filters(unsigned int filter_mask);
void ms_tester_destroy_filters(unsigned int filter_mask);
void ms_tester_tone_generation_loop(void);
void ms_tester_tone_detection_loop(void);
void ms_tester_tone_generation_and_detection_loop(void);
#endif /* _MEDIASTREAMER2_TESTER_PRIVATE_H */
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