1 /*
2 * copyright (c) 2001 Fabrice Bellard
3 *
4 * This file is part of FFmpeg.
5 *
6 * FFmpeg is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Lesser General Public
8 * License as published by the Free Software Foundation; either
9 * version 2.1 of the License, or (at your option) any later version.
10 *
11 * FFmpeg is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Lesser General Public License for more details.
15 *
16 * You should have received a copy of the GNU Lesser General Public
17 * License along with FFmpeg; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
19 */
20
21 #ifndef AVFORMAT_MUX_H
22 #define AVFORMAT_MUX_H
23
24 #include <stdint.h>
27
29
31 /**
32 * The public AVOutputFormat. See avformat.h for it.
33 */
35 /**
36 * size of private data so that it can be allocated in the wrapper
37 */
39
40 /**
41 * Internal flags. See FF_FMT_FLAG_* in internal.h.
42 */
44
46 /**
47 * Write a packet. If AVFMT_ALLOW_FLUSH is set in flags,
48 * pkt can be NULL in order to flush data buffered in the muxer.
49 * When flushing, return 0 if there still is more data to flush,
50 * or 1 if everything was flushed and there is no more buffered
51 * data.
52 */
55 /**
56 * A format-specific function for interleavement.
57 * If unset, packets will be interleaved by dts.
58 *
59 * @param s An AVFormatContext for output. pkt will be added to
60 * resp. taken from its packet buffer.
61 * @param[in,out] pkt A packet to be interleaved if has_packet is set;
62 * also used to return packets. If no packet is returned
63 * (e.g. on error), pkt is blank on return.
64 * @param flush 1 if no further packets are available as input and
65 * all remaining packets should be output.
66 * @param has_packet If set, pkt contains a packet to be interleaved
67 * on input; otherwise pkt is blank on input.
68 * @return 1 if a packet was output, 0 if no packet could be output,
69 * < 0 if an error occurred
70 */
72 int flush,
int has_packet);
73 /**
74 * Test if the given codec can be stored in this container.
75 *
76 * @return 1 if the codec is supported, 0 if it is not.
77 * A negative number if unknown.
78 * MKTAG('A', 'P', 'I', 'C') if the codec is only supported as AV_DISPOSITION_ATTACHED_PIC
79 */
81
83 int64_t *dts, int64_t *wall);
84 /**
85 * Allows sending messages from application to device.
86 */
88 void *
data,
size_t data_size);
89
90 /**
91 * Write an uncoded AVFrame.
92 *
93 * See av_write_uncoded_frame() for details.
94 *
95 * The library will free *frame afterwards, but the muxer can prevent it
96 * by setting the pointer to NULL.
97 */
100 /**
101 * Returns device list with it properties.
102 * @see avdevice_list_devices() for more details.
103 */
105 /**
106 * Initialize format. May allocate data here, and set any AVFormatContext or
107 * AVStream parameters that need to be set before packets are sent.
108 * This method must not write output.
109 *
110 * Return 0 if streams were fully configured, 1 if not, negative AVERROR on failure
111 *
112 * Any allocations made here must be freed in deinit().
113 */
115 /**
116 * Deinitialize format. If present, this is called whenever the muxer is being
117 * destroyed, regardless of whether or not the header has been written.
118 *
119 * If a trailer is being written, this is called after write_trailer().
120 *
121 * This is called if init() fails as well.
122 */
124 /**
125 * Set up any necessary bitstream filtering and extract any extra data needed
126 * for the global header.
127 *
128 * @note pkt might have been directly forwarded by a meta-muxer; therefore
129 * pkt->stream_index as well as the pkt's timebase might be invalid.
130 * Return 0 if more packets from this stream must be checked; 1 if not.
131 */
135
137 {
139 }
140
141 /**
142 * Add packet to an AVFormatContext's packet_buffer list, determining its
143 * interleaved position using compare() function argument.
144 * @return 0 on success, < 0 on error. pkt will always be blank on return.
145 */
148
149 /**
150 * Interleave an AVPacket per dts so it can be muxed.
151 * See the documentation of AVOutputFormat.interleave_packet for details.
152 */
154 int flush,
int has_packet);
155
156 /**
157 * Interleave packets directly in the order in which they arrive
158 * without any sort of buffering.
159 */
161 int flush,
int has_packet);
162
163 /**
164 * Find the next packet in the interleaving queue for the given stream.
165 *
166 * @return a pointer to a packet if one was found, NULL otherwise.
167 */
169
171
172 /**
173 * Add a bitstream filter to a stream.
174 *
175 * @param st output stream to add a filter to
176 * @param name the name of the filter to add
177 * @param args filter-specific argument string
178 * @return >0 on success;
179 * AVERROR code on failure
180 */
182
183 /**
184 * Write a packet to another muxer than the one the user originally
185 * intended. Useful when chaining muxers, where one muxer internally
186 * writes a received packet to another muxer.
187 *
188 * @param dst the muxer to write the packet to
189 * @param dst_stream the stream index within dst to write the packet to
190 * @param pkt the packet to be written. It will be returned blank when
191 * av_interleaved_write_frame() is used, unchanged otherwise.
192 * @param src the muxer the packet originally was intended for
193 * @param interleave 0->use av_write_frame, 1->av_interleaved_write_frame
194 * @return the value av_write_frame returned
195 */
198
199 /**
200 * Flags for AVFormatContext.write_uncoded_frame()
201 */
203
204 /**
205 * Query whether the feature is possible on this stream.
206 * The frame argument is ignored.
207 */
209
210 };
211
212 /**
213 * Make shift_size amount of space at read_start by shifting data in the output
214 * at read_start until the current IO position. The underlying IO context must
215 * be seekable.
216 */
218
219 /**
220 * Utility function to open IO stream of output format.
221 *
222 * @param s AVFormatContext
223 * @param url URL or file name to open for writing
224 * @options optional options which will be passed to io_open callback
225 * @return >=0 on success, negative AVERROR in case of failure
226 */
228
229 /**
230 * Parse creation_time in AVFormatContext metadata if exists and warn if the
231 * parsing fails.
232 *
233 * @param s AVFormatContext
234 * @param timestamp parsed timestamp in microseconds, only set on successful parsing
235 * @param return_seconds set this to get the number of seconds in timestamp instead of microseconds
236 * @return 1 if OK, 0 if the metadata was not present, AVERROR(EINVAL) on parse error
237 */
239
240 /**
241 * Standardize creation_time metadata in AVFormatContext to an ISO-8601
242 * timestamp string.
243 *
244 * @param s AVFormatContext
245 * @return <0 on error
246 */
248
249 #endif /* AVFORMAT_MUX_H */