X-Git-Url: https://git.sesse.net/?a=blobdiff_plain;f=include%2Fvlc_access.h;h=e83d53f4a2ab027b7e994e0935ac823367b5fdc0;hb=95c0e843694a603c2425b6743c4a63dfd194ae31;hp=fdb0312e2acb863ea7e73e6734b395ba443fd95b;hpb=3d6f02e6574743bb1a358ca9651b0fc4b5bf616e;p=vlc diff --git a/include/vlc_access.h b/include/vlc_access.h index fdb0312e2a..e83d53f4a2 100644 --- a/include/vlc_access.h +++ b/include/vlc_access.h @@ -1,24 +1,24 @@ /***************************************************************************** * vlc_access.h: Access descriptor, queries and methods ***************************************************************************** - * Copyright (C) 1999-2006 the VideoLAN team + * Copyright (C) 1999-2006 VLC authors and VideoLAN * $Id$ * * Authors: Laurent Aimar * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or + * This program is free software; you can redistribute it and/or modify it + * under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation; either version 2.1 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA. + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA. *****************************************************************************/ #ifndef VLC_ACCESS_H @@ -43,18 +43,18 @@ enum access_query_e ACCESS_CAN_FASTSEEK, /* arg1= bool* cannot fail */ ACCESS_CAN_PAUSE, /* arg1= bool* cannot fail */ ACCESS_CAN_CONTROL_PACE,/* arg1= bool* cannot fail */ + ACCESS_GET_SIZE=6, /* arg1= uin64_t* */ /* */ ACCESS_GET_PTS_DELAY = 0x101,/* arg1= int64_t* cannot fail */ - /* */ - ACCESS_GET_TITLE_INFO, /* arg1=input_title_t*** arg2=int* res=can fail */ - /* Meta data */ - ACCESS_GET_META, /* arg1= vlc_meta_t ** res=can fail */ + ACCESS_GET_TITLE_INFO, /* arg1=input_title_t*** arg2=int* res=can fail */ + ACCESS_GET_TITLE, /* arg1=unsigned * res=can fail */ + ACCESS_GET_SEEKPOINT, /* arg1=unsigned * res=can fail */ - /* */ - ACCESS_GET_CONTENT_TYPE,/* arg1=char **ppsz_content_type res=can fail */ + /* Meta data */ + ACCESS_GET_META, /* arg1= vlc_meta_t ** res=can fail */ + ACCESS_GET_CONTENT_TYPE,/* arg1=char **ppsz_content_type res=can fail */ - /* */ ACCESS_GET_SIGNAL, /* arg1=double *pf_quality, arg2=double *pf_strength res=can fail */ /* */ @@ -80,22 +80,23 @@ struct access_t /* Access name (empty if non forced) */ char *psz_access; - /* Access path/url/filename/.... */ - char *psz_path; + char *psz_location; /**< Location (URL with the scheme stripped) */ + char *psz_filepath; /**< Local file path (if applicable) */ /* Access can fill this entry to force a demuxer * XXX: fill it once you know for sure you will succeed * (if you fail, this value won't be reseted */ char *psz_demux; - /* pf_read/pf_block is used to read data. + /* pf_read/pf_block/pf_readdir is used to read data. * XXX A access should set one and only one of them */ - ssize_t (*pf_read) ( access_t *, uint8_t *, size_t ); /* Return -1 if no data yet, 0 if no more data, else real data read */ - block_t *(*pf_block)( access_t * ); /* return a block of data in his 'natural' size, NULL if not yet data or eof */ + ssize_t (*pf_read) ( access_t *, uint8_t *, size_t ); /* Return -1 if no data yet, 0 if no more data, else real data read */ + block_t *(*pf_block) ( access_t * ); /* Return a block of data in his 'natural' size, NULL if not yet data or eof */ + int (*pf_readdir)( access_t *, input_item_node_t * );/* Fills the provided item_node, see doc/browsing.txt for details */ /* Called for each seek. * XXX can be null */ - int (*pf_seek) ( access_t *, int64_t ); /* can be null if can't seek */ + int (*pf_seek) ( access_t *, uint64_t ); /* can be null if can't seek */ /* Used to retreive and configure the access * XXX mandatory. look at access_query_e to know what query you *have to* support */ @@ -104,15 +105,8 @@ struct access_t /* Access has to maintain them uptodate */ struct { - unsigned int i_update; /* Access sets them on change, - Input removes them once take into account*/ - - int64_t i_size; /* Write only for access, read only for input */ - int64_t i_pos; /* idem */ + uint64_t i_pos; /* idem */ bool b_eof; /* idem */ - - int i_title; /* idem, start from 0 (could be menu) */ - int i_seekpoint;/* idem, start from 0 */ } info; access_sys_t *p_sys; @@ -137,39 +131,49 @@ static inline int access_Control( access_t *p_access, int i_query, ... ) return i_result; } +static inline uint64_t access_GetSize( access_t *p_access ) +{ + uint64_t val; + if( access_Control( p_access, ACCESS_GET_SIZE, &val ) ) + val = 0; + return val; +} + static inline void access_InitFields( access_t *p_a ) { - p_a->info.i_update = 0; - p_a->info.i_size = 0; p_a->info.i_pos = 0; p_a->info.b_eof = false; - p_a->info.i_title = 0; - p_a->info.i_seekpoint = 0; } /** * This function will return the parent input of this access. * It is retained. It can return NULL. */ -VLC_EXPORT( input_thread_t *, access_GetParentInput, ( access_t *p_access ) ); - -#define ACCESS_SET_CALLBACKS( read, block, control, seek ) \ - p_access->pf_read = read; \ - p_access->pf_block = block; \ - p_access->pf_control = control; \ - p_access->pf_seek = seek; - -#define STANDARD_READ_ACCESS_INIT \ - access_InitFields( p_access ); \ - ACCESS_SET_CALLBACKS( Read, NULL, Control, Seek ); \ - p_sys = p_access->p_sys = calloc( 1, sizeof( access_sys_t )); \ - if( !p_sys ) return VLC_ENOMEM; - -#define STANDARD_BLOCK_ACCESS_INIT \ - access_InitFields( p_access ); \ - ACCESS_SET_CALLBACKS( NULL, Block, Control, Seek ); \ - p_sys = p_access->p_sys = calloc( 1, sizeof( access_sys_t ) ); \ - if( !p_sys ) return VLC_ENOMEM; +VLC_API input_thread_t * access_GetParentInput( access_t *p_access ) VLC_USED; + +#define ACCESS_SET_CALLBACKS( read, block, control, seek ) \ + do { \ + p_access->pf_read = (read); \ + p_access->pf_block = (block); \ + p_access->pf_control = (control); \ + p_access->pf_seek = (seek); \ + } while(0) + +#define STANDARD_READ_ACCESS_INIT \ + do { \ + access_InitFields( p_access ); \ + ACCESS_SET_CALLBACKS( Read, NULL, Control, Seek ); \ + p_sys = p_access->p_sys = (access_sys_t*)calloc( 1, sizeof( access_sys_t ) ); \ + if( !p_sys ) return VLC_ENOMEM;\ + } while(0); + +#define STANDARD_BLOCK_ACCESS_INIT \ + do { \ + access_InitFields( p_access ); \ + ACCESS_SET_CALLBACKS( NULL, Block, Control, Seek ); \ + p_sys = p_access->p_sys = (access_sys_t*)calloc( 1, sizeof( access_sys_t ) ); \ + if( !p_sys ) return VLC_ENOMEM; \ + } while(0); /** * @}