[vlc-commits] demux: add SetTime/SetPosition helpers
Thomas Guillem
git at videolan.org
Wed Sep 5 09:47:47 CEST 2018
vlc | branch: master | Thomas Guillem <thomas at gllm.fr> | Wed Sep 5 09:29:54 2018 +0200| [27a80909ec7f657372b8542ec8231e5f096de343] | committer: Thomas Guillem
demux: add SetTime/SetPosition helpers
And handle relative seeks too.
> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=27a80909ec7f657372b8542ec8231e5f096de343
---
include/vlc_demux.h | 36 ++++++++++++++++++++++++++++++++++++
1 file changed, 36 insertions(+)
diff --git a/include/vlc_demux.h b/include/vlc_demux.h
index 26328c7268..928aa0c77e 100644
--- a/include/vlc_demux.h
+++ b/include/vlc_demux.h
@@ -367,6 +367,42 @@ static inline bool demux_IsForced( demux_t *p_demux, const char *psz_name )
return true;
}
+static inline int demux_SetPosition( demux_t *p_demux, double pos, bool precise,
+ bool absolute)
+{
+ if( !absolute )
+ {
+ double current_pos;
+ int ret = demux_Control( p_demux, DEMUX_GET_POSITION, ¤t_pos );
+ if( ret != VLC_SUCCESS )
+ return ret;
+ pos += current_pos;
+ }
+
+ if( pos < 0.f )
+ pos = 0.f;
+ else if( pos > 1.f )
+ pos = 1.f;
+ return demux_Control( p_demux, DEMUX_SET_POSITION, pos, precise );
+}
+
+static inline int demux_SetTime( demux_t *p_demux, vlc_tick_t time, bool precise,
+ bool absolute )
+{
+ if( !absolute )
+ {
+ vlc_tick_t current_time;
+ int ret = demux_Control( p_demux, DEMUX_GET_TIME, ¤t_time );
+ if( ret != VLC_SUCCESS )
+ return ret;
+ time += current_time;
+ }
+
+ if( time < 0 )
+ time = 0;
+ return demux_Control( p_demux, DEMUX_SET_TIME, time, precise );
+}
+
/**
* This function will create a packetizer suitable for a demuxer that parses
* elementary stream.
More information about the vlc-commits
mailing list