[vlc-devel] [PATCH 2/3] item: detect 'fd://' type at init
Thomas Guillem
thomas at gllm.fr
Wed Nov 4 19:35:50 CET 2015
---
src/input/item.c | 23 +++++++++++++++++++++++
1 file changed, 23 insertions(+)
diff --git a/src/input/item.c b/src/input/item.c
index 3248a84..0a0ed52 100644
--- a/src/input/item.c
+++ b/src/input/item.c
@@ -26,6 +26,9 @@
#endif
#include <assert.h>
#include <time.h>
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <unistd.h>
#include <vlc_common.h>
#include <vlc_url.h>
@@ -950,6 +953,26 @@ 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
+ && !strncasecmp( p_input->psz_uri, "fd://", 5 )
+ && strlen( p_input->psz_uri ) > 5 )
+ {
+ /* Try to detect the type of the fd */
+ int fd = atoi( p_input->psz_uri + 5 );
+ struct stat st;
+ if( fd != -1 && fstat( fd, &st ) == 0 )
+ {
+ if( S_ISREG( st.st_mode ) )
+ p_input->i_type = ITEM_TYPE_FILE;
+ else if( S_ISDIR( st.st_mode ) )
+ p_input->i_type = ITEM_TYPE_DIRECTORY;
+#ifdef S_ISSOCK
+ else if( S_ISSOCK( st.st_mode ) )
+ p_input->i_type = ITEM_TYPE_STREAM;
+#endif
+ }
+ }
+
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