[vlc-commits] [Git][videolan/vlc][master] 4 commits: input: add InputSourceGetLength()
Jean-Baptiste Kempf (@jbk)
gitlab at videolan.org
Thu Jul 6 12:55:14 UTC 2023
Jean-Baptiste Kempf pushed to branch master at VideoLAN / VLC
Commits:
714c2a07 by Thomas Guillem at 2023-07-06T12:37:44+00:00
input: add InputSourceGetLength()
Helper that fetches the duration from the item in case of demux failure.
- - - - -
ad84dbdd by Thomas Guillem at 2023-07-06T12:37:44+00:00
input: use item duration fallback when seeking
- - - - -
07a6ea36 by Thomas Guillem at 2023-07-06T12:37:44+00:00
input: use item duration fallback from Statistics
But not for slaves since they don't have an input_item_t.
- - - - -
aedff471 by Thomas Guillem at 2023-07-06T12:37:44+00:00
input: initialize all Statistics from Init()
Not only the length, but position, time and normal_time.
The times event is now sent from only one place, in es_out.c
- - - - -
1 changed file:
- src/input/input.c
Changes:
=====================================
src/input/input.c
=====================================
@@ -565,7 +565,19 @@ static int MainLoopTryRepeat( input_thread_t *p_input )
return VLC_SUCCESS;
}
-static void InputSourceStatistics( input_source_t *source, es_out_t *out )
+static vlc_tick_t InputSourceGetLength( input_source_t *source, input_item_t *item )
+{
+ vlc_tick_t length;
+ if( demux_Control( source->p_demux, DEMUX_GET_LENGTH, &length ) )
+ length = 0;
+ if( length == 0 && item != NULL )
+ length = input_item_GetDuration( item );
+
+ return length;
+}
+
+static void InputSourceStatistics( input_source_t *source, input_item_t *item,
+ es_out_t *out )
{
double f_position = 0.0;
vlc_tick_t i_time;
@@ -580,8 +592,7 @@ static void InputSourceStatistics( input_source_t *source, es_out_t *out )
if( demux_Control( source->p_demux, DEMUX_GET_TIME, &i_time ) )
i_time = VLC_TICK_INVALID;
- if( demux_Control( source->p_demux, DEMUX_GET_LENGTH, &i_length ) )
- i_length = 0;
+ i_length = InputSourceGetLength( source, item );
/* In case of failure (not implemented or in case of seek), use VLC_TICK_0. */
if (demux_Control( source->p_demux, DEMUX_GET_NORMAL_TIME, &i_normal_time ) != VLC_SUCCESS)
@@ -597,12 +608,12 @@ static void MainLoopStatistics( input_thread_t *p_input )
{
input_thread_private_t *priv = input_priv(p_input);
- InputSourceStatistics( priv->master, priv->p_es_out );
+ InputSourceStatistics( priv->master, priv->p_item, priv->p_es_out );
for( int i = 0; i < priv->i_slave; i++ )
{
input_source_t *in = priv->slave[i];
- InputSourceStatistics( in, in->p_slave_es_out );
+ InputSourceStatistics( in, NULL, in->p_slave_es_out );
}
if (priv->stats != NULL)
@@ -1301,14 +1312,7 @@ static int Init( input_thread_t * p_input )
InitTitle( p_input, false );
/* Load master infos */
- /* Init length */
- vlc_tick_t i_length;
- if( demux_Control( master->p_demux, DEMUX_GET_LENGTH, &i_length ) )
- i_length = 0;
- if( i_length == 0 )
- i_length = input_item_GetDuration( priv->p_item );
-
- input_SendEventTimes( p_input, 0.0, VLC_TICK_INVALID, VLC_TICK_0, i_length );
+ InputSourceStatistics( master, priv->p_item, priv->p_es_out );
if( priv->type != INPUT_TYPE_PREPARSING )
{
@@ -2015,11 +2019,9 @@ static bool Control( input_thread_t *p_input,
!param.time.b_fast_seek, absolute );
if( i_ret )
{
- vlc_tick_t i_length;
-
+ vlc_tick_t i_length = InputSourceGetLength( priv->master, priv->p_item );
/* Emulate it with a SET_POS */
- if( !demux_Control( priv->master->p_demux,
- DEMUX_GET_LENGTH, &i_length ) && i_length > 0 )
+ if( i_length > 0 )
{
double f_pos = (double)param.time.i_val / (double)i_length;
i_ret = demux_SetPosition( priv->master->p_demux, f_pos,
View it on GitLab: https://code.videolan.org/videolan/vlc/-/compare/b73dc8841d999c6be9de718cd2cd3aeb13279792...aedff4718c5c0a547cebfaadbf0d365ab24ef88f
--
View it on GitLab: https://code.videolan.org/videolan/vlc/-/compare/b73dc8841d999c6be9de718cd2cd3aeb13279792...aedff4718c5c0a547cebfaadbf0d365ab24ef88f
You're receiving this email because of your account on code.videolan.org.
VideoLAN code repository instance
More information about the vlc-commits
mailing list