[vlc-commits] stream: replace input_thread_t by input_item_t

Thomas Guillem git at videolan.org
Fri Jul 20 17:23:16 CEST 2018


vlc | branch: master | Thomas Guillem <thomas at gllm.fr> | Fri Jul 20 17:20:55 2018 +0200| [6b96ade7dd97acb49303a0a9da9b3d2056b808e0] | committer: Thomas Guillem

stream: replace input_thread_t by input_item_t

This will prevent all demuxers/access/streams to mess with the input_thread_t
state.

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

 include/vlc_stream.h                               |  4 +--
 modules/access/http.c                              | 30 +++++++---------------
 modules/demux/directory.c                          |  5 ++--
 modules/demux/mp4/mp4.c                            |  5 ++--
 modules/demux/playlist/playlist.h                  |  2 +-
 modules/services_discovery/sap.c                   |  9 ++-----
 modules/stream_filter/record.c                     |  3 ++-
 modules/stream_out/chromecast/chromecast_demux.cpp |  3 +--
 src/input/access.c                                 |  4 +--
 src/input/demux.c                                  |  7 ++---
 src/input/stream.c                                 |  2 +-
 src/input/stream_extractor.c                       |  2 +-
 src/input/stream_filter.c                          |  2 +-
 13 files changed, 29 insertions(+), 49 deletions(-)

diff --git a/include/vlc_stream.h b/include/vlc_stream.h
index ff894280a0..7e2b568e5a 100644
--- a/include/vlc_stream.h
+++ b/include/vlc_stream.h
@@ -52,6 +52,7 @@ struct stream_t
     const char  *psz_location; /**< Location (URL with the scheme stripped) */
     char        *psz_filepath; /**< Local file path (if applicable) */
     bool         b_preparsing; /**< True if this access is used to preparse */
+    input_item_t *p_input_item;/**< Input item (can be NULL) */
 
     union {
         /**
@@ -144,9 +145,6 @@ struct stream_t
      * Private data pointer
      */
     void *p_sys;
-
-    /* Weak link to parent input */
-    input_thread_t *p_input;
 };
 
 /**
diff --git a/modules/access/http.c b/modules/access/http.c
index c2bedba461..0ffa56b33f 100644
--- a/modules/access/http.c
+++ b/modules/access/http.c
@@ -521,13 +521,9 @@ static int ReadICYMeta( stream_t *p_access )
                 free( psz_tmp );
 
             msg_Dbg( p_access, "New Icy-Title=%s", p_sys->psz_icy_title );
-            input_thread_t *p_input = p_access->p_input;
-            if( p_input )
-            {
-                input_item_t *p_input_item = input_GetItem( p_access->p_input );
-                if( p_input_item )
-                    input_item_SetMeta( p_input_item, vlc_meta_NowPlaying, p_sys->psz_icy_title );
-            }
+            if( p_access->p_input_item )
+                input_item_SetMeta( p_access->p_input_item, vlc_meta_NowPlaying,
+                                    p_sys->psz_icy_title );
         }
     }
     free( psz_meta );
@@ -892,13 +888,9 @@ static int Connect( stream_t *p_access )
             else
                 vlc_xml_decode( p_sys->psz_icy_name );
             msg_Dbg( p_access, "Icy-Name: %s", p_sys->psz_icy_name );
-            input_thread_t *p_input = p_access->p_input;
-            if ( p_input )
-            {
-                input_item_t *p_input_item = input_GetItem( p_access->p_input );
-                if ( p_input_item )
-                    input_item_SetMeta( p_input_item, vlc_meta_Title, p_sys->psz_icy_name );
-            }
+            if ( p_access->p_input_item )
+                input_item_SetMeta( p_access->p_input_item, vlc_meta_Title,
+                                    p_sys->psz_icy_name );
 
             p_sys->b_icecast = true; /* be on the safeside. set it here as well. */
             p_sys->b_reconnect = true;
@@ -913,13 +905,9 @@ static int Connect( stream_t *p_access )
             else
                 vlc_xml_decode( p_sys->psz_icy_genre );
             msg_Dbg( p_access, "Icy-Genre: %s", p_sys->psz_icy_genre );
