[vlc-devel] [PATCH V3 06/19] clock: add vlc_clock_UpdateVideo()

Thomas Guillem thomas at gllm.fr
Fri Sep 6 17:20:36 CEST 2019


Used to send the fps of the current point.
---
 src/clock/clock.c | 36 ++++++++++++++++++++++++++----------
 src/clock/clock.h | 13 +++++++++++++
 2 files changed, 39 insertions(+), 10 deletions(-)

diff --git a/src/clock/clock.c b/src/clock/clock.c
index 9d408ee3b5..735a94a8af 100644
--- a/src/clock/clock.c
+++ b/src/clock/clock.c
@@ -62,7 +62,8 @@ struct vlc_clock_main_t
 struct vlc_clock_t
 {
     vlc_tick_t (*update)(vlc_clock_t *clock, vlc_tick_t system_now,
-                         vlc_tick_t ts, double rate);
+                         vlc_tick_t ts, double rate,
+                         unsigned frame_rate, unsigned frame_rate_base);
     void (*reset)(vlc_clock_t *clock);
     vlc_tick_t (*set_delay)(vlc_clock_t *clock, vlc_tick_t delay);
     void (*set_dejitter)(vlc_clock_t *clock, vlc_tick_t delay);
@@ -144,15 +145,20 @@ static void vlc_clock_main_reset(vlc_clock_main_t *main_clock)
 
 static inline void vlc_clock_on_update(vlc_clock_t *clock,
                                        vlc_tick_t system_now,
-                                       vlc_tick_t ts, double rate)
+                                       vlc_tick_t ts, double rate,
+                                       unsigned frame_rate,
+                                       unsigned frame_rate_base)
 {
     if (clock->cbs)
-        clock->cbs->on_update(system_now, ts, rate, clock->cbs_data);
+        clock->cbs->on_update(system_now, ts, rate, frame_rate, frame_rate_base,
+                              clock->cbs_data);
 }
 
 static vlc_tick_t vlc_clock_master_update(vlc_clock_t *clock,
                                           vlc_tick_t system_now,
-                                          vlc_tick_t original_ts, double rate)
+                                          vlc_tick_t original_ts, double rate,
+                                          unsigned frame_rate,
+                                          unsigned frame_rate_base)
 {
     vlc_clock_main_t *main_clock = clock->owner;
 
@@ -190,7 +196,8 @@ static vlc_tick_t vlc_clock_master_update(vlc_clock_t *clock,
     original_ts = vlc_clock_main_update_origin(main_clock, original_ts);
     vlc_mutex_unlock(&main_clock->lock);
 
-    vlc_clock_on_update(clock, system_now, original_ts, rate);
+    vlc_clock_on_update(clock, system_now, original_ts, rate, frame_rate,
+                        frame_rate_base);
     return VLC_TICK_INVALID;
 }
 
@@ -221,7 +228,7 @@ static void vlc_clock_master_reset(vlc_clock_t *clock)
 
     vlc_mutex_unlock(&main_clock->lock);
 
-    vlc_clock_on_update(clock, VLC_TICK_INVALID, VLC_TICK_INVALID, 1.f);
+    vlc_clock_on_update(clock, VLC_TICK_INVALID, VLC_TICK_INVALID, 1.f, 0, 0);
 }
 
 static vlc_tick_t vlc_clock_master_set_delay(vlc_clock_t *clock, vlc_tick_t delay)
@@ -325,7 +332,9 @@ static vlc_tick_t vlc_clock_master_to_system_locked(vlc_clock_t *clock,
 
 static vlc_tick_t vlc_clock_slave_update(vlc_clock_t *clock,
                                          vlc_tick_t system_now,
-                                         vlc_tick_t ts, double rate)
+                                         vlc_tick_t ts, double rate,
+                                         unsigned frame_rate,
+                                         unsigned frame_rate_base)
 {
     vlc_clock_main_t *main_clock = clock->owner;
     vlc_mutex_lock(&main_clock->lock);
@@ -335,7 +344,7 @@ static vlc_tick_t vlc_clock_slave_update(vlc_clock_t *clock,
     ts = vlc_clock_main_update_origin(main_clock, ts);
     vlc_mutex_unlock(&main_clock->lock);
 
-    vlc_clock_on_update(clock, computed, ts, rate);
+    vlc_clock_on_update(clock, computed, ts, rate, frame_rate, frame_rate_base);
     return computed != INT64_MAX ? computed - system_now : INT64_MAX;
 }
 
@@ -348,7 +357,7 @@ static void vlc_clock_slave_reset(vlc_clock_t *clock)
 
     vlc_mutex_unlock(&main_clock->lock);
 
-    vlc_clock_on_update(clock, VLC_TICK_INVALID, VLC_TICK_INVALID, 1.0f);
+    vlc_clock_on_update(clock, VLC_TICK_INVALID, VLC_TICK_INVALID, 1.0f, 0, 0);
 }
 
 static vlc_tick_t vlc_clock_slave_set_delay(vlc_clock_t *clock, vlc_tick_t delay)
@@ -521,7 +530,14 @@ void vlc_clock_main_Delete(vlc_clock_main_t *main_clock)
 vlc_tick_t vlc_clock_Update(vlc_clock_t *clock, vlc_tick_t system_now,
                             vlc_tick_t ts, double rate)
 {
-    return clock->update(clock, system_now, ts, rate);
+    return clock->update(clock, system_now, ts, rate, 0, 0);
+}
+
+vlc_tick_t vlc_clock_UpdateVideo(vlc_clock_t *clock, vlc_tick_t system_now,
+                                 vlc_tick_t ts, double rate,
+                                 unsigned frame_rate, unsigned frame_rate_base)
+{
+    return clock->update(clock, system_now, ts, rate, frame_rate, frame_rate_base);
 }
 
 void vlc_clock_Reset(vlc_clock_t *clock)
diff --git a/src/clock/clock.h b/src/clock/clock.h
index 4af235cce4..96b444901f 100644
--- a/src/clock/clock.h
+++ b/src/clock/clock.h
@@ -45,9 +45,12 @@ struct vlc_clock_cbs
      * @param ts stream timestamp or VLC_TICK_INVALID when the clock is reset,
      * should be subtracted with VLC_TICK_0 to get the original value
      * @param rate rate used when updated
+     * @param frame_rate fps of the video owning the clock
+     * @param frame_rate_base fps denominator
      * @param data opaque pointer set from vlc_clock_main_New()
      */
     void (*on_update)(vlc_tick_t system_ts, vlc_tick_t ts, double rate,
+                      unsigned frame_rate, unsigned frame_rate_base,
                       void *data);
 };
 
@@ -144,6 +147,16 @@ void vlc_clock_Delete(vlc_clock_t *clock);
 vlc_tick_t vlc_clock_Update(vlc_clock_t *clock, vlc_tick_t system_now,
                             vlc_tick_t ts, double rate);
 
+/**
+ * This function will update the video clock drift and returns the drift
+ *
+ * Same behavior than vlc_clock_Update() except that the video is passed to the
+ * clock, this will be used for clock update callbacks.
+ */
+vlc_tick_t vlc_clock_UpdateVideo(vlc_clock_t *clock, vlc_tick_t system_now,
+                                 vlc_tick_t ts, double rate,
+                                 unsigned frame_rate, unsigned frame_rate_base);
+
 /**
  * This function resets the clock drift
  */
-- 
2.20.1



More information about the vlc-devel mailing list