[vlc-commits] smf: implement SET_POSITION and SET_TIME
Rémi Denis-Courmont
git at videolan.org
Thu Jul 10 19:52:00 CEST 2014
vlc | branch: master | Rémi Denis-Courmont <remi at remlab.net> | Thu Jul 10 20:35:12 2014 +0300| [084fe0f41fd06745b80c52a882f9f06e72ec1fb7] | committer: Rémi Denis-Courmont
smf: implement SET_POSITION and SET_TIME
> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=084fe0f41fd06745b80c52a882f9f06e72ec1fb7
---
modules/demux/smf.c | 38 +++++++++++++++++++++++++++++++++-----
1 file changed, 33 insertions(+), 5 deletions(-)
diff --git a/modules/demux/smf.c b/modules/demux/smf.c
index 161d81a..02fdfdd 100644
--- a/modules/demux/smf.c
+++ b/modules/demux/smf.c
@@ -423,6 +423,8 @@ static int ReadEvents (demux_t *demux, uint64_t *restrict pulse,
return 0;
}
+#define TICK (CLOCK_FREQ / 100)
+
/*****************************************************************************
* Demux: read chunks and send them to the synthesizer
*****************************************************************************
@@ -445,7 +447,7 @@ static int Demux (demux_t *demux)
es_out_Send (demux->out, sys->es, tick);
es_out_Control (demux->out, ES_OUT_SET_PCR, sys->tick);
- sys->tick += CLOCK_FREQ / 100;
+ sys->tick += TICK;
return 1;
}
@@ -462,12 +464,36 @@ static int Demux (demux_t *demux)
return 1;
}
+static int Seek (demux_t *demux, mtime_t pts)
+{
+ demux_sys_t *sys = demux->p_sys;
+
+ /* Rewind if needed */
+ if (pts < date_Get (&sys->pts) && SeekSet0 (demux))
+ return VLC_EGENERIC;
+
+ /* Fast forward */
+ uint64_t pulse = sys->pulse;
+
+ while (pts > date_Get (&sys->pts))
+ {
+ if (pulse == UINT64_MAX)
+ return VLC_SUCCESS; /* premature end */
+ if (ReadEvents (demux, &pulse, NULL))
+ return VLC_EGENERIC;
+ }
+
+ sys->pulse = pulse;
+ sys->tick = ((date_Get (&sys->pts) - VLC_TS_0) / TICK) * TICK + VLC_TS_0;
+ return VLC_SUCCESS;
+}
+
/*****************************************************************************
* Control:
*****************************************************************************/
-static int Control (demux_t *p_demux, int i_query, va_list args)
+static int Control (demux_t *demux, int i_query, va_list args)
{
- demux_sys_t *sys = p_demux->p_sys;
+ demux_sys_t *sys = demux->p_sys;
switch (i_query)
{
@@ -477,14 +503,16 @@ static int Control (demux_t *p_demux, int i_query, va_list args)
*va_arg (args, double *) = (sys->tick - (double)VLC_TS_0)
/ sys->duration;
break;
- //case DEMUX_SET_POSITION:
+ case DEMUX_SET_POSITION:
+ return Seek (demux, va_arg (args, double) * sys->duration);
case DEMUX_GET_LENGTH:
*va_arg (args, int64_t *) = sys->duration;
break;
case DEMUX_GET_TIME:
*va_arg (args, int64_t *) = sys->tick - VLC_TS_0;
break;
- //case DEMUX_SET_TIME:
+ case DEMUX_SET_TIME:
+ return Seek (demux, va_arg (args, int64_t));
default:
return VLC_EGENERIC;
}
More information about the vlc-commits
mailing list