[vlc-devel] [RFC 09/10] input/demux: input_DemuxNew: add support for mrl-fragment-identifiers

Thomas Guillem thomas at gllm.fr
Mon Nov 28 18:51:27 CET 2016



On Mon, Nov 28, 2016, at 03:22, Filip Roséen wrote:
> ---
>  src/input/demux.c | 60
>  ++++++++++++++++++++++++++++++++++++++++++++++++++++---
>  1 file changed, 57 insertions(+), 3 deletions(-)
> 
> diff --git a/src/input/demux.c b/src/input/demux.c
> index fc37683..fa8cbb6 100644
> --- a/src/input/demux.c
> +++ b/src/input/demux.c
> @@ -38,6 +38,7 @@
>  #include <vlc_stream_extractor.h>
>  
>  #include "input_internal.h"
> +#include "mrl_helpers.h"
>  
>  static bool SkipID3Tag( demux_t * );
>  static bool SkipAPETag( demux_t *p_demux );
> @@ -201,6 +202,57 @@ static void demux_HandleMRLSections( const char *p,
>      *pi_chapter_end = chapter_end;
>  }
>  
> +static int demux_HandleAnchorSpecifiers( input_source_t* in,
> +                                         stream_t** stream,
> +                                         const char* anchor )
> +{
> +    vlc_array_t* identifiers = NULL;
> +    char const* extra;
> +
> +    if( mrl_FragmentSplit( &identifiers, &extra, anchor ) )
> +    {
> +        msg_Err( in, "unable to parse MRL-fragment: %s", anchor );
> +        goto error;
> +    }
> +
> +    demux_HandleMRLSections( extra ? extra : "",
> +        &in->i_title_start, &in->i_title_end,
> +        &in->i_seekpoint_start, &in->i_seekpoint_end );
> +
> +    while( vlc_array_count( identifiers ) )
> +    {
> +        char* id = vlc_array_item_at_index( identifiers, 0 );
> +
> +        if( vlc_stream_extractor_Attach( stream, id, NULL ) )
> +        {
> +            msg_Err( in, "unable to locate entity '%s' within stream",
> id );
> +            break;
> +        }
> +        else
> +            msg_Dbg( in, "successfully located entity '%s' within
> stream", id );
> +
> +        vlc_array_remove( identifiers, 0 );
> +        free( id );
> +    }
> +
> +    int remaining = vlc_array_count( identifiers );
> +
> +    for( int i = 0; i < remaining; ++i )
> +        free( vlc_array_item_at_index( identifiers, i ) );
> +
> +    vlc_array_destroy( identifiers );
> +
> +    if( remaining == 0 )
> +    {
> +        if( vlc_stream_extractor_Attach( stream, NULL, NULL ) )
> +            msg_Dbg( in, "attach of directory extractor failed" );
> +        return VLC_SUCCESS;

I don't understand this part. Is the returned stream always a directory
? How do you read the final file inside an archive, then ?

> +    }
> +
> +error:

You could remove the label here since you don't do real clean-up and
it's used only one time.

> +    return VLC_EGENERIC;
> +}
> +
>  
>  /*****************************************************************************
>   * demux_New:
> @@ -394,9 +446,11 @@ demux_t *input_DemuxNew( input_source_t* in, const
> char *access_name,
>  
>          stream = stream_FilterAutoNew( stream );
>  
> -        demux_HandleMRLSections( anchor,
> -            &in->i_title_start, &in->i_title_end,
> -            &in->i_seekpoint_start, &in->i_seekpoint_end );
> +        if( demux_HandleAnchorSpecifiers( (input_source_t*)in, &stream,
> anchor ) )
> +        {
> +            vlc_stream_Delete( stream );
> +            goto out;
> +        }
>  
>          char *filters = var_InheritString( in, "stream-filter" );
>          if( filters != NULL )
> -- 
> 2.10.2
> 
> _______________________________________________
> vlc-devel mailing list
> To unsubscribe or modify your subscription options:
> https://mailman.videolan.org/listinfo/vlc-devel


More information about the vlc-devel mailing list