[vlc-devel] [PATCH 1/4] avformat mux: Propagate seekable status into avformat.

Rémi Denis-Courmont remi at remlab.net
Sat Aug 24 22:12:31 CEST 2013


Le vendredi 16 août 2013 16:42:11 Steinar H. Gunderson a écrit :
> Some muxes, in particular mkv/webm, behave very differently depending on
> whether we say that the stream is seekable or not (by providing the IOSeek
> function). It does not help that the seek function itself returns an error.
> 
> Thus, add a new access_out control called ACCESS_OUT_CAN_SEEK, set to true
> for seekable files in the file output only, and propagate the status of that
> into avformat at initialization time.
> ---
>  include/vlc_sout.h           |    1 +
>  modules/access_output/file.c |   14 ++++++++++++++
>  modules/demux/avformat/mux.c |    5 ++++-
>  3 files changed, 19 insertions(+), 1 deletion(-)
> 
> diff --git a/include/vlc_sout.h b/include/vlc_sout.h
> index 87d8229..e480325 100644
> --- a/include/vlc_sout.h
> +++ b/include/vlc_sout.h
> @@ -81,6 +81,7 @@ struct sout_access_out_t
>  enum access_out_query_e
>  {
>      ACCESS_OUT_CONTROLS_PACE, /* arg1=bool *, can fail (assume true) */
> +    ACCESS_OUT_CAN_SEEK, /* arg1=bool *, can fail (assume true) */
>  };
> 
>  VLC_API sout_access_out_t * sout_AccessOutNew( vlc_object_t *, const char
> *psz_access, const char *psz_name ) VLC_USED; diff --git
> a/modules/access_output/file.c b/modules/access_output/file.c index
> 8bc2b6f..84d2d9a 100644
> --- a/modules/access_output/file.c
> +++ b/modules/access_output/file.c
> @@ -34,6 +34,9 @@
>  #include <time.h>
>  #include <fcntl.h>
>  #include <errno.h>
> +#include <sys/types.h>
> +#include <sys/stat.h>
> +#include <unistd.h>
> 
>  #include <vlc_common.h>
>  #include <vlc_plugin.h>
> @@ -243,6 +246,17 @@ static int Control( sout_access_out_t *p_access, int
> i_query, va_list args ) break;
>          }
> 
> +        case ACCESS_OUT_CAN_SEEK:
> +        {
> +            bool *pb = va_arg( args, bool * );
> +            struct stat st;
> +            if( fstat( (intptr_t)p_access->p_sys, &st ) == -1 )
> +                *pb = false;
> +            else
> +                *pb = S_ISREG( st.st_mode ) || S_ISCHR( st.st_mode ) ||
> S_ISBLK( st.st_mode );

Character devices cannot be sought (or when they can, the behaviour is 
undefined and driver specific). Think of TTYs...

> +            break;
> +        }
> +
>          default:
>              return VLC_EGENERIC;
>      }

-- 
Rémi Denis-Courmont
http://www.remlab.net/




More information about the vlc-devel mailing list