[vlc-commits] input: add input_SetEsIdDelay
Thomas Guillem
git at videolan.org
Tue Jun 25 20:55:12 CEST 2019
vlc | branch: master | Thomas Guillem <thomas at gllm.fr> | Wed Jun 19 14:01:06 2019 +0200| [479f22d5442e1ae72f7d3bb627fef525fd90ce53] | committer: Thomas Guillem
input: add input_SetEsIdDelay
This function set the delay of a track from its vlc_es_id_t*.
> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=479f22d5442e1ae72f7d3bb627fef525fd90ce53
---
src/input/es_out.c | 28 +++++++++++++++++++++++++++-
src/input/es_out.h | 8 ++++++++
src/input/es_out_timeshift.c | 1 +
src/input/input.c | 8 ++++++++
src/input/input_internal.h | 6 ++++++
5 files changed, 50 insertions(+), 1 deletion(-)
diff --git a/src/input/es_out.c b/src/input/es_out.c
index 567d4257c9..f257c526b5 100644
--- a/src/input/es_out.c
+++ b/src/input/es_out.c
@@ -119,6 +119,8 @@ struct es_out_id_t
decoder_t *p_dec_record;
vlc_clock_t *p_clock;
+ vlc_tick_t delay;
+
/* Fields for Video with CC */
struct
{
@@ -696,6 +698,19 @@ static bool EsOutDecodersIsEmpty( es_out_t *out )
return true;
}
+static void EsOutSetEsDelay(es_out_t *out, es_out_id_t *es, vlc_tick_t delay)
+{
+ es_out_sys_t *p_sys = container_of(out, es_out_sys_t, out);
+
+ es->delay = delay;
+
+ EsOutDecoderChangeDelay(out, es);
+
+ /* Update the clock pts delay only if the extra tracks delay changed */
+ EsOutControlLocked(out, ES_OUT_SET_JITTER, p_sys->i_pts_delay,
+ p_sys->i_pts_jitter, p_sys->i_cr_average);
+}
+
static void EsOutSetDelay( es_out_t *out, int i_cat, vlc_tick_t i_delay )
{
es_out_sys_t *p_sys = container_of(out, es_out_sys_t, out);
@@ -1049,7 +1064,9 @@ static void EsOutDecoderChangeDelay( es_out_t *out, es_out_id_t *p_es )
es_out_sys_t *p_sys = container_of(out, es_out_sys_t, out);
vlc_tick_t i_delay;
- if( p_es->fmt.i_cat == AUDIO_ES )
+ if( p_es->delay != INT64_MAX )
+ i_delay = p_es->delay; /* The track use its own delay, and not a category delay */
+ else if( p_es->fmt.i_cat == AUDIO_ES )
i_delay = p_sys->i_audio_delay;
else if( p_es->fmt.i_cat == SPU_ES )
i_delay = p_sys->i_spu_delay;
@@ -1917,6 +1934,7 @@ static es_out_id_t *EsOutAddSlaveLocked( es_out_t *out, const es_format_t *fmt,
es->p_master = p_master;
es->mouse_event_cb = NULL;
es->mouse_event_userdata = NULL;
+ es->delay = INT64_MAX;
vlc_list_append(&es->node, es->p_master ? &p_sys->es_slaves : &p_sys->es);
@@ -3123,6 +3141,14 @@ static int EsOutVaControlLocked( es_out_t *out, int i_query, va_list args )
return VLC_SUCCESS;
}
+ case ES_OUT_SET_ES_DELAY:
+ {
+ es_out_id_t *es = va_arg(args, es_out_id_t *);
+ const vlc_tick_t delay = va_arg(args, vlc_tick_t);
+ EsOutSetEsDelay(out, es, delay);
+ return VLC_SUCCESS;
+ }
+
case ES_OUT_SET_DELAY:
{
const int i_cat = va_arg( args, int );
diff --git a/src/input/es_out.h b/src/input/es_out.h
index 4e885b4fad..30e199579e 100644
--- a/src/input/es_out.h
+++ b/src/input/es_out.h
@@ -57,6 +57,9 @@ enum es_out_query_private_e
/* Get buffering state */
ES_OUT_GET_BUFFERING, /* arg1=bool* res=cannot fail */
+ /* Set delay for an ES identifier */
+ ES_OUT_SET_ES_DELAY, /* arg1=es_out_id_t *, res=cannot fail */
+
/* Set delay for a ES category */
ES_OUT_SET_DELAY, /* arg1=es_category_e, res=cannot fail */
@@ -120,6 +123,11 @@ static inline bool es_out_GetEmpty( es_out_t *p_out )
assert( !i_ret );
return b;
}
+static inline void es_out_SetEsDelay( es_out_t *p_out, es_out_id_t *es, vlc_tick_t i_delay )
+{
+ int i_ret = es_out_Control( p_out, ES_OUT_SET_ES_DELAY, es, i_delay );
+ assert( !i_ret );
+}
static inline void es_out_SetDelay( es_out_t *p_out, int i_cat, vlc_tick_t i_delay )
{
int i_ret = es_out_Control( p_out, ES_OUT_SET_DELAY, i_cat, i_delay );
diff --git a/src/input/es_out_timeshift.c b/src/input/es_out_timeshift.c
index 09482a2a10..cff9691d71 100644
--- a/src/input/es_out_timeshift.c
+++ b/src/input/es_out_timeshift.c
@@ -741,6 +741,7 @@ static int ControlLocked( es_out_t *p_out, int i_query, va_list args )
case ES_OUT_SET_ES_DEFAULT_BY_ID:
case ES_OUT_STOP_ALL_ES:
case ES_OUT_START_ALL_ES:
+ case ES_OUT_SET_ES_DELAY:
case ES_OUT_SET_DELAY:
case ES_OUT_SET_RECORD_STATE:
case ES_OUT_SET_VBI_PAGE:
diff --git a/src/input/input.c b/src/input/input.c
index 6ab5233653..efc338f33c 100644
--- a/src/input/input.c
+++ b/src/input/input.c
@@ -244,6 +244,14 @@ void input_SetCategoryDelay(input_thread_t *input, enum es_format_category_e cat
es_out_SetDelay(input_priv(input)->p_es_out_display, cat, delay);
}
+void input_SetEsIdDelay(input_thread_t *input, vlc_es_id_t *es_id,
+ vlc_tick_t delay)
+{
+ assert(es_id);
+ es_out_SetEsDelay(input_priv(input)->p_es_out_display,
+ vlc_es_id_get_out(es_id), delay);
+}
+
/**
* Get the item from an input thread
* FIXME it does not increase ref count of the item.
diff --git a/src/input/input_internal.h b/src/input/input_internal.h
index 96357200be..3b2f5533e9 100644
--- a/src/input/input_internal.h
+++ b/src/input/input_internal.h
@@ -373,6 +373,12 @@ void input_SetCategoryDelay(input_thread_t *input, enum es_format_category_e cat
vlc_tick_t delay);
/**
+ * Set the delay of an ES identifier
+ */
+void input_SetEsIdDelay(input_thread_t *input, vlc_es_id_t *es_id,
+ vlc_tick_t delay);
+
+/**
* Get the input item for an input thread
*
* You have to keep a reference to the input or to the input_item_t until
More information about the vlc-commits
mailing list