static void play_file(const char *filepath, bool_t unsupported_format, bool_t seeking_test, bool_t play_twice, int timeout) { bool_t succeed; Eof eof; MSMediaPlayer *file_player = NULL; MSSndCard *snd_card = ms_snd_card_manager_get_default_card(ms_snd_card_manager_get()); const char *display_name = video_stream_get_default_video_renderer(); eof_init(&eof); file_player = ms_media_player_new(snd_card, display_name, NULL); CU_ASSERT_PTR_NOT_NULL(file_player); if(file_player == NULL) return; CU_ASSERT_EQUAL(ms_media_player_get_state(file_player), MSPlayerClosed); ms_media_player_set_eof_callback(file_player, eof_callback, &eof); succeed = ms_media_player_open(file_player, filepath); if(unsupported_format) { CU_ASSERT_FALSE(succeed); CU_ASSERT_EQUAL(ms_media_player_get_state(file_player), MSPlayerClosed); } else { CU_ASSERT_TRUE(succeed); CU_ASSERT_EQUAL(ms_media_player_get_state(file_player), MSPlayerPaused); } if(!succeed) { ms_media_player_free(file_player); return; } succeed = ms_media_player_start(file_player); CU_ASSERT_TRUE(succeed); CU_ASSERT_EQUAL(ms_media_player_get_state(file_player), MSPlayerPlaying); if(seeking_test) { CU_ASSERT_TRUE(ms_media_player_seek(file_player, 5000)); } if(succeed) { wait_for_eof(&eof, 100, timeout); CU_ASSERT_TRUE(eof.eof); } ms_media_player_close(file_player); CU_ASSERT_EQUAL(ms_media_player_get_state(file_player), MSPlayerClosed); if(play_twice) { eof_init(&eof); CU_ASSERT_TRUE(ms_media_player_open(file_player, filepath)); CU_ASSERT_TRUE(ms_media_player_start(file_player)); wait_for_eof(&eof, 100, timeout); ms_media_player_close(file_player); CU_ASSERT_TRUE(eof.eof); } ms_media_player_free(file_player); }
static int _local_player_start(LinphonePlayer *obj) { return ms_media_player_start((MSMediaPlayer *)obj->impl) ? 0 : -1; }