Main Page | Modules | Class Hierarchy | Class List | Directories | File List | Class Members | File Members | Related Pages

vlc_stream.h

00001 /*****************************************************************************
00002  * vlc_stream.h
00003  *****************************************************************************
00004  * Copyright (C) 1999-2004 the VideoLAN team
00005  * $Id: vlc_stream.h 12465 2005-09-03 15:55:52Z robux4 $
00006  *
00007  * Authors: Laurent Aimar <[email protected]>
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., 59 Temple Place - Suite 330, Boston, MA  02111, USA.
00022  *****************************************************************************/
00023 
00024 #ifndef _VLC_STREAM_H
00025 #define _VLC_STREAM_H 1
00026 
00027 # ifdef __cplusplus
00028 extern "C" {
00029 # endif
00030 
00041 enum stream_query_e
00042 {
00043     /* capabilities */
00044     STREAM_CAN_SEEK,            
00045     STREAM_CAN_FASTSEEK,        
00047     /* */
00048     STREAM_SET_POSITION,        
00049     STREAM_GET_POSITION,        
00051     STREAM_GET_SIZE,            
00053     STREAM_GET_MTU,             
00055     /* Special for direct access control from demuxer.
00056      * XXX: avoid using it by all means */
00057     STREAM_CONTROL_ACCESS   /* arg1= int i_access_query, args   res: can fail
00058                              if access unreachable or access control answer */
00059 };
00060 
00064 struct stream_t
00065 {
00066     VLC_COMMON_MEMBERS
00067 
00068     block_t *(*pf_block)  ( stream_t *, int i_size );
00069     int      (*pf_read)   ( stream_t *, void *p_read, int i_read );
00070     int      (*pf_peek)   ( stream_t *, uint8_t **pp_peek, int i_peek );
00071     int      (*pf_control)( stream_t *, int i_query, va_list );
00072     void     (*pf_destroy)( stream_t *);
00073 
00074     stream_sys_t *p_sys;
00075 };
00076 
00083 static inline int stream_Read( stream_t *s, void *p_read, int i_read )
00084 {
00085     return s->pf_read( s, p_read, i_read );
00086 }
00087 
00098 static inline int stream_Peek( stream_t *s, uint8_t **pp_peek, int i_peek )
00099 {
00100     return s->pf_peek( s, pp_peek, i_peek );
00101 }
00102 
00108 static inline int stream_vaControl( stream_t *s, int i_query, va_list args )
00109 {
00110     return s->pf_control( s, i_query, args );
00111 }
00112 
00116 static inline void stream_Delete( stream_t *s )
00117 {
00118     s->pf_destroy( s );
00119 }
00120 
00121 static inline int stream_Control( stream_t *s, int i_query, ... )
00122 {
00123     va_list args;
00124     int     i_result;
00125 
00126     if ( s == NULL )
00127         return VLC_EGENERIC;
00128 
00129     va_start( args, i_query );
00130     i_result = s->pf_control( s, i_query, args );
00131     va_end( args );
00132     return i_result;
00133 }
00134 
00138 static inline int64_t stream_Tell( stream_t *s )
00139 {
00140     int64_t i_pos;
00141     stream_Control( s, STREAM_GET_POSITION, &i_pos );
00142     return i_pos;
00143 }
00144 
00148 static inline int64_t stream_Size( stream_t *s )
00149 {
00150     int64_t i_pos;
00151     stream_Control( s, STREAM_GET_SIZE, &i_pos );
00152     return i_pos;
00153 }
00154 static inline int stream_MTU( stream_t *s )
00155 {
00156     int i_mtu;
00157     stream_Control( s, STREAM_GET_MTU, &i_mtu );
00158     return i_mtu;
00159 }
00160 static inline int stream_Seek( stream_t *s, int64_t i_pos )
00161 {
00162     return stream_Control( s, STREAM_SET_POSITION, i_pos );
00163 }
00164 
00170 static inline block_t *stream_Block( stream_t *s, int i_size )
00171 {
00172     if( i_size <= 0 ) return NULL;
00173 
00174     if( s->pf_block )
00175     {
00176         return s->pf_block( s, i_size );
00177     }
00178     else
00179     {
00180         /* emulate block read */
00181         block_t *p_bk = block_New( s, i_size );
00182         if( p_bk )
00183         {
00184             p_bk->i_buffer = stream_Read( s, p_bk->p_buffer, i_size );
00185             if( p_bk->i_buffer > 0 )
00186             {
00187                 return p_bk;
00188             }
00189         }
00190         if( p_bk ) block_Release( p_bk );
00191         return NULL;
00192     }
00193 }
00194 
00195 VLC_EXPORT( char *, stream_ReadLine, ( stream_t * ) );
00196 
00200 #define stream_DemuxNew( a, b, c ) __stream_DemuxNew( VLC_OBJECT(a), b, c)
00201 VLC_EXPORT( stream_t *,__stream_DemuxNew, ( vlc_object_t *p_obj, char *psz_demux, es_out_t *out ) );
00202 VLC_EXPORT( void,      stream_DemuxSend,  ( stream_t *s, block_t *p_block ) );
00203 VLC_EXPORT( void,      stream_DemuxDelete,( stream_t *s ) );
00204 
00205 
00206 #define stream_MemoryNew( a, b, c, d ) __stream_MemoryNew( VLC_OBJECT(a), b, c, d )
00207 VLC_EXPORT( stream_t *,__stream_MemoryNew, (vlc_object_t *p_obj, uint8_t *p_buffer, int64_t i_size, vlc_bool_t i_preserve_memory ) );
00208 #define stream_UrlNew( a, b ) __stream_UrlNew( VLC_OBJECT(a), b )
00209 VLC_EXPORT( stream_t *,__stream_UrlNew, (vlc_object_t *p_this, const char *psz_url ) );
00210 
00215 # ifdef __cplusplus
00216 }
00217 # endif
00218 
00219 #endif

Generated on Tue Dec 20 10:14:19 2005 for vlc-0.8.4a by  doxygen 1.4.2