[vlc-commits] access: add ACCESS_IS_DIRECTORY as STREAM_IS_DIRECTORY

Rémi Denis-Courmont git at videolan.org
Wed Sep 2 21:54:14 CEST 2015


vlc | branch: master | Rémi Denis-Courmont <remi at remlab.net> | Wed Sep  2 20:36:12 2015 +0300| [5d096c300e8702f256c6566ec74494ed78eca329] | committer: Rémi Denis-Courmont

access: add ACCESS_IS_DIRECTORY as STREAM_IS_DIRECTORY

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

 include/vlc_access.h                |    8 +-------
 modules/access/dsm/access.c         |   21 +++++++++++++++++----
 modules/access/ftp.c                |   19 +++++++++++++++++--
 modules/access/sftp.c               |   19 +++++++++++++++++--
 modules/access/smb.c                |   19 +++++++++++++++++--
 modules/services_discovery/upnp.cpp |   19 ++++++++++++++++---
 src/input/access.c                  |   13 ++++++-------
 7 files changed, 91 insertions(+), 27 deletions(-)

diff --git a/include/vlc_access.h b/include/vlc_access.h
index e5a5749..026dadd 100644
--- a/include/vlc_access.h
+++ b/include/vlc_access.h
@@ -43,6 +43,7 @@ enum access_query_e
     ACCESS_CAN_PAUSE,       /* arg1= bool*    cannot fail */
     ACCESS_CAN_CONTROL_PACE,/* arg1= bool*    cannot fail */
     ACCESS_GET_SIZE=6,      /* arg1= uin64_t* */
+    ACCESS_IS_DIRECTORY,    /* arg1= bool *, arg2= bool *, res=can fail */
 
     /* */
     ACCESS_GET_PTS_DELAY = 0x101,/* arg1= int64_t*       cannot fail */
@@ -104,13 +105,6 @@ struct access_t
     struct
     {
         bool         b_eof;     /* idem */
-
-        bool         b_dir_sorted; /* Set it to true if items returned by
-                                    * pf_readdir are already sorted. */
-
-        bool         b_dir_can_loop;  /* Set it to true if the access can't know
-                                       * if children can loop into their parents.
-                                       * It's the case for most network accesses. */
     } info;
     access_sys_t *p_sys;
 
diff --git a/modules/access/dsm/access.c b/modules/access/dsm/access.c
index 6228716..960f316 100644
--- a/modules/access/dsm/access.c
+++ b/modules/access/dsm/access.c
@@ -693,6 +693,22 @@ static input_item_t* BrowseDirectory( access_t *p_access )
     return p_item;
 }
 
+static int DirControl( access_t *p_access, int i_query, va_list args )
+{
+    switch( i_query )
+    {
+    case ACCESS_IS_DIRECTORY:
+        *va_arg( args, bool * ) = false; /* is not sorted */
+        *va_arg( args, bool * ) = p_access->pf_readdir == BrowseDirectory;
+                                  /* might loop */
+        break;
+    default:
+        return access_vaDirectoryControlHelper( p_access, i_query, args );
+    }
+
+    return VLC_SUCCESS;
+}
+
 static int BrowserInit( access_t *p_access )
 {
     access_sys_t *p_sys = p_access->p_sys;
@@ -700,11 +716,8 @@ static int BrowserInit( access_t *p_access )
     if( p_sys->psz_share == NULL )
         p_access->pf_readdir = BrowseShare;
     else
-    {
         p_access->pf_readdir = BrowseDirectory;
-        p_access->info.b_dir_can_loop = true;
-    }
-    p_access->pf_control = access_vaDirectoryControlHelper;
+    p_access->pf_control = DirControl;
 
     return VLC_SUCCESS;
 }
diff --git a/modules/access/ftp.c b/modules/access/ftp.c
index aee4b7f..da04c8d 100644
--- a/modules/access/ftp.c
+++ b/modules/access/ftp.c
@@ -108,6 +108,7 @@ static ssize_t Read( access_t *, uint8_t *, size_t );
 static int Seek( access_t *, uint64_t );
 static int Control( access_t *, int, va_list );
 static input_item_t* DirRead( access_t * );
