]> git.sesse.net Git - vlc/commitdiff
Added es_out_ControlGetPcrSystem helper.
authorLaurent Aimar <fenrir@videolan.org>
Thu, 28 Jan 2010 20:28:37 +0000 (21:28 +0100)
committerLaurent Aimar <fenrir@videolan.org>
Thu, 28 Jan 2010 21:01:39 +0000 (22:01 +0100)
Original patch by Jean-Paul Saman.

include/vlc_es_out.h
src/input/clock.c
src/input/clock.h
src/input/es_out.c
src/input/es_out_timeshift.c

index 3c425ebca6ad2d117f1d53530d320cbb01a59526..357b0ad371ba76b180058cadaf7e86f91c892e3f 100644 (file)
@@ -85,6 +85,9 @@ enum es_out_query_e
     /* Set global meta data (The vlc_meta_t is not modified nor released) */
     ES_OUT_SET_META, /* arg1=const vlc_meta_t * */
 
+    /* PCR system clock manipulation for external clock synchronization */
+    ES_OUT_GET_PCR_SYSTEM, /* arg1=mtime_t * res=can fail */
+
     /* First value usable for private control */
     ES_OUT_PRIVATE_START = 0x10000,
 };
@@ -145,6 +148,11 @@ static inline int es_out_ControlSetMeta( es_out_t *out, const vlc_meta_t *p_meta
     return es_out_Control( out, ES_OUT_SET_META, p_meta );
 }
 
+static inline int es_out_ControlGetPcrSystem( es_out_t *out, mtime_t *pi_system )
+{
+    return es_out_Control( out, ES_OUT_GET_PCR_SYSTEM, pi_system );
+}
+
 /**
  * @}
  */
index 799b8a5da086e918c1689fd4ded741f85f8bea47..29029497f40521d0cb218207705305389ea794de 100644 (file)
@@ -495,6 +495,19 @@ void input_clock_ChangeSystemOrigin( input_clock_t *cl, mtime_t i_system )
     vlc_mutex_unlock( &cl->lock );
 }
 
+mtime_t input_clock_GetSystemOrigin( input_clock_t *cl )
+{
+    vlc_mutex_lock( &cl->lock );
+
+    assert( cl->b_has_reference );
+
+    const mtime_t i_system = cl->ref.i_system;
+
+    vlc_mutex_unlock( &cl->lock );
+
+    return i_system;
+}
+
 #warning "input_clock_SetJitter needs more work"
 void input_clock_SetJitter( input_clock_t *cl,
                             mtime_t i_pts_delay, int i_cr_average )
index ff50c8233d223db6f1a201d60f266c74ba8b38c4..ab3509e4464caa143aad84fe7f26e7ac5ea3f48a 100644 (file)
@@ -83,6 +83,12 @@ void    input_clock_ChangeRate( input_clock_t *, int i_rate );
  */
 void    input_clock_ChangePause( input_clock_t *, bool b_paused, mtime_t i_date );
 
+/**
+ * This function returns the original system value date for the current
+ * reference point (a valid reference point must have been set).
+ */
+mtime_t input_clock_GetSystemOrigin( input_clock_t * );
+
 /**
  * This function allows to rebase the original system value date.
  * It can be called only imediatly after a input_clock_Update call.
index d62e23593851e8b9993a11cfa26daf4aa0e4c198..07626906e174c5a928104c15d6ea12c1736769a7 100644 (file)
@@ -2566,6 +2566,20 @@ static int EsOutControlLocked( es_out_t *out, int i_query, va_list args )
             return VLC_SUCCESS;
         }
 
+        case ES_OUT_GET_PCR_SYSTEM:
+        {
+            if( p_sys->b_buffering )
+                return VLC_EGENERIC;
+
+            es_out_pgrm_t *p_pgrm = p_sys->p_pgrm;
+            if( !p_pgrm )
+                return VLC_EGENERIC;
+
+            mtime_t *pi_system = va_arg( args, mtime_t *);
+            *pi_system = input_clock_GetSystemOrigin( p_pgrm->p_clock );
+            return VLC_SUCCESS;
+        }
+
         default:
             msg_Err( p_sys->p_input, "unknown query in es_out_Control" );
             return VLC_EGENERIC;
index 4609347d30dc8c2fd4e31028a71d76618842e871..5118936a2b67b27a608ab5f4578c12539c75cff7 100644 (file)
@@ -673,7 +673,14 @@ static int ControlLocked( es_out_t *p_out, int i_query, va_list args )
     {
         return ControlLockedSetFrameNext( p_out );
     }
+    case ES_OUT_GET_PCR_SYSTEM:
+    {
+        if( p_sys->b_delayed )
+            return VLC_EGENERIC;
 
+        mtime_t *pi_system = (mtime_t*)va_arg( args, mtime_t * );
+        return es_out_ControlGetPcrSystem( p_sys->p_out, pi_system );
+    }
     default:
         msg_Err( p_sys->p_input, "Unknown es_out_Control query !" );
         assert(0);