]> git.sesse.net Git - vlc/blob - include/stream_output.h
removed an unused configuration category
[vlc] / include / stream_output.h
1 /*****************************************************************************
2  * stream_output.h : stream output module
3  *****************************************************************************
4  * Copyright (C) 2002 VideoLAN
5  * $Id: stream_output.h,v 1.9 2003/03/11 19:02:30 fenrir Exp $
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 /*
31  * i_allocated_size: size of allocated buffer
32  * p_allocated_buffer: where data has been allocated
33  *
34  * i_buffer_size: sizeof buffer from p_buffer
35  * p_buffer: where data begins
36  * i_size: size of valid data
37  *
38  */
39 #define SOUT_BUFFER_FLAGS_HEADER    0x0001
40 struct sout_buffer_t
41 {
42     size_t                  i_allocated_size;
43     byte_t                  *p_allocated_buffer;
44
45     size_t                  i_buffer_size;
46     byte_t                  *p_buffer;
47
48     size_t                  i_size;
49     mtime_t                 i_length;
50
51     mtime_t                 i_dts;
52     mtime_t                 i_pts;
53
54     uint32_t                i_flags;
55     int                     i_bitrate;
56
57     struct sout_buffer_t    *p_next;
58 };
59
60 struct sout_packet_format_t
61 {
62     int             i_cat;      // AUDIO_ES, VIDEO_ES, SPU_ES
63     vlc_fourcc_t    i_fourcc;
64
65     void            *p_format;  // WAVEFORMATEX or BITMAPINFOHEADER
66 };
67
68 struct sout_fifo_t
69 {
70     vlc_mutex_t         lock;                         /* fifo data lock */
71     vlc_cond_t          wait;         /* fifo data conditional variable */
72
73     int                 i_depth;
74     sout_buffer_t       *p_first;
75     sout_buffer_t       **pp_last;
76 };
77
78 /* for mux */
79 struct sout_input_t
80 {
81 //    vlc_mutex_t             lock;
82
83     sout_instance_t         *p_sout;
84
85     sout_packet_format_t    input_format;
86     sout_fifo_t             *p_fifo;
87
88     void                    *p_sys;
89 };
90
91 /* for packetizr */
92 struct sout_packetizer_input_t
93 {
94
95     sout_instance_t         *p_sout;
96     sout_packet_format_t    input_format;
97
98 //    vlc_mutex_t             lock;
99     int                     i_nb_inputs;
100     sout_input_t            **pp_inputs;
101
102     int                     i_nb_mux;   // not really used, just usefull with TAB_*
103     sout_mux_t              **pp_mux;
104
105 };
106
107 #define SOUT_METHOD_NONE        0x00
108 #define SOUT_METHOD_FILE        0x10
109 #define SOUT_METHOD_NETWORK     0x20
110
111 struct sout_access_out_t
112 {
113     VLC_COMMON_MEMBERS
114
115     module_t                *p_module;
116
117     sout_instance_t         *p_sout;
118
119     char                    *psz_access;
120     char                    *psz_name;
121     sout_access_out_sys_t   *p_sys;
122     int                     (* pf_seek  )( sout_access_out_t *,
123                                            off_t );
124     int                     (* pf_write )( sout_access_out_t *,
125                                            sout_buffer_t * );
126 };
127 /*
128  * i_query parameter of pf_mux_capacity
129  */
130 /* SOUT_MUX_CAP_GET_ADD_STREAM_ANY_TIME:    p_args=NULL, p_answer=&boolean */
131 #define SOUT_MUX_CAP_GET_ADD_STREAM_ANY_TIME    0x01
132 /* SOUT_MUX_CAP_GET_STREAMABLE:             p_args=NULL, p_answer=&boolean */
133 #define SOUT_MUX_CAP_GET_STREAMABLE             0x02
134 /*
135  * return error code
136  */
137 #define SOUT_MUX_CAP_ERR_OK                 0x00
138 #define SOUT_MUX_CAP_ERR_UNKNOWN            0x01
139 #define SOUT_MUX_CAP_ERR_UNIMPLEMENTED      0x02
140
141 typedef struct sout_mux_sys_t sout_mux_sys_t;
142 struct  sout_mux_t
143 {
144     VLC_COMMON_MEMBERS
145     module_t                *p_module;
146
147     sout_instance_t         *p_sout;
148
149     char                    *psz_mux;
150
151     sout_access_out_t       *p_access;
152
153     int                     i_preheader;
154     int                     (* pf_capacity)  ( sout_mux_t *,
155                                                int, void *, void *);
156     int                     (* pf_addstream )( sout_mux_t *,
157                                                sout_input_t * );
158     int                     (* pf_delstream )( sout_mux_t *,
159                                                sout_input_t * );
160     int                     (* pf_mux )      ( sout_mux_t * );
161
162
163     /* here are all inputs accepted by muxer */
164     int                     i_nb_inputs;
165     sout_input_t            **pp_inputs;
166
167
168     /* mux private */
169     sout_mux_sys_t          *p_sys;
170
171 //    /* creater private */
172 //    void                    *p_sys_owner;
173
174     /* XXX private to stream_output.c */
175     /* if muxer doesn't support adding stream at any time then we first wait
176      *  for stream then we refuse all stream and start muxing */
177     vlc_bool_t  b_add_stream_any_time;
178     vlc_bool_t  b_waiting_stream;
179     /* we wait one second after first stream added */
180     mtime_t     i_add_stream_start;
181 };
182
183 typedef struct sout_instance_sys_t sout_instance_sys_t;
184 struct sout_instance_t
185 {
186     VLC_COMMON_MEMBERS
187
188     /* complete sout string like udp/ts:239.255.12.42#file/ps://essai.ps */
189     char * psz_sout;
190
191     /* here are stored the parsed psz_sout */
192     int                     i_nb_dest;
193     char                    **ppsz_dest;
194
195     /* muxer data */
196     int                     i_preheader;    /* max over all muxer */
197
198     int                     i_nb_mux;
199     sout_mux_t              **pp_mux;
200
201     /* here are all packetizer inputs accepted by at least one muxer */
202     vlc_mutex_t             lock;
203     int                     i_nb_inputs;
204     sout_packetizer_input_t **pp_inputs;
205
206     /* sout private */
207     sout_instance_sys_t     *p_sys;
208 };
209
210
211
212
213 /*****************************************************************************
214  * Prototypes
215  *****************************************************************************/
216 #define sout_NewInstance(a,b) __sout_NewInstance(VLC_OBJECT(a),b)
217 VLC_EXPORT( sout_instance_t *, __sout_NewInstance,  ( vlc_object_t *, char * ) );
218 VLC_EXPORT( void,              sout_DeleteInstance, ( sout_instance_t * ) );
219
220 VLC_EXPORT( sout_fifo_t *,   sout_FifoCreate,     ( sout_instance_t * ) );
221 VLC_EXPORT( void,            sout_FifoDestroy,    ( sout_instance_t *, sout_fifo_t * ) );
222 VLC_EXPORT( void,            sout_FifoFree,       ( sout_instance_t *,sout_fifo_t * ) );
223
224 VLC_EXPORT( void,            sout_FifoPut,        ( sout_fifo_t *, sout_buffer_t* ) );
225 VLC_EXPORT( sout_buffer_t *, sout_FifoGet,        ( sout_fifo_t * ) );
226 VLC_EXPORT( sout_buffer_t *, sout_FifoShow,       ( sout_fifo_t * ) );
227
228
229 #define sout_InputNew( a, b ) __sout_InputNew( VLC_OBJECT(a), b )
230 VLC_EXPORT( sout_packetizer_input_t *, __sout_InputNew,       ( vlc_object_t *, sout_packet_format_t * ) );
231 VLC_EXPORT( int,            sout_InputDelete,      ( sout_packetizer_input_t * ) );
232 VLC_EXPORT( int,            sout_InputSendBuffer,  ( sout_packetizer_input_t *, sout_buffer_t* ) );
233
234 VLC_EXPORT( sout_buffer_t*, sout_BufferNew,    ( sout_instance_t *, size_t ) );
235 VLC_EXPORT( int,            sout_BufferRealloc,( sout_instance_t *, sout_buffer_t*, size_t ) );
236 VLC_EXPORT( int,            sout_BufferReallocFromPreHeader,( sout_instance_t *, sout_buffer_t*, size_t ) );
237 VLC_EXPORT( int,            sout_BufferDelete, ( sout_instance_t *, sout_buffer_t* ) );
238 VLC_EXPORT( sout_buffer_t*, sout_BufferDuplicate,(sout_instance_t *, sout_buffer_t * ) );
239 VLC_EXPORT( void,           sout_BufferChain,  ( sout_buffer_t **, sout_buffer_t * ) );
240
241 VLC_EXPORT( sout_access_out_t *, sout_AccessOutNew, ( sout_instance_t *, char *psz_access, char *psz_name ) );
242 VLC_EXPORT( void,                sout_AccessOutDelete, ( sout_access_out_t * ) );
243 VLC_EXPORT( int,                 sout_AccessOutSeek,   ( sout_access_out_t *, off_t ) );
244 VLC_EXPORT( int,                 sout_AccessOutWrite,  ( sout_access_out_t *, sout_buffer_t * ) );
245