+static int DirControl( access_t *, int, va_list );
 #ifdef ENABLE_SOUT
 static int OutSeek( sout_access_out_t *, off_t );
 static ssize_t Write( sout_access_out_t *, block_t * );
@@ -671,8 +672,7 @@ static int InOpen( vlc_object_t *p_this )
     if( b_directory )
     {
         p_access->pf_readdir = DirRead;
-        p_access->pf_control = access_vaDirectoryControlHelper;
-        p_access->info.b_dir_can_loop = true;
+        p_access->pf_control = DirControl;
     } else
         ACCESS_SET_CALLBACKS( Read, NULL, Control, Seek ); \
 
@@ -887,6 +887,21 @@ static input_item_t* DirRead( access_t *p_access )
     return p_item;
 }
 
+static int DirControl( access_t *p_access, int i_query, va_list args )
+{
+    switch( i_query )
+    {
+    case ACCESS_IS_DIRECTORY:
+        *va_arg( args, bool * ) = false; /* is not sorted */
+        *va_arg( args, bool * ) = true; /* might loop */
+        break;
+    default:
+        return access_vaDirectoryControlHelper( p_access, i_query, args );
+    }
+
+    return VLC_SUCCESS;
+}
+
 /*****************************************************************************
  * Write:
  *****************************************************************************/
diff --git a/modules/access/sftp.c b/modules/access/sftp.c
index a0b6fab..0caad68 100644
--- a/modules/access/sftp.c
+++ b/modules/access/sftp.c
@@ -84,6 +84,7 @@ static int      Seek( access_t *, uint64_t );
 static int      Control( access_t *, int, va_list );
 
 static input_item_t* DirRead( access_t *p_access );
+static int DirControl( access_t *, int, va_list );
 
 struct access_sys_t
 {
@@ -296,8 +297,7 @@ static int Open( vlc_object_t* p_this )
         p_sys->file = libssh2_sftp_opendir( p_sys->sftp_session, psz_path );
 
         p_access->pf_readdir = DirRead;
-        p_access->pf_control = access_vaDirectoryControlHelper;
-        p_access->info.b_dir_can_loop = true;
+        p_access->pf_control = DirControl;
 
         if( p_sys->file )
         {
@@ -515,3 +515,18 @@ static input_item_t* DirRead( access_t *p_access )
     free( psz_file );
     return p_item;
 }
+
+static int DirControl( access_t *p_access, int i_query, va_list args )
+{
+    switch( i_query )
+    {
+    case ACCESS_IS_DIRECTORY:
+        *va_arg( args, bool * ) = false; /* is not sorted */
+        *va_arg( args, bool * ) = true; /* might loop */
+        break;
+    default:
+        return access_vaDirectoryControlHelper( p_access, i_query, args );
+    }
+
+    return VLC_SUCCESS;
+}
diff --git a/modules/access/smb.c b/modules/access/smb.c
index 2f19106..7f76fa7 100644
--- a/modules/access/smb.c
+++ b/modules/access/smb.c
@@ -90,6 +90,7 @@ static int Seek( access_t *, uint64_t );
 static int Control( access_t *, int, va_list );
 #ifndef _WIN32
 static input_item_t* DirRead( access_t * );
+static int DirControl( access_t *, int, va_list );
 #endif
 
 struct access_sys_t
@@ -253,8 +254,7 @@ static int Open( vlc_object_t *p_this )
         return VLC_EGENERIC;
 #else
         p_access->pf_readdir = DirRead;
-        p_access->pf_control = access_vaDirectoryControlHelper;
-        p_access->info.b_dir_can_loop = true;
+        p_access->pf_control = DirControl;
         i_smb = smbc_opendir( psz_uri );
         i_size = 0;
 #endif
@@ -395,6 +395,21 @@ static input_item_t* DirRead (access_t *p_access )
     }
     return p_item;
 }
