demux: mp4: only have unsigned pts offsets
[vlc.git] / include / vlc_sout.h
blob23a7b90d36fea88c5a456a503916a1c6ef58edbf
1 /*****************************************************************************
2 * vlc_sout.h : stream output module
3 *****************************************************************************
4 * Copyright (C) 2002-2008 VLC authors and VideoLAN
6 * Authors: Christophe Massiot <massiot@via.ecp.fr>
7 * Laurent Aimar <fenrir@via.ecp.fr>
8 * Eric Petit <titer@videolan.org>
9 * Jean-Paul Saman <jpsaman #_at_# m2x.nl>
10 * RĂ©mi Denis-Courmont
12 * This program is free software; you can redistribute it and/or modify it
13 * under the terms of the GNU Lesser General Public License as published by
14 * the Free Software Foundation; either version 2.1 of the License, or
15 * (at your option) any later version.
17 * This program is distributed in the hope that it will be useful,
18 * but WITHOUT ANY WARRANTY; without even the implied warranty of
19 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20 * GNU Lesser General Public License for more details.
22 * You should have received a copy of the GNU Lesser General Public License
23 * along with this program; if not, write to the Free Software Foundation,
24 * Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
25 *****************************************************************************/
27 #ifndef VLC_SOUT_H_
28 #define VLC_SOUT_H_
30 #ifdef __cplusplus
31 extern "C" {
32 #endif
34 #include <sys/types.h>
35 #include <vlc_es.h>
37 /**
38 * \defgroup sout Stream output
39 * \ingroup output
40 * @{
41 * \file
42 * Stream output modules interface
45 /**
46 * \defgroup sout_access Access output
47 * Raw output byte streams
48 * @{
51 /** Stream output access_output */
52 struct sout_access_out_t
54 struct vlc_object_t obj;
56 module_t *p_module;
57 char *psz_access;
59 char *psz_path;
60 void *p_sys;
61 int (*pf_seek)( sout_access_out_t *, off_t );
62 ssize_t (*pf_read)( sout_access_out_t *, block_t * );
63 ssize_t (*pf_write)( sout_access_out_t *, block_t * );
64 int (*pf_control)( sout_access_out_t *, int, va_list );
66 config_chain_t *p_cfg;
69 enum access_out_query_e
71 ACCESS_OUT_CONTROLS_PACE, /* arg1=bool *, can fail (assume true) */
72 ACCESS_OUT_CAN_SEEK, /* arg1=bool *, can fail (assume false) */
75 VLC_API sout_access_out_t * sout_AccessOutNew( vlc_object_t *, const char *psz_access, const char *psz_name ) VLC_USED;
76 #define sout_AccessOutNew( obj, access, name ) \
77 sout_AccessOutNew( VLC_OBJECT(obj), access, name )
78 VLC_API void sout_AccessOutDelete( sout_access_out_t * );
79 VLC_API int sout_AccessOutSeek( sout_access_out_t *, off_t );
80 VLC_API ssize_t sout_AccessOutRead( sout_access_out_t *, block_t * );
81 VLC_API ssize_t sout_AccessOutWrite( sout_access_out_t *, block_t * );
82 VLC_API int sout_AccessOutControl( sout_access_out_t *, int, ... );
84 static inline bool sout_AccessOutCanControlPace( sout_access_out_t *p_ao )
86 bool b;
87 if( sout_AccessOutControl( p_ao, ACCESS_OUT_CONTROLS_PACE, &b ) )
88 return true;
89 return b;
92 /**
93 * @}
94 * \defgroup sout_mux Multiplexer
95 * Multiplexers (file formatters)
96 * @{
99 /** Muxer structure */
100 struct sout_mux_t
102 struct vlc_object_t obj;
103 module_t *p_module;
105 char *psz_mux;
106 config_chain_t *p_cfg;
108 sout_access_out_t *p_access;
110 int (*pf_addstream)( sout_mux_t *, sout_input_t * );
111 void (*pf_delstream)( sout_mux_t *, sout_input_t * );
112 int (*pf_mux) ( sout_mux_t * );
113 int (*pf_control) ( sout_mux_t *, int, va_list );
115 /* here are all inputs accepted by muxer */
116 int i_nb_inputs;
117 sout_input_t **pp_inputs;
119 /* mux private */
120 void *p_sys;
122 /* XXX private to stream_output.c */
123 /* if muxer doesn't support adding stream at any time then we first wait
124 * for stream then we refuse all stream and start muxing */
125 bool b_add_stream_any_time;
126 bool b_waiting_stream;
127 /* we wait 1.5 second after first stream added */
128 vlc_tick_t i_add_stream_start;
131 enum sout_mux_query_e
133 /* capabilities */
134 MUX_CAN_ADD_STREAM_WHILE_MUXING, /* arg1= bool *, res=cannot fail */
135 /* properties */
136 MUX_GET_MIME, /* arg1= char ** res=can fail */
139 struct sout_input_t
141 const es_format_t *p_fmt;
142 block_fifo_t *p_fifo;
143 void *p_sys;
144 es_format_t fmt;
148 VLC_API sout_mux_t * sout_MuxNew( sout_access_out_t *, const char * ) VLC_USED;
149 VLC_API sout_input_t *sout_MuxAddStream( sout_mux_t *, const es_format_t * ) VLC_USED;
150 VLC_API void sout_MuxDeleteStream( sout_mux_t *, sout_input_t * );
151 VLC_API void sout_MuxDelete( sout_mux_t * );
152 VLC_API int sout_MuxSendBuffer( sout_mux_t *, sout_input_t *, block_t * );
153 VLC_API int sout_MuxGetStream(sout_mux_t *, unsigned, vlc_tick_t *);
154 VLC_API void sout_MuxFlush( sout_mux_t *, sout_input_t * );
156 static inline int sout_MuxControl( sout_mux_t *p_mux, int i_query, ... )
158 va_list args;
159 int i_result;
161 va_start( args, i_query );
162 i_result = p_mux->pf_control( p_mux, i_query, args );
163 va_end( args );
164 return i_result;
167 /** @} */
169 enum sout_stream_query_e {
170 SOUT_STREAM_WANTS_SUBSTREAMS, /* arg1=bool *, res=can fail (assume false) */
171 SOUT_STREAM_ID_SPU_HIGHLIGHT, /* arg1=void *, arg2=const vlc_spu_highlight_t *, res=can fail */
172 SOUT_STREAM_IS_SYNCHRONOUS, /* arg1=bool *, can fail (assume false) */
175 struct sout_stream_operations {
176 void *(*add)(sout_stream_t *, const es_format_t *);
177 void (*del)(sout_stream_t *, void *);
178 int (*send)(sout_stream_t *, void *, block_t *);
179 int (*control)( sout_stream_t *, int, va_list );
180 void (*flush)( sout_stream_t *, void *);
183 struct sout_stream_t
185 struct vlc_object_t obj;
187 char *psz_name;
188 config_chain_t *p_cfg;
189 sout_stream_t *p_next;
191 const struct sout_stream_operations *ops;
192 void *p_sys;
195 VLC_API void sout_StreamChainDelete(sout_stream_t *first, sout_stream_t *end);
196 VLC_API sout_stream_t *sout_StreamChainNew(vlc_object_t *parent,
197 const char *psz_chain, sout_stream_t *p_next) VLC_USED;
199 VLC_API void *sout_StreamIdAdd(sout_stream_t *s, const es_format_t *fmt);
200 VLC_API void sout_StreamIdDel(sout_stream_t *s, void *id);
201 VLC_API int sout_StreamIdSend( sout_stream_t *s, void *id, block_t *b);
202 VLC_API void sout_StreamFlush(sout_stream_t *s, void *id);
203 VLC_API int sout_StreamControlVa(sout_stream_t *s, int i_query, va_list args);
205 static inline int sout_StreamControl( sout_stream_t *s, int i_query, ... )
207 va_list args;
208 int i_result;
210 va_start( args, i_query );
211 i_result = sout_StreamControlVa( s, i_query, args );
212 va_end( args );
213 return i_result;
216 static inline bool sout_StreamIsSynchronous(sout_stream_t *s)
218 bool b;
220 if (sout_StreamControl(s, SOUT_STREAM_IS_SYNCHRONOUS, &b))
221 b = false;
223 return b;
226 /****************************************************************************
227 * Encoder
228 ****************************************************************************/
230 VLC_API encoder_t * sout_EncoderCreate( vlc_object_t *, size_t );
231 #define sout_EncoderCreate(o,s) sout_EncoderCreate(VLC_OBJECT(o),s)
233 /****************************************************************************
234 * Announce handler
235 ****************************************************************************/
236 VLC_API session_descriptor_t* sout_AnnounceRegisterSDP( vlc_object_t *, const char *, const char * ) VLC_USED;
237 VLC_API void sout_AnnounceUnRegister(vlc_object_t *,session_descriptor_t* );
238 #define sout_AnnounceRegisterSDP(o, sdp, addr) \
239 sout_AnnounceRegisterSDP(VLC_OBJECT (o), sdp, addr)
240 #define sout_AnnounceUnRegister(o, a) \
241 sout_AnnounceUnRegister(VLC_OBJECT (o), a)
243 /** @} */
245 #ifdef __cplusplus
247 #endif
249 #endif