From 454a3688d220aa86bfa5ea39d6d9177ea6e95060 Mon Sep 17 00:00:00 2001 From: Laurent Aimar Date: Thu, 28 Jan 2010 21:28:37 +0100 Subject: [PATCH] Added es_out_ControlGetPcrSystem helper. Original patch by Jean-Paul Saman. --- include/vlc_es_out.h | 8 ++++++++ src/input/clock.c | 13 +++++++++++++ src/input/clock.h | 6 ++++++ src/input/es_out.c | 14 ++++++++++++++ src/input/es_out_timeshift.c | 7 +++++++ 5 files changed, 48 insertions(+) diff --git a/include/vlc_es_out.h b/include/vlc_es_out.h index 3c425ebca6..357b0ad371 100644 --- a/include/vlc_es_out.h +++ b/include/vlc_es_out.h @@ -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 ); +} + /** * @} */ diff --git a/src/input/clock.c b/src/input/clock.c index 799b8a5da0..29029497f4 100644 --- a/src/input/clock.c +++ b/src/input/clock.c @@ -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 ) diff --git a/src/input/clock.h b/src/input/clock.h index ff50c8233d..ab3509e446 100644 --- a/src/input/clock.h +++ b/src/input/clock.h @@ -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. diff --git a/src/input/es_out.c b/src/input/es_out.c index d62e235938..07626906e1 100644 --- a/src/input/es_out.c +++ b/src/input/es_out.c @@ -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; diff --git a/src/input/es_out_timeshift.c b/src/input/es_out_timeshift.c index 4609347d30..5118936a2b 100644 --- a/src/input/es_out_timeshift.c +++ b/src/input/es_out_timeshift.c @@ -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); -- 2.39.2