+
+static int DirControl( access_t *p_access, int i_query, va_list args )
+{
+    switch( i_query )
+    {
+    case ACCESS_IS_DIRECTORY:
+        *va_arg( args, bool * ) = false; /* is not sorted */
+        *va_arg( args, bool * ) = true; /* might loop */
+        break;
+    default:
+        return access_vaDirectoryControlHelper( p_access, i_query, args );
+    }
+
+    return VLC_SUCCESS;
+}
 #endif
 
 /*****************************************************************************
diff --git a/modules/services_discovery/upnp.cpp b/modules/services_discovery/upnp.cpp
index 2eaaf20..86f2590 100644
--- a/modules/services_discovery/upnp.cpp
+++ b/modules/services_discovery/upnp.cpp
@@ -813,6 +813,21 @@ static input_item_t* ReadDirectory( access_t *p_access )
     return p_access->p_sys->p_server->getNextItem();
 }
 
+static int ControlDirectory( access_t *p_access, int i_query, va_list args )
+{
+    switch( i_query )
+    {
+    case ACCESS_IS_DIRECTORY:
+        *va_arg( args, bool * ) = true; /* is sorted */
+        *va_arg( args, bool * ) = true; /* might loop */
+        break;
+    default:
+        return access_vaDirectoryControlHelper( p_access, i_query, args );
+    }
+
+    return VLC_SUCCESS;
+}
+
 static int Open( vlc_object_t *p_this )
 {
     access_t* p_access = (access_t*)p_this;
@@ -837,9 +852,7 @@ static int Open( vlc_object_t *p_this )
     }
 
     p_access->pf_readdir = ReadDirectory;
-    p_access->pf_control = access_vaDirectoryControlHelper;
-    p_access->info.b_dir_sorted = true;
-    p_access->info.b_dir_can_loop = true;
+    p_access->pf_control = ControlDirectory;
 
     return VLC_SUCCESS;
 }
diff --git a/src/input/access.c b/src/input/access.c
index 468602d..2b83a2d 100644
--- a/src/input/access.c
+++ b/src/input/access.c
@@ -137,6 +137,10 @@ int access_vaDirectoryControlHelper( access_t *p_access, int i_query, va_list ar
         case ACCESS_GET_PTS_DELAY:
             *va_arg( args, int64_t * ) = 0;
             break;
+        case ACCESS_IS_DIRECTORY:
+            *va_arg( args, bool * ) = false;
+            *va_arg( args, bool * ) = false;
+            break;
         default:
             return VLC_EGENERIC;
      }
@@ -274,6 +278,7 @@ static int AStreamControl(stream_t *s, int cmd, va_list args)
     static_control_match(CAN_PAUSE);
     static_control_match(CAN_CONTROL_PACE);
     static_control_match(GET_SIZE);
+    static_control_match(IS_DIRECTORY);
     static_control_match(GET_PTS_DELAY);
     static_control_match(GET_TITLE_INFO);
     static_control_match(GET_TITLE);
@@ -295,6 +300,7 @@ static int AStreamControl(stream_t *s, int cmd, va_list args)
         case STREAM_CAN_PAUSE:
         case STREAM_CAN_CONTROL_PACE:
         case STREAM_GET_SIZE:
+        case STREAM_IS_DIRECTORY:
         case STREAM_GET_PTS_DELAY:
         case STREAM_GET_TITLE_INFO:
         case STREAM_GET_TITLE:
@@ -310,13 +316,6 @@ static int AStreamControl(stream_t *s, int cmd, va_list args)
         case STREAM_GET_PRIVATE_ID_STATE:
             return access_vaControl(access, cmd, args);
 
-        case STREAM_IS_DIRECTORY:
-            if (access->pf_readdir == NULL)
-                return VLC_EGENERIC;
-            *va_arg(args, bool *) = access->info.b_dir_sorted;
-            *va_arg(args, bool *) = access->info.b_dir_can_loop;
-            break;
-
         case STREAM_GET_PRIVATE_BLOCK:
         {
             block_t **b = va_arg(args, block_t **);



More information about the vlc-commits mailing list