[vlc-devel] [RFC PATCH 3/4] input: spread npt via input events

Thomas Guillem thomas at gllm.fr
Tue Sep 10 18:33:06 CEST 2019


---
 src/input/es_out.c           | 7 +++++--
 src/input/es_out.h           | 9 ++++++---
 src/input/es_out_timeshift.c | 4 ++++
 src/input/event.h            | 4 ++--
 src/input/input.c            | 9 +++++++--
 src/input/input_internal.h   | 1 +
 6 files changed, 25 insertions(+), 9 deletions(-)

diff --git a/src/input/es_out.c b/src/input/es_out.c
index 6e30fbfe43..27b54ba1b5 100644
--- a/src/input/es_out.c
+++ b/src/input/es_out.c
@@ -3309,6 +3309,7 @@ static int EsOutVaControlLocked( es_out_t *out, int i_query, va_list args )
     {
         double f_position = va_arg( args, double );
         vlc_tick_t i_time = va_arg( args, vlc_tick_t );
+        vlc_tick_t i_npt = va_arg( args, vlc_tick_t );
         vlc_tick_t i_length = va_arg( args, vlc_tick_t );
 
         if( !p_sys->b_buffering )
@@ -3334,12 +3335,14 @@ static int EsOutVaControlLocked( es_out_t *out, int i_query, va_list args )
             if( f_position < 0 )
                 f_position = 0;
 
-            input_SendEventTimes( p_sys->p_input, f_position, i_time,
+            assert( i_npt >= VLC_TICK_0 );
+
+            input_SendEventTimes( p_sys->p_input, f_position, i_time, i_npt,
                                   i_length );
         }
         else
             input_SendEventTimes( p_sys->p_input, 0.0, VLC_TICK_INVALID,
-                                  i_length );
+                                  VLC_TICK_INVALID, i_length );
         return VLC_SUCCESS;
     }
     case ES_OUT_SET_JITTER:
diff --git a/src/input/es_out.h b/src/input/es_out.h
index 30e199579e..96d70bce9e 100644
--- a/src/input/es_out.h
+++ b/src/input/es_out.h
@@ -76,7 +76,7 @@ enum es_out_query_private_e
     ES_OUT_SET_FRAME_NEXT,                          /*                          res=can fail */
 
     /* Set position/time/length */
-    ES_OUT_SET_TIMES,                               /* arg1=double f_position arg2=vlc_tick_t i_time arg3=vlc_tick_t i_length res=cannot fail */
+    ES_OUT_SET_TIMES,                               /* arg1=double f_position arg2=vlc_tick_t i_time arg3=vlc_tick_t i_npt arg4=vlc_tick_t i_length res=cannot fail */
 
     /* Set jitter */
     ES_OUT_SET_JITTER,                              /* arg1=vlc_tick_t i_pts_delay arg2= vlc_tick_t i_pts_jitter, arg2=int i_cr_average res=cannot fail */
@@ -149,9 +149,12 @@ static inline int es_out_SetFrameNext( es_out_t *p_out )
 {
     return es_out_Control( p_out, ES_OUT_SET_FRAME_NEXT );
 }
-static inline void es_out_SetTimes( es_out_t *p_out, double f_position, vlc_tick_t i_time, vlc_tick_t i_length )
+static inline void es_out_SetTimes( es_out_t *p_out, double f_position,
+                                    vlc_tick_t i_time, vlc_tick_t i_npt,
+                                    vlc_tick_t i_length )
 {
-    int i_ret = es_out_Control( p_out, ES_OUT_SET_TIMES, f_position, i_time, i_length );
+    int i_ret = es_out_Control( p_out, ES_OUT_SET_TIMES, f_position, i_time,
+                                i_npt, i_length );
     assert( !i_ret );
 }
 static inline void es_out_SetJitter( es_out_t *p_out,
diff --git a/src/input/es_out_timeshift.c b/src/input/es_out_timeshift.c
index 2fd8855251..047c02fcff 100644
--- a/src/input/es_out_timeshift.c
+++ b/src/input/es_out_timeshift.c
@@ -135,6 +135,7 @@ typedef struct attribute_packed
             /* FIXME Really too big (double make the whole thing too big) */
             double  f_position;
             vlc_tick_t i_time;
+            vlc_tick_t i_npt;
             vlc_tick_t i_length;
         } times;
         struct
