VLC  4.0.0-dev
vlc_sout.h
Go to the documentation of this file.
1 /*****************************************************************************
2  * vlc_sout.h : stream output module
3  *****************************************************************************
4  * Copyright (C) 2002-2008 VLC authors and VideoLAN
5  *
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
11  *
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.
16  *
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.
21  *
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  *****************************************************************************/
26 
27 #ifndef VLC_SOUT_H_
28 #define VLC_SOUT_H_
29 
30 #ifdef __cplusplus
31 extern "C" {
32 #endif
33 
34 #include <sys/types.h>
35 #include <vlc_es.h>
36 
37 /**
38  * \defgroup sout Stream output
39  * \ingroup output
40  * @{
41  * \file
42  * Stream output modules interface
43  */
44 
45 /**
46  * \defgroup sout_access Access output
47  * Raw output byte streams
48  * @{
49  */
50 
51 /** Stream output access_output */
52 struct sout_access_out_t
53 {
54  struct vlc_object_t obj;
55 
57  char *psz_access;
58 
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 );
65 
67 };
68 
70 {
71  ACCESS_OUT_CONTROLS_PACE, /* arg1=bool *, can fail (assume true) */
72  ACCESS_OUT_CAN_SEEK, /* arg1=bool *, can fail (assume false) */
73 };
74 
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 )
83 
84 static inline bool sout_AccessOutCanControlPace( sout_access_out_t *p_ao )
85 {
86  bool b;
88  return true;
89  return b;
90 }
91 
92 /**
93  * @}
94  * \defgroup sout_mux Multiplexer
95  * Multiplexers (file formatters)
96  * @{
97  */
98 
99 /** Muxer structure */
100 struct sout_mux_t
101 {
102  struct vlc_object_t obj;
104 
105  char *psz_mux;
107 
109 
110  int (*pf_addstream)( sout_mux_t *, sout_input_t * );
112  int (*pf_mux) ( sout_mux_t * );
113  int (*pf_control) ( sout_mux_t *, int, va_list );
114 
115  /* here are all inputs accepted by muxer */
116  int i_nb_inputs;
118 
119  /* mux private */
120  void *p_sys;
121 
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 */
127  /* we wait 1.5 second after first stream added */
129 };
130 
131 enum sout_mux_query_e
132 {
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 */
137 };
138 
139 struct sout_input_t
140 {
141  const es_format_t *p_fmt;
143  void *p_sys;
145 };
146 
147 
153 VLC_API int sout_MuxGetStream(sout_mux_t *, unsigned, vlc_tick_t *);
155 
156 static inline int sout_MuxControl( sout_mux_t *p_mux, int i_query, ... )
157 {
158  va_list args;
159  int i_result;
160 
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;
165 }
166 
167 /** @} */
168 
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) */
173 };
174 
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 *);
181 };
182 
183 struct sout_stream_t
184 {
185  struct vlc_object_t obj;
186 
187  char *psz_name;
190 
191  const struct sout_stream_operations *ops;
192  void *p_sys;
193 };
194 
197  const char *psz_chain, sout_stream_t *p_next) VLC_USED;
198 
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);
204 
205 static inline int sout_StreamControl( sout_stream_t *s, int i_query, ... )
206 {
207  va_list args;
208  int i_result;
209 
210  va_start( args, i_query );
211  i_result = sout_StreamControlVa( s, i_query, args );
212  va_end( args );
213  return i_result;
214 }
215 
216 static inline bool sout_StreamIsSynchronous(sout_stream_t *s)
217 {
218  bool b;
219 
221  b = false;
222 
223  return b;
224 }
225 
226 /****************************************************************************
227  * Encoder
228  ****************************************************************************/
229 
231 #define sout_EncoderCreate(o,s) sout_EncoderCreate(VLC_OBJECT(o),s)
232 
233 /****************************************************************************
234  * Announce handler
235  ****************************************************************************/
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)
242 
243 /** @} */
244 
245 #ifdef __cplusplus
246 }
247 #endif
248 
249 #endif
#define VLC_USED
Definition: fourcc_gen.c:32
#define VLC_API
Definition: fourcc_gen.c:31
static bool sout_AccessOutCanControlPace(sout_access_out_t *p_ao)
Definition: vlc_sout.h:85
access_out_query_e
Definition: vlc_sout.h:71
ssize_t sout_AccessOutWrite(sout_access_out_t *, block_t *)
Definition: missing.c:78
int sout_AccessOutControl(sout_access_out_t *, int,...)
sout_AccessOutControl
Definition: missing.c:45
#define sout_AccessOutNew(obj, access, name)
Definition: vlc_sout.h:77
void sout_AccessOutDelete(sout_access_out_t *)
Definition: missing.c:51
ssize_t sout_AccessOutRead(sout_access_out_t *, block_t *)
Definition: missing.c:66
int sout_AccessOutSeek(sout_access_out_t *, off_t)
Definition: missing.c:72
@ ACCESS_OUT_CAN_SEEK
Definition: vlc_sout.h:73
@ ACCESS_OUT_CONTROLS_PACE
Definition: vlc_sout.h:72
void sout_MuxDelete(sout_mux_t *)
Definition: missing.c:116
static int sout_MuxControl(sout_mux_t *p_mux, int i_query,...)
Definition: vlc_sout.h:157
sout_input_t * sout_MuxAddStream(sout_mux_t *, const es_format_t *)
Definition: missing.c:109
int sout_MuxGetStream(sout_mux_t *, unsigned, vlc_tick_t *)
Definition: missing.c:128
void sout_MuxFlush(sout_mux_t *, sout_input_t *)
Definition: missing.c:147
void sout_MuxDeleteStream(sout_mux_t *, sout_input_t *)
Definition: missing.c:122
int sout_MuxSendBuffer(sout_mux_t *, sout_input_t *, block_t *)
Definition: missing.c:140
sout_mux_t * sout_MuxNew(sout_access_out_t *, const char *)
Definition: missing.c:134
sout_mux_query_e
Definition: vlc_sout.h:133
@ MUX_GET_MIME
Definition: vlc_sout.h:137
@ MUX_CAN_ADD_STREAM_WHILE_MUXING
Definition: vlc_sout.h:135
static bool sout_StreamIsSynchronous(sout_stream_t *s)
Definition: vlc_sout.h:217
void sout_StreamIdDel(sout_stream_t *s, void *id)
Definition: stream_output.c:704
static int sout_StreamControl(sout_stream_t *s, int i_query,...)
Definition: vlc_sout.h:206
void sout_StreamChainDelete(sout_stream_t *first, sout_stream_t *end)
Definition: missing.c:153
int sout_StreamIdSend(sout_stream_t *s, void *id, block_t *b)
Definition: stream_output.c:711
void sout_StreamFlush(sout_stream_t *s, void *id)
Definition: stream_output.c:721
#define sout_AnnounceRegisterSDP(o, sdp, addr)
Definition: vlc_sout.h:239
#define sout_AnnounceUnRegister(o, a)
Definition: vlc_sout.h:241
#define sout_EncoderCreate(o, s)
Definition: vlc_sout.h:232
int sout_StreamControlVa(sout_stream_t *s, int i_query, va_list args)
Definition: stream_output.c:731
sout_stream_t * sout_StreamChainNew(vlc_object_t *parent, const char *psz_chain, sout_stream_t *p_next)
Definition: missing.c:160
sout_stream_query_e
Definition: vlc_sout.h:170
void * sout_StreamIdAdd(sout_stream_t *s, const es_format_t *fmt)
Definition: stream_output.c:694
@ SOUT_STREAM_ID_SPU_HIGHLIGHT
Definition: vlc_sout.h:172
@ SOUT_STREAM_WANTS_SUBSTREAMS
Definition: vlc_sout.h:171
@ SOUT_STREAM_IS_SYNCHRONOUS
Definition: vlc_sout.h:173
Internal state for block queues.
Definition: fifo.c:39
Definition: vlc_block.h:118
Definition: vlc_configuration.h:326
Definition: vlc_codec.h:243
Definition: vlc_es.h:619
Internal module descriptor.
Definition: modules.h:81
Definition: sap.c:49
Stream output access_output.
Definition: vlc_sout.h:54
config_chain_t * p_cfg
Definition: vlc_sout.h:67
char * psz_path
Definition: vlc_sout.h:60
module_t * p_module
Definition: vlc_sout.h:57
int(* pf_control)(sout_access_out_t *, int, va_list)
Definition: vlc_sout.h:65
int(* pf_seek)(sout_access_out_t *, off_t)
Definition: vlc_sout.h:62
struct vlc_object_t obj
Definition: vlc_sout.h:55
ssize_t(* pf_write)(sout_access_out_t *, block_t *)
Definition: vlc_sout.h:64
char * psz_access
Definition: vlc_sout.h:58
ssize_t(* pf_read)(sout_access_out_t *, block_t *)
Definition: vlc_sout.h:63
void * p_sys
Definition: vlc_sout.h:61
Definition: vlc_sout.h:141
block_fifo_t * p_fifo
Definition: vlc_sout.h:143
es_format_t fmt
Definition: vlc_sout.h:145
void * p_sys
Definition: vlc_sout.h:144
const es_format_t * p_fmt
Definition: vlc_sout.h:142
Muxer structure.
Definition: vlc_sout.h:102
module_t * p_module
Definition: vlc_sout.h:104
void * p_sys
Definition: vlc_sout.h:121
int i_nb_inputs
Definition: vlc_sout.h:117
bool b_add_stream_any_time
Definition: vlc_sout.h:126
int(* pf_mux)(sout_mux_t *)
Definition: vlc_sout.h:113
int(* pf_control)(sout_mux_t *, int, va_list)
Definition: vlc_sout.h:114
struct vlc_object_t obj
Definition: vlc_sout.h:103
void(* pf_delstream)(sout_mux_t *, sout_input_t *)
Definition: vlc_sout.h:112
sout_input_t ** pp_inputs
Definition: vlc_sout.h:118
vlc_tick_t i_add_stream_start
Definition: vlc_sout.h:129
sout_access_out_t * p_access
Definition: vlc_sout.h:109
char * psz_mux
Definition: vlc_sout.h:106
bool b_waiting_stream
Definition: vlc_sout.h:127
int(* pf_addstream)(sout_mux_t *, sout_input_t *)
Definition: vlc_sout.h:111
config_chain_t * p_cfg
Definition: vlc_sout.h:107
Definition: vlc_sout.h:176
int(* control)(sout_stream_t *, int, va_list)
Definition: vlc_sout.h:180
int(* send)(sout_stream_t *, void *, block_t *)
Definition: vlc_sout.h:179
void(* del)(sout_stream_t *, void *)
Definition: vlc_sout.h:178
void(* flush)(sout_stream_t *, void *)
Definition: vlc_sout.h:181
Definition: vlc_sout.h:185
const struct sout_stream_operations * ops
Definition: vlc_sout.h:192
char * psz_name
Definition: vlc_sout.h:188
struct vlc_object_t obj
Definition: vlc_sout.h:186
config_chain_t * p_cfg
Definition: vlc_sout.h:189
void * p_sys
Definition: vlc_sout.h:193
sout_stream_t * p_next
Definition: vlc_sout.h:190
VLC object common members.
Definition: vlc_objects.h:45
const char * psz_name
Definition: text_style.c:33
This file defines the elementary streams format types.
int64_t vlc_tick_t
High precision date or time interval.
Definition: vlc_tick.h:45