00001 /***************************************************************************** 00002 * vlc_demux.h: Demuxer descriptor, queries and methods 00003 ***************************************************************************** 00004 * Copyright (C) 1999-2005 VLC authors and VideoLAN 00005 * $Id: a5b525710ca3f41843e7a14298dbe06d4a7df06d $ 00006 * 00007 * Authors: Laurent Aimar <fenrir@via.ecp.fr> 00008 * 00009 * This program is free software; you can redistribute it and/or modify it 00010 * under the terms of the GNU Lesser General Public License as published by 00011 * the Free Software Foundation; either version 2.1 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 Lesser General Public License for more details. 00018 * 00019 * You should have received a copy of the GNU Lesser General Public License 00020 * along with this program; if not, write to the Free Software Foundation, 00021 * Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA. 00022 *****************************************************************************/ 00023 00024 #ifndef VLC_DEMUX_H 00025 #define VLC_DEMUX_H 1 00026 00027 /** 00028 * \file 00029 * This files defines functions and structures used by demux objects in vlc 00030 */ 00031 00032 #include <vlc_es.h> 00033 #include <vlc_stream.h> 00034 #include <vlc_es_out.h> 00035 00036 /** 00037 * \defgroup demux Demux 00038 * @{ 00039 */ 00040 00041 struct demux_t 00042 { 00043 VLC_COMMON_MEMBERS 00044 00045 /* Module properties */ 00046 module_t *p_module; 00047 00048 /* eg informative but needed (we can have access+demux) */ 00049 char *psz_access; 00050 char *psz_demux; 00051 char *psz_location; 00052 char *psz_file; 00053 00054 /* input stream */ 00055 stream_t *s; /* NULL in case of a access+demux in one */ 00056 00057 /* es output */ 00058 es_out_t *out; /* our p_es_out */ 00059 00060 /* set by demuxer */ 00061 int (*pf_demux) ( demux_t * ); /* demux one frame only */ 00062 int (*pf_control)( demux_t *, int i_query, va_list args); 00063 00064 /* Demux has to maintain them uptodate 00065 * when it is responsible of seekpoint/title */ 00066 struct 00067 { 00068 unsigned int i_update; /* Demux sets them on change, 00069 Input removes them once take into account*/ 00070 /* Seekpoint/Title at demux level */ 00071 int i_title; /* idem, start from 0 (could be menu) */ 00072 int i_seekpoint; /* idem, start from 0 */ 00073 } info; 00074 demux_sys_t *p_sys; 00075 00076 /* Weak link to parent input */ 00077 input_thread_t *p_input; 00078 }; 00079 00080 00081 /* demux_meta_t is returned by "meta reader" module to the demuxer */ 00082 typedef struct demux_meta_t 00083 { 00084 VLC_COMMON_MEMBERS 00085 demux_t *p_demux; /** FIXME: use stream_t instead? */ 00086 input_item_t *p_item; /***< the input item that is being read */ 00087 00088 vlc_meta_t *p_meta; /**< meta data */ 00089 00090 int i_attachments; /**< number of attachments */ 00091 input_attachment_t **attachments; /**< array of attachments */ 00092 } demux_meta_t; 00093 00094 enum demux_query_e 00095 { 00096 /* I. Common queries to access_demux and demux */ 00097 /* POSITION double between 0.0 and 1.0 */ 00098 DEMUX_GET_POSITION, /* arg1= double * res= */ 00099 DEMUX_SET_POSITION, /* arg1= double arg2= bool b_precise res=can fail */ 00100 00101 /* LENGTH/TIME in microsecond, 0 if unknown */ 00102 DEMUX_GET_LENGTH, /* arg1= int64_t * res= */ 00103 DEMUX_GET_TIME, /* arg1= int64_t * res= */ 00104 DEMUX_SET_TIME, /* arg1= int64_t arg2= bool b_precise res=can fail */ 00105 00106 /* TITLE_INFO only if more than 1 title or 1 chapter */ 00107 DEMUX_GET_TITLE_INFO, /* arg1=input_title_t*** arg2=int* 00108 arg3=int*pi_title_offset(0), arg4=int*pi_seekpoint_offset(0) can fail */ 00109 /* TITLE/SEEKPOINT, only when TITLE_INFO succeed */ 00110 DEMUX_SET_TITLE, /* arg1= int can fail */ 00111 DEMUX_SET_SEEKPOINT, /* arg1= int can fail */ 00112 00113 /* DEMUX_SET_GROUP only a hint for demuxer (mainly DVB) to allow not 00114 * reading everything (you should not use this to call es_out_Control) 00115 * if you don't know what to do with it, just IGNORE it, it is safe(r) 00116 * -1 means all group, 0 default group (first es added) */ 00117 DEMUX_SET_GROUP, /* arg1= int, arg2=const vlc_list_t * can fail */ 00118 00119 /* Ask the demux to demux until the given date at the next pf_demux call 00120 * but not more (and not less, at the precision available of course). 00121 * XXX: not mandatory (except for subtitle demux) but will help a lot 00122 * for multi-input 00123 */ 00124 DEMUX_SET_NEXT_DEMUX_TIME, /* arg1= int64_t * can fail */ 00125 /* FPS for correct subtitles handling */ 00126 DEMUX_GET_FPS, /* arg1= double * res=can fail */ 00127 00128 /* Meta data */ 00129 DEMUX_GET_META, /* arg1= vlc_meta_t ** res=can fail */ 00130 DEMUX_HAS_UNSUPPORTED_META, /* arg1= bool * res can fail */ 00131 00132 /* Attachments */ 00133 DEMUX_GET_ATTACHMENTS, /* arg1=input_attachment_t***, int* res=can fail */ 00134 00135 /* RECORD you are ensured that it is never called twice with the same state 00136 * you should accept it only if the stream can be recorded without 00137 * any modification or header addition. */ 00138 DEMUX_CAN_RECORD, /* arg1=bool* res=can fail(assume false) */ 00139 DEMUX_SET_RECORD_STATE, /* arg1=bool res=can fail */ 00140 00141 00142 /* II. Specific access_demux queries */ 00143 /* PAUSE you are ensured that it is never called twice with the same state */ 00144 DEMUX_CAN_PAUSE = 0x1000, /* arg1= bool* can fail (assume false)*/ 00145 DEMUX_SET_PAUSE_STATE, /* arg1= bool can fail */ 00146 00147 DEMUX_GET_PTS_DELAY, /* arg1= int64_t* cannot fail */ 00148 00149 /* DEMUX_CAN_CONTROL_PACE returns true (*pb_pace) if we can read the 00150 * data at our pace */ 00151 DEMUX_CAN_CONTROL_PACE, /* arg1= bool*pb_pace can fail (assume false) */ 00152 00153 /* DEMUX_CAN_CONTROL_RATE is called only if DEMUX_CAN_CONTROL_PACE has returned false. 00154 * *pb_rate should be true when the rate can be changed (using DEMUX_SET_RATE) 00155 * *pb_ts_rescale should be true when the timestamps (pts/dts/pcr) have to be rescaled */ 00156 DEMUX_CAN_CONTROL_RATE, /* arg1= bool*pb_rate arg2= bool*pb_ts_rescale can fail(assume false) */ 00157 /* DEMUX_SET_RATE is called only if DEMUX_CAN_CONTROL_RATE has returned true. 00158 * It should return the value really used in *pi_rate */ 00159 DEMUX_SET_RATE, /* arg1= int*pi_rate can fail */ 00160 00161 DEMUX_CAN_SEEK, /* arg1= bool* can fail (assume false)*/ 00162 }; 00163 00164 VLC_API int demux_vaControlHelper( stream_t *, int64_t i_start, int64_t i_end, int64_t i_bitrate, int i_align, int i_query, va_list args ); 00165 00166 /************************************************************************* 00167 * Miscellaneous helpers for demuxers 00168 *************************************************************************/ 00169 00170 VLC_USED 00171 static inline bool demux_IsPathExtension( demux_t *p_demux, const char *psz_extension ) 00172 { 00173 if( !p_demux->psz_file ) 00174 return false; 00175 00176 const char *psz_ext = strrchr ( p_demux->psz_file, '.' ); 00177 if( !psz_ext || strcasecmp( psz_ext, psz_extension ) ) 00178 return false; 00179 return true; 00180 } 00181 00182 VLC_USED 00183 static inline bool demux_IsForced( demux_t *p_demux, const char *psz_name ) 00184 { 00185 if( !p_demux->psz_demux || strcmp( p_demux->psz_demux, psz_name ) ) 00186 return false; 00187 return true; 00188 } 00189 00190 /** 00191 * This function will create a packetizer suitable for a demuxer that parses 00192 * elementary stream. 00193 * 00194 * The provided es_format_t will be cleaned on error or by 00195 * demux_PacketizerDestroy. 00196 */ 00197 VLC_API decoder_t * demux_PacketizerNew( demux_t *p_demux, es_format_t *p_fmt, const char *psz_msg ) VLC_USED; 00198 00199 /** 00200 * This function will destroy a packetizer create by demux_PacketizerNew. 00201 */ 00202 VLC_API void demux_PacketizerDestroy( decoder_t *p_packetizer ); 00203 00204 /** 00205 * This function will return the parent input of this demux. 00206 * It is retained. Can return NULL. 00207 */ 00208 VLC_API input_thread_t * demux_GetParentInput( demux_t *p_demux ) VLC_USED; 00209 00210 /* */ 00211 #define DEMUX_INIT_COMMON() do { \ 00212 p_demux->pf_control = Control; \ 00213 p_demux->pf_demux = Demux; \ 00214 p_demux->p_sys = calloc( 1, sizeof( demux_sys_t ) ); \ 00215 if( !p_demux->p_sys ) return VLC_ENOMEM;\ 00216 } while(0) 00217 00218 /** 00219 * @} 00220 */ 00221 00222 #endif
1.7.1