Commit 9abf28b2 authored by Sandrine Avakian's avatar Sandrine Avakian

Attempt updating media streamer tests.

mediastreamer2-sound_card_tester still uses the fallback factory.
Added reference to MSFactory in MSSndCard an MSSndCardManager.
parent 90c2aed3
......@@ -131,6 +131,7 @@ typedef struct _MSSndCardDesc MSSndCardDesc;
struct _MSSndCard{
MSSndCardDesc *desc;
MSFactory* factory;
char *name;
char *id;
unsigned int capabilities;
......@@ -222,6 +223,8 @@ MS2_PUBLIC const MSList * ms_snd_card_manager_get_list(MSSndCardManager *m);
*
*/
MS2_PUBLIC void ms_snd_card_manager_add_card(MSSndCardManager *m, MSSndCard *c);
MS2_PUBLIC void ms_snd_card_set_factory(MSSndCardManager*m, MSSndCard *c);
/**
* Prepend a list of sound card object to the sound card manager's list.
......
......@@ -356,11 +356,14 @@ static void au_card_detect(MSSndCardManager * m)
if (check_card_capability(devices[i],TRUE,devname,uidname,sizeof(uidname))){
card_capacity|=MS_SND_CARD_CAP_CAPTURE;
}
if (card_capacity) {
card=ca_card_new(devname, uidname, devices[i], card_capacity);
ms_snd_card_set_factory(m, card);
ms_snd_card_manager_add_card(m, card);
}
}
}
......
......@@ -385,6 +385,10 @@ MSFilter *ms_factory_create_filter_from_desc(MSFactory* factory, MSFilterDesc *d
obj->desc->init(obj);
return obj;
}
//
//struct _MSSndCardManager* ms_factory_get_snd_card_manager(MSFactory *factory){
// return factory->scm;
//}
MSFilter *ms_factory_create_filter(MSFactory* factory, MSFilterId id){
MSFilterDesc *desc;
......
......@@ -106,6 +106,10 @@ void ms_snd_card_manager_add_card(MSSndCardManager *m, MSSndCard *c){
m->cards=ms_list_append(m->cards,c);
}
void ms_snd_card_set_factory(MSSndCardManager*m, MSSndCard *c){
c->factory = m->factory;
}
void ms_snd_card_manager_prepend_cards(MSSndCardManager *m, MSList *l) {
MSList *elem;
MSList *lcopy = ms_list_copy(l);
......@@ -149,6 +153,7 @@ MSSndCard * ms_snd_card_new(MSSndCardDesc *desc){
MSSndCard * ms_snd_card_new_with_name(MSSndCardDesc *desc,const char* name) {
MSSndCard *obj=(MSSndCard *)ms_new0(MSSndCard,1);
obj->factory = NULL;
obj->desc=desc;
obj->name=name?ms_strdup(name):NULL;
obj->data=NULL;
......
......@@ -260,6 +260,8 @@ void ms_audio_endpoint_destroy(MSAudioEndpoint *ep){
MSAudioEndpoint * ms_audio_endpoint_new_recorder(MSFactory* factory){
MSAudioEndpoint *ep=ms_audio_endpoint_new();
ep->in_resampler=ms_factory_create_filter(factory, MS_RESAMPLE_ID);
ep->out_resampler=ms_factory_create_filter(factory, MS_RESAMPLE_ID);
ep->recorder=ms_factory_create_filter(factory, MS_FILE_REC_ID);
ep->player=ms_factory_create_filter(factory, MS_FILE_PLAYER_ID);
ep->mixer_out.filter=ep->recorder;
......
......@@ -41,9 +41,15 @@ static RtpProfile rtp_profile;
#define EDGE_BW 10
#define THIRDGENERATION_BW 200
static MSFactory *factory;
static int tester_before_all(void) {
ms_init();
ms_filter_enable_statistics(TRUE);
//ms_init();
factory = ms_factory_new();
ms_factory_init_voip(factory);
ms_factory_init_plugins(factory);
//ms_filter_enable_statistics(TRUE);
ms_factory_enable_statistics(factory, TRUE);
ortp_init();
rtp_profile_set_payload (&rtp_profile,0,&payload_type_pcmu8000);
rtp_profile_set_payload (&rtp_profile,OPUS_PAYLOAD_TYPE,&payload_type_opus);
......@@ -59,7 +65,11 @@ static int tester_before_all(void) {
static int tester_after_all(void) {
ortp_exit();
ms_exit();
//ms_exit();
ms_factory_uninit_voip(factory);
ms_factory_uninit_plugins(factory);
ms_factory_destroy(factory);
rtp_profile_clear_all(&rtp_profile);
return 0;
}
......@@ -96,10 +106,10 @@ stream_manager_t * stream_manager_new(MSFormatType type) {
mgr->user_data = 0;
if (mgr->type==MSAudio){
mgr->audio_stream=audio_stream_new (mgr->local_rtp, mgr->local_rtcp,FALSE);
mgr->audio_stream=audio_stream_new (mgr->local_rtp, mgr->local_rtcp,FALSE, factory);
}else{
#if VIDEO_ENABLED
mgr->video_stream=video_stream_new (mgr->local_rtp, mgr->local_rtcp,FALSE);
mgr->video_stream=video_stream_new (mgr->local_rtp, mgr->local_rtcp,FALSE, factory);
#else
ms_fatal("Unsupported stream type [%s]",ms_format_type_to_string(mgr->type));
#endif
......@@ -346,7 +356,10 @@ static void packet_duplication(void) {
}
static void upload_bandwidth_computation(void) {
bool_t supported = ms_filter_codec_supported("pcma");
//bool_t supported = ms_filter_codec_supported("pcma");
bool_t supported = ms_factory_codec_supported(factory, "pcma");
if( supported ) {
stream_manager_t * marielle, * margaux;
int i;
......@@ -365,7 +378,8 @@ static void upload_bandwidth_computation(void) {
}
static void loss_rate_estimation(void) {
bool_t supported = ms_filter_codec_supported("pcma");
//bool_t supported = ms_filter_codec_supported("pcma");
bool_t supported = ms_factory_codec_supported(factory, "pcma");
if( supported ) {
LossRateEstimatorCtx ctx;
stream_manager_t * marielle, * margaux;
......@@ -391,7 +405,8 @@ static void loss_rate_estimation(void) {
}
void upload_bitrate(const char* codec, int payload, int target_bw, int expect_bw) {
bool_t supported = ms_filter_codec_supported(codec);
//bool_t supported = ms_filter_codec_supported("pcma");
bool_t supported = ms_factory_codec_supported(factory, "pcma");
if( supported ) {
float upload_bw;
stream_manager_t * marielle, * margaux;
......
......@@ -27,6 +27,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#include "mediastreamer2_tester_private.h"
static RtpProfile rtp_profile;
static MSFactory *factory ;
#define OPUS_PAYLOAD_TYPE 121
#define SPEEX16_PAYLOAD_TYPE 122
......@@ -34,8 +35,13 @@ static RtpProfile rtp_profile;
#define PCMA8_PAYLOAD_TYPE 8
static int tester_before_all(void) {
ms_init();
ms_filter_enable_statistics(TRUE);
//ms_init();
factory = ms_factory_new();
ms_factory_init_voip(factory);
ms_factory_init_plugins(factory);
//ms_filter_enable_statistics(TRUE);
ms_factory_enable_statistics(factory, TRUE);
ortp_init();
rtp_profile_set_payload (&rtp_profile,0,&payload_type_pcmu8000);
rtp_profile_set_payload (&rtp_profile,OPUS_PAYLOAD_TYPE,&payload_type_opus);
......@@ -47,7 +53,11 @@ static int tester_before_all(void) {
}
static int tester_after_all(void) {
ms_exit();
//ms_exit();
ms_factory_uninit_voip(factory);
ms_factory_uninit_plugins(factory);
ms_factory_destroy(factory);
rtp_profile_clear_all(&rtp_profile);
return 0;
}
......@@ -130,9 +140,9 @@ static void basic_audio_stream_base_2( const char* marielle_local_ip
, int margaux_local_rtcp_port
, int margaux_remote_rtcp_port
, int lost_percentage) {
AudioStream * marielle = audio_stream_new2 (marielle_local_ip, marielle_local_rtp_port, marielle_local_rtcp_port);
AudioStream * marielle = audio_stream_new2 (marielle_local_ip, marielle_local_rtp_port, marielle_local_rtcp_port, factory);
stats_t marielle_stats;
AudioStream * margaux = audio_stream_new2 (margaux_local_ip, margaux_local_rtp_port,margaux_local_rtcp_port);
AudioStream * margaux = audio_stream_new2 (margaux_local_ip, margaux_local_rtp_port,margaux_local_rtcp_port, factory);
stats_t margaux_stats;
RtpProfile* profile = rtp_profile_new("default profile");
char* hello_file = bc_tester_res(HELLO_8K_1S_FILE);
......@@ -241,8 +251,8 @@ static void encrypted_audio_stream_base( bool_t change_ssrc,
,bool_t set_both_send_recv_key
,bool_t send_key_first
,bool_t encryption_mandatory) {
AudioStream * marielle = audio_stream_new (MARIELLE_RTP_PORT, MARIELLE_RTCP_PORT,FALSE);
AudioStream * margaux = audio_stream_new (MARGAUX_RTP_PORT,MARGAUX_RTCP_PORT, FALSE);
AudioStream * marielle = audio_stream_new (MARIELLE_RTP_PORT, MARIELLE_RTCP_PORT,FALSE, factory);
AudioStream * margaux = audio_stream_new (MARGAUX_RTP_PORT,MARGAUX_RTCP_PORT, FALSE, factory);
RtpProfile* profile = rtp_profile_new("default profile");
char* hello_file = bc_tester_res(HELLO_8K_1S_FILE);
char* recorded_file = bc_tester_file(RECORDED_8K_1S_FILE);
......@@ -350,7 +360,7 @@ static void encrypted_audio_stream_base( bool_t change_ssrc,
if (change_ssrc) {
audio_stream_stop(marielle);
marielle = audio_stream_new (MARIELLE_RTP_PORT, MARIELLE_RTCP_PORT,FALSE);
marielle = audio_stream_new (MARIELLE_RTP_PORT, MARIELLE_RTCP_PORT,FALSE, factory);
BC_ASSERT_EQUAL(audio_stream_start_full(marielle
, profile
, MARGAUX_IP
......@@ -421,9 +431,9 @@ static void encrypted_audio_stream_with_key_change_encryption_mandatory(void) {
}
static void codec_change_for_audio_stream(void) {
AudioStream *marielle = audio_stream_new2(MARIELLE_IP, MARIELLE_RTP_PORT, MARIELLE_RTCP_PORT);
AudioStream *marielle = audio_stream_new2(MARIELLE_IP, MARIELLE_RTP_PORT, MARIELLE_RTCP_PORT, factory);
stats_t marielle_stats;
AudioStream *margaux = audio_stream_new2(MARGAUX_IP, MARGAUX_RTP_PORT, MARGAUX_RTCP_PORT);
AudioStream *margaux = audio_stream_new2(MARGAUX_IP, MARGAUX_RTP_PORT, MARGAUX_RTCP_PORT, factory);
stats_t margaux_stats;
RtpProfile *profile = rtp_profile_new("default profile");
char* hello_file = bc_tester_res(HELLO_8K_1S_FILE);
......@@ -460,7 +470,7 @@ static void codec_change_for_audio_stream(void) {
audio_stream_stop(marielle);
reset_stats(&marielle_stats);
reset_stats(&margaux_stats);
marielle = audio_stream_new2(MARIELLE_IP, MARIELLE_RTP_PORT, MARIELLE_RTCP_PORT);
marielle = audio_stream_new2(MARIELLE_IP, MARIELLE_RTP_PORT, MARIELLE_RTCP_PORT,factory);
BC_ASSERT_EQUAL(audio_stream_start_full(marielle, profile, MARGAUX_IP, MARGAUX_RTP_PORT, MARGAUX_IP, MARGAUX_RTCP_PORT,
8, 50, hello_file, NULL, NULL, NULL, 0), 0, int, "%d");
......@@ -487,9 +497,9 @@ static void codec_change_for_audio_stream(void) {
}
static void tmmbr_feedback_for_audio_stream(void) {
AudioStream *marielle = audio_stream_new2(MARIELLE_IP, MARIELLE_RTP_PORT, MARIELLE_RTCP_PORT);
AudioStream *marielle = audio_stream_new2(MARIELLE_IP, MARIELLE_RTP_PORT, MARIELLE_RTCP_PORT,factory);
stats_t marielle_stats;
AudioStream *margaux = audio_stream_new2(MARGAUX_IP, MARGAUX_RTP_PORT, MARGAUX_RTCP_PORT);
AudioStream *margaux = audio_stream_new2(MARGAUX_IP, MARGAUX_RTP_PORT, MARGAUX_RTCP_PORT,factory);
stats_t margaux_stats;
RtpProfile *profile = rtp_profile_new("default profile");
RtpSession *marielle_session;
......
......@@ -28,15 +28,24 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#include "mediastreamer2_tester_private.h"
#include "private.h"
static MSFactory *factory;
static int basic_audio_tester_before_all(void) {
ms_init();
ms_filter_enable_statistics(TRUE);
//ms_init();
factory = ms_factory_new();
ms_factory_init_voip(factory);
ms_factory_init_plugins(factory);
ms_factory_enable_statistics(factory, TRUE);
ortp_init();
return 0;
}
static int basic_audio_tester_after_all(void) {
ms_exit();
//ms_exit();
ms_factory_uninit_voip(factory);
ms_factory_uninit_plugins(factory);
ms_factory_destroy(factory);
ortp_exit();
return 0;
}
......@@ -50,9 +59,12 @@ static void dtmfgen_tonedet(void) {
unsigned int filter_mask = FILTER_MASK_VOIDSOURCE | FILTER_MASK_DTMFGEN | FILTER_MASK_TONEDET | FILTER_MASK_VOIDSINK;
bool_t send_silence = TRUE;
ms_filter_reset_statistics();
// ms_filter_reset_statistics();
ms_factory_reset_statistics(factory);
ms_tester_create_ticker();
ms_tester_create_filters(filter_mask);
ms_tester_create_filters(filter_mask, factory);
ms_filter_add_notify_callback(ms_tester_tonedet, (MSFilterNotifyFunc)tone_detected_cb, NULL,TRUE);
ms_filter_call_method(ms_tester_voidsource, MS_VOID_SOURCE_SEND_SILENCE, &send_silence);
ms_connection_helper_start(&h);
......@@ -73,7 +85,8 @@ static void dtmfgen_tonedet(void) {
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_factory_log_statistics(factory);
//ms_filter_log_statistics();
ms_tester_destroy_filters(filter_mask);
ms_tester_destroy_ticker();
}
......@@ -84,11 +97,14 @@ static void dtmfgen_enc_dec_tonedet(char *mime, int sample_rate, int nchannels)
unsigned int filter_mask = FILTER_MASK_VOIDSOURCE | FILTER_MASK_DTMFGEN | FILTER_MASK_ENCODER
| FILTER_MASK_DECODER | FILTER_MASK_TONEDET | FILTER_MASK_VOIDSINK;
bool_t send_silence = TRUE;
ms_filter_reset_statistics();
MSSndCardManager *scm = ms_snd_card_manager_get();
ms_factory_reset_statistics(scm->factory);
//ms_filter_reset_statistics();
ms_tester_create_ticker();
ms_tester_codec_mime = mime;
ms_tester_create_filters(filter_mask);
ms_tester_create_filters(filter_mask, scm->factory);
/* set sample rate and channel number to all filters (might need to check the return value to insert a resampler if needed?) */
ms_filter_call_method(ms_tester_voidsource, MS_FILTER_SET_SAMPLE_RATE, &sample_rate);
......@@ -126,7 +142,8 @@ static void dtmfgen_enc_dec_tonedet(char *mime, int sample_rate, int nchannels)
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_filter_log_statistics();
ms_factory_log_statistics(scm->factory);
ms_tester_destroy_filters(filter_mask);
ms_tester_destroy_ticker();
}
......@@ -136,7 +153,9 @@ static void dtmfgen_enc_dec_tonedet_pcmu(void) {
}
static void dtmfgen_enc_dec_tonedet_isac(void) {
bool_t supported = ms_filter_codec_supported("iSAC");
MSSndCardManager *scm = ms_snd_card_manager_get();
bool_t supported = ms_factory_codec_supported(scm->factory, "iSAC");
// bool_t supported = ms_filter_codec_supported("iSAC");
if( supported ) {
dtmfgen_enc_dec_tonedet("iSAC", 16000, 1);
}
......@@ -154,11 +173,13 @@ static void dtmfgen_enc_rtp_dec_tonedet(void) {
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;
bool_t send_silence = TRUE;
ms_filter_reset_statistics();
MSSndCardManager *scm = ms_snd_card_manager_get();
ms_factory_reset_statistics(scm->factory);
//ms_filter_reset_statistics();
ms_tester_create_ticker();
ms_tester_codec_mime = "pcmu";
ms_tester_create_filters(filter_mask);
ms_tester_create_filters(filter_mask, scm->factory);
ms_filter_add_notify_callback(ms_tester_tonedet, (MSFilterNotifyFunc)tone_detected_cb, NULL,TRUE);
rtps = ms_create_duplex_rtp_session("0.0.0.0", 50060, 0);
rtp_session_set_remote_addr_full(rtps, "127.0.0.1", 50060, "127.0.0.1", 50061);
......@@ -193,7 +214,8 @@ static void dtmfgen_enc_rtp_dec_tonedet(void) {
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_filter_log_statistics();
ms_factory_log_statistics(scm->factory);
ms_tester_destroy_filters(filter_mask);
ms_tester_destroy_ticker();
rtp_session_destroy(rtps);
......@@ -208,9 +230,10 @@ static void dtmfgen_filerec_fileplay_tonedet(void) {
bool_t send_silence = TRUE;
char* recorded_file = bc_tester_file(DTMFGEN_FILE_NAME);
ms_filter_reset_statistics();
ms_factory_reset_statistics(factory);
ms_tester_create_ticker();
ms_tester_create_filters(filter_mask);
ms_tester_create_filters(filter_mask, factory);
ms_filter_add_notify_callback(ms_tester_tonedet, (MSFilterNotifyFunc)tone_detected_cb, NULL,TRUE);
// Generate tones and save them to a file
......@@ -247,7 +270,8 @@ static void dtmfgen_filerec_fileplay_tonedet(void) {
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_factory_log_statistics(factory);
// ms_filter_log_statistics();
ms_tester_destroy_filters(filter_mask);
ms_tester_destroy_ticker();
unlink(recorded_file);
......
......@@ -41,24 +41,38 @@ static int tester_after_all(void) {
static void filter_register_tester(void) {
MSFilter* filter;
ms_init();
ms_init();
BC_ASSERT_PTR_NOT_NULL(ms_filter_lookup_by_name("MSVoidSource"));
filter= ms_filter_create_decoder("pcma");
MSFactory* factory;
factory = ms_factory_new();
ms_factory_init_voip(factory);
ms_factory_init_plugins(factory);
ms_factory_init_voip(factory);
ms_factory_init_plugins(factory);
//ms_init();
//ms_init();
BC_ASSERT_PTR_NOT_NULL(ms_factory_lookup_filter_by_name(factory, "MSVoidSource"));
BC_ASSERT_PTR_NOT_NULL(ms_factory_lookup_filter_by_name(factory, "MSVoidSource"));
filter= ms_factory_create_decoder(factory, "pcma");
BC_ASSERT_PTR_NOT_NULL(filter);
ms_filter_destroy(filter);
ms_exit();
ms_factory_uninit_voip(factory);
ms_factory_uninit_plugins(factory);
ms_factory_destroy(factory);
// ms_exit();
BC_ASSERT_PTR_NOT_NULL(ms_filter_lookup_by_name("MSVoidSource"));
filter= ms_filter_create_decoder("pcma");
BC_ASSERT_PTR_NOT_NULL(ms_factory_lookup_filter_by_name(factory,"MSVoidSource"));
filter= ms_factory_create_decoder(factory, "pcma");
BC_ASSERT_PTR_NOT_NULL(filter);
ms_filter_destroy(filter);
ms_exit();
BC_ASSERT_PTR_NULL(ms_factory_get_fallback());
ms_factory_uninit_voip(factory);
ms_factory_uninit_plugins(factory);
ms_factory_destroy(factory);
BC_ASSERT_PTR_NULL(factory);
}
#ifdef VIDEO_ENABLED
static void test_video_processing (void) {
......@@ -145,34 +159,39 @@ static void test_is_multicast(void) {
static void test_filterdesc_enable_disable_base(const char* mime, const char* filtername,bool_t is_enc) {
MSFilter *filter;
ms_init();
MSFactory *factory = ms_factory_new();
ms_factory_init_voip(factory);
ms_factory_init_plugins(factory);
if (is_enc)
filter = ms_filter_create_encoder(mime);
filter = ms_factory_create_filter(factory,mime);
else
filter = ms_filter_create_decoder(mime);
filter = ms_factory_create_filter(factory,mime);
BC_ASSERT_PTR_NOT_NULL(filter);
ms_filter_destroy(filter);
BC_ASSERT_FALSE(ms_factory_enable_filter_from_name(ms_factory_get_fallback(),filtername,FALSE));
BC_ASSERT_FALSE(ms_factory_filter_from_name_enabled(ms_factory_get_fallback(),filtername));
BC_ASSERT_FALSE(ms_factory_enable_filter_from_name(factory,filtername,FALSE));
BC_ASSERT_FALSE(ms_factory_filter_from_name_enabled(factory,filtername));
if (is_enc)
filter = ms_filter_create_encoder(mime);
filter = ms_factory_create_encoder(factory,mime);
else
filter = ms_filter_create_decoder(mime);
filter = ms_factory_create_encoder(factory,mime);
BC_ASSERT_PTR_NULL(filter);
BC_ASSERT_FALSE(ms_factory_enable_filter_from_name(ms_factory_get_fallback(),filtername,TRUE));
BC_ASSERT_TRUE(ms_factory_filter_from_name_enabled(ms_factory_get_fallback(),filtername));
BC_ASSERT_FALSE(ms_factory_enable_filter_from_name(factory,filtername,TRUE));
BC_ASSERT_TRUE(ms_factory_filter_from_name_enabled(factory,filtername));
if (is_enc)
filter = ms_filter_create_encoder(mime);
filter = ms_factory_create_encoder(factory,mime);
else
filter = ms_filter_create_decoder(mime);
filter = ms_factory_create_decoder(factory,mime);
BC_ASSERT_PTR_NOT_NULL(filter);
ms_filter_destroy(filter);
ms_exit();
ms_factory_uninit_voip(factory);
ms_factory_uninit_plugins(factory);
ms_factory_destroy(factory);
}
static void test_filterdesc_enable_disable(void) {
test_filterdesc_enable_disable_base("pcmu", "MSUlawDec", FALSE);
......
......@@ -21,13 +21,19 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#include "mediastreamer2/msmediaplayer.h"
#include "mediastreamer2/mediastream.h"
static MSFactory* factory;
static int tester_before_all(void) {
ms_init();
factory = ms_factory_new();
ms_factory_init_voip(factory);
ms_factory_init_plugins(factory);
return 0;
}
static int tester_after_all(void) {
ms_exit();
ms_factory_uninit_voip(factory);
ms_factory_uninit_plugins(factory);
ms_factory_destroy(factory);
return 0;
}
......@@ -81,7 +87,7 @@ static void play_file(const char *filepath, bool_t unsupported_format, bool_t se
BC_ASSERT_EQUAL(ms_media_player_get_state(file_player), MSPlayerClosed, int, "%d");
ms_media_player_set_eof_callback(file_player, eof_callback, &eof);
succeed = ms_media_player_open(file_player, filepath);
succeed = ms_media_player_open(file_player, filepath, snd_card->factory);
if(unsupported_format) {
BC_ASSERT_FALSE(succeed);
BC_ASSERT_EQUAL(ms_media_player_get_state(file_player), MSPlayerClosed, int, "%d");
......@@ -125,7 +131,7 @@ static void play_file(const char *filepath, bool_t unsupported_format, bool_t se
if(play_twice) {
eof_init(&eof);
BC_ASSERT_TRUE(ms_media_player_open(file_player, filepath));
BC_ASSERT_TRUE(ms_media_player_open(file_player, filepath,snd_card->factory));
BC_ASSERT_TRUE(ms_media_player_start(file_player));
wait_for_eof(&eof, 100, timeout);
ms_media_player_close(file_player);
......
......@@ -26,6 +26,8 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#include "mediastreamer2_tester.h"
#include "mediastreamer2_tester_private.h"
#pragma GCC diagnostic ignored "-Wdeprecated-declarations"
static int sound_card_tester_before_all(void) {
ms_init();
ms_filter_enable_statistics(TRUE);
......@@ -62,7 +64,7 @@ static void dtmfgen_soundwrite(void) {
ms_filter_reset_statistics();
ms_tester_create_ticker();
ms_tester_create_filters(filter_mask);
ms_tester_create_filters(filter_mask, ms_factory_get_fallback());
ms_filter_call_method(ms_tester_voidsource, MS_FILTER_SET_SAMPLE_RATE, &sample_rate);
ms_filter_call_method(ms_tester_voidsource, MS_FILTER_SET_NCHANNELS, &nchannels);
ms_filter_call_method(ms_tester_voidsource, MS_VOID_SOURCE_SEND_SILENCE, &send_silence);
......@@ -75,7 +77,7 @@ static void dtmfgen_soundwrite(void) {
need_resampler = TRUE;
}
if (need_resampler == TRUE) {
ms_tester_create_filters(FILTER_MASK_RESAMPLER);
ms_tester_create_filters(FILTER_MASK_RESAMPLER, ms_factory_get_fallback());
configure_resampler(ms_tester_resampler, ms_tester_dtmfgen, ms_tester_soundwrite);
}
ms_connection_helper_start(&h);
......@@ -133,7 +135,7 @@ static void fileplay_soundwrite(const char *filename) {
ms_filter_reset_statistics();
ms_tester_create_ticker();
ms_tester_create_filters(filter_mask);
ms_tester_create_filters(filter_mask, ms_factory_get_fallback());
ms_filter_add_notify_callback(ms_tester_fileplay, fileplay_eof, &done,TRUE);
ms_filter_call_method_noarg(ms_tester_fileplay, MS_FILE_PLAYER_CLOSE);
ms_filter_call_method(ms_tester_fileplay, MS_FILE_PLAYER_OPEN, (void *)filename);
......@@ -150,7 +152,7 @@ static void fileplay_soundwrite(const char *filename) {
if (nchannels != soundwrite_nchannels) need_resampler = TRUE;
}
if (need_resampler == TRUE) {
ms_tester_create_filters(FILTER_MASK_RESAMPLER);
ms_tester_create_filters(FILTER_MASK_RESAMPLER, ms_factory_get_fallback());
configure_resampler(ms_tester_resampler, ms_tester_fileplay, ms_tester_soundwrite);
}
ms_filter_call_method_noarg(ms_tester_fileplay, MS_FILE_PLAYER_START);
......@@ -231,7 +233,7 @@ static void soundread_soundwrite(void) {
ms_filter_reset_statistics();
ms_tester_create_ticker();
ms_tester_create_filters(filter_mask);
ms_tester_create_filters(filter_mask, ms_factory_get_fallback());
ms_filter_call_method(ms_tester_soundread, MS_FILTER_GET_SAMPLE_RATE, &sample_rate);
ms_filter_call_method(ms_tester_soundread, MS_FILTER_GET_NCHANNELS, &nchannels);
if (ms_filter_call_method(ms_tester_soundwrite, MS_FILTER_SET_SAMPLE_RATE, &sample_rate) != 0) {
......@@ -245,7 +247,7 @@ static void soundread_soundwrite(void) {
if (nchannels != soundwrite_nchannels) need_resampler = TRUE;
}
if (need_resampler == TRUE) {
ms_tester_create_filters(FILTER_MASK_RESAMPLER);
ms_tester_create_filters(FILTER_MASK_RESAMPLER, ms_factory_get_fallback());
configure_resampler(ms_tester_resampler, ms_tester_soundread, ms_tester_soundwrite);
}
ms_connection_helper_start(&h);
......@@ -284,7 +286,7 @@ static void soundread_speexenc_speexdec_soundwrite(void) {
ms_filter_reset_statistics();
ms_tester_create_ticker();
ms_tester_codec_mime = "speex";
ms_tester_create_filters(filter_mask);
ms_tester_create_filters(filter_mask, ms_factory_get_fallback());
ms_filter_call_method(ms_tester_encoder, MS_FILTER_GET_BITRATE, &sample_rate);
ms_filter_call_method(ms_tester_decoder, MS_FILTER_SET_BITRATE, &sample_rate);
if (ms_filter_call_method(ms_tester_soundread, MS_FILTER_SET_BITRATE, &sample_rate) != 0) {
......@@ -298,7 +300,7 @@ static void soundread_speexenc_speexdec_soundwrite(void) {
if (nchannels != soundread_nchannels) need_read_resampler = TRUE;
}
if (need_read_resampler == TRUE) {
ms_tester_create_filter(&read_resampler, MS_RESAMPLE_ID);
ms_tester_create_filter(&read_resampler, MS_RESAMPLE_ID, ms_factory_get_fallback());
configure_resampler(read_resampler, ms_tester_soundread, ms_tester_encoder);
}
if (ms_filter_call_method(ms_tester_soundwrite, MS_FILTER_SET_BITRATE, &sample_rate) != 0) {
......@@ -312,7 +314,7 @@ static void soundread_speexenc_speexdec_soundwrite(void) {
if (nchannels != soundwrite_nchannels) need_write_resampler = TRUE;
}
if (need_write_resampler == TRUE) {
ms_tester_create_filter(&write_resampler, MS_RESAMPLE_ID);
ms_tester_create_filter(&write_resampler, MS_RESAMPLE_ID, ms_factory_get_fallback());
configure_resampler(write_resampler, ms_tester_decoder, ms_tester_soundwrite);
}
ms_connection_helper_start(&h);
......@@ -366,7 +368,7 @@ static void soundread_filerec_fileplay_soundwrite(void) {
ms_filter_reset_statistics();
ms_tester_create_ticker();
ms_tester_create_filters(filter_mask);
ms_tester_create_filters(filter_mask, ms_factory_get_fallback());
// Write audio capture to a file
ms_filter_call_method(ms_tester_soundread, MS_FILTER_GET_SAMPLE_RATE, &capture_sample_rate);
......@@ -393,7 +395,7 @@ static void soundread_filerec_fileplay_soundwrite(void) {
ms_filter_call_method(ms_tester_soundwrite, MS_FILTER_GET_SAMPLE_RATE, &playback_sample_rate);
ms_filter_call_method(ms_tester_soundwrite, MS_FILTER_GET_NCHANNELS, &playback_nchannels);
if ((capture_sample_rate != playback_sample_rate) || (capture_nchannels != playback_nchannels)) {
ms_tester_create_filter(&ms_tester_resampler, MS_RESAMPLE_ID);
ms_tester_create_filter(&ms_tester_resampler, MS_RESAMPLE_ID, ms_factory_get_fallback());
}
ms_filter_call_method_noarg(ms_tester_fileplay, MS_FILE_PLAYER_CLOSE);
ms_filter_call_method(ms_tester_fileplay, MS_FILE_PLAYER_OPEN, writable_filename);
......
......@@ -82,46 +82,48 @@ void ms_tester_destroy_ticker(void) {
}
}
#define CREATE_FILTER(mask, filter, id) \
#define CREATE_FILTER(mask, filter, factory, id) \
if (filter_mask & mask) { \
BC_ASSERT_PTR_NULL(filter); \
filter = ms_filter_new(id); \
filter = ms_factory_create_filter(factory, id); \
BC_ASSERT_PTR_NOT_NULL_FATAL(filter); \
}
void ms_tester_create_filter(MSFilter **filter, MSFilterId id) {
void ms_tester_create_filter(MSFilter **filter, MSFilterId id, MSFactory *f) {
BC_ASSERT_PTR_NOT_NULL(filter);
BC_ASSERT_PTR_NULL(*filter);
*filter = ms_filter_new(id);
*filter = ms_factory_create_filter(f, id);
BC_ASSERT_PTR_NOT_NULL_FATAL(*filter);
}
void ms_tester_create_filters(unsigned int filter_mask) {
void ms_tester_create_filters(unsigned int filter_mask, MSFactory * f) {
MSSndCardManager *snd_manager;
MSWebCamManager *cam_manager;
MSSndCard *playcard;
MSSndCard *captcard;
MSWebCam *camera;
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_FILEPLAY, ms_tester_fileplay,f, MS_FILE_PLAYER_ID);
CREATE_FILTER(FILTER_MASK_FILEREC, ms_tester_filerec,f, MS_FILE_REC_ID);
CREATE_FILTER(FILTER_MASK_DTMFGEN, ms_tester_dtmfgen, f, MS_DTMF_GEN_ID);
CREATE_FILTER(FILTER_MASK_TONEDET, ms_tester_tonedet, f, MS_TONE_DETECTOR_ID);
CREATE_FILTER(FILTER_MASK_VOIDSOURCE, ms_tester_voidsource, f, MS_VOID_SOURCE_ID);
CREATE_FILTER(FILTER_MASK_VOIDSINK, ms_tester_voidsink, f, MS_VOID_SINK_ID);
if (filter_mask & FILTER_MASK_ENCODER) {
BC_ASSERT_PTR_NULL(ms_tester_encoder);
ms_tester_encoder = ms_filter_create_encoder(ms_tester_codec_mime);
ms_tester_encoder = ms_factory_create_encoder(f, ms_tester_codec_mime);
BC_ASSERT_PTR_NOT_NULL_FATAL(ms_tester_encoder);
}
if (filter_mask & FILTER_MASK_DECODER) {
BC_ASSERT_PTR_NULL(ms_tester_decoder);
ms_tester_decoder = ms_filter_create_decoder(ms_tester_codec_mime);
ms_tester_decoder = ms_factory_create_decoder(f, ms_tester_codec_mime);
BC_ASSERT_PTR_NOT_NULL_FATAL(ms_tester_decoder);
}
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);
CREATE_FILTER(FILTER_MASK_RTPRECV, ms_tester_rtprecv, f, MS_RTP_RECV_ID);
CREATE_FILTER(FILTER_MASK_RTPSEND, ms_tester_rtpsend, f ,MS_RTP_SEND_ID);
CREATE_FILTER(FILTER_MASK_RESAMPLER, ms_tester_resampler, f, MS_RESAMPLE_ID);
if (filter_mask & FILTER_MASK_SOUNDWRITE) {
BC_ASSERT_PTR_NULL(ms_tester_soundwrite);
snd_manager = ms_snd_card_manager_get();
......@@ -143,7 +145,7 @@ void ms_tester_create_filters(unsigned int filter_mask) {
cam_manager = ms_web_cam_manager_get();
camera = ms_web_cam_manager_get_default_cam(cam_manager);
BC_ASSERT_PTR_NOT_NULL_FATAL(camera);
ms_tester_videocapture = ms_web_cam_create_reader(camera);
ms_tester_videocapture = ms_web_cam_create_reader(camera, f);
BC_ASSERT_PTR_NOT_NULL_FATAL(ms_tester_videocapture);
}
}
......
......@@ -75,8 +75,8 @@ extern unsigned char ms_tester_tone_detected;
void ms_tester_create_ticker(void);
void ms_tester_destroy_ticker(void);
void ms_tester_create_filter(MSFilter **filter, MSFilterId id);
void ms_tester_create_filters(unsigned int filter_mask);
void ms_tester_create_filter(MSFilter **filter, MSFilterId id, MSFactory *f);
void ms_tester_create_filters(unsigned int filter_mask, MSFactory *f);
void ms_tester_destroy_filter(MSFilter **filter);
void ms_tester_destroy_filters(unsigned int filter_mask);
void ms_tester_tone_generation_loop(void);
......