[vlc-devel] [PATCH v2 2/7] es_out: add ES_OUT_SET_NPT
Thomas Guillem
thomas at gllm.fr
Thu Apr 1 15:30:07 UTC 2021
This will replace DEMUX_GET_NORMAL_TIME.
Demux modules should set a valid normal play time if the PCR and the
time reported by DEMUX_GET_TIME don't have the same origin. This is the
case for mpeg/ts, dvd, bluray, cdda, adaptive.
---
include/vlc_es_out.h | 14 ++++++++++++++
src/input/es_out.c | 27 +++++++++++++++++++++++++++
2 files changed, 41 insertions(+)
diff --git a/include/vlc_es_out.h b/include/vlc_es_out.h
index 49635f8594f..dac56ebb77c 100644
--- a/include/vlc_es_out.h
+++ b/include/vlc_es_out.h
@@ -65,6 +65,15 @@ enum es_out_query_e
ES_OUT_SET_GROUP_PCR, /* arg1= int i_group, arg2=vlc_tick_t i_pcr(microsecond!)*/
ES_OUT_RESET_PCR, /* no arg */
+ /* Set the Normal Playing Time (if needed)
+ *
+ * Demux modules should set a valid NPT (!= VLC_TICK_INVALID) when their
+ * PCR is not based on VLC_TICK_0 (DEMUX_GET_TIME and PCR are not based on
+ * the same origin).
+ * */
+ ES_OUT_SET_NPT, /* arg1=vlc_tick_t i_npt (using default group 0) */
+ ES_OUT_SET_GROUP_NPT, /* arg1= int i_group, arg2=vlc_tick_t i_npt */
+
/* This will update the fmt, drain and restart the decoder (if any).
* The new fmt must have the same i_cat and i_id. */
ES_OUT_SET_ES_FMT, /* arg1= es_out_id_t* arg2=es_format_t* res=can fail */
@@ -187,6 +196,11 @@ static inline int es_out_SetPCR( es_out_t *out, vlc_tick_t pcr )
return es_out_Control( out, ES_OUT_SET_PCR, pcr );
}
+static inline int es_out_SetNPT( es_out_t *out, vlc_tick_t npt )
+{
+ return es_out_Control( out, ES_OUT_SET_NPT, npt );
+}
+
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 );
diff --git a/src/input/es_out.c b/src/input/es_out.c
index a209031406d..0eb37d7ca9e 100644
--- a/src/input/es_out.c
+++ b/src/input/es_out.c
@@ -3351,6 +3351,33 @@ static int EsOutVaControlLocked( es_out_t *out, input_source_t *source,
EsOutChangePosition( out, true );
return VLC_SUCCESS;
+ case ES_OUT_SET_NPT:
+ case ES_OUT_SET_GROUP_NPT:
+ {
+ es_out_pgrm_t *p_pgrm = NULL;
+
+ /* Search program */
+ if( i_query == ES_OUT_SET_NPT )
+ {
+ p_pgrm = p_sys->p_pgrm;
+ if( !p_pgrm )
+ p_pgrm = EsOutProgramAdd( out, source, 0 ); /* Create it */
+ }
+ else
+ {
+ int i_group = va_arg( args, int );
+ p_pgrm = EsOutProgramInsert( out, source, i_group );
+ }
+ if( !p_pgrm )
+ return VLC_EGENERIC;
+
+ vlc_tick_t npt = va_arg( args, int64_t );
+
+ vlc_clock_main_SetInputNPT( p_pgrm->p_main_clock, npt );
+
+ return VLC_SUCCESS;
+ }
+
case ES_OUT_SET_GROUP:
{
int i = va_arg( args, int );
--
2.30.0
More information about the vlc-devel
mailing list