stream_t *p_source;
/* */
- int (*pf_read) ( stream_t *, void *p_read, unsigned int i_read );
- int (*pf_peek) ( stream_t *, const uint8_t **pp_peek, unsigned int i_peek );
- int (*pf_control)( stream_t *, int i_query, va_list );
+ int (*pf_read) ( stream_t *, void *p_read, unsigned int i_read );
+ int (*pf_peek) ( stream_t *, const uint8_t **pp_peek, unsigned int i_peek );
+ int (*pf_readdir)( stream_t *, input_item_node_t * );
+ int (*pf_control)( stream_t *, int i_query, va_list );
/* */
void (*pf_destroy)( stream_t *);
STREAM_CAN_FASTSEEK, /**< arg1= bool * res=cannot fail*/
STREAM_CAN_PAUSE, /**< arg1= bool * res=cannot fail*/
STREAM_CAN_CONTROL_PACE, /**< arg1= bool * res=cannot fail*/
+ STREAM_IS_DIRECTORY, /**< arg1= bool * res=cannot fail*/
/* */
STREAM_SET_POSITION, /**< arg1= uint64_t res=can fail */
VLC_API block_t * stream_Block( stream_t *s, int i_size );
VLC_API block_t * stream_BlockRemaining( stream_t *s, int i_max_size );
VLC_API char * stream_ReadLine( stream_t * );
+VLC_API int stream_ReadDir( stream_t *, input_item_node_t * );
/**
* Get the current position in a stream
typedef enum
{
STREAM_METHOD_BLOCK,
- STREAM_METHOD_STREAM
+ STREAM_METHOD_STREAM,
+ STREAM_METHOD_READDIR
} stream_read_method_t;
struct stream_sys_t
static void AStreamPrebufferStream( stream_t *s );
static int AReadStream( stream_t *s, void *p_read, unsigned int i_read );
+/* ReadDir */
+static int AStreamReadDir( stream_t *s, input_item_node_t *p_node );
+
/* Common */
+static int AStreamGenericError( ) { return VLC_EGENERIC; }
static int AStreamControl( stream_t *s, int i_query, va_list );
static void AStreamDestroy( stream_t *s );
static int ASeek( stream_t *s, uint64_t i_pos );
return NULL;
}
- s->pf_read = NULL; /* Set up later */
- s->pf_peek = NULL;
+ s->pf_read = (void *)AStreamGenericError; /* Replaced later */
+ s->pf_peek = (void *)AStreamGenericError;
+ s->pf_readdir = (void *)AStreamGenericError;
s->pf_control = AStreamControl;
s->pf_destroy = AStreamDestroy;
p_sys->p_access = p_access;
if( p_access->pf_block )
p_sys->method = STREAM_METHOD_BLOCK;
- else
+ else if( p_access->pf_read )
p_sys->method = STREAM_METHOD_STREAM;
+ else
+ p_sys->method = STREAM_METHOD_READDIR;
p_sys->i_pos = p_access->info.i_pos;
goto error;
}
}
- else
+ else if ( p_sys->method == STREAM_METHOD_STREAM )
{
int i;
- assert( p_sys->method == STREAM_METHOD_STREAM );
-
msg_Dbg( s, "Using stream method for AStream*" );
s->pf_read = AStreamReadStream;
goto error;
}
}
+ else
+ {
+ assert( p_sys->method == STREAM_METHOD_READDIR );
+ s->pf_readdir = AStreamReadDir;
+ }
return s;
{
/* Nothing yet */
}
- else
+ else if( p_sys->method == STREAM_METHOD_STREAM )
{
free( p_sys->stream.p_buffer );
}
if( p_sys->method == STREAM_METHOD_BLOCK )
block_ChainRelease( p_sys->block.p_first );
- else
+ else if( p_sys->method == STREAM_METHOD_STREAM )
free( p_sys->stream.p_buffer );
free( p_sys->p_peek );
return ret;
}
+ case STREAM_IS_DIRECTORY:
+ {
+ bool *pb_canreaddir = va_arg( args, bool * );
+ *pb_canreaddir = p_sys->method == STREAM_METHOD_READDIR;
+ return VLC_SUCCESS;
+ }
+
case STREAM_SET_RECORD_STATE:
default:
msg_Err( s, "invalid stream_vaControl query=0x%x", i_query );
char *p_line = NULL;
int i_line = 0, i_read = 0;
+ /* Let's fail quickly if this is a readdir access */
+ if( s->pf_read == NULL )
+ return NULL;
+
for( ;; )
{
char *psz_eol;
return p_access->pf_seek( p_access, i_pos );
}
+static int AStreamReadDir( stream_t *s, input_item_node_t *p_node )
+{
+ access_t *p_access = s->p_sys->p_access;
+
+ if( p_access->pf_readdir != NULL )
+ return p_access->pf_readdir( p_access, p_node );
+ else
+ return VLC_ENOITEM;
+}
/**
* Try to read "i_read" bytes into a buffer pointed by "p_read". If
return p_block;
}
+/**
+ * Returns a node containing all the input_item of the directory pointer by
+ * this stream. returns VLC_SUCCESS on success.
+ */
+int stream_ReadDir( stream_t *s, input_item_node_t *p_node )
+{
+ return s->pf_readdir( s, p_node );
+}