]> git.sesse.net Git - vlc/blob - include/stream_output.h
* stream_output.* : added a flags variable to sout_buffer_t, allowing to
[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.8 2003/02/25 17:17:43 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
69 struct sout_fifo_t
70 {
71     vlc_mutex_t         lock;                         /* fifo data lock */
72     vlc_cond_t          wait;         /* fifo data conditional variable */
73
74     int                 i_depth;
75     sout_buffer_t       *p_first;
76     sout_buffer_t       **pp_last;
77 };
78
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_mux_data;
89 };
90
91 #define SOUT_METHOD_NONE        0x00
92 #define SOUT_METHOD_FILE        0x10
93 #define SOUT_METHOD_NETWORK     0x20
94
95
96 struct sout_access_out_t
97 {
98     VLC_COMMON_MEMBERS
99
100     module_t                *p_module;
101
102     sout_instance_t         *p_sout;
103
104     char                    *psz_access;
105     char                    *psz_name;
106     sout_access_out_sys_t   *p_sys;
107     int                     (* pf_seek  )( sout_access_out_t *,
108                                            off_t );
109     int                     (* pf_write )( sout_access_out_t *,
110                                            sout_buffer_t * );
111 };
112 /*
113  * i_query parameter of pf_mux_capacity
114  */
115 /* SOUT_MUX_CAP_GET_ADD_STREAM_ANY_TIME:    p_args=NULL, p_answer=&boolean */
116 #define SOUT_MUX_CAP_GET_ADD_STREAM_ANY_TIME    0x01
117 /* SOUT_MUX_CAP_GET_STREAMABLE:             p_args=NULL, p_answer=&boolean */
118 #define SOUT_MUX_CAP_GET_STREAMABLE             0x02
119 /*
120  * return error code
121  */
122 #define SOUT_MUX_CAP_ERR_OK                 0x00
123 #define SOUT_MUX_CAP_ERR_UNKNOWN            0x01
124 #define SOUT_MUX_CAP_ERR_UNIMPLEMENTED      0x02
125
126 typedef struct sout_instance_sys_t sout_instance_sys_t;
127 struct sout_instance_t
128 {
129     VLC_COMMON_MEMBERS
130
131
132     char * psz_dest;
133     char * psz_access;
134     char * psz_mux;
135     char * psz_name;
136
137     int                     i_method;
138
139     sout_access_out_t       *p_access;
140
141     module_t                *p_mux;
142     void                    *p_mux_data;
143     int                     i_mux_preheader;
144     int                     (* pf_mux_capacity)  ( sout_instance_t *,
145                                                    int, void *, void *);
146     int                     (* pf_mux_addstream )( sout_instance_t *,
147                                                    sout_input_t * );
148     int                     (* pf_mux_delstream )( sout_instance_t *,
149                                                    sout_input_t * );
150     int                     (* pf_mux )          ( sout_instance_t * );
151
152
153     vlc_mutex_t             lock;
154
155     int                     i_nb_inputs;
156     sout_input_t            **pp_inputs;
157
158     sout_instance_sys_t     *p_sys;
159 };
160
161
162
163
164 /*****************************************************************************
165  * Prototypes
166  *****************************************************************************/
167 #define sout_NewInstance(a,b) __sout_NewInstance(VLC_OBJECT(a),b)
168 VLC_EXPORT( sout_instance_t *, __sout_NewInstance,  ( vlc_object_t *, char * ) );
169 VLC_EXPORT( void,              sout_DeleteInstance, ( sout_instance_t * ) );
170
171 VLC_EXPORT( sout_fifo_t *,   sout_FifoCreate,     ( sout_instance_t * ) );
172 VLC_EXPORT( void,            sout_FifoDestroy,    ( sout_instance_t *, sout_fifo_t * ) );
173 VLC_EXPORT( void,            sout_FifoFree,       ( sout_instance_t *,sout_fifo_t * ) );
174
175 VLC_EXPORT( void,            sout_FifoPut,        ( sout_fifo_t *, sout_buffer_t* ) );
176 VLC_EXPORT( sout_buffer_t *, sout_FifoGet,        ( sout_fifo_t * ) );
177 VLC_EXPORT( sout_buffer_t *, sout_FifoShow,       ( sout_fifo_t * ) );
178
179
180 #define sout_InputNew( a, b ) __sout_InputNew( VLC_OBJECT(a), b )
181 VLC_EXPORT( sout_input_t *, __sout_InputNew,       ( vlc_object_t *, sout_packet_format_t * ) );
182 VLC_EXPORT( int,            sout_InputDelete,      ( sout_input_t * ) );
183 VLC_EXPORT( int,            sout_InputSendBuffer,  ( sout_input_t *, sout_buffer_t* ) );
184
185 VLC_EXPORT( sout_buffer_t*, sout_BufferNew,    ( sout_instance_t *, size_t ) );
186 VLC_EXPORT( int,            sout_BufferRealloc,( sout_instance_t *, sout_buffer_t*, size_t ) );
187 VLC_EXPORT( int,            sout_BufferReallocFromPreHeader,( sout_instance_t *, sout_buffer_t*, size_t ) );
188 VLC_EXPORT( int,            sout_BufferDelete, ( sout_instance_t *, sout_buffer_t* ) );
189 VLC_EXPORT( sout_buffer_t*, sout_BufferDuplicate,(sout_instance_t *, sout_buffer_t * ) );
190 VLC_EXPORT( void,           sout_BufferChain,  ( sout_buffer_t **, sout_buffer_t * ) );
191
192 VLC_EXPORT( sout_access_out_t *, sout_AccessOutNew, ( sout_instance_t *, char *psz_access, char *psz_name ) );
193 VLC_EXPORT( void,                sout_AccessOutDelete, ( sout_access_out_t * ) );
194 VLC_EXPORT( int,                 sout_AccessOutSeek,   ( sout_access_out_t *, off_t ) );
195 VLC_EXPORT( int,                 sout_AccessOutWrite,  ( sout_access_out_t *, sout_buffer_t * ) );
196