[vlc-commits] mpeg: add DEMUX_GET_(TITLE|SEEKPOINT)
Rémi Denis-Courmont
git at videolan.org
Sun Dec 3 13:27:24 CET 2017
vlc | branch: master | Rémi Denis-Courmont <remi at remlab.net> | Sun Dec 3 12:14:15 2017 +0200| [9e329ea40145282f6547abbef9ee62984e44f022] | committer: Rémi Denis-Courmont
mpeg: add DEMUX_GET_(TITLE|SEEKPOINT)
> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=9e329ea40145282f6547abbef9ee62984e44f022
---
include/vlc_demux.h | 16 +++++++++++-----
modules/demux/mpeg/ps.c | 13 +++++++++++++
modules/demux/mpeg/ts.c | 8 ++++++++
modules/demux/mpeg/ts.h | 2 ++
4 files changed, 34 insertions(+), 5 deletions(-)
diff --git a/include/vlc_demux.h b/include/vlc_demux.h
index 0cf4255772..ebd9e4b78d 100644
--- a/include/vlc_demux.h
+++ b/include/vlc_demux.h
@@ -371,26 +371,32 @@ static inline int demux_Control( demux_t *p_demux, int i_query, ... )
* Miscellaneous helpers for demuxers
*************************************************************************/
-static inline void demux_UpdateTitleFromStream( demux_t *demux )
+#ifndef __cplusplus
+static inline void demux_UpdateTitleFromStream( demux_t *demux,
+ int *restrict titlep, int *restrict seekpointp )
{
stream_t *s = demux->s;
unsigned title, seekpoint;
if( vlc_stream_Control( s, STREAM_GET_TITLE, &title ) == VLC_SUCCESS
- && title != (unsigned)demux->info.i_title )
+ && title != (unsigned)*titlep )
{
- demux->info.i_title = title;
+ *titlep = title;
demux->info.i_update |= INPUT_UPDATE_TITLE;
}
if( vlc_stream_Control( s, STREAM_GET_SEEKPOINT,
&seekpoint ) == VLC_SUCCESS
- && seekpoint != (unsigned)demux->info.i_seekpoint )
+ && seekpoint != (unsigned)*seekpointp )
{
- demux->info.i_seekpoint = seekpoint;
+ *seekpointp = seekpoint;
demux->info.i_update |= INPUT_UPDATE_SEEKPOINT;
}
}
+# define demux_UpdateTitleFromStream(demux) \
+ demux_UpdateTitleFromStream(demux, &(demux)->p_sys->current_title, \
+ &(demux)->p_sys->current_seekpoint)
+#endif
VLC_USED
static inline bool demux_IsPathExtension( demux_t *p_demux, const char *psz_extension )
diff --git a/modules/demux/mpeg/ps.c b/modules/demux/mpeg/ps.c
index e6c5ab1da9..f4ef17dba5 100644
--- a/modules/demux/mpeg/ps.c
+++ b/modules/demux/mpeg/ps.c
@@ -110,6 +110,9 @@ struct demux_sys_t
CDXA_PS,
PSMF_PS,
} format;
+
+ int current_title;
+ int current_seekpoint;
};
static int Demux ( demux_t *p_demux );
@@ -223,6 +226,8 @@ static int OpenCommon( vlc_object_t *p_this, bool b_force )
p_sys->b_bad_scr = false;
p_sys->b_seekable = false;
p_sys->format = format;
+ p_sys->current_title = 0;
+ p_sys->current_seekpoint = 0;
vlc_stream_Control( p_demux->s, STREAM_CAN_SEEK, &p_sys->b_seekable );
@@ -666,6 +671,14 @@ static int Control( demux_t *p_demux, int i_query, va_list args )
*va_arg( args, bool * ) = p_sys->b_seekable;
return VLC_SUCCESS;
+ case DEMUX_GET_TITLE:
+ *va_arg( args, int * ) = p_sys->current_title;
+ return VLC_SUCCESS;
+
+ case DEMUX_GET_SEEKPOINT:
+ *va_arg( args, int * ) = p_sys->current_seekpoint;
+ return VLC_SUCCESS;
+
case DEMUX_GET_POSITION:
pf = va_arg( args, double * );
i64 = stream_Size( p_demux->s ) - p_sys->i_start_byte;
diff --git a/modules/demux/mpeg/ts.c b/modules/demux/mpeg/ts.c
index d2964de435..b366cb8d33 100644
--- a/modules/demux/mpeg/ts.c
+++ b/modules/demux/mpeg/ts.c
@@ -894,6 +894,14 @@ static int Control( demux_t *p_demux, int i_query, va_list args )
*va_arg( args, bool * ) = p_sys->b_canseek;
return VLC_SUCCESS;
+ case DEMUX_GET_TITLE:
+ *va_arg( args, int * ) = p_sys->current_title;
+ return VLC_SUCCESS;
+
+ case DEMUX_GET_SEEKPOINT:
+ *va_arg( args, int * ) = p_sys->current_seekpoint;
+ return VLC_SUCCESS;
+
case DEMUX_GET_POSITION:
pf = va_arg( args, double * );
diff --git a/modules/demux/mpeg/ts.h b/modules/demux/mpeg/ts.h
index cb50e36ba0..2b2ad16109 100644
--- a/modules/demux/mpeg/ts.h
+++ b/modules/demux/mpeg/ts.h
@@ -49,6 +49,8 @@ struct demux_sys_t
stream_t *stream;
bool b_canseek;
bool b_canfastseek;
+ int current_title;
+ int current_seekpoint;
vlc_mutex_t csa_lock;
/* TS packet size (188, 192, 204) */
More information about the vlc-commits
mailing list