]> git.sesse.net Git - vlc/blob - include/stream_output.h
* stream_output.h: removed sout_buffer_t and use block_t instead.
[vlc] / include / stream_output.h
1 /*****************************************************************************
2  * stream_output.h : stream output module
3  *****************************************************************************
4  * Copyright (C) 2002 VideoLAN
5  * $Id$
6  *
7  * Authors: Christophe Massiot <massiot@via.ecp.fr>
8  *          Laurent Aimar <fenrir@via.ecp.fr>
9  *          Eric Petit <titer@videolan.org>
10  *
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.
15  *
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.
20  *
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  *****************************************************************************/
25
26 /*****************************************************************************
27  * sout_instance_t: stream output thread descriptor
28  *****************************************************************************/
29
30 #include "vlc_es.h"
31
32
33 typedef struct sout_stream_id_t  sout_stream_id_t;
34
35 /* for mux */
36 struct sout_input_t
37 {
38     sout_instance_t *p_sout;
39
40     es_format_t     *p_fmt;
41     block_fifo_t    *p_fifo;
42
43     void            *p_sys;
44 };
45
46 /* for packetizer */
47 struct sout_packetizer_input_t
48 {
49     sout_instance_t     *p_sout;
50
51     es_format_t         *p_fmt;
52
53     sout_stream_id_t    *id;
54 };
55
56
57 #define SOUT_METHOD_NONE        0x00
58 #define SOUT_METHOD_FILE        0x10
59 #define SOUT_METHOD_NETWORK     0x20
60
61 typedef struct sout_access_out_sys_t   sout_access_out_sys_t;
62 struct sout_access_out_t
63 {
64     VLC_COMMON_MEMBERS
65
66     module_t                *p_module;
67
68     sout_instance_t         *p_sout;
69
70     char                    *psz_access;
71     sout_cfg_t              *p_cfg;
72
73     char                    *psz_name;
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 * );
78 };
79
80 /*
81  * i_query parameter of pf_mux_capacity
82  */
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
89
90 /*
91  * return error code
92  */
93 #define SOUT_MUX_CAP_ERR_OK                 0x00
94 #define SOUT_MUX_CAP_ERR_UNKNOWN            0x01
95 #define SOUT_MUX_CAP_ERR_UNIMPLEMENTED      0x02
96
97 typedef struct sout_mux_sys_t sout_mux_sys_t;
98 struct  sout_mux_t
99 {
100     VLC_COMMON_MEMBERS
101     module_t            *p_module;
102
103     sout_instance_t     *p_sout;
104
105     char                *psz_mux;
106     sout_cfg_t          *p_cfg;
107
108     sout_access_out_t   *p_access;
109
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 * );
114
115     /* here are all inputs accepted by muxer */
116     int                 i_nb_inputs;
117     sout_input_t        **pp_inputs;
118
119
120     /* mux private */
121     sout_mux_sys_t      *p_sys;
122
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;
130 };
131
132
133
134 struct sout_cfg_t
135 {
136     sout_cfg_t  *p_next;
137
138     char        *psz_name;
139     char        *psz_value;
140 };
141
142 typedef struct sout_stream_sys_t sout_stream_sys_t;
143 struct sout_stream_t
144 {
145     VLC_COMMON_MEMBERS
146
147     module_t          *p_module;
148     sout_instance_t   *p_sout;
149
150     char              *psz_name;
151     sout_cfg_t        *p_cfg;
152     char              *psz_next;
153
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* );
159
160     /* private */
161     sout_stream_sys_t *p_sys;
162 };
163
164 typedef struct sout_instance_sys_t sout_instance_sys_t;
165 struct sout_instance_t
166 {
167     VLC_COMMON_MEMBERS
168
169     char *psz_sout;
170     char *psz_chain;
171
172     /* meta data (Read only) XXX it won't be set before the first packet received */
173     vlc_meta_t          *p_meta;
174
175     int                 i_out_pace_nocontrol;   /* count of output that can't control the space */
176
177     vlc_mutex_t         lock;
178     sout_stream_t       *p_stream;
179
180     /* sout private */
181     sout_instance_sys_t *p_sys;
182 };
183
184 static inline sout_cfg_t *sout_cfg_find( sout_cfg_t *p_cfg, char *psz_name )
185 {
186     while( p_cfg && strcmp( p_cfg->psz_name, psz_name ) )
187     {
188         p_cfg = p_cfg->p_next;
189     }
190
191     return p_cfg;
192 }
193
194 static inline char *sout_cfg_find_value( sout_cfg_t *p_cfg, char *psz_name )
195 {
196     while( p_cfg && strcmp( p_cfg->psz_name, psz_name ) )
197     {
198         p_cfg = p_cfg->p_next;
199     }
200
201     if( p_cfg && p_cfg->psz_value )
202     {
203         return( p_cfg->psz_value );
204     }
205
206     return NULL;
207 }
208 /*****************************************************************************
209  * Prototypes
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 * ) );
214
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* ) );
218
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 * ) );
224
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 * ) );
230
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 ) );
234