00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
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
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
00056
00057 STREAM_CONTROL_ACCESS
00058
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
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