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_DEMUX_H
00025 #define VLC_DEMUX_H 1
00026
00027 #include <vlc_es.h>
00028 #include <vlc_stream.h>
00029 #include <vlc_es_out.h>
00030
00031
00032
00033
00034
00035
00036 struct demux_t
00037 {
00038 VLC_COMMON_MEMBERS
00039
00040
00041 module_t *p_module;
00042
00043
00044 char *psz_access;
00045 char *psz_demux;
00046 char *psz_path;
00047
00048
00049 stream_t *s;
00050
00051
00052 es_out_t *out;
00053
00054
00055 int (*pf_demux) ( demux_t * );
00056 int (*pf_control)( demux_t *, int i_query, va_list args);
00057
00058
00059
00060 struct
00061 {
00062 unsigned int i_update;
00063
00064
00065 int i_title;
00066 int i_seekpoint;
00067 } info;
00068 demux_sys_t *p_sys;
00069 };
00070
00071
00072
00073 struct demux_meta_t
00074 {
00075 vlc_meta_t *p_meta;
00076
00077 int i_attachments;
00078 input_attachment_t **attachments;
00079 };
00080
00081 enum demux_query_e
00082 {
00083
00084
00085 DEMUX_GET_POSITION,
00086 DEMUX_SET_POSITION,
00087
00088
00089 DEMUX_GET_LENGTH,
00090 DEMUX_GET_TIME,
00091 DEMUX_SET_TIME,
00092
00093
00094 DEMUX_GET_TITLE_INFO,
00095
00096
00097 DEMUX_SET_TITLE,
00098 DEMUX_SET_SEEKPOINT,
00099
00100
00101
00102
00103
00104 DEMUX_SET_GROUP,
00105
00106
00107
00108
00109
00110
00111 DEMUX_SET_NEXT_DEMUX_TIME,
00112
00113 DEMUX_GET_FPS,
00114
00115
00116 DEMUX_GET_META,
00117 DEMUX_HAS_UNSUPPORTED_META,
00118
00119
00120 DEMUX_GET_ATTACHMENTS,
00121
00122
00123 DEMUX_CAN_PAUSE,
00124 DEMUX_SET_PAUSE_STATE,
00125
00126 DEMUX_GET_PTS_DELAY,
00127
00128
00129
00130 DEMUX_CAN_CONTROL_PACE,
00131
00132
00133
00134
00135 DEMUX_CAN_CONTROL_RATE,
00136
00137
00138 DEMUX_SET_RATE,
00139
00140 DEMUX_CAN_SEEK,
00141 };
00142
00143 VLC_EXPORT( int, demux_vaControlHelper, ( stream_t *, int64_t i_start, int64_t i_end, int i_bitrate, int i_align, int i_query, va_list args ) );
00144
00145
00146
00147
00148
00149 static inline bool demux_IsPathExtension( demux_t *p_demux, const char *psz_extension )
00150 {
00151 const char *psz_ext = strrchr ( p_demux->psz_path, '.' );
00152 if( !psz_ext || strcasecmp( psz_ext, psz_extension ) )
00153 return false;
00154 return true;
00155 }
00156
00157 static inline bool demux_IsForced( demux_t *p_demux, const char *psz_name )
00158 {
00159 if( !p_demux->psz_demux || strcmp( p_demux->psz_demux, psz_name ) )
00160 return false;
00161 return true;
00162 }
00163
00164 #define DEMUX_INIT_COMMON() do { \
00165 p_demux->pf_control = Control; \
00166 p_demux->pf_demux = Demux; \
00167 MALLOC_ERR( p_demux->p_sys, demux_sys_t ); \
00168 memset( p_demux->p_sys, 0, sizeof( demux_sys_t ) ); } while(0)
00169
00170 #define STANDARD_DEMUX_INIT_MSG( msg ) do { \
00171 DEMUX_INIT_COMMON(); \
00172 msg_Dbg( p_demux, msg ); } while(0)
00173
00174 #define DEMUX_BY_EXTENSION( ext ) \
00175 demux_t *p_demux = (demux_t *)p_this; \
00176 if( !demux_IsPathExtension( p_demux, ext ) ) \
00177 return VLC_EGENERIC; \
00178 DEMUX_INIT_COMMON();
00179
00180 #define DEMUX_BY_EXTENSION_MSG( ext, msg ) \
00181 demux_t *p_demux = (demux_t *)p_this; \
00182 if( !demux_IsPathExtension( p_demux, ext ) ) \
00183 return VLC_EGENERIC; \
00184 STANDARD_DEMUX_INIT_MSG( msg );
00185
00186 #define DEMUX_BY_EXTENSION_OR_FORCED( ext, module ) \
00187 demux_t *p_demux = (demux_t *)p_this; \
00188 if( !demux_IsPathExtension( p_demux, ext ) && !demux_IsForced( p_demux, module ) ) \
00189 return VLC_EGENERIC; \
00190 DEMUX_INIT_COMMON();
00191
00192 #define DEMUX_BY_EXTENSION_OR_FORCED_MSG( ext, module, msg ) \
00193 demux_t *p_demux = (demux_t *)p_this; \
00194 if( !demux_IsPathExtension( p_demux, ext ) && !demux_IsForced( p_demux, module ) ) \
00195 return VLC_EGENERIC; \
00196 STANDARD_DEMUX_INIT_MSG( msg );
00197
00198 #define CHECK_PEEK( zepeek, size ) \
00199 if( stream_Peek( p_demux->s , &zepeek, size ) < size ){ \
00200 msg_Dbg( p_demux, "not enough data" ); return VLC_EGENERIC; }
00201
00202 #define CHECK_PEEK_GOTO( zepeek, size ) \
00203 if( stream_Peek( p_demux->s , &zepeek, size ) < size ) { \
00204 msg_Dbg( p_demux, "not enough data" ); goto error; }
00205
00206 #define POKE( peek, stuff, size ) (strncasecmp( (const char *)peek, stuff, size )==0)
00207
00208 #define COMMON_INIT_PACKETIZER( location ) \
00209 location = vlc_object_create( p_demux, VLC_OBJECT_PACKETIZER ); \
00210 location->pf_decode_audio = 0; \
00211 location->pf_decode_video = 0; \
00212 location->pf_decode_sub = 0; \
00213 location->pf_packetize = 0; \
00214
00215 #define INIT_APACKETIZER( location, a,b,c,d ) \
00216 COMMON_INIT_PACKETIZER(location ); \
00217 es_format_Init( &location->fmt_in, AUDIO_ES, \
00218 VLC_FOURCC( a, b, c, d ) );
00219
00220 #define INIT_VPACKETIZER( location, a,b,c,d ) \
00221 COMMON_INIT_PACKETIZER(location ); \
00222 es_format_Init( &location->fmt_in, VIDEO_ES, \
00223 VLC_FOURCC( a, b, c, d ) );
00224
00225
00226 #define LOAD_PACKETIZER_OR_FAIL( location, msg ) \
00227 location->p_module = \
00228 module_Need( location, "packetizer", NULL, 0 ); \
00229 if( location->p_module == NULL ) \
00230 { \
00231 vlc_object_release( location ); \
00232 msg_Err( p_demux, "cannot find packetizer for " # msg ); \
00233 free( p_sys ); \
00234 return VLC_EGENERIC; \
00235 }
00236
00237 #define DESTROY_PACKETIZER( location ) \
00238 if( location->p_module ) module_Unneed( location, location->p_module ); \
00239 vlc_object_release( location );
00240
00241
00242
00243
00244
00245 #endif