vlc_access.h

Go to the documentation of this file.
00001 /*****************************************************************************
00002  * vlc_access.h: Access descriptor, queries and methods
00003  *****************************************************************************
00004  * Copyright (C) 1999-2006 the VideoLAN team
00005  * $Id$
00006  *
00007  * Authors: Laurent Aimar <fenrir@via.ecp.fr>
00008  *
00009  * This program is free software; you can redistribute it and/or modify
00010  * it under the terms of the GNU General Public License as published by
00011  * the Free Software Foundation; either version 2 of the License, or
00012  * (at your option) any later version.
00013  *
00014  * This program is distributed in the hope that it will be useful,
00015  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00016  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00017  * GNU General Public License for more details.
00018  *
00019  * You should have received a copy of the GNU General Public License
00020  * along with this program; if not, write to the Free Software
00021  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
00022  *****************************************************************************/
00023 
00024 #ifndef VLC_ACCESS_H
00025 #define VLC_ACCESS_H 1
00026 
00027 #include <vlc_block.h>
00028 
00029 /**
00030  * \defgroup access Access
00031  * @{
00032  */
00033 
00034 enum access_query_e
00035 {
00036     /* capabilities */
00037     ACCESS_CAN_SEEK,        /* arg1= bool*    cannot fail */
00038     ACCESS_CAN_FASTSEEK,    /* arg1= bool*    cannot fail */
00039     ACCESS_CAN_PAUSE,       /* arg1= bool*    cannot fail */
00040     ACCESS_CAN_CONTROL_PACE,/* arg1= bool*    cannot fail */
00041 
00042     /* */
00043     ACCESS_GET_MTU,         /* arg1= int*           cannot fail(0 if no sense)*/
00044     ACCESS_GET_PTS_DELAY,   /* arg1= int64_t*       cannot fail */
00045     /* */
00046     ACCESS_GET_TITLE_INFO,  /* arg1=input_title_t*** arg2=int* can fail */
00047     /* Meta data */
00048     ACCESS_GET_META,        /* arg1= vlc_meta_t **  res=can fail    */
00049 
00050     /* */
00051     ACCESS_SET_PAUSE_STATE, /* arg1= bool     can fail */
00052 
00053     /* */
00054     ACCESS_SET_TITLE,       /* arg1= int            can fail */
00055     ACCESS_SET_SEEKPOINT,   /* arg1= int            can fail */
00056 
00057     /* Special mode for access/demux communication
00058      * XXX: avoid to use it unless you can't */
00059     ACCESS_SET_PRIVATE_ID_STATE,    /* arg1= int i_private_data, bool b_selected can fail */
00060     ACCESS_SET_PRIVATE_ID_CA,    /* arg1= int i_program_number, uint16_t i_vpid, uint16_t i_apid1, uint16_t i_apid2, uint16_t i_apid3, uint8_t i_length, uint8_t *p_data */
00061     ACCESS_GET_PRIVATE_ID_STATE,    /* arg1=int i_private_data arg2=bool *  res=can fail */
00062 
00063     ACCESS_GET_CONTENT_TYPE, /* arg1=char **ppsz_content_type */
00064 };
00065 
00066 struct access_t
00067 {
00068     VLC_COMMON_MEMBERS
00069 
00070     /* Module properties */
00071     module_t    *p_module;
00072 
00073     /* Access name (empty if non forced) */
00074     char        *psz_access;
00075     /* Access path/url/filename/.... */
00076     char        *psz_path;
00077     /* Access source for access_filter (NULL for regular access) */
00078     access_t    *p_source;
00079 
00080     /* Access can fill this entry to force a demuxer
00081      * XXX: fill it once you know for sure you will succeed
00082      * (if you fail, this value won't be reseted */
00083     char        *psz_demux;
00084 
00085     /* pf_read/pf_block is used to read data.
00086      * XXX A access should set one and only one of them */
00087     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 */
00088     block_t    *(*pf_block)( access_t * );                  /* return a block of data in his 'natural' size, NULL if not yet data or eof */
00089 
00090     /* Called for each seek.
00091      * XXX can be null */
00092     int         (*pf_seek) ( access_t *, int64_t );         /* can be null if can't seek */
00093 
00094     /* Used to retreive and configure the access
00095      * XXX mandatory. look at access_query_e to know what query you *have to* support */
00096     int         (*pf_control)( access_t *, int i_query, va_list args);
00097 
00098     /* Access has to maintain them uptodate */
00099     struct
00100     {
00101         unsigned int i_update;  /* Access sets them on change,
00102                                    Input removes them once take into account*/
00103 
00104         int64_t      i_size;    /* Write only for access, read only for input */
00105         int64_t      i_pos;     /* idem */
00106         bool   b_eof;     /* idem */
00107 
00108         int          i_title;    /* idem, start from 0 (could be menu) */
00109         int          i_seekpoint;/* idem, start from 0 */
00110 
00111         bool   b_prebuffered; /* Read only for input */
00112     } info;
00113     access_sys_t *p_sys;
00114 };
00115 
00116 static inline int access_vaControl( access_t *p_access, int i_query, va_list args )
00117 {
00118     if( !p_access ) return VLC_EGENERIC;
00119     return p_access->pf_control( p_access, i_query, args );
00120 }
00121 
00122 static inline int access_Control( access_t *p_access, int i_query, ... )
00123 {
00124     va_list args;
00125     int     i_result;
00126 
00127     va_start( args, i_query );
00128     i_result = access_vaControl( p_access, i_query, args );
00129     va_end( args );
00130     return i_result;
00131 }
00132 
00133 static inline char *access_GetContentType( access_t *p_access )
00134 {
00135     char *res;
00136     if( access_Control( p_access, ACCESS_GET_CONTENT_TYPE, &res ) )
00137         return NULL;
00138     return res;
00139 }
00140 
00141 static inline void access_InitFields( access_t *p_a )
00142 {
00143     p_a->info.i_update = 0;
00144     p_a->info.i_size = 0;
00145     p_a->info.i_pos = 0;
00146     p_a->info.b_eof = false;
00147     p_a->info.i_title = 0;
00148     p_a->info.i_seekpoint = 0;
00149 }
00150 
00151 #define ACCESS_SET_CALLBACKS( read, block, control, seek ) \
00152     p_access->pf_read = read;  \
00153     p_access->pf_block = block; \
00154     p_access->pf_control = control; \
00155     p_access->pf_seek = seek; \
00156 
00157 #define STANDARD_READ_ACCESS_INIT \
00158     access_InitFields( p_access ); \
00159     ACCESS_SET_CALLBACKS( Read, NULL, Control, Seek ); \
00160     MALLOC_ERR( p_access->p_sys, access_sys_t ); \
00161     p_sys = p_access->p_sys; memset( p_sys, 0, sizeof( access_sys_t ) );
00162 
00163 #define STANDARD_BLOCK_ACCESS_INIT \
00164     access_InitFields( p_access ); \
00165     ACCESS_SET_CALLBACKS( NULL, Block, Control, Seek ); \
00166     MALLOC_ERR( p_access->p_sys, access_sys_t ); \
00167     p_sys = p_access->p_sys; memset( p_sys, 0, sizeof( access_sys_t ) );
00168 
00169 #endif

Generated on Wed Aug 13 08:02:37 2008 for VLC by  doxygen 1.5.1