Commit 2acee668 authored by François Grisez's avatar François Grisez

Add a tester for the media file player

parent 90933e5e
mediastreamer2 @ e87f1b6a
Subproject commit cc5da3abb97767b04ffb1bcd6b246be556aa54f1
Subproject commit e87f1b6af632cfca73b8ca963c8136c3f75c6f52
......@@ -22,7 +22,8 @@ liblinphonetester_la_SOURCES = tester.c \
stun_tester.c \
remote_provisioning_tester.c \
quality_reporting_tester.c \
transport_tester.c
transport_tester.c \
player_tester.c
liblinphonetester_la_LDFLAGS= -no-undefined
liblinphonetester_la_LIBADD= ../coreapi/liblinphone.la $(CUNIT_LIBS)
......
......@@ -59,6 +59,7 @@ extern test_suite_t stun_test_suite;
extern test_suite_t remote_provisioning_test_suite;
extern test_suite_t quality_reporting_test_suite;
extern test_suite_t transport_test_suite;
extern test_suite_t player_test_suite;
extern int liblinphone_tester_nb_test_suites(void);
......
#include "liblinphone_tester.h"
static bool_t wait_for_eof(bool_t *eof, int *time,int time_refresh, int timeout) {
while(*time < timeout && !*eof) {
usleep(time_refresh * 1000U);
*time += time_refresh;
}
return *time < timeout;
}
static void eof_callback(LinphonePlayer *player, void *user_data) {
bool_t *eof = (bool_t *)user_data;
*eof = TRUE;
}
static void playing_test(void) {
LinphoneCoreManager *lc_manager;
LinphonePlayer *player;
const char *filename = "sounds/hello_opus_h264.mkv";
int res, time = 0;
bool_t eof = FALSE;
lc_manager = linphone_core_manager_new("marie_rc");
CU_ASSERT_PTR_NOT_NULL(lc_manager);
if(lc_manager == NULL) return;
player = linphone_core_create_file_player(lc_manager->lc, ms_snd_card_manager_get_default_card(ms_snd_card_manager_get()), video_stream_get_default_video_renderer());
CU_ASSERT_PTR_NOT_NULL(player);
if(player == NULL) goto fail;
CU_ASSERT_EQUAL((res = linphone_player_open(player, filename, eof_callback, &eof)), 0);
if(res == -1) goto fail;
CU_ASSERT_EQUAL((res = linphone_player_start(player)), 0);
if(res == -1) goto fail;
CU_ASSERT_TRUE(wait_for_eof(&eof, &time, 100, 13000));
linphone_player_close(player);
fail:
if(player) file_player_destroy(player);
if(lc_manager) linphone_core_manager_destroy(lc_manager);
}
test_t player_tests[] = {
{ "Playing" , playing_test }
};
test_suite_t player_test_suite = {
"Player",
NULL,
NULL,
sizeof(player_tests) / sizeof(test_t),
player_tests
};
......@@ -388,6 +388,7 @@ void liblinphone_tester_init(void) {
add_test_suite(&remote_provisioning_test_suite);
add_test_suite(&quality_reporting_test_suite);
add_test_suite(&transport_test_suite);
add_test_suite(&player_test_suite);
}
void liblinphone_tester_uninit(void) {
......
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