[vlc-devel] [PATCH] libvlc: add function to get track id from video setup callback.
Jerome Forissier
jerome at taodyne.com
Mon Mar 3 13:20:05 CET 2014
This commit adds a new function to the media player interface:
libvlc_video_format_cb_get_track_id(), which may be called form the
video setup callback (libvlc_video_format_cb). It returns the ID of
the track for which the video decoder thread is creating the video
output. It is useful e.g., when playing an MP4 file with several
streams.
---
include/vlc/libvlc_media_player.h | 8 ++++++++
include/vlc_es.h | 2 ++
lib/libvlc.sym | 1 +
lib/media_player.c | 8 ++++++++
modules/video_output/vmem.c | 3 +++
src/input/decoder.c | 1 +
6 files changed, 23 insertions(+)
diff --git a/include/vlc/libvlc_media_player.h b/include/vlc/libvlc_media_player.h
index fb91f59..75e7577 100644
--- a/include/vlc/libvlc_media_player.h
+++ b/include/vlc/libvlc_media_player.h
@@ -393,6 +393,14 @@ void libvlc_video_set_format_callbacks( libvlc_media_player_t *mp,
libvlc_video_cleanup_cb cleanup );
/**
+ * Return the track ID of the video stream for which @ref libvlc_video_format_cb
+ * is being called. This function is valid only when called from the setup
+ * callback.
+ */
+LIBVLC_API
+int libvlc_video_format_cb_get_track_id( void **opaque );
+
+/**
* Set the NSView handler where the media player should render its video output.
*
* Use the vout called "macosx".
diff --git a/include/vlc_es.h b/include/vlc_es.h
index 38d63da..536883e 100644
--- a/include/vlc_es.h
+++ b/include/vlc_es.h
@@ -202,6 +202,8 @@ struct video_format_t
int i_rbshift, i_lbshift;
video_palette_t *p_palette; /**< video palette from demuxer */
video_orientation_t orientation; /**< picture orientation */
+
+ int i_dec_es_id; /**< elementary stream ID from decoder */
};
/**
diff --git a/lib/libvlc.sym b/lib/libvlc.sym
index fdfd164..f24ad30 100644
--- a/lib/libvlc.sym
+++ b/lib/libvlc.sym
@@ -199,6 +199,7 @@ libvlc_toggle_fullscreen
libvlc_toggle_teletext
libvlc_track_description_release
libvlc_track_description_list_release
+libvlc_video_format_cb_get_track_id
libvlc_video_get_adjust_float
libvlc_video_get_adjust_int
libvlc_video_get_aspect_ratio
diff --git a/lib/media_player.c b/lib/media_player.c
index 868aefe..54c7cd1 100644
--- a/lib/media_player.c
+++ b/lib/media_player.c
@@ -861,6 +861,14 @@ void libvlc_video_set_format_callbacks( libvlc_media_player_t *mp,
var_SetAddress( mp, "vmem-cleanup", cleanup );
}
+/**************************************************************************
+ * Get track id from opaque pointer passed to libvlc_video_format_cb.
+ **************************************************************************/
+int libvlc_video_format_cb_get_track_id( void **opaque )
+{
+ return *(int *)(opaque + 1);
+}
+
void libvlc_video_set_format( libvlc_media_player_t *mp, const char *chroma,
unsigned width, unsigned height, unsigned pitch )
{
diff --git a/modules/video_output/vmem.c b/modules/video_output/vmem.c
index 2575f75..8acfcb1 100644
--- a/modules/video_output/vmem.c
+++ b/modules/video_output/vmem.c
@@ -92,6 +92,8 @@ struct vout_display_sys_t {
unsigned count;
void *opaque;
+ int track_id; /* Keep at (int *)(opaque + 1) --
+ see libvlc_video_format_cb_get_track_id() */
void *(*lock)(void *sys, void **plane);
void (*unlock)(void *sys, void *id, void *const *plane);
void (*display)(void *sys, void *id);
@@ -136,6 +138,7 @@ static int Open(vlc_object_t *object)
sys->display = var_InheritAddress(vd, "vmem-display");
sys->cleanup = var_InheritAddress(vd, "vmem-cleanup");
sys->opaque = var_InheritAddress(vd, "vmem-data");
+ sys->track_id = vd->fmt.i_dec_es_id;
sys->pool = NULL;
/* Define the video format */
diff --git a/src/input/decoder.c b/src/input/decoder.c
index 46129fc..892a3c7 100644
--- a/src/input/decoder.c
+++ b/src/input/decoder.c
@@ -2060,6 +2060,7 @@ static picture_t *vout_new_buffer( decoder_t *p_dec )
video_format_t fmt = p_dec->fmt_out.video;
fmt.i_chroma = p_dec->fmt_out.i_codec;
+ fmt.i_dec_es_id = p_dec->fmt_in.i_id;
p_owner->video = fmt;
if( vlc_fourcc_IsYUV( fmt.i_chroma ) )
--
1.8.1.5
More information about the vlc-devel
mailing list