[vlc-commits] demux: allow demuxer to expose pf_readdir

Rémi Denis-Courmont git at videolan.org
Mon Sep 28 17:08:59 CEST 2020


vlc | branch: master | Rémi Denis-Courmont <remi at remlab.net> | Sun Sep 27 12:13:58 2020 +0300| [54df0541eef1c923b1cfb2238c16fd2c967a822a] | committer: Rémi Denis-Courmont

demux: allow demuxer to expose pf_readdir

This makes the demux_Demux() function handle a demuxer plugin that
exposes a pf_readdir function, and invoke it if the demuxer does not
provide a pf_demux function.

> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=54df0541eef1c923b1cfb2238c16fd2c967a822a
---

 src/input/demux.c | 18 ++++++++++++++++++
 src/input/input.c |  6 ++++--
 2 files changed, 22 insertions(+), 2 deletions(-)

diff --git a/src/input/demux.c b/src/input/demux.c
index 849fde2a3a..5946013755 100644
--- a/src/input/demux.c
+++ b/src/input/demux.c
@@ -149,6 +149,7 @@ demux_t *demux_NewAdvanced( vlc_object_t *p_obj, input_thread_t *p_input,
     p_demux->out            = out;
     p_demux->b_preparsing   = b_preparsing;
 
+    p_demux->pf_readdir = NULL;
     p_demux->pf_demux   = NULL;
     p_demux->pf_control = NULL;
     p_demux->p_sys      = NULL;
@@ -202,6 +203,23 @@ int demux_Demux(demux_t *demux)
 {
     if (demux->pf_demux != NULL)
         return demux->pf_demux(demux);
+
+    if (demux->pf_readdir != NULL && demux->p_input_item != NULL) {
+        input_item_node_t *node = input_item_node_Create(demux->p_input_item);
+
+        if (unlikely(node == NULL))
+            return VLC_DEMUXER_EGENERIC;
+
+        if (vlc_stream_ReadDir(demux, node)) {
+             input_item_node_Delete(node);
+             return VLC_DEMUXER_EGENERIC;
+        }
+
+        if (es_out_Control(demux->out, ES_OUT_POST_SUBNODE, node))
+            input_item_node_Delete(node);
+        return VLC_DEMUXER_EOF;
+    }
+
     return VLC_DEMUXER_SUCCESS;
 }
 
diff --git a/src/input/input.c b/src/input/input.c
index 73b52530aa..d28507bd97 100644
--- a/src/input/input.c
+++ b/src/input/input.c
@@ -500,7 +500,7 @@ static void *Preparse( void *data )
         if ( input_item_ShouldPreparseSubItems( priv->p_item )
           && demux_Control( priv->master->p_demux, DEMUX_IS_PLAYLIST,
                             &b_is_playlist ) )
-            b_is_playlist = false;
+            b_is_playlist = priv->master->p_demux->pf_readdir != NULL;
         if( b_is_playlist )
             MainLoop( p_input, false );
         End( p_input );
@@ -675,7 +675,8 @@ static void MainLoop( input_thread_t *p_input, bool b_interactive )
     bool b_paused_at_eof = false;
 
     demux_t *p_demux = input_priv(p_input)->master->p_demux;
-    const bool b_can_demux = p_demux->pf_demux != NULL;
+    const bool b_can_demux = p_demux->pf_demux != NULL
+                          || p_demux->pf_readdir != NULL;
 
     while( !input_Stopped( p_input ) && input_priv(p_input)->i_state != ERROR_S )
     {
@@ -2713,6 +2714,7 @@ static int InputSourceInit( input_source_t *in, input_thread_t *p_input,
                        &in->b_can_pace_control ) )
         in->b_can_pace_control = false;
 
+    /* Threaded and directory demuxers do not have pace control */
     assert( in->p_demux->pf_demux != NULL || !in->b_can_pace_control );
 
     if( !in->b_can_pace_control )



More information about the vlc-commits mailing list