-            input_thread_t *p_input = p_access->p_input;
-            if( p_input )
-            {
-                input_item_t *p_input_item = input_GetItem( p_access->p_input );
-                if( p_input_item )
-                    input_item_SetMeta( p_input_item, vlc_meta_Genre, p_sys->psz_icy_genre );
-            }
+            if( p_access->p_input_item )
+                input_item_SetMeta( p_access->p_input_item, vlc_meta_Genre,
+                                    p_sys->psz_icy_genre );
         }
         else if( !strncasecmp( psz, "Icy-Notice", 10 ) )
         {
diff --git a/modules/demux/directory.c b/modules/demux/directory.c
index 3510c77b45..ab46082d1c 100644
--- a/modules/demux/directory.c
+++ b/modules/demux/directory.c
@@ -32,8 +32,7 @@
 
 static int Demux( demux_t *p_demux )
 {
-    input_item_t *p_input = input_GetItem( p_demux->p_input );
-    input_item_node_t *p_node = input_item_node_Create( p_input );
+    input_item_node_t *p_node = input_item_node_Create( p_demux->p_input_item );
 
     if( vlc_stream_ReadDir( p_demux->s, p_node ) )
     {
@@ -78,7 +77,7 @@ static int Import_Dir( vlc_object_t *p_this )
 
     if( p_demux->s->pf_readdir == NULL )
         return VLC_EGENERIC;
-    if( p_demux->p_input == NULL )
+    if( p_demux->p_input_item == NULL )
         return VLC_ETIMEOUT;
 
     p_demux->pf_demux = Demux;
diff --git a/modules/demux/mp4/mp4.c b/modules/demux/mp4/mp4.c
index 7d72a3b9d1..5bdab8766e 100644
--- a/modules/demux/mp4/mp4.c
+++ b/modules/demux/mp4/mp4.c
@@ -851,15 +851,14 @@ static int Open( vlc_object_t * p_this )
     }
 
     MP4_Box_t *p_rmra = MP4_BoxGet( p_sys->p_root, "/moov/rmra" );
-    if( p_rmra != NULL && p_demux->p_input != NULL )
+    if( p_rmra != NULL && p_demux->p_input_item != NULL )
     {
         int        i_count = MP4_BoxCount( p_rmra, "rmda" );
         int        i;
 
         msg_Dbg( p_demux, "detected playlist mov file (%d ref)", i_count );
 
-        input_thread_t *p_input = p_demux->p_input;
-        input_item_t *p_current = input_GetItem( p_input );
+        input_item_t *p_current = p_demux->p_input_item;
 
         input_item_node_t *p_subitems = input_item_node_Create( p_current );
 
diff --git a/modules/demux/playlist/playlist.h b/modules/demux/playlist/playlist.h
index 51f3e4bcf6..883ca677df 100644
--- a/modules/demux/playlist/playlist.h
+++ b/modules/demux/playlist/playlist.h
@@ -60,7 +60,7 @@ int Import_iTML ( vlc_object_t * );
 int Import_WPL ( vlc_object_t * );
 void Close_WPL ( vlc_object_t * );
 
-#define GetCurrentItem(obj) input_GetItem((obj)->p_input)
+#define GetCurrentItem(obj) input_GetItem((obj)->p_input_item)
 #define GetSource(obj) ((obj)->s)
 
 #define CHECK_FILE(obj) \
diff --git a/modules/services_discovery/sap.c b/modules/services_discovery/sap.c
index e58647d5ad..a3233f3b26 100644
--- a/modules/services_discovery/sap.c
+++ b/modules/services_discovery/sap.c
@@ -616,19 +616,14 @@ static int Demux( demux_t *p_demux )
 {
     demux_sys_t *p_sys = p_demux->p_sys;
     sdp_t *p_sdp = p_sys->p_sdp;
-    input_thread_t *p_input = p_demux->p_input;
-    input_item_t *p_parent_input;
+    input_item_t *p_parent_input = p_demux->p_input_item;
 
-    if( !p_input )
+    if( !p_parent_input )
     {
         msg_Err( p_demux, "parent input could not be found" );
         return VLC_EGENERIC;
     }
 
-    /* This item hasn't been held by input_GetItem
-     * don't release it */
-    p_parent_input = input_GetItem( p_input );
-
     input_item_SetURI( p_parent_input, p_sdp->psz_uri );
     input_item_SetName( p_parent_input, p_sdp->psz_sessionname );
     if( p_sdp->rtcp_port )
diff --git a/modules/stream_filter/record.c b/modules/stream_filter/record.c
index d35fba73a9..3563663cb8 100644
--- a/modules/stream_filter/record.c
+++ b/modules/stream_filter/record.c
@@ -180,7 +180,8 @@ static int Start( stream_t *s, const char *psz_extension )
 
     /* Create file name
      * TODO allow prefix configuration */
-    psz_file = input_CreateFilename( s->p_input, NULL, psz_path, INPUT_RECORD_PREFIX, psz_extension );
+    psz_file = input_CreateFilename( NULL, s->p_input_item, psz_path,
+                                     INPUT_RECORD_PREFIX, psz_extension );
 
     free( psz_path );
 
diff --git a/modules/stream_out/chromecast/chromecast_demux.cpp b/modules/stream_out/chromecast/chromecast_demux.cpp
index e076a18f4d..14b21d7fe6 100644
--- a/modules/stream_out/chromecast/chromecast_demux.cpp
+++ b/modules/stream_out/chromecast/chromecast_demux.cpp
@@ -58,8 +58,7 @@ struct demux_cc
         vlc_meta_t *p_meta = vlc_meta_New();
         if( likely(p_meta != NULL) )
         {
-            input_item_t *p_item = p_demux->p_next->p_input ?
-                                   input_GetItem( p_demux->p_next->p_input ) : NULL;
+            input_item_t *p_item = p_demux->p_next->p_input_item;
             if( p_item )
             {
                 /* Favor Meta from the input item of the input_thread since
diff --git a/src/input/access.c b/src/input/access.c
index 94281a5762..9a34898f83 100644
--- a/src/input/access.c
+++ b/src/input/access.c
@@ -118,7 +118,7 @@ static stream_t *access_New(vlc_object_t *parent, input_thread_t *input,
     if (unlikely(access == NULL))
         return NULL;
 
-    access->p_input = input;
+    access->p_input_item = input ? input_GetItem(input) : NULL;
     access->out = out;
     access->psz_name = NULL;
     access->psz_url = strdup(mrl);
@@ -312,7 +312,7 @@ stream_t *stream_AccessNew(vlc_object_t *parent, input_thread_t *input,
         priv = vlc_stream_Private(s);
         priv->input = input;
 
-        s->p_input = input;
+        s->p_input_item = input ? input_GetItem(input) : NULL;
         s->psz_url = strdup(access->psz_url);
 
         if (access->pf_block != NULL)
diff --git a/src/input/demux.c b/src/input/demux.c
index bb87fa39c2..3631e08984 100644
--- a/src/input/demux.c
+++ b/src/input/demux.c
@@ -32,6 +32,7 @@
 #include <libvlc.h>
 #include <vlc_codec.h>
 #include <vlc_meta.h>
+#include <vlc_input.h>
 #include <vlc_url.h>
 #include <vlc_modules.h>
 #include <vlc_strings.h>
@@ -178,7 +179,7 @@ static int demux_Probe(void *func, va_list ap)
     return probe(VLC_OBJECT(demux));
 }
 
-demux_t *demux_NewAdvanced( vlc_object_t *p_obj, input_thread_t *p_parent_input,
+demux_t *demux_NewAdvanced( vlc_object_t *p_obj, input_thread_t *p_input,
                             const char *psz_demux, const char *url,
                             stream_t *s, es_out_t *out, bool b_preparsing )
 {
@@ -202,7 +203,7 @@ demux_t *demux_NewAdvanced( vlc_object_t *p_obj, input_thread_t *p_parent_input,
         }
     }
 
-    p_demux->p_input = p_parent_input;
+    p_demux->p_input_item = p_input ? input_GetItem(p_input) : NULL;
     p_demux->psz_name = strdup( psz_demux );
     if (unlikely(p_demux->psz_name == NULL))
         goto error;
@@ -485,7 +486,7 @@ static demux_t *demux_FilterNew( demux_t *p_next, const char *p_name )
 
     priv = vlc_stream_Private(p_demux);
     p_demux->p_next       = p_next;
-    p_demux->p_input      = NULL;
+    p_demux->p_input_item = NULL;
     p_demux->p_sys        = NULL;
     p_demux->psz_name     = NULL;
     p_demux->psz_url      = NULL;
diff --git a/src/input/stream.c b/src/input/stream.c
index c4224b0c08..684290a537 100644
--- a/src/input/stream.c
+++ b/src/input/stream.c
@@ -85,7 +85,7 @@ stream_t *vlc_stream_CustomNew(vlc_object_t *parent,
     s->pf_seek = NULL;
     s->pf_control = NULL;
     s->p_sys = NULL;
-    s->p_input = NULL;
+    s->p_input_item = NULL;
     assert(destroy != NULL);
     priv->destroy = destroy;
     priv->block = NULL;
diff --git a/src/input/stream_extractor.c b/src/input/stream_extractor.c
index 7ccc4b6296..c8e9298ab0 100644
--- a/src/input/stream_extractor.c
+++ b/src/input/stream_extractor.c
@@ -265,7 +265,7 @@ se_AttachWrapper( struct stream_extractor_private* priv, stream_t* source )
     }
 
     priv->wrapper = s;
-    priv->wrapper->p_input = source->p_input;
+    priv->wrapper->p_input_item = source->p_input_item;
     priv->wrapper->p_sys = priv;
 
     priv->source = source;
diff --git a/src/input/stream_filter.c b/src/input/stream_filter.c
index a14d34dd5e..ea6fd308a7 100644
--- a/src/input/stream_filter.c
+++ b/src/input/stream_filter.c
@@ -60,7 +60,7 @@ stream_t *vlc_stream_FilterNew( stream_t *p_source,
         return NULL;
 
     priv = vlc_stream_Private(s);
-    s->p_input = p_source->p_input;
+    s->p_input_item = p_source->p_input_item;
 
     if( p_source->psz_url != NULL )
     {



More information about the vlc-commits mailing list