[vlc-devel] [RFC PATCH 06/10] sout: Add time/pos/pause controls

Rémi Denis-Courmont remi at remlab.net
Thu Sep 7 16:55:57 CEST 2017


Le torstaina 7. syyskuuta 2017, 15.46.02 EEST Hugo Beauzée-Luyssen a écrit :
> ---
>  include/vlc_sout.h                |  7 ++++-
>  src/stream_output/stream_output.c | 66
> +++++++++++++++++++++++++++++++++++++++ src/stream_output/stream_output.h |
>  6 ++++
>  3 files changed, 78 insertions(+), 1 deletion(-)
> 
> diff --git a/include/vlc_sout.h b/include/vlc_sout.h
> index c710780e2e..38ac269303 100644
> --- a/include/vlc_sout.h
> +++ b/include/vlc_sout.h
> @@ -191,7 +191,12 @@ static inline int sout_MuxControl( sout_mux_t *p_mux,
> int i_query, ... ) /** @} */
> 
>  enum sout_stream_query_e {
> -    SOUT_STREAM_EMPTY,    /* arg1=bool *,       res=can fail (assume true)
> */ +    SOUT_STREAM_EMPTY,          /* arg1=bool *,       res=can fail
> (assume true) */ +    SOUT_STREAM_GET_TIME,       /* arg1=mtime_t*     
> res=can fail */ +    SOUT_STREAM_SET_TIME,       /* arg1=mtime_t      
> res=can fail */ +    SOUT_STREAM_GET_POSITION,   /* arg1=float*       
> res=can fail */ +    SOUT_STREAM_SET_POSITION,   /* arg1=float        
> res=can fail */ +    SOUT_STREAM_SET_PAUSE_STATE /* arg1=bool         
> res=can fail */ };

As per patch 0, this does not seem to make much sense, except maybe the last 
one.

> 
>  struct sout_stream_t
> diff --git a/src/stream_output/stream_output.c
> b/src/stream_output/stream_output.c index a30e66852c..89f7503eee 100644
> --- a/src/stream_output/stream_output.c
> +++ b/src/stream_output/stream_output.c
> @@ -150,6 +150,72 @@ void sout_DeleteInstance( sout_instance_t * p_sout )
>      vlc_object_release( p_sout );
>  }
> 
> +int sout_InstanceGetTime( sout_instance_t* p_sout, mtime_t* pi_time )
> +{
> +    if( !p_sout )
> +        return VLC_EGENERIC;

Probably redundant.

> +
> +    int i_res;
> +    vlc_mutex_lock( &p_sout->lock );
> +    i_res = sout_StreamControl( p_sout->p_stream,
> +                                SOUT_STREAM_GET_TIME, pi_time );
> +    vlc_mutex_unlock( &p_sout->lock );
> +    return i_res;
> +}
> +
> +int sout_InstanceSetTime( sout_instance_t* p_sout, mtime_t i_time )
> +{
> +    if( !p_sout )
> +        return VLC_EGENERIC;
> +
> +    int i_res;
> +    vlc_mutex_lock( &p_sout->lock );
> +    i_res = sout_StreamControl( p_sout->p_stream,
> +                                SOUT_STREAM_SET_TIME, i_time );
> +    vlc_mutex_unlock( &p_sout->lock );
> +    return i_res;
> +}
> +
> +int sout_InstanceGetPosition( sout_instance_t* p_sout, double* pf_pos )
> +{
> +    if( !p_sout )
> +        return VLC_EGENERIC;
> +
> +    int i_res;
> +    vlc_mutex_lock( &p_sout->lock );
> +    i_res = sout_StreamControl( p_sout->p_stream,
> +                                SOUT_STREAM_GET_POSITION, pf_pos );
> +    vlc_mutex_unlock( &p_sout->lock );
> +    return i_res;
> +}
> +
> +int sout_InstanceSetPosition( sout_instance_t* p_sout, double f_pos )
> +{
> +    if( !p_sout )
> +        return VLC_EGENERIC;
> +
> +    int i_res;
> +    vlc_mutex_lock( &p_sout->lock );
> +    if( p_sout->p_stream )
> +        i_res = sout_StreamControl( p_sout->p_stream,
> +                                    SOUT_STREAM_SET_POSITION, f_pos );
> +    vlc_mutex_unlock( &p_sout->lock );
> +    return i_res;
> +}
> +
> +int sout_InstanceSetPauseState( sout_instance_t* p_sout, bool b_state )
> +{
> +    if( !p_sout )
> +        return VLC_EGENERIC;
> +
> +    int i_res = VLC_EGENERIC;
> +    vlc_mutex_lock( &p_sout->lock );
> +    i_res = sout_StreamControl( p_sout->p_stream,
> +                                SOUT_STREAM_SET_PAUSE_STATE, b_state );
> +    vlc_mutex_unlock( &p_sout->lock );
> +    return i_res;
> +}

Lot of trivially avoidable copy paste.

> +
>  /**************************************************************************
> *** * Packetizer/Input
>  
> ***************************************************************************
> **/ diff --git a/src/stream_output/stream_output.h
> b/src/stream_output/stream_output.h index c7ff95269d..24187a179a 100644
> --- a/src/stream_output/stream_output.h
> +++ b/src/stream_output/stream_output.h
> @@ -44,6 +44,12 @@ sout_instance_t *sout_NewInstance( vlc_object_t *, const
> char * ); #define sout_NewInstance(a,b) sout_NewInstance(VLC_OBJECT(a),b)
>  void sout_DeleteInstance( sout_instance_t * );
> 
> +int sout_InstanceGetTime( sout_instance_t*, mtime_t* );
> +int sout_InstanceSetTime( sout_instance_t*, mtime_t );
> +int sout_InstanceGetPosition( sout_instance_t*, double* );
> +int sout_InstanceSetPosition( sout_instance_t*, double );
> +int sout_InstanceSetPauseState( sout_instance_t*, bool );
> +
>  sout_packetizer_input_t *sout_InputNew( sout_instance_t *, const
> es_format_t * ); int sout_InputDelete( sout_packetizer_input_t * );
>  int sout_InputSendBuffer( sout_packetizer_input_t *, block_t* );


-- 
雷米‧德尼-库尔蒙
https://www.remlab.net/



More information about the vlc-devel mailing list