mirror of https://code.videolan.org/videolan/vlc
access: add ACCESS_IS_DIRECTORY as STREAM_IS_DIRECTORY
This commit is contained in:
parent
8368744397
commit
5d096c300e
|
@ -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;
|
||||
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
|
|
@ -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:
|
||||
*****************************************************************************/
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
|
|
@ -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
|
||||
|
||||
/*****************************************************************************
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
|
|
@ -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 **);
|
||||
|
|
Loading…
Reference in New Issue