[vlc-devel] [PATCH 1/3] input: add input_item_browsable_e to input_item

Thomas Guillem thomas at gllm.fr
Mon Feb 2 17:45:40 CET 2015


Automatically set to ITEM_BROWSABLE when the file type is a directory or a
playlist or during a parse if the demux return DEMUX_IS_PLAYLIST.

Add input_item_NewWithTypeExt function that can force input_item_browsable_e.
---
 include/vlc_input_item.h | 16 ++++++++++++++++
 src/input/input.c        |  6 ++++++
 src/input/item.c         | 28 +++++++++++++++++++++++++---
 src/libvlccore.sym       |  1 +
 4 files changed, 48 insertions(+), 3 deletions(-)

diff --git a/include/vlc_input_item.h b/include/vlc_input_item.h
index 8502dd3..2a9b13f 100644
--- a/include/vlc_input_item.h
+++ b/include/vlc_input_item.h
@@ -85,6 +85,7 @@ struct input_item_t
     vlc_mutex_t lock;                 /**< Lock for the item */
 
     uint8_t     i_type;              /**< Type (file, disc, ... see input_item_type_e) */
+    uint8_t     i_browsable;         /**< Browsable (see input_item_browsable_e) */
     bool        b_error_when_reading;/**< Error When Reading */
 };
 
@@ -106,6 +107,13 @@ enum input_item_type_e
     ITEM_TYPE_NUMBER
 };
 
+enum input_item_browsable_e
+{
+    ITEM_BROWSABLE_UNKNOWN,
+    ITEM_BROWSABLE,
+    ITEM_NOT_BROWSABLE,
+};
+
 struct input_item_node_t
 {
     input_item_t *         p_item;
@@ -258,6 +266,14 @@ VLC_API input_item_t * input_item_NewWithType( const char *psz_uri, const char *
 /**
  * This function creates a new input_item_t with the provided information.
  *
+ * XXX You may also use input_item_New, input_item_NewExt, or
+ * input_item_NewWithType as they need less arguments.
+ */
+VLC_API input_item_t * input_item_NewWithTypeExt( const char *psz_uri, const char *psz_name, int i_options, const char *const *ppsz_options, unsigned i_option_flags, mtime_t i_duration, int i_type, int i_browsable ) VLC_USED;
+
+/**
+ * This function creates a new input_item_t with the provided information.
+ *
  * Provided for convenience.
  */
 VLC_API input_item_t * input_item_NewExt( const char *psz_uri, const char *psz_name, int i_options, const char *const *ppsz_options, unsigned i_option_flags, mtime_t i_duration ) VLC_USED;
diff --git a/src/input/input.c b/src/input/input.c
index 4e9fb49..a0d6659 100644
--- a/src/input/input.c
+++ b/src/input/input.c
@@ -202,7 +202,13 @@ int input_Preparse( vlc_object_t *p_parent, input_item_t *p_item )
                             &b_is_playlist ) )
             b_is_playlist = false;
         if( b_is_playlist )
+        {
+            vlc_mutex_lock( &p_input->p->p_item->lock );
+            p_input->p->p_item->i_browsable = ITEM_BROWSABLE;
+            vlc_mutex_unlock( &p_input->p->p_item->lock );
+
             MainLoop( p_input, false );
+        }
         End( p_input );
     }
 
diff --git a/src/input/item.c b/src/input/item.c
index 33c7b26..cb03f90 100644
--- a/src/input/item.c
+++ b/src/input/item.c
@@ -824,9 +824,10 @@ input_item_t *input_item_NewExt( const char *psz_uri,
 
 
 input_item_t *
-input_item_NewWithType( const char *psz_uri, const char *psz_name,
-                        int i_options, const char *const *ppsz_options,
-                        unsigned flags, mtime_t duration, int type )
+input_item_NewWithTypeExt( const char *psz_uri, const char *psz_name,
+                           int i_options, const char *const *ppsz_options,
+                           unsigned flags, mtime_t duration, int type,
+                           int browsable )
 {
     static atomic_uint last_input_id = ATOMIC_VAR_INIT(0);
 
@@ -877,10 +878,31 @@ input_item_NewWithType( const char *psz_uri, const char *psz_name,
 
     if( type != ITEM_TYPE_UNKNOWN )
         p_input->i_type = type;
+    if( browsable == ITEM_BROWSABLE_UNKNOWN )
+    {
+        if( p_input->i_type == ITEM_TYPE_DIRECTORY
+            || p_input->i_type == ITEM_TYPE_PLAYLIST )
+            p_input->i_browsable = ITEM_BROWSABLE;
+        else if( p_input->i_type == ITEM_TYPE_FILE )
+            p_input->i_browsable = ITEM_NOT_BROWSABLE;
+        else
+            p_input->i_browsable = ITEM_BROWSABLE_UNKNOWN;
+    } else
+        p_input->i_browsable = browsable;
     p_input->b_error_when_reading = false;
     return p_input;
 }
 
+input_item_t *
+input_item_NewWithType( const char *psz_uri, const char *psz_name,
+                        int i_options, const char *const *ppsz_options,
+                        unsigned flags, mtime_t duration, int type )
+{
+    return input_item_NewWithTypeExt( psz_uri, psz_name, i_options,
+                                      ppsz_options, flags, duration, type,
+                                      ITEM_BROWSABLE_UNKNOWN );
+}
+
 input_item_t *input_item_Copy( input_item_t *p_input )
 {
     vlc_mutex_lock( &p_input->lock );
diff --git a/src/libvlccore.sym b/src/libvlccore.sym
index 7f06ed6..42496db 100644
--- a/src/libvlccore.sym
+++ b/src/libvlccore.sym
@@ -199,6 +199,7 @@ input_item_MetaMatch
 input_item_MergeInfos
 input_item_NewExt
 input_item_NewWithType
+input_item_NewWithTypeExt
 input_item_Hold
 input_item_Release
 input_item_node_AppendItem
-- 
2.1.3




More information about the vlc-devel mailing list