Commit b6330070 authored by Sandrine Avakian's avatar Sandrine Avakian

Adding tests media streamer for bv16.

Cleaning bv16 audio filter file.
parent d3e6edc1
......@@ -39,7 +39,6 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#define SIGNAL_FRAME_SIZE 80
#define BITSTREAM_FRAME_SIZE 10
#define NO_OF_BYTES_PER_5MS 10
typedef struct EncState{
struct BV16_Encoder_State state;
......@@ -147,7 +146,7 @@ static void enc_process (MSFilter *f){
ms_bufferizer_put(s->bufferizer,inputMessage);
}
// ms_message("MSBV16Enc in_rcvd_bytes %d frame_per_packet %d", in_rcvd_bytes, frame_per_packet );
/* process ptimes ms of data : (ptime in ms)/1000->ptime is seconds * 8000(sample rate) * 2(byte per sample) */
while(ms_bufferizer_get_avail(s->bufferizer)>= in_rcvd_bytes){
outputMessage = allocb(BITSTREAM_FRAME_SIZE*frame_per_packet,0); /* output bitStream is 80 bits long * number of samples */
......@@ -176,7 +175,7 @@ static MSFilterMethod enc_methods[]={
{MS_FILTER_ADD_FMTP ,enc_add_fmtp},
{MS_FILTER_ADD_ATTR ,enc_add_attr},
{MS_FILTER_GET_SAMPLE_RATE ,enc_get_sample_rate },
{MS_FILTER_GET_NCHANNELS , get_channels},
{MS_FILTER_GET_NCHANNELS ,get_channels},
{MS_AUDIO_ENCODER_SET_PTIME, enc_set_ptime},
{ 0 , NULL }
};
......
......@@ -27,6 +27,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#include "mediastreamer2_tester_private.h"
#include "qosanalyzer.h"
#include <math.h>
#include <sys/stat.h>
static RtpProfile rtp_profile;
......@@ -34,6 +35,7 @@ static RtpProfile rtp_profile;
#define SPEEX_PAYLOAD_TYPE 122
#define SILK16_PAYLOAD_TYPE 123
#define PCMA8_PAYLOAD_TYPE 8
#define BV16_PAYLOAD_TYPE 127
#define H263_PAYLOAD_TYPE 34
#define H264_PAYLOAD_TYPE 102
#define VP8_PAYLOAD_TYPE 103
......@@ -73,6 +75,8 @@ static int tester_after_all(void) {
#define HELLO_16K_1S_FILE "sounds/hello16000-1s.wav"
#define RECORDED_16K_1S_FILE "recorded_hello16000-1s.wav"
#define RECORDED_16K_1S_BV16_FILE "recorded_hello16000-1sbv16.wav"
#define RECORDED_16K_1S_BV16_NO_PLC_FILE "withoutplc_recorded_hello16000-1sbv16.wav"
typedef struct _stream_manager_t {
MSFormatType type;
......@@ -195,8 +199,17 @@ static void qos_analyzer_on_action_suggested(void *user_data, int datac, const c
}
}
static void disable_plc_on_audio_stream(AudioStream *p1){
if (p1 != NULL){
uint32_t features_p1 = audio_stream_get_features(p1);
features_p1 &= ~AUDIO_STREAM_FEATURE_PLC;
audio_stream_set_features(p1, features_p1);
}
}
void start_adaptive_stream(MSFormatType type, stream_manager_t ** pmarielle, stream_manager_t ** pmargaux,
int payload, int initial_bitrate, int max_bw, float loss_rate, int latency, float dup_ratio) {
int payload, int initial_bitrate, int max_bw, float loss_rate, int latency, float dup_ratio, bool_t disable_plc) {
int pause_time=0;
PayloadType* pt;
MediaStream *marielle_ms,*margaux_ms;
......@@ -204,11 +217,23 @@ void start_adaptive_stream(MSFormatType type, stream_manager_t ** pmarielle, str
#if VIDEO_ENABLED
MSWebCam * marielle_webcam=mediastreamer2_tester_get_mire_webcam(ms_factory_get_web_cam_manager(_factory));
#endif
stream_manager_t *marielle=*pmarielle=stream_manager_new(type);
stream_manager_t *margaux=*pmargaux=stream_manager_new(type);
if(disable_plc){
disable_plc_on_audio_stream(margaux->audio_stream);
disable_plc_on_audio_stream(marielle->audio_stream);
}
char* recorded_file = NULL;
char* file = bc_tester_res(HELLO_16K_1S_FILE);
char* recorded_file = bc_tester_file(RECORDED_16K_1S_FILE);
if (!disable_plc ){
recorded_file = bc_tester_file(RECORDED_16K_1S_FILE);
}
else{
recorded_file = bc_tester_file(RECORDED_16K_1S_NO_PLC_FILE);
}
marielle->user_data = recorded_file;
params.enabled=TRUE;
......@@ -223,7 +248,7 @@ void start_adaptive_stream(MSFormatType type, stream_manager_t ** pmarielle, str
marielle_ms=&marielle->video_stream->ms;
margaux_ms=&margaux->video_stream->ms;
}
/* Disable avpf. */
pt = rtp_profile_get_payload(&rtp_profile, VP8_PAYLOAD_TYPE);
BC_ASSERT_PTR_NOT_NULL_FATAL(pt);
......@@ -331,7 +356,7 @@ static void packet_duplication(void) {
stream_manager_t * marielle, * margaux;
dup_ratio = 0;
start_adaptive_stream(MSAudio, &marielle, &margaux, SPEEX_PAYLOAD_TYPE, 32000, 0, 0, 50,dup_ratio);
start_adaptive_stream(MSAudio, &marielle, &margaux, SPEEX_PAYLOAD_TYPE, 32000, 0, 0, 50,dup_ratio, 0);
media_stream_enable_adaptive_bitrate_control(&marielle->audio_stream->ms,FALSE);
iterate_adaptive_stream(marielle, margaux, 10000, NULL, 0);
stats=rtp_session_get_stats(margaux->video_stream->ms.sessions.rtp_session);
......@@ -343,7 +368,7 @@ static void packet_duplication(void) {
stop_adaptive_stream(marielle,margaux);
dup_ratio = 1;
start_adaptive_stream(MSAudio, &marielle, &margaux, SPEEX_PAYLOAD_TYPE, 32000, 0, 0, 50,dup_ratio);
start_adaptive_stream(MSAudio, &marielle, &margaux, SPEEX_PAYLOAD_TYPE, 32000, 0, 0, 50,dup_ratio,0);
media_stream_enable_adaptive_bitrate_control(&marielle->audio_stream->ms,FALSE);
iterate_adaptive_stream(marielle, margaux, 10000, NULL, 0);
stats=rtp_session_get_stats(margaux->video_stream->ms.sessions.rtp_session);
......@@ -361,7 +386,7 @@ static void upload_bandwidth_computation(void) {
stream_manager_t * marielle, * margaux;
int i;
start_adaptive_stream(MSAudio, &marielle, &margaux, PCMA8_PAYLOAD_TYPE, 8000, 0, 0, 0, 0);
start_adaptive_stream(MSAudio, &marielle, &margaux, PCMA8_PAYLOAD_TYPE, 8000, 0, 0, 0, 0,0);
media_stream_enable_adaptive_bitrate_control(&marielle->audio_stream->ms,FALSE);
for (i = 0; i < 5; i++){
......@@ -374,15 +399,64 @@ static void upload_bandwidth_computation(void) {
}
}
off_t fsize(const char *filename) {
struct stat st;
if (stat(filename, &st) == 0)
return st.st_size;
return -1;
}
static void loss_rate_estimation_bv16(void){
bool_t supported = ms_factory_codec_supported(_factory, "bv16");
int plc_disabled=0 ;
int size_with_plc = 0, size_no_plc= 0;
rtp_profile_set_payload(&rtp_profile,BV16_PAYLOAD_TYPE,&payload_type_bv16);
if( supported ) {
LossRateEstimatorCtx ctx;
stream_manager_t * marielle, * margaux;
int loss_rate = 15;
for (plc_disabled = 0; plc_disabled <=1; plc_disabled++){
start_adaptive_stream(MSAudio, &marielle, &margaux, BV16_PAYLOAD_TYPE, 8000, 0, loss_rate, 0, 0, plc_disabled);
ctx.estimator=ortp_loss_rate_estimator_new(120, 2500, marielle->audio_stream->ms.sessions.rtp_session);
ctx.q = ortp_ev_queue_new();
rtp_session_register_event_queue(marielle->audio_stream->ms.sessions.rtp_session, ctx.q);
ctx.loss_rate = loss_rate;
/*loss rate should be the initial one*/
wait_for_until_with_parse_events(&marielle->audio_stream->ms, &margaux->audio_stream->ms, &loss_rate, 100, 10000, event_queue_cb,&ctx,NULL,NULL);
stop_adaptive_stream(marielle,margaux);
ortp_loss_rate_estimator_destroy(ctx.estimator);
ortp_ev_queue_destroy(ctx.q);
}
/*file without plc must be approx 15% smaller in size than with plc */
size_with_plc= fsize(bc_tester_file(RECORDED_16K_1S_BV16_FILE));
size_no_plc = fsize(bc_tester_file(RECORDED_16K_1S_BV16_NO_PLC_FILE));
int result = (size_with_plc*loss_rate/100 + size_no_plc) ;
BC_ASSERT_TRUE(result >= size_with_plc);
ms_message("%d %d %d ", size_no_plc, size_with_plc, result);
}
}
static void loss_rate_estimation(void) {
//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;
int loss_rate = 15;
start_adaptive_stream(MSAudio, &marielle, &margaux, PCMA8_PAYLOAD_TYPE, 8000, 0, loss_rate, 0, 0,0);
start_adaptive_stream(MSAudio, &marielle, &margaux, PCMA8_PAYLOAD_TYPE, 8000, 0, loss_rate, 0, 0);
ctx.estimator=ortp_loss_rate_estimator_new(120, 2500, marielle->audio_stream->ms.sessions.rtp_session);
ctx.q = ortp_ev_queue_new();
rtp_session_register_event_queue(marielle->audio_stream->ms.sessions.rtp_session, ctx.q);
......@@ -408,7 +482,7 @@ void upload_bitrate(const char* codec, int payload, int target_bw, int expect_bw
float upload_bw;
stream_manager_t * marielle, * margaux;
start_adaptive_stream(MSAudio, &marielle, &margaux, payload, target_bw*1000, target_bw*1000, 0, 50,0);
start_adaptive_stream(MSAudio, &marielle, &margaux, payload, target_bw*1000, target_bw*1000, 0, 50,0,0);
//these tests check that encoders stick to the guidelines, so we must use NOT
//the adaptive algorithm which would modify these guidelines
media_stream_enable_adaptive_bitrate_control(&marielle->audio_stream->ms,FALSE);
......@@ -488,6 +562,7 @@ static test_t tests[] = {
{ "Packet duplication", packet_duplication},
{ "Upload bandwidth computation", upload_bandwidth_computation },
{ "Loss rate estimation", loss_rate_estimation },
{ "Loss rate estimationBV16", loss_rate_estimation_bv16 },
{ "Upload bitrate [pcma] - 3g", upload_bitrate_pcma_3g },
{ "Upload bitrate [speex] - low", upload_bitrate_speex_low },
......
......@@ -86,11 +86,20 @@ static void dtmfgen_tonedet(void) {
ms_tester_destroy_ticker();
}
static void dtmfgen_enc_dec_tonedet(char *mime, int sample_rate, int nchannels) {
/*fileplay awt to TRUE: uses soundwrite instaed of voidsink so we can hear what;s going on */
static void dtmfgen_enc_dec_tonedet(char *mime, int sample_rate, int nchannels, bool_t fileplay) {
MSConnectionHelper h;
unsigned int filter_mask = FILTER_MASK_VOIDSOURCE | FILTER_MASK_DTMFGEN | FILTER_MASK_ENCODER
unsigned int filter_mask ;
if (!fileplay){
filter_mask= FILTER_MASK_VOIDSOURCE | FILTER_MASK_DTMFGEN | FILTER_MASK_ENCODER
| FILTER_MASK_DECODER | FILTER_MASK_TONEDET | FILTER_MASK_VOIDSINK;
}else{
filter_mask = FILTER_MASK_VOIDSOURCE | FILTER_MASK_DTMFGEN | FILTER_MASK_ENCODER
| FILTER_MASK_DECODER | FILTER_MASK_TONEDET | FILTER_MASK_SOUNDWRITE;
}
bool_t send_silence = TRUE;
MSSndCardManager *scm = ms_factory_get_snd_card_manager(factory);
......@@ -113,10 +122,106 @@ static void dtmfgen_enc_dec_tonedet(char *mime, int sample_rate, int nchannels)
ms_filter_call_method(ms_tester_decoder, MS_FILTER_SET_NCHANNELS, &nchannels);
ms_filter_call_method(ms_tester_tonedet, MS_FILTER_SET_SAMPLE_RATE, &sample_rate);
ms_filter_call_method(ms_tester_tonedet, MS_FILTER_SET_NCHANNELS, &nchannels);
ms_filter_call_method(ms_tester_voidsink, MS_FILTER_SET_SAMPLE_RATE, &sample_rate);
ms_filter_call_method(ms_tester_voidsink, MS_FILTER_SET_NCHANNELS, &nchannels);
if (!fileplay){
ms_filter_call_method(ms_tester_voidsink, MS_FILTER_SET_SAMPLE_RATE, &sample_rate);
ms_filter_call_method(ms_tester_voidsink, MS_FILTER_SET_NCHANNELS, &nchannels);
}else{
ms_filter_call_method(ms_tester_soundwrite, MS_FILTER_SET_SAMPLE_RATE, &sample_rate);
ms_filter_call_method(ms_tester_soundwrite, MS_FILTER_SET_NCHANNELS, &nchannels);
}
ms_filter_add_notify_callback(ms_tester_tonedet, (MSFilterNotifyFunc)tone_detected_cb, NULL,TRUE);
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);
if (!fileplay) {
ms_connection_helper_link(&h, ms_tester_voidsink, 0, -1);
}else{
ms_connection_helper_link(&h, ms_tester_soundwrite, 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);
if (!fileplay){
ms_connection_helper_unlink(&h, ms_tester_voidsink, 0, -1);
}else{
ms_connection_helper_unlink(&h, ms_tester_soundwrite, 0, -1);
}
// ms_filter_log_statistics();
ms_factory_log_statistics(scm->factory);
ms_tester_destroy_filters(filter_mask);
ms_tester_destroy_ticker();
}
#define SOUNDREAD_FILE_NAME "soundread_filetest.raw"
static void dtmfgen_enc_dec_tonedet_filerec_fileplay(char *mime, int sample_rate, int nchannels) {
MSConnectionHelper h;
unsigned int filter_mask = FILTER_MASK_VOIDSOURCE | FILTER_MASK_DTMFGEN | FILTER_MASK_ENCODER
| FILTER_MASK_DECODER | FILTER_MASK_TONEDET | FILTER_MASK_VOIDSINK | FILTER_MASK_SOUNDREAD | FILTER_MASK_FILEREC | FILTER_MASK_FILEPLAY | FILTER_MASK_SOUNDWRITE;
bool_t send_silence = TRUE;
int capture_sample_rate = 8000;
int playback_sample_rate = 8000;
int capture_nchannels = 1;
int playback_nchannels = 1;
char *writable_filename = bc_tester_file(SOUNDREAD_FILE_NAME);
MSSndCardManager *scm = ms_factory_get_snd_card_manager(factory);
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, scm->factory);
// Write audio capture to a file
ms_filter_call_method(ms_tester_soundread, MS_FILTER_GET_SAMPLE_RATE, &capture_sample_rate);
ms_filter_call_method(ms_tester_soundread, MS_FILTER_GET_NCHANNELS, &capture_nchannels);
ms_filter_call_method(ms_tester_filerec, MS_FILTER_SET_SAMPLE_RATE, &capture_sample_rate);
ms_filter_call_method(ms_tester_filerec, MS_FILTER_SET_NCHANNELS, &capture_nchannels);
ms_filter_call_method_noarg(ms_tester_filerec, MS_FILE_REC_CLOSE);
ms_filter_call_method(ms_tester_filerec, MS_FILE_REC_OPEN, writable_filename);
ms_filter_call_method_noarg(ms_tester_filerec, MS_FILE_REC_START);
ms_connection_helper_start(&h);
ms_connection_helper_link(&h, ms_tester_soundread, -1, 0);
ms_connection_helper_link(&h, ms_tester_filerec, 0, -1);
ms_ticker_attach(ms_tester_ticker, ms_tester_soundread);
/* 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);
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);
ms_filter_call_method(ms_tester_dtmfgen, MS_FILTER_SET_SAMPLE_RATE, &sample_rate);
ms_filter_call_method(ms_tester_dtmfgen, MS_FILTER_SET_NCHANNELS, &nchannels);
ms_filter_call_method(ms_tester_encoder, MS_FILTER_SET_SAMPLE_RATE, &sample_rate);
ms_filter_call_method(ms_tester_encoder, MS_FILTER_SET_NCHANNELS, &nchannels);
ms_filter_call_method(ms_tester_decoder, MS_FILTER_SET_SAMPLE_RATE, &sample_rate);
ms_filter_call_method(ms_tester_decoder, MS_FILTER_SET_NCHANNELS, &nchannels);
ms_filter_call_method(ms_tester_tonedet, MS_FILTER_SET_SAMPLE_RATE, &sample_rate);
ms_filter_call_method(ms_tester_tonedet, MS_FILTER_SET_NCHANNELS, &nchannels);
ms_filter_call_method(ms_tester_voidsink, MS_FILTER_SET_SAMPLE_RATE, &sample_rate);
ms_filter_call_method(ms_tester_voidsink, MS_FILTER_SET_NCHANNELS, &nchannels);
ms_filter_add_notify_callback(ms_tester_tonedet, (MSFilterNotifyFunc)tone_detected_cb, NULL,TRUE);
ms_connection_helper_start(&h);
ms_connection_helper_link(&h, ms_tester_voidsource, -1, 0);
......@@ -126,8 +231,26 @@ static void dtmfgen_enc_dec_tonedet(char *mime, int sample_rate, int nchannels)
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_filter_call_method_noarg(ms_tester_filerec, MS_FILE_REC_CLOSE);
ms_ticker_detach(ms_tester_ticker, ms_tester_soundread);
ms_connection_helper_start(&h);
ms_connection_helper_unlink(&h, ms_tester_soundread, -1, 0);
ms_connection_helper_unlink(&h, ms_tester_filerec, 0, -1);
// Read the previous file and play it
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, scm->factory);
}
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);
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_ticker_detach(ms_tester_ticker, ms_tester_voidsource);
ms_connection_helper_start(&h);
......@@ -137,27 +260,33 @@ 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();
}
static void dtmfgen_enc_dec_tonedet_pcmu(void) {
dtmfgen_enc_dec_tonedet("pcmu", 8000, 1);
dtmfgen_enc_dec_tonedet("pcmu", 8000, 1, FALSE);
}
static void dtmfgen_enc_dec_tonedet_bv16(void) {
dtmfgen_enc_dec_tonedet("bv16", 8000, 1, TRUE);
}
static void dtmfgen_enc_dec_tonedet_isac(void) {
bool_t supported = ms_factory_codec_supported(factory, "iSAC");
// bool_t supported = ms_filter_codec_supported("iSAC");
if( supported ) {
dtmfgen_enc_dec_tonedet("iSAC", 16000, 1);
dtmfgen_enc_dec_tonedet("iSAC", 16000, 1,FALSE);
}
}
#if HAVE_OPUS
static void dtmfgen_enc_dec_tonedet_opus(void) {
dtmfgen_enc_dec_tonedet("opus", 48000, 1);
dtmfgen_enc_dec_tonedet("opus", 48000, 1, FALSE);
}
#endif
......@@ -275,6 +404,7 @@ static void dtmfgen_filerec_fileplay_tonedet(void) {
test_t basic_audio_tests[] = {
{ "dtmfgen-tonedet", dtmfgen_tonedet },
{ "dtmfgen-enc-dec-tonedet-bv16", dtmfgen_enc_dec_tonedet_bv16 },
{ "dtmfgen-enc-dec-tonedet-pcmu", dtmfgen_enc_dec_tonedet_pcmu },
{ "dtmfgen-enc-dec-tonedet-isac", dtmfgen_enc_dec_tonedet_isac },
#if HAVE_OPUS
......
......@@ -279,6 +279,105 @@ static void soundread_soundwrite(void) {
ms_tester_destroy_ticker();
}
static void fileplay_bv16enc_bv16dec_soundwrite(void) {
MSConnectionHelper h;
MSFilter *read_resampler = NULL, *write_resampler = NULL;
bool_t need_read_resampler = FALSE, need_write_resampler = TRUE;
unsigned int filter_mask = FILTER_MASK_FILEPLAY | FILTER_MASK_ENCODER | FILTER_MASK_DECODER | FILTER_MASK_SOUNDWRITE;
int sample_rate = 8000;
int nchannels = 1;
int done = FALSE;
const char* filepath = ARPEGGIO_8000_MONO_FILE_NAME;
char* filename = bc_tester_res(filepath);
int elapsed = 0;
ms_filter_reset_statistics();
ms_tester_create_ticker();
ms_tester_codec_mime = "bv16";
ms_tester_create_filters(filter_mask, ms_factory_get_fallback());
//file
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);
ms_filter_call_method_noarg(ms_tester_fileplay, MS_FILE_PLAYER_START);
ms_filter_call_method(ms_tester_fileplay, MS_FILTER_GET_SAMPLE_RATE, &sample_rate);
ms_filter_call_method(ms_tester_fileplay, MS_FILTER_GET_NCHANNELS, &nchannels);
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 (need_read_resampler == TRUE) {
ms_tester_create_filters(FILTER_MASK_RESAMPLER, ms_factory_get_fallback());
configure_resampler(ms_tester_resampler, ms_tester_fileplay, ms_tester_encoder);
}
ms_connection_helper_start(&h);
ms_connection_helper_link(&h, ms_tester_fileplay, -1, 0);
if (need_read_resampler == TRUE) {
ms_connection_helper_link(&h, ms_tester_resampler, 0, 0);
}
if (ms_filter_call_method(ms_tester_soundwrite, MS_FILTER_SET_BITRATE, &sample_rate) != 0) {
int soundwrite_sample_rate = 8000;
ms_filter_call_method(ms_tester_soundwrite, MS_FILTER_GET_BITRATE, &soundwrite_sample_rate);
if (sample_rate != soundwrite_sample_rate) need_write_resampler = TRUE;
}
if (ms_filter_call_method(ms_tester_soundwrite, MS_FILTER_SET_NCHANNELS, &nchannels) != 0) {
int soundwrite_nchannels = 1;
ms_filter_call_method(ms_tester_soundwrite, MS_FILTER_GET_NCHANNELS, &soundwrite_nchannels);
if (nchannels != soundwrite_nchannels) need_write_resampler = TRUE;
}
if (need_write_resampler == TRUE) {
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_link(&h, ms_tester_encoder, 0, 0);
ms_connection_helper_link(&h, ms_tester_decoder, 0, 0);
if (need_write_resampler == TRUE) {
ms_connection_helper_link(&h, write_resampler, 0, 0);
}
ms_connection_helper_link(&h, ms_tester_soundwrite, 0, -1);
ms_ticker_attach(ms_tester_ticker, ms_tester_fileplay);
while (done != TRUE && elapsed < 6000) {
elapsed++;
ms_usleep(10000);
}
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);
if (need_read_resampler == TRUE) {
ms_connection_helper_unlink(&h, ms_tester_resampler, 0, 0);
}
ms_connection_helper_unlink(&h, ms_tester_encoder, 0, 0);
ms_connection_helper_unlink(&h, ms_tester_decoder, 0, 0);
if (need_write_resampler == TRUE) {
ms_connection_helper_unlink(&h, write_resampler, 0, 0);
}
ms_connection_helper_unlink(&h, ms_tester_soundwrite, 0, -1);
if (need_read_resampler == TRUE) {
ms_tester_destroy_filter(&read_resampler);
}
if (need_write_resampler == TRUE) {
ms_tester_destroy_filter(&write_resampler);
}
ms_filter_log_statistics();
ms_tester_destroy_filters(filter_mask);
ms_tester_destroy_ticker();
free(filename);
}
static void soundread_speexenc_speexdec_soundwrite(void) {
MSConnectionHelper h;
MSFilter *read_resampler = NULL, *write_resampler = NULL;
......@@ -447,7 +546,8 @@ test_t sound_card_tests[] = {
{ "fileplay-soundwrite-8000-mono", fileplay_soundwrite_8000_mono },
{ "soundread-soundwrite", soundread_soundwrite },
{ "soundread-speexenc-speexdec-soundwrite", soundread_speexenc_speexdec_soundwrite },
{ "soundread-filerec-fileplay-soundwrite", soundread_filerec_fileplay_soundwrite }
{ "soundread-filerec-fileplay-soundwrite", soundread_filerec_fileplay_soundwrite },
{ "fileplay-bv16enc-bv16dec-soundwrite", fileplay_bv16enc_bv16dec_soundwrite}
};
test_suite_t sound_card_test_suite = {
......
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