[vlc-devel] [PATCH 1/2] libvlc: add libvlc_media_player_dump
Thomas Guillem
thomas at gllm.fr
Thu May 19 16:47:06 CEST 2016
---
include/vlc/libvlc_media_player.h | 18 ++++++++++++++++++
lib/libvlc.sym | 1 +
lib/media_player.c | 28 ++++++++++++++++++++++++++++
3 files changed, 47 insertions(+)
diff --git a/include/vlc/libvlc_media_player.h b/include/vlc/libvlc_media_player.h
index 456e99e..7b77af5 100644
--- a/include/vlc/libvlc_media_player.h
+++ b/include/vlc/libvlc_media_player.h
@@ -961,6 +961,24 @@ LIBVLC_API void libvlc_media_player_set_video_title_display( libvlc_media_player
*/
LIBVLC_API void libvlc_track_description_list_release( libvlc_track_description_t *p_track_description );
+/**
+ * Dump the media attached to the Media Player into a local file
+ *
+ * \note You can't dump if the Media Player is already playing. The dump is
+ * done asynchronously. Listen to \ref libvlc_MediaPlayerEndReached and \ref
+ * libvlc_MediaPlayerEncounteredError events to be notified when the dump ends.
+ * You can call libvlc_media_player_stop() to abort the dump.
+ *
+ * \version LibVLC 3.0.0 and later.
+ *
+ * \param p_mi the Media Player
+ * \param psz_path local filesystem path where to dump the media
+ *
+ * \return -1 if an error was detected, 0 otherwise.
+ */
+LIBVLC_API int libvlc_media_player_dump( libvlc_media_player_t *p_mi,
+ const char *psz_path );
+
/** \defgroup libvlc_video LibVLC video controls
* @{
*/
diff --git a/lib/libvlc.sym b/lib/libvlc.sym
index 816025d..be6872c 100644
--- a/lib/libvlc.sym
+++ b/lib/libvlc.sym
@@ -149,6 +149,7 @@ libvlc_media_parse
libvlc_media_parse_async
libvlc_media_parse_with_options
libvlc_media_player_can_pause
+libvlc_media_player_dump
libvlc_media_player_program_scrambled
libvlc_media_player_next_frame
libvlc_media_player_event_manager
diff --git a/lib/media_player.c b/lib/media_player.c
index 4761fee..f8aa6d6 100644
--- a/lib/media_player.c
+++ b/lib/media_player.c
@@ -669,6 +669,10 @@ libvlc_media_player_new( libvlc_instance_t *instance )
var_Create (mp, "equalizer-vlcfreqs", VLC_VAR_BOOL);
var_Create (mp, "equalizer-bands", VLC_VAR_STRING);
+ /* Demux (for demuxdump) */
+ var_Create (mp, "demux", VLC_VAR_STRING | VLC_VAR_DOINHERIT);
+ var_Create (mp, "demuxdump-file", VLC_VAR_STRING | VLC_VAR_DOINHERIT);
+
mp->p_md = NULL;
mp->state = libvlc_NothingSpecial;
mp->p_libvlc_instance = instance;
@@ -1014,6 +1018,8 @@ void libvlc_media_player_stop( libvlc_media_player_t *p_mi )
input_resource_Terminate( p_mi->input.p_resource );
unlock_input(p_mi);
+
+ var_SetString( p_mi, "demux", "" );
}
@@ -1856,6 +1862,28 @@ void libvlc_media_player_set_video_title_display( libvlc_media_player_t *p_mi, l
}
}
+int libvlc_media_player_dump( libvlc_media_player_t *p_mi, const char *psz_path )
+{
+ assert( p_mi != NULL && psz_path != NULL );
+
+ lock_input( p_mi );
+ input_thread_t *p_input_thread = p_mi->input.p_thread;
+ if( p_input_thread )
+ {
+ unlock_input( p_mi );
+ libvlc_printerr( "can't dump while playing" );
+ return -1;
+ }
+ unlock_input( p_mi );
+
+ var_SetString( p_mi, "demux", "dump,none" );
+ var_SetString( p_mi, "demuxdump-file", psz_path );
+
+ int i_ret = libvlc_media_player_play( p_mi );
+ if (i_ret != 0)
+ var_SetString( p_mi, "demux", "" );
+ return i_ret;
+}
/**
* Maximum size of a formatted equalizer amplification band frequency value.
*
--
2.8.1
More information about the vlc-devel
mailing list