1 /*****************************************************************************
2 * stream_output.h : stream output module
3 *****************************************************************************
4 * Copyright (C) 2002 VideoLAN
7 * Authors: Christophe Massiot <massiot@via.ecp.fr>
8 * Laurent Aimar <fenrir@via.ecp.fr>
9 * Eric Petit <titer@videolan.org>
11 * This program is free software; you can redistribute it and/or modify
12 * it under the terms of the GNU General Public License as published by
13 * the Free Software Foundation; either version 2 of the License, or
14 * (at your option) any later version.
16 * This program is distributed in the hope that it will be useful,
17 * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 * GNU General Public License for more details.
21 * You should have received a copy of the GNU General Public License
22 * along with this program; if not, write to the Free Software
23 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111, USA.
24 *****************************************************************************/
26 /*****************************************************************************
27 * sout_instance_t: stream output thread descriptor
28 *****************************************************************************/
33 typedef struct sout_stream_id_t sout_stream_id_t;
38 sout_instance_t *p_sout;
47 struct sout_packetizer_input_t
49 sout_instance_t *p_sout;
57 #define SOUT_METHOD_NONE 0x00
58 #define SOUT_METHOD_FILE 0x10
59 #define SOUT_METHOD_NETWORK 0x20
61 typedef struct sout_access_out_sys_t sout_access_out_sys_t;
62 struct sout_access_out_t
68 sout_instance_t *p_sout;
74 sout_access_out_sys_t *p_sys;
75 int (*pf_seek)( sout_access_out_t *, off_t );
76 int (*pf_read)( sout_access_out_t *, block_t * );
77 int (*pf_write)( sout_access_out_t *, block_t * );
81 * i_query parameter of pf_mux_capacity
83 /* SOUT_MUX_CAP_GET_ADD_STREAM_ANY_TIME: p_args=NULL, p_answer=&boolean */
84 #define SOUT_MUX_CAP_GET_ADD_STREAM_ANY_TIME 0x01
85 /* SOUT_MUX_CAP_GET_STREAMABLE: p_args=NULL, p_answer=&boolean */
86 #define SOUT_MUX_CAP_GET_STREAMABLE 0x02
87 /* SOUT_MUX_CAP_GET_ADD_STREAM_WAIT: p_args=NULL, p_answer=&boolean */
88 #define SOUT_MUX_CAP_GET_ADD_STREAM_WAIT 0x03
93 #define SOUT_MUX_CAP_ERR_OK 0x00
94 #define SOUT_MUX_CAP_ERR_UNKNOWN 0x01
95 #define SOUT_MUX_CAP_ERR_UNIMPLEMENTED 0x02
97 typedef struct sout_mux_sys_t sout_mux_sys_t;
103 sout_instance_t *p_sout;
108 sout_access_out_t *p_access;
110 int (*pf_capacity)( sout_mux_t *, int, void *, void *);
111 int (*pf_addstream)( sout_mux_t *, sout_input_t * );
112 int (*pf_delstream)( sout_mux_t *, sout_input_t * );
113 int (*pf_mux) ( sout_mux_t * );
115 /* here are all inputs accepted by muxer */
117 sout_input_t **pp_inputs;
121 sout_mux_sys_t *p_sys;
123 /* XXX private to stream_output.c */
124 /* if muxer doesn't support adding stream at any time then we first wait
125 * for stream then we refuse all stream and start muxing */
126 vlc_bool_t b_add_stream_any_time;
127 vlc_bool_t b_waiting_stream;
128 /* we wait one second after first stream added */
129 mtime_t i_add_stream_start;
142 typedef struct sout_stream_sys_t sout_stream_sys_t;
148 sout_instance_t *p_sout;
154 /* add, remove a stream */
155 sout_stream_id_t *(*pf_add)( sout_stream_t *, es_format_t * );
156 int (*pf_del)( sout_stream_t *, sout_stream_id_t * );
157 /* manage a packet */
158 int (*pf_send)( sout_stream_t *, sout_stream_id_t *, block_t* );
161 sout_stream_sys_t *p_sys;
164 typedef struct sout_instance_sys_t sout_instance_sys_t;
165 struct sout_instance_t
172 /* meta data (Read only) XXX it won't be set before the first packet received */
175 int i_out_pace_nocontrol; /* count of output that can't control the space */
178 sout_stream_t *p_stream;
181 sout_instance_sys_t *p_sys;
184 static inline sout_cfg_t *sout_cfg_find( sout_cfg_t *p_cfg, char *psz_name )
186 while( p_cfg && strcmp( p_cfg->psz_name, psz_name ) )
188 p_cfg = p_cfg->p_next;
194 static inline char *sout_cfg_find_value( sout_cfg_t *p_cfg, char *psz_name )
196 while( p_cfg && strcmp( p_cfg->psz_name, psz_name ) )
198 p_cfg = p_cfg->p_next;
201 if( p_cfg && p_cfg->psz_value )
203 return( p_cfg->psz_value );
208 /*****************************************************************************
210 *****************************************************************************/
211 #define sout_NewInstance(a,b) __sout_NewInstance(VLC_OBJECT(a),b)
212 VLC_EXPORT( sout_instance_t *, __sout_NewInstance, ( vlc_object_t *, char * ) );
213 VLC_EXPORT( void, sout_DeleteInstance, ( sout_instance_t * ) );
215 VLC_EXPORT( sout_packetizer_input_t *, sout_InputNew,( sout_instance_t *, es_format_t * ) );
216 VLC_EXPORT( int, sout_InputDelete, ( sout_packetizer_input_t * ) );
217 VLC_EXPORT( int, sout_InputSendBuffer, ( sout_packetizer_input_t *, block_t* ) );
219 VLC_EXPORT( sout_access_out_t *,sout_AccessOutNew, ( sout_instance_t *, char *psz_access, char *psz_name ) );
220 VLC_EXPORT( void, sout_AccessOutDelete, ( sout_access_out_t * ) );
221 VLC_EXPORT( int, sout_AccessOutSeek, ( sout_access_out_t *, off_t ) );
222 VLC_EXPORT( int, sout_AccessOutRead, ( sout_access_out_t *, block_t * ) );
223 VLC_EXPORT( int, sout_AccessOutWrite, ( sout_access_out_t *, block_t * ) );
225 VLC_EXPORT( sout_mux_t *, sout_MuxNew, ( sout_instance_t*, char *, sout_access_out_t * ) );
226 VLC_EXPORT( sout_input_t *, sout_MuxAddStream, ( sout_mux_t *, es_format_t * ) );
227 VLC_EXPORT( void, sout_MuxDeleteStream, ( sout_mux_t *, sout_input_t * ) );
228 VLC_EXPORT( void, sout_MuxDelete, ( sout_mux_t * ) );
229 VLC_EXPORT( void, sout_MuxSendBuffer, ( sout_mux_t *, sout_input_t *, block_t * ) );
231 VLC_EXPORT( char *, sout_cfg_parser, ( char **, sout_cfg_t **, char * ) );
232 VLC_EXPORT( sout_stream_t *, sout_stream_new, ( sout_instance_t *, char *psz_chain ) );
233 VLC_EXPORT( void, sout_stream_delete, ( sout_stream_t *p_stream ) );