From 90933e5e367ba3e4cabe7e0f7865ef96d3986ae5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fran=C3=A7ois=20Grisez?= Date: Thu, 2 Oct 2014 14:54:58 +0200 Subject: [PATCH] Add an implementation to LinphonePlayer --- coreapi/Makefile.am | 1 + coreapi/fileplayer.c | 60 ++++++++++++++++++++++++++++++++++++++++++ coreapi/linphonecore.h | 16 +++++++++++ mediastreamer2 | 2 +- 4 files changed, 78 insertions(+), 1 deletion(-) create mode 100644 coreapi/fileplayer.c diff --git a/coreapi/Makefile.am b/coreapi/Makefile.am index 2897affcf..e2a6beb4f 100644 --- a/coreapi/Makefile.am +++ b/coreapi/Makefile.am @@ -62,6 +62,7 @@ liblinphone_la_SOURCES=\ call_log.c \ call_params.c \ player.c \ + fileplayer.c \ $(GITVERSION_FILE) if BUILD_UPNP diff --git a/coreapi/fileplayer.c b/coreapi/fileplayer.c new file mode 100644 index 000000000..6ed5f0394 --- /dev/null +++ b/coreapi/fileplayer.c @@ -0,0 +1,60 @@ +#include "private.h" +#include +#include + +static int file_player_open(LinphonePlayer *obj, const char *filename); +static int file_player_start(LinphonePlayer *obj); +static int file_player_pause(LinphonePlayer *obj); +static int file_player_seek(LinphonePlayer *obj, int time_ms); +static MSPlayerState file_player_get_state(LinphonePlayer *obj); +static void file_player_close(LinphonePlayer *obj); +static void file_player_eof_callback(void *user_data); + +LinphonePlayer *linphone_core_create_file_player(LinphoneCore *lc, MSSndCard *snd_card, const char *video_out) { + LinphonePlayer *obj = ms_new0(LinphonePlayer, 1); + if(snd_card == NULL) snd_card = lc->sound_conf.play_sndcard; + if(video_out == NULL) video_out = linphone_core_get_video_display_filter(lc); + obj->impl = ms_file_player_new(snd_card, video_out); + obj->open = file_player_open; + obj->start = file_player_start; + obj->pause = file_player_pause; + obj->seek = file_player_seek; + obj->get_state = file_player_get_state; + obj->close = file_player_close; + ms_file_player_set_eof_callback((MSFilePlayer *)obj->impl, file_player_eof_callback, obj); + return obj; +} + +void file_player_destroy(LinphonePlayer *obj) { + ms_file_player_free((MSFilePlayer *)obj->impl); +} + +static int file_player_open(LinphonePlayer *obj, const char *filename) { + return ms_file_player_open((MSFilePlayer *)obj->impl, filename) ? 0 : -1; +} + +static int file_player_start(LinphonePlayer *obj) { + return ms_file_player_start((MSFilePlayer *)obj->impl) ? 0 : -1; +} + +static int file_player_pause(LinphonePlayer *obj) { + ms_file_player_pause((MSFilePlayer *)obj->impl); + return 0; +} + +static int file_player_seek(LinphonePlayer *obj, int time_ms) { + return ms_file_player_seek((MSFilePlayer *)obj->impl, time_ms) ? 0 : -1; +} + +static MSPlayerState file_player_get_state(LinphonePlayer *obj) { + return ms_file_player_get_state((MSFilePlayer *)obj->impl); +} + +static void file_player_close(LinphonePlayer *obj) { + ms_file_player_close((MSFilePlayer *)obj->impl); +} + +static void file_player_eof_callback(void *user_data) { + LinphonePlayer *obj = (LinphonePlayer *)user_data; + obj->cb(obj, obj->user_data); +} diff --git a/coreapi/linphonecore.h b/coreapi/linphonecore.h index 74d464e77..f8508b2de 100644 --- a/coreapi/linphonecore.h +++ b/coreapi/linphonecore.h @@ -594,6 +594,22 @@ int linphone_player_seek(LinphonePlayer *obj, int time_ms); MSPlayerState linphone_player_get_state(LinphonePlayer *obj); void linphone_player_close(LinphonePlayer *obj); +/** + * @brief Create an independent media file player. + * This player support WAVE and MATROSKA formats. + * @param lc A LinphoneCore + * @param snd_card Playback sound card. If NULL, the sound card set in LinphoneCore will be used + * @param video_out Video display. If NULL, the video display set in LinphoneCore will be used + * @return A pointer on the new instance. NULL if faild. + */ +LINPHONE_PUBLIC LinphonePlayer *linphone_core_create_file_player(LinphoneCore *lc, MSSndCard *snd_card, const char *video_out); + +/** + * @brief Destroy a file player + * @param obj File player to destroy + */ +LINPHONE_PUBLIC void file_player_destroy(LinphonePlayer *obj); + /** * LinphoneCallState enum represents the different state a call can reach into. * The application is notified of state changes through the LinphoneCoreVTable::call_state_changed callback. diff --git a/mediastreamer2 b/mediastreamer2 index 895c19eda..cc5da3abb 160000 --- a/mediastreamer2 +++ b/mediastreamer2 @@ -1 +1 @@ -Subproject commit 895c19eda9a33d4086d4fe3b33505fb40fbd1019 +Subproject commit cc5da3abb97767b04ffb1bcd6b246be556aa54f1