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

Filip Roséen filip at atch.se
Mon Nov 28 03:22:28 CET 2016


---
 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;
+    }
+
+error:
+    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



More information about the vlc-devel mailing list