00001 /***************************************************************************** 00002 * vlc_demux.h: Demuxer descriptor, queries and methods 00003 ***************************************************************************** 00004 * Copyright (C) 1999-2005 the VideoLAN team 00005 * $Id: 68204d144bb1939165d64dc011da23a35d775b41 $ 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_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_path; 00052 00053 /* input stream */ 00054 stream_t *s; /* NULL in case of a access+demux in one */ 00055 00056 /* es output */ 00057 es_out_t *out; /* our p_es_out */ 00058 00059 /* set by demuxer */ 00060 int (*pf_demux) ( demux_t * ); /* demux one frame only */ 00061 int (*pf_control)( demux_t *, int i_query, va_list args); 00062 00063 /* Demux has to maintain them uptodate 00064 * when it is responsible of seekpoint/title */ 00065 struct 00066 { 00067 unsigned int i_update; /* Demux sets them on change, 00068 Input removes them once take into account*/ 00069 /* Seekpoint/Title at demux level */ 00070 int i_title; /* idem, start from 0 (could be menu) */ 00071 int i_seekpoint; /* idem, start from 0 */ 00072 } info; 00073 demux_sys_t *p_sys; 00074 00075 /* Weak link to parent input */ 00076 input_thread_t *p_input; 00077 }; 00078 00079 00080 /* demux_meta_t is returned by "meta reader" module to the demuxer */ 00081 typedef struct demux_meta_t 00082 { 00083 VLC_COMMON_MEMBERS 00084 demux_t *p_demux; /** FIXME: use stream_t instead? */ 00085 vlc_meta_t *p_meta; /**< meta data */ 00086 00087 int i_attachments; /**< number of attachments */ 00088 input_attachment_t **attachments; /**< array of attachments */ 00089 } demux_meta_t; 00090 00091 enum demux_query_e 00092 { 00093 /* I. Common queries to access_demux and demux */ 00094 /* POSITION double between 0.0 and 1.0 */ 00095 DEMUX_GET_POSITION, /* arg1= double * res= */ 00096 DEMUX_SET_POSITION, /* arg1= double arg2= bool b_precise res=can fail */ 00097 00098 /* LENGTH/TIME in microsecond, 0 if unknown */ 00099 DEMUX_GET_LENGTH, /* arg1= int64_t * res= */ 00100 DEMUX_GET_TIME, /* arg1= int64_t * res= */ 00101 DEMUX_SET_TIME, /* arg1= int64_t arg2= bool b_precise res=can fail */ 00102 00103 /* TITLE_INFO only if more than 1 title or 1 chapter */ 00104 DEMUX_GET_TITLE_INFO, /* arg1=input_title_t*** arg2=int* 00105 arg3=int*pi_title_offset(0), arg4=int*pi_seekpoint_offset(0) can fail */ 00106 /* TITLE/SEEKPOINT, only when TITLE_INFO succeed */ 00107 DEMUX_SET_TITLE, /* arg1= int can fail */ 00108 DEMUX_SET_SEEKPOINT, /* arg1= int can fail */ 00109 00110 /* DEMUX_SET_GROUP only a hit for demuxer (mainly DVB) to allow not 00111 * reading everything (you should not use this to call es_out_Control) 00112 * if you don't know what to do with it, just IGNORE it, it is safe(r) 00113 * -1 means all group, 0 default group (first es added) */ 00114 DEMUX_SET_GROUP, /* arg1= int, arg2=const vlc_list_t * can fail */ 00115 00116 /* Ask the demux to demux until the given date at the next pf_demux call 00117 * but not more (and not less, at the precision available of course). 00118 * XXX: not mandatory (except for subtitle demux) but I will help a lot 00119 * for multi-input 00120 */ 00121 DEMUX_SET_NEXT_DEMUX_TIME, /* arg1= int64_t * can fail */ 00122 /* FPS for correct subtitles handling */ 00123 DEMUX_GET_FPS, /* arg1= double * res=can fail */ 00124 00125 /* Meta data */ 00126 DEMUX_GET_META, /* arg1= vlc_meta_t ** res=can fail */ 00127 DEMUX_HAS_UNSUPPORTED_META, /* arg1= bool * res can fail */ 00128 00129 /* Attachments */ 00130 DEMUX_GET_ATTACHMENTS, /* arg1=input_attachment_t***, int* res=can fail */ 00131 00132 /* RECORD you are ensured that it is never called twice with the same state 00133 * you should accept it only if the stream can be recorded without 00134 * any modification or header addition. */ 00135 DEMUX_CAN_RECORD, /* arg1=bool* res=can fail(assume false) */ 00136 DEMUX_SET_RECORD_STATE, /* arg1=bool res=can fail */ 00137 00138 00139 /* II. Specific access_demux queries */ 00140 /* PAUSE you are ensured that it is never called twice with the same state */ 00141 DEMUX_CAN_PAUSE = 0x1000, /* arg1= bool* can fail (assume false)*/ 00142 DEMUX_SET_PAUSE_STATE, /* arg1= bool can fail */ 00143 00144 DEMUX_GET_PTS_DELAY, /* arg1= int64_t* cannot fail */ 00145 00146 /* DEMUX_CAN_CONTROL_PACE returns true (*pb_pace) if we can read the 00147 * data at our pace */ 00148 DEMUX_CAN_CONTROL_PACE, /* arg1= bool*pb_pace can fail (assume false) */ 00149 00150 /* DEMUX_CAN_CONTROL_RATE is called only if DEMUX_CAN_CONTROL_PACE has returned false. 00151 * *pb_rate should be true when the rate can be changed (using DEMUX_SET_RATE) 00152 * *pb_ts_rescale should be true when the timestamps (pts/dts/pcr) have to be rescaled */ 00153 DEMUX_CAN_CONTROL_RATE, /* arg1= bool*pb_rate arg2= bool*pb_ts_rescale can fail(assume false) */ 00154 /* DEMUX_SET_RATE is called only if DEMUX_CAN_CONTROL_RATE has returned true. 00155 * It should return the value really used in *pi_rate */ 00156 DEMUX_SET_RATE, /* arg1= int*pi_rate can fail */ 00157 00158 DEMUX_CAN_SEEK, /* arg1= bool* can fail (assume false)*/ 00159 }; 00160 00161 VLC_EXPORT( 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 ) ); 00162 00163 /************************************************************************* 00164 * Miscellaneous helpers for demuxers 00165 *************************************************************************/ 00166 00167 LIBVLC_USED 00168 static inline bool demux_IsPathExtension( demux_t *p_demux, const char *psz_extension ) 00169 { 00170 const char *psz_ext = strrchr ( p_demux->psz_path, '.' ); 00171 if( !psz_ext || strcasecmp( psz_ext, psz_extension ) ) 00172 return false; 00173 return true; 00174 } 00175 00176 LIBVLC_USED 00177 static inline bool demux_IsForced( demux_t *p_demux, const char *psz_name ) 00178 { 00179 if( !p_demux->psz_demux || strcmp( p_demux->psz_demux, psz_name ) ) 00180 return false; 00181 return true; 00182 } 00183 00184 /** 00185 * This function will create a packetizer suitable for a demuxer that parses 00186 * elementary stream. 00187 * 00188 * The provided es_format_t will be cleaned on error or by 00189 * demux_PacketizerDestroy. 00190 */ 00191 VLC_EXPORT( decoder_t *,demux_PacketizerNew, ( demux_t *p_demux, es_format_t *p_fmt, const char *psz_msg ) ); 00192 00193 /** 00194 * This function will destroy a packetizer create by demux_PacketizerNew. 00195 */ 00196 VLC_EXPORT( void, demux_PacketizerDestroy, ( decoder_t *p_packetizer ) ); 00197 00198 /** 00199 * This function will return the parent input of this demux. 00200 * It is retained. Can return NULL. 00201 */ 00202 VLC_EXPORT( input_thread_t *, demux_GetParentInput, ( demux_t *p_demux ) ); 00203 00204 /* */ 00205 #define DEMUX_INIT_COMMON() do { \ 00206 p_demux->pf_control = Control; \ 00207 p_demux->pf_demux = Demux; \ 00208 p_demux->p_sys = calloc( 1, sizeof( demux_sys_t ) ); \ 00209 if( !p_demux->p_sys ) return VLC_ENOMEM;\ 00210 } while(0) 00211 00212 /** 00213 * @} 00214 */ 00215 00216 #endif
1.5.6