[vlc-devel] [PATCH 3/5] item: detect unknown item type via stat

Thomas Guillem thomas at gllm.fr
Thu Nov 5 12:09:10 CET 2015


---
 src/input/item.c | 13 +++++++++++++
 1 file changed, 13 insertions(+)

diff --git a/src/input/item.c b/src/input/item.c
index 9b93c6b..296227f 100644
--- a/src/input/item.c
+++ b/src/input/item.c
@@ -953,6 +953,19 @@ input_item_NewWithTypeExt( const char *psz_uri, const char *psz_name,
         p_input->i_type = type;
     p_input->b_error_when_reading = false;
 
+    if( p_input->i_type == ITEM_TYPE_UNKNOWN )
+    {
+        /* Try to detect the type if uri is valid file, fd or stream */
+        int fd = vlc_uri2fd( p_input->psz_uri );
+        struct stat st;
+        if( fd != -1 )
+        {
+            if( fstat( fd, &st ) == 0 )
+                p_input->i_type = input_stat2type( &st, &p_input->b_net );
+            close( fd );
+        }
+    }
+
     if( i_net != -1 )
         p_input->b_net = !!i_net;
     else if( p_input->i_type == ITEM_TYPE_STREAM )
-- 
2.1.4



More information about the vlc-devel mailing list