@@ -1517,10 +1518,12 @@ static int CmdInitControl( ts_cmd_t *p_cmd, int i_query, va_list args, bool b_co
     {
         double f_position = va_arg( args, double );
         vlc_tick_t i_time = va_arg( args, vlc_tick_t );
+        vlc_tick_t i_npt = va_arg( args, vlc_tick_t );
         vlc_tick_t i_length = va_arg( args, vlc_tick_t );
 
         p_cmd->u.control.u.times.f_position = f_position;
         p_cmd->u.control.u.times.i_time = i_time;
+        p_cmd->u.control.u.times.i_npt = i_npt;
         p_cmd->u.control.u.times.i_length = i_length;
         break;
     }
@@ -1612,6 +1615,7 @@ static int CmdExecuteControl( es_out_t *p_out, ts_cmd_t *p_cmd )
     case ES_OUT_SET_TIMES:
         return es_out_Control( p_out, i_query, p_cmd->u.control.u.times.f_position,
                                                p_cmd->u.control.u.times.i_time,
+                                               p_cmd->u.control.u.times.i_npt,
                                                p_cmd->u.control.u.times.i_length );
     case ES_OUT_SET_JITTER:
         return es_out_Control( p_out, i_query, p_cmd->u.control.u.jitter.i_pts_delay,
diff --git a/src/input/event.h b/src/input/event.h
index 3899563889..46c0611b29 100644
--- a/src/input/event.h
+++ b/src/input/event.h
@@ -56,11 +56,11 @@ static inline void input_SendEventCapabilities(input_thread_t *p_input,
 
 static inline void input_SendEventTimes(input_thread_t *p_input,
                                         double f_position, vlc_tick_t i_time,
-                                        vlc_tick_t i_length)
+                                        vlc_tick_t i_npt, vlc_tick_t i_length)
 {
     input_SendEvent(p_input, &(struct vlc_input_event) {
         .type = INPUT_EVENT_TIMES,
-        .times = { f_position, i_time, i_length }
+        .times = { f_position, i_time, i_npt, i_length }
     });
 }
 
diff --git a/src/input/input.c b/src/input/input.c
index ebb1af8817..624a90b0a1 100644
--- a/src/input/input.c
+++ b/src/input/input.c
@@ -613,6 +613,7 @@ static void MainLoopStatistics( input_thread_t *p_input )
     double f_position = 0.0;
     vlc_tick_t i_time;
     vlc_tick_t i_length;
+    vlc_tick_t i_npt;
 
     /* update input status variables */
     if( demux_Control( priv->master->p_demux,
@@ -625,7 +626,10 @@ static void MainLoopStatistics( input_thread_t *p_input )
     if( demux_Control( priv->master->p_demux, DEMUX_GET_LENGTH, &i_length ) )
         i_length = VLC_TICK_INVALID;
 
-    es_out_SetTimes( priv->p_es_out, f_position, i_time, i_length );
+    if( demux_Control( priv->master->p_demux, DEMUX_GET_NPT, &i_npt ) )
+        i_npt = VLC_TICK_0;
+
+    es_out_SetTimes( priv->p_es_out, f_position, i_time, i_npt, i_length );
 
     struct input_stats_t new_stats;
     if( priv->stats != NULL )
@@ -1272,7 +1276,8 @@ static int Init( input_thread_t * p_input )
     if( i_length == VLC_TICK_INVALID )
         i_length = input_item_GetDuration( priv->p_item );
 
-    input_SendEventTimes( p_input, 0.0, VLC_TICK_INVALID, i_length );
+    input_SendEventTimes( p_input, 0.0, VLC_TICK_INVALID, VLC_TICK_INVALID,
+                          i_length );
 
     if( !priv->b_preparsing )
     {
diff --git a/src/input/input_internal.h b/src/input/input_internal.h
index 12613bafc6..585d0dbe65 100644
--- a/src/input/input_internal.h
+++ b/src/input/input_internal.h
@@ -161,6 +161,7 @@ struct vlc_input_event_times
 {
     float percentage;
     vlc_tick_t ms;
+    vlc_tick_t npt;
     vlc_tick_t length;
 };
 
-- 
2.20.1



More information about the vlc-devel mailing list