1cabdff1aSopenharmony_ci/*
2cabdff1aSopenharmony_ci * copyright (c) 2001 Fabrice Bellard
3cabdff1aSopenharmony_ci *
4cabdff1aSopenharmony_ci * This file is part of FFmpeg.
5cabdff1aSopenharmony_ci *
6cabdff1aSopenharmony_ci * FFmpeg is free software; you can redistribute it and/or
7cabdff1aSopenharmony_ci * modify it under the terms of the GNU Lesser General Public
8cabdff1aSopenharmony_ci * License as published by the Free Software Foundation; either
9cabdff1aSopenharmony_ci * version 2.1 of the License, or (at your option) any later version.
10cabdff1aSopenharmony_ci *
11cabdff1aSopenharmony_ci * FFmpeg is distributed in the hope that it will be useful,
12cabdff1aSopenharmony_ci * but WITHOUT ANY WARRANTY; without even the implied warranty of
13cabdff1aSopenharmony_ci * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
14cabdff1aSopenharmony_ci * Lesser General Public License for more details.
15cabdff1aSopenharmony_ci *
16cabdff1aSopenharmony_ci * You should have received a copy of the GNU Lesser General Public
17cabdff1aSopenharmony_ci * License along with FFmpeg; if not, write to the Free Software
18cabdff1aSopenharmony_ci * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
19cabdff1aSopenharmony_ci */
20cabdff1aSopenharmony_ci
21cabdff1aSopenharmony_ci#ifndef AVFORMAT_AVFORMAT_H
22cabdff1aSopenharmony_ci#define AVFORMAT_AVFORMAT_H
23cabdff1aSopenharmony_ci
24cabdff1aSopenharmony_ci/**
25cabdff1aSopenharmony_ci * @file
26cabdff1aSopenharmony_ci * @ingroup libavf
27cabdff1aSopenharmony_ci * Main libavformat public API header
28cabdff1aSopenharmony_ci */
29cabdff1aSopenharmony_ci
30cabdff1aSopenharmony_ci/**
31cabdff1aSopenharmony_ci * @defgroup libavf libavformat
32cabdff1aSopenharmony_ci * I/O and Muxing/Demuxing Library
33cabdff1aSopenharmony_ci *
34cabdff1aSopenharmony_ci * Libavformat (lavf) is a library for dealing with various media container
35cabdff1aSopenharmony_ci * formats. Its main two purposes are demuxing - i.e. splitting a media file
36cabdff1aSopenharmony_ci * into component streams, and the reverse process of muxing - writing supplied
37cabdff1aSopenharmony_ci * data in a specified container format. It also has an @ref lavf_io
38cabdff1aSopenharmony_ci * "I/O module" which supports a number of protocols for accessing the data (e.g.
39cabdff1aSopenharmony_ci * file, tcp, http and others).
40cabdff1aSopenharmony_ci * Unless you are absolutely sure you won't use libavformat's network
41cabdff1aSopenharmony_ci * capabilities, you should also call avformat_network_init().
42cabdff1aSopenharmony_ci *
43cabdff1aSopenharmony_ci * A supported input format is described by an AVInputFormat struct, conversely
44cabdff1aSopenharmony_ci * an output format is described by AVOutputFormat. You can iterate over all
45cabdff1aSopenharmony_ci * input/output formats using the  av_demuxer_iterate / av_muxer_iterate() functions.
46cabdff1aSopenharmony_ci * The protocols layer is not part of the public API, so you can only get the names
47cabdff1aSopenharmony_ci * of supported protocols with the avio_enum_protocols() function.
48cabdff1aSopenharmony_ci *
49cabdff1aSopenharmony_ci * Main lavf structure used for both muxing and demuxing is AVFormatContext,
50cabdff1aSopenharmony_ci * which exports all information about the file being read or written. As with
51cabdff1aSopenharmony_ci * most Libavformat structures, its size is not part of public ABI, so it cannot be
52cabdff1aSopenharmony_ci * allocated on stack or directly with av_malloc(). To create an
53cabdff1aSopenharmony_ci * AVFormatContext, use avformat_alloc_context() (some functions, like
54cabdff1aSopenharmony_ci * avformat_open_input() might do that for you).
55cabdff1aSopenharmony_ci *
56cabdff1aSopenharmony_ci * Most importantly an AVFormatContext contains:
57cabdff1aSopenharmony_ci * @li the @ref AVFormatContext.iformat "input" or @ref AVFormatContext.oformat
58cabdff1aSopenharmony_ci * "output" format. It is either autodetected or set by user for input;
59cabdff1aSopenharmony_ci * always set by user for output.
60cabdff1aSopenharmony_ci * @li an @ref AVFormatContext.streams "array" of AVStreams, which describe all
61cabdff1aSopenharmony_ci * elementary streams stored in the file. AVStreams are typically referred to
62cabdff1aSopenharmony_ci * using their index in this array.
63cabdff1aSopenharmony_ci * @li an @ref AVFormatContext.pb "I/O context". It is either opened by lavf or
64cabdff1aSopenharmony_ci * set by user for input, always set by user for output (unless you are dealing
65cabdff1aSopenharmony_ci * with an AVFMT_NOFILE format).
66cabdff1aSopenharmony_ci *
67cabdff1aSopenharmony_ci * @section lavf_options Passing options to (de)muxers
68cabdff1aSopenharmony_ci * It is possible to configure lavf muxers and demuxers using the @ref avoptions
69cabdff1aSopenharmony_ci * mechanism. Generic (format-independent) libavformat options are provided by
70cabdff1aSopenharmony_ci * AVFormatContext, they can be examined from a user program by calling
71cabdff1aSopenharmony_ci * av_opt_next() / av_opt_find() on an allocated AVFormatContext (or its AVClass
72cabdff1aSopenharmony_ci * from avformat_get_class()). Private (format-specific) options are provided by
73cabdff1aSopenharmony_ci * AVFormatContext.priv_data if and only if AVInputFormat.priv_class /
74cabdff1aSopenharmony_ci * AVOutputFormat.priv_class of the corresponding format struct is non-NULL.
75cabdff1aSopenharmony_ci * Further options may be provided by the @ref AVFormatContext.pb "I/O context",
76cabdff1aSopenharmony_ci * if its AVClass is non-NULL, and the protocols layer. See the discussion on
77cabdff1aSopenharmony_ci * nesting in @ref avoptions documentation to learn how to access those.
78cabdff1aSopenharmony_ci *
79cabdff1aSopenharmony_ci * @section urls
80cabdff1aSopenharmony_ci * URL strings in libavformat are made of a scheme/protocol, a ':', and a
81cabdff1aSopenharmony_ci * scheme specific string. URLs without a scheme and ':' used for local files
82cabdff1aSopenharmony_ci * are supported but deprecated. "file:" should be used for local files.
83cabdff1aSopenharmony_ci *
84cabdff1aSopenharmony_ci * It is important that the scheme string is not taken from untrusted
85cabdff1aSopenharmony_ci * sources without checks.
86cabdff1aSopenharmony_ci *
87cabdff1aSopenharmony_ci * Note that some schemes/protocols are quite powerful, allowing access to
88cabdff1aSopenharmony_ci * both local and remote files, parts of them, concatenations of them, local
89cabdff1aSopenharmony_ci * audio and video devices and so on.
90cabdff1aSopenharmony_ci *
91cabdff1aSopenharmony_ci * @{
92cabdff1aSopenharmony_ci *
93cabdff1aSopenharmony_ci * @defgroup lavf_decoding Demuxing
94cabdff1aSopenharmony_ci * @{
95cabdff1aSopenharmony_ci * Demuxers read a media file and split it into chunks of data (@em packets). A
96cabdff1aSopenharmony_ci * @ref AVPacket "packet" contains one or more encoded frames which belongs to a
97cabdff1aSopenharmony_ci * single elementary stream. In the lavf API this process is represented by the
98cabdff1aSopenharmony_ci * avformat_open_input() function for opening a file, av_read_frame() for
99cabdff1aSopenharmony_ci * reading a single packet and finally avformat_close_input(), which does the
100cabdff1aSopenharmony_ci * cleanup.
101cabdff1aSopenharmony_ci *
102cabdff1aSopenharmony_ci * @section lavf_decoding_open Opening a media file
103cabdff1aSopenharmony_ci * The minimum information required to open a file is its URL, which
104cabdff1aSopenharmony_ci * is passed to avformat_open_input(), as in the following code:
105cabdff1aSopenharmony_ci * @code
106cabdff1aSopenharmony_ci * const char    *url = "file:in.mp3";
107cabdff1aSopenharmony_ci * AVFormatContext *s = NULL;
108cabdff1aSopenharmony_ci * int ret = avformat_open_input(&s, url, NULL, NULL);
109cabdff1aSopenharmony_ci * if (ret < 0)
110cabdff1aSopenharmony_ci *     abort();
111cabdff1aSopenharmony_ci * @endcode
112cabdff1aSopenharmony_ci * The above code attempts to allocate an AVFormatContext, open the
113cabdff1aSopenharmony_ci * specified file (autodetecting the format) and read the header, exporting the
114cabdff1aSopenharmony_ci * information stored there into s. Some formats do not have a header or do not
115cabdff1aSopenharmony_ci * store enough information there, so it is recommended that you call the
116cabdff1aSopenharmony_ci * avformat_find_stream_info() function which tries to read and decode a few
117cabdff1aSopenharmony_ci * frames to find missing information.
118cabdff1aSopenharmony_ci *
119cabdff1aSopenharmony_ci * In some cases you might want to preallocate an AVFormatContext yourself with
120cabdff1aSopenharmony_ci * avformat_alloc_context() and do some tweaking on it before passing it to
121cabdff1aSopenharmony_ci * avformat_open_input(). One such case is when you want to use custom functions
122cabdff1aSopenharmony_ci * for reading input data instead of lavf internal I/O layer.
123cabdff1aSopenharmony_ci * To do that, create your own AVIOContext with avio_alloc_context(), passing
124cabdff1aSopenharmony_ci * your reading callbacks to it. Then set the @em pb field of your
125cabdff1aSopenharmony_ci * AVFormatContext to newly created AVIOContext.
126cabdff1aSopenharmony_ci *
127cabdff1aSopenharmony_ci * Since the format of the opened file is in general not known until after
128cabdff1aSopenharmony_ci * avformat_open_input() has returned, it is not possible to set demuxer private
129cabdff1aSopenharmony_ci * options on a preallocated context. Instead, the options should be passed to
130cabdff1aSopenharmony_ci * avformat_open_input() wrapped in an AVDictionary:
131cabdff1aSopenharmony_ci * @code
132cabdff1aSopenharmony_ci * AVDictionary *options = NULL;
133cabdff1aSopenharmony_ci * av_dict_set(&options, "video_size", "640x480", 0);
134cabdff1aSopenharmony_ci * av_dict_set(&options, "pixel_format", "rgb24", 0);
135cabdff1aSopenharmony_ci *
136cabdff1aSopenharmony_ci * if (avformat_open_input(&s, url, NULL, &options) < 0)
137cabdff1aSopenharmony_ci *     abort();
138cabdff1aSopenharmony_ci * av_dict_free(&options);
139cabdff1aSopenharmony_ci * @endcode
140cabdff1aSopenharmony_ci * This code passes the private options 'video_size' and 'pixel_format' to the
141cabdff1aSopenharmony_ci * demuxer. They would be necessary for e.g. the rawvideo demuxer, since it
142cabdff1aSopenharmony_ci * cannot know how to interpret raw video data otherwise. If the format turns
143cabdff1aSopenharmony_ci * out to be something different than raw video, those options will not be
144cabdff1aSopenharmony_ci * recognized by the demuxer and therefore will not be applied. Such unrecognized
145cabdff1aSopenharmony_ci * options are then returned in the options dictionary (recognized options are
146cabdff1aSopenharmony_ci * consumed). The calling program can handle such unrecognized options as it
147cabdff1aSopenharmony_ci * wishes, e.g.
148cabdff1aSopenharmony_ci * @code
149cabdff1aSopenharmony_ci * AVDictionaryEntry *e;
150cabdff1aSopenharmony_ci * if (e = av_dict_get(options, "", NULL, AV_DICT_IGNORE_SUFFIX)) {
151cabdff1aSopenharmony_ci *     fprintf(stderr, "Option %s not recognized by the demuxer.\n", e->key);
152cabdff1aSopenharmony_ci *     abort();
153cabdff1aSopenharmony_ci * }
154cabdff1aSopenharmony_ci * @endcode
155cabdff1aSopenharmony_ci *
156cabdff1aSopenharmony_ci * After you have finished reading the file, you must close it with
157cabdff1aSopenharmony_ci * avformat_close_input(). It will free everything associated with the file.
158cabdff1aSopenharmony_ci *
159cabdff1aSopenharmony_ci * @section lavf_decoding_read Reading from an opened file
160cabdff1aSopenharmony_ci * Reading data from an opened AVFormatContext is done by repeatedly calling
161cabdff1aSopenharmony_ci * av_read_frame() on it. Each call, if successful, will return an AVPacket
162cabdff1aSopenharmony_ci * containing encoded data for one AVStream, identified by
163cabdff1aSopenharmony_ci * AVPacket.stream_index. This packet may be passed straight into the libavcodec
164cabdff1aSopenharmony_ci * decoding functions avcodec_send_packet() or avcodec_decode_subtitle2() if the
165cabdff1aSopenharmony_ci * caller wishes to decode the data.
166cabdff1aSopenharmony_ci *
167cabdff1aSopenharmony_ci * AVPacket.pts, AVPacket.dts and AVPacket.duration timing information will be
168cabdff1aSopenharmony_ci * set if known. They may also be unset (i.e. AV_NOPTS_VALUE for
169cabdff1aSopenharmony_ci * pts/dts, 0 for duration) if the stream does not provide them. The timing
170cabdff1aSopenharmony_ci * information will be in AVStream.time_base units, i.e. it has to be
171cabdff1aSopenharmony_ci * multiplied by the timebase to convert them to seconds.
172cabdff1aSopenharmony_ci *
173cabdff1aSopenharmony_ci * A packet returned by av_read_frame() is always reference-counted,
174cabdff1aSopenharmony_ci * i.e. AVPacket.buf is set and the user may keep it indefinitely.
175cabdff1aSopenharmony_ci * The packet must be freed with av_packet_unref() when it is no
176cabdff1aSopenharmony_ci * longer needed.
177cabdff1aSopenharmony_ci *
178cabdff1aSopenharmony_ci * @section lavf_decoding_seek Seeking
179cabdff1aSopenharmony_ci * @}
180cabdff1aSopenharmony_ci *
181cabdff1aSopenharmony_ci * @defgroup lavf_encoding Muxing
182cabdff1aSopenharmony_ci * @{
183cabdff1aSopenharmony_ci * Muxers take encoded data in the form of @ref AVPacket "AVPackets" and write
184cabdff1aSopenharmony_ci * it into files or other output bytestreams in the specified container format.
185cabdff1aSopenharmony_ci *
186cabdff1aSopenharmony_ci * The main API functions for muxing are avformat_write_header() for writing the
187cabdff1aSopenharmony_ci * file header, av_write_frame() / av_interleaved_write_frame() for writing the
188cabdff1aSopenharmony_ci * packets and av_write_trailer() for finalizing the file.
189cabdff1aSopenharmony_ci *
190cabdff1aSopenharmony_ci * At the beginning of the muxing process, the caller must first call
191cabdff1aSopenharmony_ci * avformat_alloc_context() to create a muxing context. The caller then sets up
192cabdff1aSopenharmony_ci * the muxer by filling the various fields in this context:
193cabdff1aSopenharmony_ci *
194cabdff1aSopenharmony_ci * - The @ref AVFormatContext.oformat "oformat" field must be set to select the
195cabdff1aSopenharmony_ci *   muxer that will be used.
196cabdff1aSopenharmony_ci * - Unless the format is of the AVFMT_NOFILE type, the @ref AVFormatContext.pb
197cabdff1aSopenharmony_ci *   "pb" field must be set to an opened IO context, either returned from
198cabdff1aSopenharmony_ci *   avio_open2() or a custom one.
199cabdff1aSopenharmony_ci * - Unless the format is of the AVFMT_NOSTREAMS type, at least one stream must
200cabdff1aSopenharmony_ci *   be created with the avformat_new_stream() function. The caller should fill
201cabdff1aSopenharmony_ci *   the @ref AVStream.codecpar "stream codec parameters" information, such as the
202cabdff1aSopenharmony_ci *   codec @ref AVCodecParameters.codec_type "type", @ref AVCodecParameters.codec_id
203cabdff1aSopenharmony_ci *   "id" and other parameters (e.g. width / height, the pixel or sample format,
204cabdff1aSopenharmony_ci *   etc.) as known. The @ref AVStream.time_base "stream timebase" should
205cabdff1aSopenharmony_ci *   be set to the timebase that the caller desires to use for this stream (note
206cabdff1aSopenharmony_ci *   that the timebase actually used by the muxer can be different, as will be
207cabdff1aSopenharmony_ci *   described later).
208cabdff1aSopenharmony_ci * - It is advised to manually initialize only the relevant fields in
209cabdff1aSopenharmony_ci *   AVCodecParameters, rather than using @ref avcodec_parameters_copy() during
210cabdff1aSopenharmony_ci *   remuxing: there is no guarantee that the codec context values remain valid
211cabdff1aSopenharmony_ci *   for both input and output format contexts.
212cabdff1aSopenharmony_ci * - The caller may fill in additional information, such as @ref
213cabdff1aSopenharmony_ci *   AVFormatContext.metadata "global" or @ref AVStream.metadata "per-stream"
214cabdff1aSopenharmony_ci *   metadata, @ref AVFormatContext.chapters "chapters", @ref
215cabdff1aSopenharmony_ci *   AVFormatContext.programs "programs", etc. as described in the
216cabdff1aSopenharmony_ci *   AVFormatContext documentation. Whether such information will actually be
217cabdff1aSopenharmony_ci *   stored in the output depends on what the container format and the muxer
218cabdff1aSopenharmony_ci *   support.
219cabdff1aSopenharmony_ci *
220cabdff1aSopenharmony_ci * When the muxing context is fully set up, the caller must call
221cabdff1aSopenharmony_ci * avformat_write_header() to initialize the muxer internals and write the file
222cabdff1aSopenharmony_ci * header. Whether anything actually is written to the IO context at this step
223cabdff1aSopenharmony_ci * depends on the muxer, but this function must always be called. Any muxer
224cabdff1aSopenharmony_ci * private options must be passed in the options parameter to this function.
225cabdff1aSopenharmony_ci *
226cabdff1aSopenharmony_ci * The data is then sent to the muxer by repeatedly calling av_write_frame() or
227cabdff1aSopenharmony_ci * av_interleaved_write_frame() (consult those functions' documentation for
228cabdff1aSopenharmony_ci * discussion on the difference between them; only one of them may be used with
229cabdff1aSopenharmony_ci * a single muxing context, they should not be mixed). Do note that the timing
230cabdff1aSopenharmony_ci * information on the packets sent to the muxer must be in the corresponding
231cabdff1aSopenharmony_ci * AVStream's timebase. That timebase is set by the muxer (in the
232cabdff1aSopenharmony_ci * avformat_write_header() step) and may be different from the timebase
233cabdff1aSopenharmony_ci * requested by the caller.
234cabdff1aSopenharmony_ci *
235cabdff1aSopenharmony_ci * Once all the data has been written, the caller must call av_write_trailer()
236cabdff1aSopenharmony_ci * to flush any buffered packets and finalize the output file, then close the IO
237cabdff1aSopenharmony_ci * context (if any) and finally free the muxing context with
238cabdff1aSopenharmony_ci * avformat_free_context().
239cabdff1aSopenharmony_ci * @}
240cabdff1aSopenharmony_ci *
241cabdff1aSopenharmony_ci * @defgroup lavf_io I/O Read/Write
242cabdff1aSopenharmony_ci * @{
243cabdff1aSopenharmony_ci * @section lavf_io_dirlist Directory listing
244cabdff1aSopenharmony_ci * The directory listing API makes it possible to list files on remote servers.
245cabdff1aSopenharmony_ci *
246cabdff1aSopenharmony_ci * Some of possible use cases:
247cabdff1aSopenharmony_ci * - an "open file" dialog to choose files from a remote location,
248cabdff1aSopenharmony_ci * - a recursive media finder providing a player with an ability to play all
249cabdff1aSopenharmony_ci * files from a given directory.
250cabdff1aSopenharmony_ci *
251cabdff1aSopenharmony_ci * @subsection lavf_io_dirlist_open Opening a directory
252cabdff1aSopenharmony_ci * At first, a directory needs to be opened by calling avio_open_dir()
253cabdff1aSopenharmony_ci * supplied with a URL and, optionally, ::AVDictionary containing
254cabdff1aSopenharmony_ci * protocol-specific parameters. The function returns zero or positive
255cabdff1aSopenharmony_ci * integer and allocates AVIODirContext on success.
256cabdff1aSopenharmony_ci *
257cabdff1aSopenharmony_ci * @code
258cabdff1aSopenharmony_ci * AVIODirContext *ctx = NULL;
259cabdff1aSopenharmony_ci * if (avio_open_dir(&ctx, "smb://example.com/some_dir", NULL) < 0) {
260cabdff1aSopenharmony_ci *     fprintf(stderr, "Cannot open directory.\n");
261cabdff1aSopenharmony_ci *     abort();
262cabdff1aSopenharmony_ci * }
263cabdff1aSopenharmony_ci * @endcode
264cabdff1aSopenharmony_ci *
265cabdff1aSopenharmony_ci * This code tries to open a sample directory using smb protocol without
266cabdff1aSopenharmony_ci * any additional parameters.
267cabdff1aSopenharmony_ci *
268cabdff1aSopenharmony_ci * @subsection lavf_io_dirlist_read Reading entries
269cabdff1aSopenharmony_ci * Each directory's entry (i.e. file, another directory, anything else
270cabdff1aSopenharmony_ci * within ::AVIODirEntryType) is represented by AVIODirEntry.
271cabdff1aSopenharmony_ci * Reading consecutive entries from an opened AVIODirContext is done by
272cabdff1aSopenharmony_ci * repeatedly calling avio_read_dir() on it. Each call returns zero or
273cabdff1aSopenharmony_ci * positive integer if successful. Reading can be stopped right after the
274cabdff1aSopenharmony_ci * NULL entry has been read -- it means there are no entries left to be
275cabdff1aSopenharmony_ci * read. The following code reads all entries from a directory associated
276cabdff1aSopenharmony_ci * with ctx and prints their names to standard output.
277cabdff1aSopenharmony_ci * @code
278cabdff1aSopenharmony_ci * AVIODirEntry *entry = NULL;
279cabdff1aSopenharmony_ci * for (;;) {
280cabdff1aSopenharmony_ci *     if (avio_read_dir(ctx, &entry) < 0) {
281cabdff1aSopenharmony_ci *         fprintf(stderr, "Cannot list directory.\n");
282cabdff1aSopenharmony_ci *         abort();
283cabdff1aSopenharmony_ci *     }
284cabdff1aSopenharmony_ci *     if (!entry)
285cabdff1aSopenharmony_ci *         break;
286cabdff1aSopenharmony_ci *     printf("%s\n", entry->name);
287cabdff1aSopenharmony_ci *     avio_free_directory_entry(&entry);
288cabdff1aSopenharmony_ci * }
289cabdff1aSopenharmony_ci * @endcode
290cabdff1aSopenharmony_ci * @}
291cabdff1aSopenharmony_ci *
292cabdff1aSopenharmony_ci * @defgroup lavf_codec Demuxers
293cabdff1aSopenharmony_ci * @{
294cabdff1aSopenharmony_ci * @defgroup lavf_codec_native Native Demuxers
295cabdff1aSopenharmony_ci * @{
296cabdff1aSopenharmony_ci * @}
297cabdff1aSopenharmony_ci * @defgroup lavf_codec_wrappers External library wrappers
298cabdff1aSopenharmony_ci * @{
299cabdff1aSopenharmony_ci * @}
300cabdff1aSopenharmony_ci * @}
301cabdff1aSopenharmony_ci * @defgroup lavf_protos I/O Protocols
302cabdff1aSopenharmony_ci * @{
303cabdff1aSopenharmony_ci * @}
304cabdff1aSopenharmony_ci * @defgroup lavf_internal Internal
305cabdff1aSopenharmony_ci * @{
306cabdff1aSopenharmony_ci * @}
307cabdff1aSopenharmony_ci * @}
308cabdff1aSopenharmony_ci */
309cabdff1aSopenharmony_ci
310cabdff1aSopenharmony_ci#include <time.h>
311cabdff1aSopenharmony_ci#include <stdio.h>  /* FILE */
312cabdff1aSopenharmony_ci
313cabdff1aSopenharmony_ci#include "libavcodec/codec.h"
314cabdff1aSopenharmony_ci#include "libavcodec/codec_par.h"
315cabdff1aSopenharmony_ci#include "libavcodec/defs.h"
316cabdff1aSopenharmony_ci#include "libavcodec/packet.h"
317cabdff1aSopenharmony_ci
318cabdff1aSopenharmony_ci#include "libavutil/dict.h"
319cabdff1aSopenharmony_ci#include "libavutil/log.h"
320cabdff1aSopenharmony_ci
321cabdff1aSopenharmony_ci#include "avio.h"
322cabdff1aSopenharmony_ci#include "libavformat/version_major.h"
323cabdff1aSopenharmony_ci#ifndef HAVE_AV_CONFIG_H
324cabdff1aSopenharmony_ci/* When included as part of the ffmpeg build, only include the major version
325cabdff1aSopenharmony_ci * to avoid unnecessary rebuilds. When included externally, keep including
326cabdff1aSopenharmony_ci * the full version information. */
327cabdff1aSopenharmony_ci#include "libavformat/version.h"
328cabdff1aSopenharmony_ci#endif
329cabdff1aSopenharmony_ci
330cabdff1aSopenharmony_cistruct AVFormatContext;
331cabdff1aSopenharmony_cistruct AVStream;
332cabdff1aSopenharmony_ci
333cabdff1aSopenharmony_cistruct AVDeviceInfoList;
334cabdff1aSopenharmony_cistruct AVDeviceCapabilitiesQuery;
335cabdff1aSopenharmony_ci
336cabdff1aSopenharmony_ci/**
337cabdff1aSopenharmony_ci * @defgroup metadata_api Public Metadata API
338cabdff1aSopenharmony_ci * @{
339cabdff1aSopenharmony_ci * @ingroup libavf
340cabdff1aSopenharmony_ci * The metadata API allows libavformat to export metadata tags to a client
341cabdff1aSopenharmony_ci * application when demuxing. Conversely it allows a client application to
342cabdff1aSopenharmony_ci * set metadata when muxing.
343cabdff1aSopenharmony_ci *
344cabdff1aSopenharmony_ci * Metadata is exported or set as pairs of key/value strings in the 'metadata'
345cabdff1aSopenharmony_ci * fields of the AVFormatContext, AVStream, AVChapter and AVProgram structs
346cabdff1aSopenharmony_ci * using the @ref lavu_dict "AVDictionary" API. Like all strings in FFmpeg,
347cabdff1aSopenharmony_ci * metadata is assumed to be UTF-8 encoded Unicode. Note that metadata
348cabdff1aSopenharmony_ci * exported by demuxers isn't checked to be valid UTF-8 in most cases.
349cabdff1aSopenharmony_ci *
350cabdff1aSopenharmony_ci * Important concepts to keep in mind:
351cabdff1aSopenharmony_ci * -  Keys are unique; there can never be 2 tags with the same key. This is
352cabdff1aSopenharmony_ci *    also meant semantically, i.e., a demuxer should not knowingly produce
353cabdff1aSopenharmony_ci *    several keys that are literally different but semantically identical.
354cabdff1aSopenharmony_ci *    E.g., key=Author5, key=Author6. In this example, all authors must be
355cabdff1aSopenharmony_ci *    placed in the same tag.
356cabdff1aSopenharmony_ci * -  Metadata is flat, not hierarchical; there are no subtags. If you
357cabdff1aSopenharmony_ci *    want to store, e.g., the email address of the child of producer Alice
358cabdff1aSopenharmony_ci *    and actor Bob, that could have key=alice_and_bobs_childs_email_address.
359cabdff1aSopenharmony_ci * -  Several modifiers can be applied to the tag name. This is done by
360cabdff1aSopenharmony_ci *    appending a dash character ('-') and the modifier name in the order
361cabdff1aSopenharmony_ci *    they appear in the list below -- e.g. foo-eng-sort, not foo-sort-eng.
362cabdff1aSopenharmony_ci *    -  language -- a tag whose value is localized for a particular language
363cabdff1aSopenharmony_ci *       is appended with the ISO 639-2/B 3-letter language code.
364cabdff1aSopenharmony_ci *       For example: Author-ger=Michael, Author-eng=Mike
365cabdff1aSopenharmony_ci *       The original/default language is in the unqualified "Author" tag.
366cabdff1aSopenharmony_ci *       A demuxer should set a default if it sets any translated tag.
367cabdff1aSopenharmony_ci *    -  sorting  -- a modified version of a tag that should be used for
368cabdff1aSopenharmony_ci *       sorting will have '-sort' appended. E.g. artist="The Beatles",
369cabdff1aSopenharmony_ci *       artist-sort="Beatles, The".
370cabdff1aSopenharmony_ci * - Some protocols and demuxers support metadata updates. After a successful
371cabdff1aSopenharmony_ci *   call to av_read_frame(), AVFormatContext.event_flags or AVStream.event_flags
372cabdff1aSopenharmony_ci *   will be updated to indicate if metadata changed. In order to detect metadata
373cabdff1aSopenharmony_ci *   changes on a stream, you need to loop through all streams in the AVFormatContext
374cabdff1aSopenharmony_ci *   and check their individual event_flags.
375cabdff1aSopenharmony_ci *
376cabdff1aSopenharmony_ci * -  Demuxers attempt to export metadata in a generic format, however tags
377cabdff1aSopenharmony_ci *    with no generic equivalents are left as they are stored in the container.
378cabdff1aSopenharmony_ci *    Follows a list of generic tag names:
379cabdff1aSopenharmony_ci *
380cabdff1aSopenharmony_ci @verbatim
381cabdff1aSopenharmony_ci album        -- name of the set this work belongs to
382cabdff1aSopenharmony_ci album_artist -- main creator of the set/album, if different from artist.
383cabdff1aSopenharmony_ci                 e.g. "Various Artists" for compilation albums.
384cabdff1aSopenharmony_ci artist       -- main creator of the work
385cabdff1aSopenharmony_ci comment      -- any additional description of the file.
386cabdff1aSopenharmony_ci composer     -- who composed the work, if different from artist.
387cabdff1aSopenharmony_ci copyright    -- name of copyright holder.
388cabdff1aSopenharmony_ci creation_time-- date when the file was created, preferably in ISO 8601.
389cabdff1aSopenharmony_ci date         -- date when the work was created, preferably in ISO 8601.
390cabdff1aSopenharmony_ci disc         -- number of a subset, e.g. disc in a multi-disc collection.
391cabdff1aSopenharmony_ci encoder      -- name/settings of the software/hardware that produced the file.
392cabdff1aSopenharmony_ci encoded_by   -- person/group who created the file.
393cabdff1aSopenharmony_ci filename     -- original name of the file.
394cabdff1aSopenharmony_ci genre        -- <self-evident>.
395cabdff1aSopenharmony_ci language     -- main language in which the work is performed, preferably
396cabdff1aSopenharmony_ci                 in ISO 639-2 format. Multiple languages can be specified by
397cabdff1aSopenharmony_ci                 separating them with commas.
398cabdff1aSopenharmony_ci performer    -- artist who performed the work, if different from artist.
399cabdff1aSopenharmony_ci                 E.g for "Also sprach Zarathustra", artist would be "Richard
400cabdff1aSopenharmony_ci                 Strauss" and performer "London Philharmonic Orchestra".
401cabdff1aSopenharmony_ci publisher    -- name of the label/publisher.
402cabdff1aSopenharmony_ci service_name     -- name of the service in broadcasting (channel name).
403cabdff1aSopenharmony_ci service_provider -- name of the service provider in broadcasting.
404cabdff1aSopenharmony_ci title        -- name of the work.
405cabdff1aSopenharmony_ci track        -- number of this work in the set, can be in form current/total.
406cabdff1aSopenharmony_ci variant_bitrate -- the total bitrate of the bitrate variant that the current stream is part of
407cabdff1aSopenharmony_ci @endverbatim
408cabdff1aSopenharmony_ci *
409cabdff1aSopenharmony_ci * Look in the examples section for an application example how to use the Metadata API.
410cabdff1aSopenharmony_ci *
411cabdff1aSopenharmony_ci * @}
412cabdff1aSopenharmony_ci */
413cabdff1aSopenharmony_ci
414cabdff1aSopenharmony_ci/* packet functions */
415cabdff1aSopenharmony_ci
416cabdff1aSopenharmony_ci
417cabdff1aSopenharmony_ci/**
418cabdff1aSopenharmony_ci * Allocate and read the payload of a packet and initialize its
419cabdff1aSopenharmony_ci * fields with default values.
420cabdff1aSopenharmony_ci *
421cabdff1aSopenharmony_ci * @param s    associated IO context
422cabdff1aSopenharmony_ci * @param pkt packet
423cabdff1aSopenharmony_ci * @param size desired payload size
424cabdff1aSopenharmony_ci * @return >0 (read size) if OK, AVERROR_xxx otherwise
425cabdff1aSopenharmony_ci */
426cabdff1aSopenharmony_ciint av_get_packet(AVIOContext *s, AVPacket *pkt, int size);
427cabdff1aSopenharmony_ci
428cabdff1aSopenharmony_ci
429cabdff1aSopenharmony_ci/**
430cabdff1aSopenharmony_ci * Read data and append it to the current content of the AVPacket.
431cabdff1aSopenharmony_ci * If pkt->size is 0 this is identical to av_get_packet.
432cabdff1aSopenharmony_ci * Note that this uses av_grow_packet and thus involves a realloc
433cabdff1aSopenharmony_ci * which is inefficient. Thus this function should only be used
434cabdff1aSopenharmony_ci * when there is no reasonable way to know (an upper bound of)
435cabdff1aSopenharmony_ci * the final size.
436cabdff1aSopenharmony_ci *
437cabdff1aSopenharmony_ci * @param s    associated IO context
438cabdff1aSopenharmony_ci * @param pkt packet
439cabdff1aSopenharmony_ci * @param size amount of data to read
440cabdff1aSopenharmony_ci * @return >0 (read size) if OK, AVERROR_xxx otherwise, previous data
441cabdff1aSopenharmony_ci *         will not be lost even if an error occurs.
442cabdff1aSopenharmony_ci */
443cabdff1aSopenharmony_ciint av_append_packet(AVIOContext *s, AVPacket *pkt, int size);
444cabdff1aSopenharmony_ci
445cabdff1aSopenharmony_ci/*************************************************/
446cabdff1aSopenharmony_ci/* input/output formats */
447cabdff1aSopenharmony_ci
448cabdff1aSopenharmony_cistruct AVCodecTag;
449cabdff1aSopenharmony_ci
450cabdff1aSopenharmony_ci/**
451cabdff1aSopenharmony_ci * This structure contains the data a format has to probe a file.
452cabdff1aSopenharmony_ci */
453cabdff1aSopenharmony_citypedef struct AVProbeData {
454cabdff1aSopenharmony_ci    const char *filename;
455cabdff1aSopenharmony_ci    unsigned char *buf; /**< Buffer must have AVPROBE_PADDING_SIZE of extra allocated bytes filled with zero. */
456cabdff1aSopenharmony_ci    int buf_size;       /**< Size of buf except extra allocated bytes */
457cabdff1aSopenharmony_ci    const char *mime_type; /**< mime_type, when known. */
458cabdff1aSopenharmony_ci} AVProbeData;
459cabdff1aSopenharmony_ci
460cabdff1aSopenharmony_ci#define AVPROBE_SCORE_RETRY (AVPROBE_SCORE_MAX/4)
461cabdff1aSopenharmony_ci#define AVPROBE_SCORE_STREAM_RETRY (AVPROBE_SCORE_MAX/4-1)
462cabdff1aSopenharmony_ci
463cabdff1aSopenharmony_ci#define AVPROBE_SCORE_EXTENSION  50 ///< score for file extension
464cabdff1aSopenharmony_ci#define AVPROBE_SCORE_MIME       75 ///< score for file mime type
465cabdff1aSopenharmony_ci#define AVPROBE_SCORE_MAX       100 ///< maximum score
466cabdff1aSopenharmony_ci
467cabdff1aSopenharmony_ci#define AVPROBE_PADDING_SIZE 32             ///< extra allocated bytes at the end of the probe buffer
468cabdff1aSopenharmony_ci
469cabdff1aSopenharmony_ci/// Demuxer will use avio_open, no opened file should be provided by the caller.
470cabdff1aSopenharmony_ci#define AVFMT_NOFILE        0x0001
471cabdff1aSopenharmony_ci#define AVFMT_NEEDNUMBER    0x0002 /**< Needs '%d' in filename. */
472cabdff1aSopenharmony_ci/**
473cabdff1aSopenharmony_ci * The muxer/demuxer is experimental and should be used with caution.
474cabdff1aSopenharmony_ci *
475cabdff1aSopenharmony_ci * - demuxers: will not be selected automatically by probing, must be specified
476cabdff1aSopenharmony_ci *             explicitly.
477cabdff1aSopenharmony_ci */
478cabdff1aSopenharmony_ci#define AVFMT_EXPERIMENTAL  0x0004
479cabdff1aSopenharmony_ci#define AVFMT_SHOW_IDS      0x0008 /**< Show format stream IDs numbers. */
480cabdff1aSopenharmony_ci#define AVFMT_GLOBALHEADER  0x0040 /**< Format wants global header. */
481cabdff1aSopenharmony_ci#define AVFMT_NOTIMESTAMPS  0x0080 /**< Format does not need / have any timestamps. */
482cabdff1aSopenharmony_ci#define AVFMT_GENERIC_INDEX 0x0100 /**< Use generic index building code. */
483cabdff1aSopenharmony_ci#define AVFMT_TS_DISCONT    0x0200 /**< Format allows timestamp discontinuities. Note, muxers always require valid (monotone) timestamps */
484cabdff1aSopenharmony_ci#define AVFMT_VARIABLE_FPS  0x0400 /**< Format allows variable fps. */
485cabdff1aSopenharmony_ci#define AVFMT_NODIMENSIONS  0x0800 /**< Format does not need width/height */
486cabdff1aSopenharmony_ci#define AVFMT_NOSTREAMS     0x1000 /**< Format does not require any streams */
487cabdff1aSopenharmony_ci#define AVFMT_NOBINSEARCH   0x2000 /**< Format does not allow to fall back on binary search via read_timestamp */
488cabdff1aSopenharmony_ci#define AVFMT_NOGENSEARCH   0x4000 /**< Format does not allow to fall back on generic search */
489cabdff1aSopenharmony_ci#define AVFMT_NO_BYTE_SEEK  0x8000 /**< Format does not allow seeking by bytes */
490cabdff1aSopenharmony_ci#define AVFMT_ALLOW_FLUSH  0x10000 /**< Format allows flushing. If not set, the muxer will not receive a NULL packet in the write_packet function. */
491cabdff1aSopenharmony_ci#define AVFMT_TS_NONSTRICT 0x20000 /**< Format does not require strictly
492cabdff1aSopenharmony_ci                                        increasing timestamps, but they must
493cabdff1aSopenharmony_ci                                        still be monotonic */
494cabdff1aSopenharmony_ci#define AVFMT_TS_NEGATIVE  0x40000 /**< Format allows muxing negative
495cabdff1aSopenharmony_ci                                        timestamps. If not set the timestamp
496cabdff1aSopenharmony_ci                                        will be shifted in av_write_frame and
497cabdff1aSopenharmony_ci                                        av_interleaved_write_frame so they
498cabdff1aSopenharmony_ci                                        start from 0.
499cabdff1aSopenharmony_ci                                        The user or muxer can override this through
500cabdff1aSopenharmony_ci                                        AVFormatContext.avoid_negative_ts
501cabdff1aSopenharmony_ci                                        */
502cabdff1aSopenharmony_ci
503cabdff1aSopenharmony_ci#define AVFMT_SEEK_TO_PTS   0x4000000 /**< Seeking is based on PTS */
504cabdff1aSopenharmony_ci
505cabdff1aSopenharmony_ci/**
506cabdff1aSopenharmony_ci * @addtogroup lavf_encoding
507cabdff1aSopenharmony_ci * @{
508cabdff1aSopenharmony_ci */
509cabdff1aSopenharmony_citypedef struct AVOutputFormat {
510cabdff1aSopenharmony_ci    const char *name;
511cabdff1aSopenharmony_ci    /**
512cabdff1aSopenharmony_ci     * Descriptive name for the format, meant to be more human-readable
513cabdff1aSopenharmony_ci     * than name. You should use the NULL_IF_CONFIG_SMALL() macro
514cabdff1aSopenharmony_ci     * to define it.
515cabdff1aSopenharmony_ci     */
516cabdff1aSopenharmony_ci    const char *long_name;
517cabdff1aSopenharmony_ci    const char *mime_type;
518cabdff1aSopenharmony_ci    const char *extensions; /**< comma-separated filename extensions */
519cabdff1aSopenharmony_ci    /* output support */
520cabdff1aSopenharmony_ci    enum AVCodecID audio_codec;    /**< default audio codec */
521cabdff1aSopenharmony_ci    enum AVCodecID video_codec;    /**< default video codec */
522cabdff1aSopenharmony_ci    enum AVCodecID subtitle_codec; /**< default subtitle codec */
523cabdff1aSopenharmony_ci    /**
524cabdff1aSopenharmony_ci     * can use flags: AVFMT_NOFILE, AVFMT_NEEDNUMBER,
525cabdff1aSopenharmony_ci     * AVFMT_GLOBALHEADER, AVFMT_NOTIMESTAMPS, AVFMT_VARIABLE_FPS,
526cabdff1aSopenharmony_ci     * AVFMT_NODIMENSIONS, AVFMT_NOSTREAMS, AVFMT_ALLOW_FLUSH,
527cabdff1aSopenharmony_ci     * AVFMT_TS_NONSTRICT, AVFMT_TS_NEGATIVE
528cabdff1aSopenharmony_ci     */
529cabdff1aSopenharmony_ci    int flags;
530cabdff1aSopenharmony_ci
531cabdff1aSopenharmony_ci    /**
532cabdff1aSopenharmony_ci     * List of supported codec_id-codec_tag pairs, ordered by "better
533cabdff1aSopenharmony_ci     * choice first". The arrays are all terminated by AV_CODEC_ID_NONE.
534cabdff1aSopenharmony_ci     */
535cabdff1aSopenharmony_ci    const struct AVCodecTag * const *codec_tag;
536cabdff1aSopenharmony_ci
537cabdff1aSopenharmony_ci
538cabdff1aSopenharmony_ci    const AVClass *priv_class; ///< AVClass for the private context
539cabdff1aSopenharmony_ci
540cabdff1aSopenharmony_ci    /*****************************************************************
541cabdff1aSopenharmony_ci     * No fields below this line are part of the public API. They
542cabdff1aSopenharmony_ci     * may not be used outside of libavformat and can be changed and
543cabdff1aSopenharmony_ci     * removed at will.
544cabdff1aSopenharmony_ci     * New public fields should be added right above.
545cabdff1aSopenharmony_ci     *****************************************************************
546cabdff1aSopenharmony_ci     */
547cabdff1aSopenharmony_ci    /**
548cabdff1aSopenharmony_ci     * size of private data so that it can be allocated in the wrapper
549cabdff1aSopenharmony_ci     */
550cabdff1aSopenharmony_ci    int priv_data_size;
551cabdff1aSopenharmony_ci
552cabdff1aSopenharmony_ci    /**
553cabdff1aSopenharmony_ci     * Internal flags. See FF_FMT_FLAG_* in internal.h.
554cabdff1aSopenharmony_ci     */
555cabdff1aSopenharmony_ci    int flags_internal;
556cabdff1aSopenharmony_ci
557cabdff1aSopenharmony_ci    int (*write_header)(struct AVFormatContext *);
558cabdff1aSopenharmony_ci    /**
559cabdff1aSopenharmony_ci     * Write a packet. If AVFMT_ALLOW_FLUSH is set in flags,
560cabdff1aSopenharmony_ci     * pkt can be NULL in order to flush data buffered in the muxer.
561cabdff1aSopenharmony_ci     * When flushing, return 0 if there still is more data to flush,
562cabdff1aSopenharmony_ci     * or 1 if everything was flushed and there is no more buffered
563cabdff1aSopenharmony_ci     * data.
564cabdff1aSopenharmony_ci     */
565cabdff1aSopenharmony_ci    int (*write_packet)(struct AVFormatContext *, AVPacket *pkt);
566cabdff1aSopenharmony_ci    int (*write_trailer)(struct AVFormatContext *);
567cabdff1aSopenharmony_ci    /**
568cabdff1aSopenharmony_ci     * A format-specific function for interleavement.
569cabdff1aSopenharmony_ci     * If unset, packets will be interleaved by dts.
570cabdff1aSopenharmony_ci     *
571cabdff1aSopenharmony_ci     * @param s           An AVFormatContext for output. pkt will be added to
572cabdff1aSopenharmony_ci     *                    resp. taken from its packet buffer.
573cabdff1aSopenharmony_ci     * @param[in,out] pkt A packet to be interleaved if has_packet is set;
574cabdff1aSopenharmony_ci     *                    also used to return packets. If no packet is returned
575cabdff1aSopenharmony_ci     *                    (e.g. on error), pkt is blank on return.
576cabdff1aSopenharmony_ci     * @param flush       1 if no further packets are available as input and
577cabdff1aSopenharmony_ci     *                    all remaining packets should be output.
578cabdff1aSopenharmony_ci     * @param has_packet  If set, pkt contains a packet to be interleaved
579cabdff1aSopenharmony_ci     *                    on input; otherwise pkt is blank on input.
580cabdff1aSopenharmony_ci     * @return 1 if a packet was output, 0 if no packet could be output,
581cabdff1aSopenharmony_ci     *         < 0 if an error occurred
582cabdff1aSopenharmony_ci     */
583cabdff1aSopenharmony_ci    int (*interleave_packet)(struct AVFormatContext *s, AVPacket *pkt,
584cabdff1aSopenharmony_ci                             int flush, int has_packet);
585cabdff1aSopenharmony_ci    /**
586cabdff1aSopenharmony_ci     * Test if the given codec can be stored in this container.
587cabdff1aSopenharmony_ci     *
588cabdff1aSopenharmony_ci     * @return 1 if the codec is supported, 0 if it is not.
589cabdff1aSopenharmony_ci     *         A negative number if unknown.
590cabdff1aSopenharmony_ci     *         MKTAG('A', 'P', 'I', 'C') if the codec is only supported as AV_DISPOSITION_ATTACHED_PIC
591cabdff1aSopenharmony_ci     */
592cabdff1aSopenharmony_ci    int (*query_codec)(enum AVCodecID id, int std_compliance);
593cabdff1aSopenharmony_ci
594cabdff1aSopenharmony_ci    void (*get_output_timestamp)(struct AVFormatContext *s, int stream,
595cabdff1aSopenharmony_ci                                 int64_t *dts, int64_t *wall);
596cabdff1aSopenharmony_ci    /**
597cabdff1aSopenharmony_ci     * Allows sending messages from application to device.
598cabdff1aSopenharmony_ci     */
599cabdff1aSopenharmony_ci    int (*control_message)(struct AVFormatContext *s, int type,
600cabdff1aSopenharmony_ci                           void *data, size_t data_size);
601cabdff1aSopenharmony_ci
602cabdff1aSopenharmony_ci    /**
603cabdff1aSopenharmony_ci     * Write an uncoded AVFrame.
604cabdff1aSopenharmony_ci     *
605cabdff1aSopenharmony_ci     * See av_write_uncoded_frame() for details.
606cabdff1aSopenharmony_ci     *
607cabdff1aSopenharmony_ci     * The library will free *frame afterwards, but the muxer can prevent it
608cabdff1aSopenharmony_ci     * by setting the pointer to NULL.
609cabdff1aSopenharmony_ci     */
610cabdff1aSopenharmony_ci    int (*write_uncoded_frame)(struct AVFormatContext *, int stream_index,
611cabdff1aSopenharmony_ci                               AVFrame **frame, unsigned flags);
612cabdff1aSopenharmony_ci    /**
613cabdff1aSopenharmony_ci     * Returns device list with it properties.
614cabdff1aSopenharmony_ci     * @see avdevice_list_devices() for more details.
615cabdff1aSopenharmony_ci     */
616cabdff1aSopenharmony_ci    int (*get_device_list)(struct AVFormatContext *s, struct AVDeviceInfoList *device_list);
617cabdff1aSopenharmony_ci    enum AVCodecID data_codec; /**< default data codec */
618cabdff1aSopenharmony_ci    /**
619cabdff1aSopenharmony_ci     * Initialize format. May allocate data here, and set any AVFormatContext or
620cabdff1aSopenharmony_ci     * AVStream parameters that need to be set before packets are sent.
621cabdff1aSopenharmony_ci     * This method must not write output.
622cabdff1aSopenharmony_ci     *
623cabdff1aSopenharmony_ci     * Return 0 if streams were fully configured, 1 if not, negative AVERROR on failure
624cabdff1aSopenharmony_ci     *
625cabdff1aSopenharmony_ci     * Any allocations made here must be freed in deinit().
626cabdff1aSopenharmony_ci     */
627cabdff1aSopenharmony_ci    int (*init)(struct AVFormatContext *);
628cabdff1aSopenharmony_ci    /**
629cabdff1aSopenharmony_ci     * Deinitialize format. If present, this is called whenever the muxer is being
630cabdff1aSopenharmony_ci     * destroyed, regardless of whether or not the header has been written.
631cabdff1aSopenharmony_ci     *
632cabdff1aSopenharmony_ci     * If a trailer is being written, this is called after write_trailer().
633cabdff1aSopenharmony_ci     *
634cabdff1aSopenharmony_ci     * This is called if init() fails as well.
635cabdff1aSopenharmony_ci     */
636cabdff1aSopenharmony_ci    void (*deinit)(struct AVFormatContext *);
637cabdff1aSopenharmony_ci    /**
638cabdff1aSopenharmony_ci     * Set up any necessary bitstream filtering and extract any extra data needed
639cabdff1aSopenharmony_ci     * for the global header.
640cabdff1aSopenharmony_ci     *
641cabdff1aSopenharmony_ci     * @note pkt might have been directly forwarded by a meta-muxer; therefore
642cabdff1aSopenharmony_ci     *       pkt->stream_index as well as the pkt's timebase might be invalid.
643cabdff1aSopenharmony_ci     * Return 0 if more packets from this stream must be checked; 1 if not.
644cabdff1aSopenharmony_ci     */
645cabdff1aSopenharmony_ci    int (*check_bitstream)(struct AVFormatContext *s, struct AVStream *st,
646cabdff1aSopenharmony_ci                           const AVPacket *pkt);
647cabdff1aSopenharmony_ci} AVOutputFormat;
648cabdff1aSopenharmony_ci/**
649cabdff1aSopenharmony_ci * @}
650cabdff1aSopenharmony_ci */
651cabdff1aSopenharmony_ci
652cabdff1aSopenharmony_ci/**
653cabdff1aSopenharmony_ci * @addtogroup lavf_decoding
654cabdff1aSopenharmony_ci * @{
655cabdff1aSopenharmony_ci */
656cabdff1aSopenharmony_citypedef struct AVInputFormat {
657cabdff1aSopenharmony_ci    /**
658cabdff1aSopenharmony_ci     * A comma separated list of short names for the format. New names
659cabdff1aSopenharmony_ci     * may be appended with a minor bump.
660cabdff1aSopenharmony_ci     */
661cabdff1aSopenharmony_ci    const char *name;
662cabdff1aSopenharmony_ci
663cabdff1aSopenharmony_ci    /**
664cabdff1aSopenharmony_ci     * Descriptive name for the format, meant to be more human-readable
665cabdff1aSopenharmony_ci     * than name. You should use the NULL_IF_CONFIG_SMALL() macro
666cabdff1aSopenharmony_ci     * to define it.
667cabdff1aSopenharmony_ci     */
668cabdff1aSopenharmony_ci    const char *long_name;
669cabdff1aSopenharmony_ci
670cabdff1aSopenharmony_ci    /**
671cabdff1aSopenharmony_ci     * Can use flags: AVFMT_NOFILE, AVFMT_NEEDNUMBER, AVFMT_SHOW_IDS,
672cabdff1aSopenharmony_ci     * AVFMT_NOTIMESTAMPS, AVFMT_GENERIC_INDEX, AVFMT_TS_DISCONT, AVFMT_NOBINSEARCH,
673cabdff1aSopenharmony_ci     * AVFMT_NOGENSEARCH, AVFMT_NO_BYTE_SEEK, AVFMT_SEEK_TO_PTS.
674cabdff1aSopenharmony_ci     */
675cabdff1aSopenharmony_ci    int flags;
676cabdff1aSopenharmony_ci
677cabdff1aSopenharmony_ci    /**
678cabdff1aSopenharmony_ci     * If extensions are defined, then no probe is done. You should
679cabdff1aSopenharmony_ci     * usually not use extension format guessing because it is not
680cabdff1aSopenharmony_ci     * reliable enough
681cabdff1aSopenharmony_ci     */
682cabdff1aSopenharmony_ci    const char *extensions;
683cabdff1aSopenharmony_ci
684cabdff1aSopenharmony_ci    const struct AVCodecTag * const *codec_tag;
685cabdff1aSopenharmony_ci
686cabdff1aSopenharmony_ci    const AVClass *priv_class; ///< AVClass for the private context
687cabdff1aSopenharmony_ci
688cabdff1aSopenharmony_ci    /**
689cabdff1aSopenharmony_ci     * Comma-separated list of mime types.
690cabdff1aSopenharmony_ci     * It is used check for matching mime types while probing.
691cabdff1aSopenharmony_ci     * @see av_probe_input_format2
692cabdff1aSopenharmony_ci     */
693cabdff1aSopenharmony_ci    const char *mime_type;
694cabdff1aSopenharmony_ci
695cabdff1aSopenharmony_ci    /*****************************************************************
696cabdff1aSopenharmony_ci     * No fields below this line are part of the public API. They
697cabdff1aSopenharmony_ci     * may not be used outside of libavformat and can be changed and
698cabdff1aSopenharmony_ci     * removed at will.
699cabdff1aSopenharmony_ci     * New public fields should be added right above.
700cabdff1aSopenharmony_ci     *****************************************************************
701cabdff1aSopenharmony_ci     */
702cabdff1aSopenharmony_ci    /**
703cabdff1aSopenharmony_ci     * Raw demuxers store their codec ID here.
704cabdff1aSopenharmony_ci     */
705cabdff1aSopenharmony_ci    int raw_codec_id;
706cabdff1aSopenharmony_ci
707cabdff1aSopenharmony_ci    /**
708cabdff1aSopenharmony_ci     * Size of private data so that it can be allocated in the wrapper.
709cabdff1aSopenharmony_ci     */
710cabdff1aSopenharmony_ci    int priv_data_size;
711cabdff1aSopenharmony_ci
712cabdff1aSopenharmony_ci    /**
713cabdff1aSopenharmony_ci     * Internal flags. See FF_FMT_FLAG_* in internal.h.
714cabdff1aSopenharmony_ci     */
715cabdff1aSopenharmony_ci    int flags_internal;
716cabdff1aSopenharmony_ci
717cabdff1aSopenharmony_ci    /**
718cabdff1aSopenharmony_ci     * Tell if a given file has a chance of being parsed as this format.
719cabdff1aSopenharmony_ci     * The buffer provided is guaranteed to be AVPROBE_PADDING_SIZE bytes
720cabdff1aSopenharmony_ci     * big so you do not have to check for that unless you need more.
721cabdff1aSopenharmony_ci     */
722cabdff1aSopenharmony_ci    int (*read_probe)(const AVProbeData *);
723cabdff1aSopenharmony_ci
724cabdff1aSopenharmony_ci    /**
725cabdff1aSopenharmony_ci     * Read the format header and initialize the AVFormatContext
726cabdff1aSopenharmony_ci     * structure. Return 0 if OK. 'avformat_new_stream' should be
727cabdff1aSopenharmony_ci     * called to create new streams.
728cabdff1aSopenharmony_ci     */
729cabdff1aSopenharmony_ci    int (*read_header)(struct AVFormatContext *);
730cabdff1aSopenharmony_ci
731cabdff1aSopenharmony_ci    /**
732cabdff1aSopenharmony_ci     * Read one packet and put it in 'pkt'. pts and flags are also
733cabdff1aSopenharmony_ci     * set. 'avformat_new_stream' can be called only if the flag
734cabdff1aSopenharmony_ci     * AVFMTCTX_NOHEADER is used and only in the calling thread (not in a
735cabdff1aSopenharmony_ci     * background thread).
736cabdff1aSopenharmony_ci     * @return 0 on success, < 0 on error.
737cabdff1aSopenharmony_ci     *         Upon returning an error, pkt must be unreferenced by the caller.
738cabdff1aSopenharmony_ci     */
739cabdff1aSopenharmony_ci    int (*read_packet)(struct AVFormatContext *, AVPacket *pkt);
740cabdff1aSopenharmony_ci
741cabdff1aSopenharmony_ci    /**
742cabdff1aSopenharmony_ci     * Close the stream. The AVFormatContext and AVStreams are not
743cabdff1aSopenharmony_ci     * freed by this function
744cabdff1aSopenharmony_ci     */
745cabdff1aSopenharmony_ci    int (*read_close)(struct AVFormatContext *);
746cabdff1aSopenharmony_ci
747cabdff1aSopenharmony_ci    /**
748cabdff1aSopenharmony_ci     * Seek to a given timestamp relative to the frames in
749cabdff1aSopenharmony_ci     * stream component stream_index.
750cabdff1aSopenharmony_ci     * @param stream_index Must not be -1.
751cabdff1aSopenharmony_ci     * @param flags Selects which direction should be preferred if no exact
752cabdff1aSopenharmony_ci     *              match is available.
753cabdff1aSopenharmony_ci     * @return >= 0 on success (but not necessarily the new offset)
754cabdff1aSopenharmony_ci     */
755cabdff1aSopenharmony_ci    int (*read_seek)(struct AVFormatContext *,
756cabdff1aSopenharmony_ci                     int stream_index, int64_t timestamp, int flags);
757cabdff1aSopenharmony_ci
758cabdff1aSopenharmony_ci    /**
759cabdff1aSopenharmony_ci     * Get the next timestamp in stream[stream_index].time_base units.
760cabdff1aSopenharmony_ci     * @return the timestamp or AV_NOPTS_VALUE if an error occurred
761cabdff1aSopenharmony_ci     */
762cabdff1aSopenharmony_ci    int64_t (*read_timestamp)(struct AVFormatContext *s, int stream_index,
763cabdff1aSopenharmony_ci                              int64_t *pos, int64_t pos_limit);
764cabdff1aSopenharmony_ci
765cabdff1aSopenharmony_ci    /**
766cabdff1aSopenharmony_ci     * Start/resume playing - only meaningful if using a network-based format
767cabdff1aSopenharmony_ci     * (RTSP).
768cabdff1aSopenharmony_ci     */
769cabdff1aSopenharmony_ci    int (*read_play)(struct AVFormatContext *);
770cabdff1aSopenharmony_ci
771cabdff1aSopenharmony_ci    /**
772cabdff1aSopenharmony_ci     * Pause playing - only meaningful if using a network-based format
773cabdff1aSopenharmony_ci     * (RTSP).
774cabdff1aSopenharmony_ci     */
775cabdff1aSopenharmony_ci    int (*read_pause)(struct AVFormatContext *);
776cabdff1aSopenharmony_ci
777cabdff1aSopenharmony_ci    /**
778cabdff1aSopenharmony_ci     * Seek to timestamp ts.
779cabdff1aSopenharmony_ci     * Seeking will be done so that the point from which all active streams
780cabdff1aSopenharmony_ci     * can be presented successfully will be closest to ts and within min/max_ts.
781cabdff1aSopenharmony_ci     * Active streams are all streams that have AVStream.discard < AVDISCARD_ALL.
782cabdff1aSopenharmony_ci     */
783cabdff1aSopenharmony_ci    int (*read_seek2)(struct AVFormatContext *s, int stream_index, int64_t min_ts, int64_t ts, int64_t max_ts, int flags);
784cabdff1aSopenharmony_ci
785cabdff1aSopenharmony_ci    /**
786cabdff1aSopenharmony_ci     * Returns device list with it properties.
787cabdff1aSopenharmony_ci     * @see avdevice_list_devices() for more details.
788cabdff1aSopenharmony_ci     */
789cabdff1aSopenharmony_ci    int (*get_device_list)(struct AVFormatContext *s, struct AVDeviceInfoList *device_list);
790cabdff1aSopenharmony_ci
791cabdff1aSopenharmony_ci} AVInputFormat;
792cabdff1aSopenharmony_ci/**
793cabdff1aSopenharmony_ci * @}
794cabdff1aSopenharmony_ci */
795cabdff1aSopenharmony_ci
796cabdff1aSopenharmony_cienum AVStreamParseType {
797cabdff1aSopenharmony_ci    AVSTREAM_PARSE_NONE,
798cabdff1aSopenharmony_ci    AVSTREAM_PARSE_FULL,       /**< full parsing and repack */
799cabdff1aSopenharmony_ci    AVSTREAM_PARSE_HEADERS,    /**< Only parse headers, do not repack. */
800cabdff1aSopenharmony_ci    AVSTREAM_PARSE_TIMESTAMPS, /**< full parsing and interpolation of timestamps for frames not starting on a packet boundary */
801cabdff1aSopenharmony_ci    AVSTREAM_PARSE_FULL_ONCE,  /**< full parsing and repack of the first frame only, only implemented for H.264 currently */
802cabdff1aSopenharmony_ci    AVSTREAM_PARSE_FULL_RAW,   /**< full parsing and repack with timestamp and position generation by parser for raw
803cabdff1aSopenharmony_ci                                    this assumes that each packet in the file contains no demuxer level headers and
804cabdff1aSopenharmony_ci                                    just codec level data, otherwise position generation would fail */
805cabdff1aSopenharmony_ci};
806cabdff1aSopenharmony_ci
807cabdff1aSopenharmony_citypedef struct AVIndexEntry {
808cabdff1aSopenharmony_ci    int64_t pos;
809cabdff1aSopenharmony_ci    int64_t timestamp;        /**<
810cabdff1aSopenharmony_ci                               * Timestamp in AVStream.time_base units, preferably the time from which on correctly decoded frames are available
811cabdff1aSopenharmony_ci                               * when seeking to this entry. That means preferable PTS on keyframe based formats.
812cabdff1aSopenharmony_ci                               * But demuxers can choose to store a different timestamp, if it is more convenient for the implementation or nothing better
813cabdff1aSopenharmony_ci                               * is known
814cabdff1aSopenharmony_ci                               */
815cabdff1aSopenharmony_ci#define AVINDEX_KEYFRAME 0x0001
816cabdff1aSopenharmony_ci#define AVINDEX_DISCARD_FRAME  0x0002    /**
817cabdff1aSopenharmony_ci                                          * Flag is used to indicate which frame should be discarded after decoding.
818cabdff1aSopenharmony_ci                                          */
819cabdff1aSopenharmony_ci    int flags:2;
820cabdff1aSopenharmony_ci    int size:30; //Yeah, trying to keep the size of this small to reduce memory requirements (it is 24 vs. 32 bytes due to possible 8-byte alignment).
821cabdff1aSopenharmony_ci    int min_distance;         /**< Minimum distance between this and the previous keyframe, used to avoid unneeded searching. */
822cabdff1aSopenharmony_ci} AVIndexEntry;
823cabdff1aSopenharmony_ci
824cabdff1aSopenharmony_ci/**
825cabdff1aSopenharmony_ci * The stream should be chosen by default among other streams of the same type,
826cabdff1aSopenharmony_ci * unless the user has explicitly specified otherwise.
827cabdff1aSopenharmony_ci */
828cabdff1aSopenharmony_ci#define AV_DISPOSITION_DEFAULT              (1 << 0)
829cabdff1aSopenharmony_ci/**
830cabdff1aSopenharmony_ci * The stream is not in original language.
831cabdff1aSopenharmony_ci *
832cabdff1aSopenharmony_ci * @note AV_DISPOSITION_ORIGINAL is the inverse of this disposition. At most
833cabdff1aSopenharmony_ci *       one of them should be set in properly tagged streams.
834cabdff1aSopenharmony_ci * @note This disposition may apply to any stream type, not just audio.
835cabdff1aSopenharmony_ci */
836cabdff1aSopenharmony_ci#define AV_DISPOSITION_DUB                  (1 << 1)
837cabdff1aSopenharmony_ci/**
838cabdff1aSopenharmony_ci * The stream is in original language.
839cabdff1aSopenharmony_ci *
840cabdff1aSopenharmony_ci * @see the notes for AV_DISPOSITION_DUB
841cabdff1aSopenharmony_ci */
842cabdff1aSopenharmony_ci#define AV_DISPOSITION_ORIGINAL             (1 << 2)
843cabdff1aSopenharmony_ci/**
844cabdff1aSopenharmony_ci * The stream is a commentary track.
845cabdff1aSopenharmony_ci */
846cabdff1aSopenharmony_ci#define AV_DISPOSITION_COMMENT              (1 << 3)
847cabdff1aSopenharmony_ci/**
848cabdff1aSopenharmony_ci * The stream contains song lyrics.
849cabdff1aSopenharmony_ci */
850cabdff1aSopenharmony_ci#define AV_DISPOSITION_LYRICS               (1 << 4)
851cabdff1aSopenharmony_ci/**
852cabdff1aSopenharmony_ci * The stream contains karaoke audio.
853cabdff1aSopenharmony_ci */
854cabdff1aSopenharmony_ci#define AV_DISPOSITION_KARAOKE              (1 << 5)
855cabdff1aSopenharmony_ci
856cabdff1aSopenharmony_ci/**
857cabdff1aSopenharmony_ci * Track should be used during playback by default.
858cabdff1aSopenharmony_ci * Useful for subtitle track that should be displayed
859cabdff1aSopenharmony_ci * even when user did not explicitly ask for subtitles.
860cabdff1aSopenharmony_ci */
861cabdff1aSopenharmony_ci#define AV_DISPOSITION_FORCED               (1 << 6)
862cabdff1aSopenharmony_ci/**
863cabdff1aSopenharmony_ci * The stream is intended for hearing impaired audiences.
864cabdff1aSopenharmony_ci */
865cabdff1aSopenharmony_ci#define AV_DISPOSITION_HEARING_IMPAIRED     (1 << 7)
866cabdff1aSopenharmony_ci/**
867cabdff1aSopenharmony_ci * The stream is intended for visually impaired audiences.
868cabdff1aSopenharmony_ci */
869cabdff1aSopenharmony_ci#define AV_DISPOSITION_VISUAL_IMPAIRED      (1 << 8)
870cabdff1aSopenharmony_ci/**
871cabdff1aSopenharmony_ci * The audio stream contains music and sound effects without voice.
872cabdff1aSopenharmony_ci */
873cabdff1aSopenharmony_ci#define AV_DISPOSITION_CLEAN_EFFECTS        (1 << 9)
874cabdff1aSopenharmony_ci/**
875cabdff1aSopenharmony_ci * The stream is stored in the file as an attached picture/"cover art" (e.g.
876cabdff1aSopenharmony_ci * APIC frame in ID3v2). The first (usually only) packet associated with it
877cabdff1aSopenharmony_ci * will be returned among the first few packets read from the file unless
878cabdff1aSopenharmony_ci * seeking takes place. It can also be accessed at any time in
879cabdff1aSopenharmony_ci * AVStream.attached_pic.
880cabdff1aSopenharmony_ci */
881cabdff1aSopenharmony_ci#define AV_DISPOSITION_ATTACHED_PIC         (1 << 10)
882cabdff1aSopenharmony_ci/**
883cabdff1aSopenharmony_ci * The stream is sparse, and contains thumbnail images, often corresponding
884cabdff1aSopenharmony_ci * to chapter markers. Only ever used with AV_DISPOSITION_ATTACHED_PIC.
885cabdff1aSopenharmony_ci */
886cabdff1aSopenharmony_ci#define AV_DISPOSITION_TIMED_THUMBNAILS     (1 << 11)
887cabdff1aSopenharmony_ci
888cabdff1aSopenharmony_ci/**
889cabdff1aSopenharmony_ci * The stream is intended to be mixed with a spatial audio track. For example,
890cabdff1aSopenharmony_ci * it could be used for narration or stereo music, and may remain unchanged by
891cabdff1aSopenharmony_ci * listener head rotation.
892cabdff1aSopenharmony_ci */
893cabdff1aSopenharmony_ci#define AV_DISPOSITION_NON_DIEGETIC         (1 << 12)
894cabdff1aSopenharmony_ci
895cabdff1aSopenharmony_ci/**
896cabdff1aSopenharmony_ci * The subtitle stream contains captions, providing a transcription and possibly
897cabdff1aSopenharmony_ci * a translation of audio. Typically intended for hearing-impaired audiences.
898cabdff1aSopenharmony_ci */
899cabdff1aSopenharmony_ci#define AV_DISPOSITION_CAPTIONS             (1 << 16)
900cabdff1aSopenharmony_ci/**
901cabdff1aSopenharmony_ci * The subtitle stream contains a textual description of the video content.
902cabdff1aSopenharmony_ci * Typically intended for visually-impaired audiences or for the cases where the
903cabdff1aSopenharmony_ci * video cannot be seen.
904cabdff1aSopenharmony_ci */
905cabdff1aSopenharmony_ci#define AV_DISPOSITION_DESCRIPTIONS         (1 << 17)
906cabdff1aSopenharmony_ci/**
907cabdff1aSopenharmony_ci * The subtitle stream contains time-aligned metadata that is not intended to be
908cabdff1aSopenharmony_ci * directly presented to the user.
909cabdff1aSopenharmony_ci */
910cabdff1aSopenharmony_ci#define AV_DISPOSITION_METADATA             (1 << 18)
911cabdff1aSopenharmony_ci/**
912cabdff1aSopenharmony_ci * The audio stream is intended to be mixed with another stream before
913cabdff1aSopenharmony_ci * presentation.
914cabdff1aSopenharmony_ci * Corresponds to mix_type=0 in mpegts.
915cabdff1aSopenharmony_ci */
916cabdff1aSopenharmony_ci#define AV_DISPOSITION_DEPENDENT            (1 << 19)
917cabdff1aSopenharmony_ci/**
918cabdff1aSopenharmony_ci * The video stream contains still images.
919cabdff1aSopenharmony_ci */
920cabdff1aSopenharmony_ci#define AV_DISPOSITION_STILL_IMAGE          (1 << 20)
921cabdff1aSopenharmony_ci
922cabdff1aSopenharmony_ci/**
923cabdff1aSopenharmony_ci * @return The AV_DISPOSITION_* flag corresponding to disp or a negative error
924cabdff1aSopenharmony_ci *         code if disp does not correspond to a known stream disposition.
925cabdff1aSopenharmony_ci */
926cabdff1aSopenharmony_ciint av_disposition_from_string(const char *disp);
927cabdff1aSopenharmony_ci
928cabdff1aSopenharmony_ci/**
929cabdff1aSopenharmony_ci * @param disposition a combination of AV_DISPOSITION_* values
930cabdff1aSopenharmony_ci * @return The string description corresponding to the lowest set bit in
931cabdff1aSopenharmony_ci *         disposition. NULL when the lowest set bit does not correspond
932cabdff1aSopenharmony_ci *         to a known disposition or when disposition is 0.
933cabdff1aSopenharmony_ci */
934cabdff1aSopenharmony_ciconst char *av_disposition_to_string(int disposition);
935cabdff1aSopenharmony_ci
936cabdff1aSopenharmony_ci/**
937cabdff1aSopenharmony_ci * Options for behavior on timestamp wrap detection.
938cabdff1aSopenharmony_ci */
939cabdff1aSopenharmony_ci#define AV_PTS_WRAP_IGNORE      0   ///< ignore the wrap
940cabdff1aSopenharmony_ci#define AV_PTS_WRAP_ADD_OFFSET  1   ///< add the format specific offset on wrap detection
941cabdff1aSopenharmony_ci#define AV_PTS_WRAP_SUB_OFFSET  -1  ///< subtract the format specific offset on wrap detection
942cabdff1aSopenharmony_ci
943cabdff1aSopenharmony_citypedef struct AVMOVStts {
944cabdff1aSopenharmony_ci    unsigned int count;
945cabdff1aSopenharmony_ci    unsigned int duration;
946cabdff1aSopenharmony_ci} AVMOVStts;
947cabdff1aSopenharmony_ci
948cabdff1aSopenharmony_citypedef struct AVMOVCtts {
949cabdff1aSopenharmony_ci    unsigned int count;
950cabdff1aSopenharmony_ci    int duration;
951cabdff1aSopenharmony_ci} AVMOVCtts;
952cabdff1aSopenharmony_ci
953cabdff1aSopenharmony_ci/**
954cabdff1aSopenharmony_ci * Stream structure.
955cabdff1aSopenharmony_ci * New fields can be added to the end with minor version bumps.
956cabdff1aSopenharmony_ci * Removal, reordering and changes to existing fields require a major
957cabdff1aSopenharmony_ci * version bump.
958cabdff1aSopenharmony_ci * sizeof(AVStream) must not be used outside libav*.
959cabdff1aSopenharmony_ci */
960cabdff1aSopenharmony_citypedef struct AVStream {
961cabdff1aSopenharmony_ci#if FF_API_AVSTREAM_CLASS
962cabdff1aSopenharmony_ci    /**
963cabdff1aSopenharmony_ci     * A class for @ref avoptions. Set on stream creation.
964cabdff1aSopenharmony_ci     */
965cabdff1aSopenharmony_ci    const AVClass *av_class;
966cabdff1aSopenharmony_ci#endif
967cabdff1aSopenharmony_ci
968cabdff1aSopenharmony_ci    int index;    /**< stream index in AVFormatContext */
969cabdff1aSopenharmony_ci    /**
970cabdff1aSopenharmony_ci     * Format-specific stream ID.
971cabdff1aSopenharmony_ci     * decoding: set by libavformat
972cabdff1aSopenharmony_ci     * encoding: set by the user, replaced by libavformat if left unset
973cabdff1aSopenharmony_ci     */
974cabdff1aSopenharmony_ci    int id;
975cabdff1aSopenharmony_ci
976cabdff1aSopenharmony_ci    void *priv_data;
977cabdff1aSopenharmony_ci
978cabdff1aSopenharmony_ci    /**
979cabdff1aSopenharmony_ci     * This is the fundamental unit of time (in seconds) in terms
980cabdff1aSopenharmony_ci     * of which frame timestamps are represented.
981cabdff1aSopenharmony_ci     *
982cabdff1aSopenharmony_ci     * decoding: set by libavformat
983cabdff1aSopenharmony_ci     * encoding: May be set by the caller before avformat_write_header() to
984cabdff1aSopenharmony_ci     *           provide a hint to the muxer about the desired timebase. In
985cabdff1aSopenharmony_ci     *           avformat_write_header(), the muxer will overwrite this field
986cabdff1aSopenharmony_ci     *           with the timebase that will actually be used for the timestamps
987cabdff1aSopenharmony_ci     *           written into the file (which may or may not be related to the
988cabdff1aSopenharmony_ci     *           user-provided one, depending on the format).
989cabdff1aSopenharmony_ci     */
990cabdff1aSopenharmony_ci    AVRational time_base;
991cabdff1aSopenharmony_ci
992cabdff1aSopenharmony_ci    /**
993cabdff1aSopenharmony_ci     * Decoding: pts of the first frame of the stream in presentation order, in stream time base.
994cabdff1aSopenharmony_ci     * Only set this if you are absolutely 100% sure that the value you set
995cabdff1aSopenharmony_ci     * it to really is the pts of the first frame.
996cabdff1aSopenharmony_ci     * This may be undefined (AV_NOPTS_VALUE).
997cabdff1aSopenharmony_ci     * @note The ASF header does NOT contain a correct start_time the ASF
998cabdff1aSopenharmony_ci     * demuxer must NOT set this.
999cabdff1aSopenharmony_ci     */
1000cabdff1aSopenharmony_ci    int64_t start_time;
1001cabdff1aSopenharmony_ci
1002cabdff1aSopenharmony_ci    /**
1003cabdff1aSopenharmony_ci     * Decoding: duration of the stream, in stream time base.
1004cabdff1aSopenharmony_ci     * If a source file does not specify a duration, but does specify
1005cabdff1aSopenharmony_ci     * a bitrate, this value will be estimated from bitrate and file size.
1006cabdff1aSopenharmony_ci     *
1007cabdff1aSopenharmony_ci     * Encoding: May be set by the caller before avformat_write_header() to
1008cabdff1aSopenharmony_ci     * provide a hint to the muxer about the estimated duration.
1009cabdff1aSopenharmony_ci     */
1010cabdff1aSopenharmony_ci    int64_t duration;
1011cabdff1aSopenharmony_ci
1012cabdff1aSopenharmony_ci    int64_t nb_frames;                 ///< number of frames in this stream if known or 0
1013cabdff1aSopenharmony_ci
1014cabdff1aSopenharmony_ci    /**
1015cabdff1aSopenharmony_ci     * Stream disposition - a combination of AV_DISPOSITION_* flags.
1016cabdff1aSopenharmony_ci     * - demuxing: set by libavformat when creating the stream or in
1017cabdff1aSopenharmony_ci     *             avformat_find_stream_info().
1018cabdff1aSopenharmony_ci     * - muxing: may be set by the caller before avformat_write_header().
1019cabdff1aSopenharmony_ci     */
1020cabdff1aSopenharmony_ci    int disposition;
1021cabdff1aSopenharmony_ci
1022cabdff1aSopenharmony_ci    enum AVDiscard discard; ///< Selects which packets can be discarded at will and do not need to be demuxed.
1023cabdff1aSopenharmony_ci
1024cabdff1aSopenharmony_ci    /**
1025cabdff1aSopenharmony_ci     * sample aspect ratio (0 if unknown)
1026cabdff1aSopenharmony_ci     * - encoding: Set by user.
1027cabdff1aSopenharmony_ci     * - decoding: Set by libavformat.
1028cabdff1aSopenharmony_ci     */
1029cabdff1aSopenharmony_ci    AVRational sample_aspect_ratio;
1030cabdff1aSopenharmony_ci
1031cabdff1aSopenharmony_ci    AVDictionary *metadata;
1032cabdff1aSopenharmony_ci
1033cabdff1aSopenharmony_ci    /**
1034cabdff1aSopenharmony_ci     * Average framerate
1035cabdff1aSopenharmony_ci     *
1036cabdff1aSopenharmony_ci     * - demuxing: May be set by libavformat when creating the stream or in
1037cabdff1aSopenharmony_ci     *             avformat_find_stream_info().
1038cabdff1aSopenharmony_ci     * - muxing: May be set by the caller before avformat_write_header().
1039cabdff1aSopenharmony_ci     */
1040cabdff1aSopenharmony_ci    AVRational avg_frame_rate;
1041cabdff1aSopenharmony_ci
1042cabdff1aSopenharmony_ci    /**
1043cabdff1aSopenharmony_ci     * For streams with AV_DISPOSITION_ATTACHED_PIC disposition, this packet
1044cabdff1aSopenharmony_ci     * will contain the attached picture.
1045cabdff1aSopenharmony_ci     *
1046cabdff1aSopenharmony_ci     * decoding: set by libavformat, must not be modified by the caller.
1047cabdff1aSopenharmony_ci     * encoding: unused
1048cabdff1aSopenharmony_ci     */
1049cabdff1aSopenharmony_ci    AVPacket attached_pic;
1050cabdff1aSopenharmony_ci
1051cabdff1aSopenharmony_ci    /**
1052cabdff1aSopenharmony_ci     * An array of side data that applies to the whole stream (i.e. the
1053cabdff1aSopenharmony_ci     * container does not allow it to change between packets).
1054cabdff1aSopenharmony_ci     *
1055cabdff1aSopenharmony_ci     * There may be no overlap between the side data in this array and side data
1056cabdff1aSopenharmony_ci     * in the packets. I.e. a given side data is either exported by the muxer
1057cabdff1aSopenharmony_ci     * (demuxing) / set by the caller (muxing) in this array, then it never
1058cabdff1aSopenharmony_ci     * appears in the packets, or the side data is exported / sent through
1059cabdff1aSopenharmony_ci     * the packets (always in the first packet where the value becomes known or
1060cabdff1aSopenharmony_ci     * changes), then it does not appear in this array.
1061cabdff1aSopenharmony_ci     *
1062cabdff1aSopenharmony_ci     * - demuxing: Set by libavformat when the stream is created.
1063cabdff1aSopenharmony_ci     * - muxing: May be set by the caller before avformat_write_header().
1064cabdff1aSopenharmony_ci     *
1065cabdff1aSopenharmony_ci     * Freed by libavformat in avformat_free_context().
1066cabdff1aSopenharmony_ci     *
1067cabdff1aSopenharmony_ci     * @see av_format_inject_global_side_data()
1068cabdff1aSopenharmony_ci     */
1069cabdff1aSopenharmony_ci    AVPacketSideData *side_data;
1070cabdff1aSopenharmony_ci    /**
1071cabdff1aSopenharmony_ci     * The number of elements in the AVStream.side_data array.
1072cabdff1aSopenharmony_ci     */
1073cabdff1aSopenharmony_ci    int            nb_side_data;
1074cabdff1aSopenharmony_ci
1075cabdff1aSopenharmony_ci    /**
1076cabdff1aSopenharmony_ci     * Flags indicating events happening on the stream, a combination of
1077cabdff1aSopenharmony_ci     * AVSTREAM_EVENT_FLAG_*.
1078cabdff1aSopenharmony_ci     *
1079cabdff1aSopenharmony_ci     * - demuxing: may be set by the demuxer in avformat_open_input(),
1080cabdff1aSopenharmony_ci     *   avformat_find_stream_info() and av_read_frame(). Flags must be cleared
1081cabdff1aSopenharmony_ci     *   by the user once the event has been handled.
1082cabdff1aSopenharmony_ci     * - muxing: may be set by the user after avformat_write_header(). to
1083cabdff1aSopenharmony_ci     *   indicate a user-triggered event.  The muxer will clear the flags for
1084cabdff1aSopenharmony_ci     *   events it has handled in av_[interleaved]_write_frame().
1085cabdff1aSopenharmony_ci     */
1086cabdff1aSopenharmony_ci    int event_flags;
1087cabdff1aSopenharmony_ci/**
1088cabdff1aSopenharmony_ci * - demuxing: the demuxer read new metadata from the file and updated
1089cabdff1aSopenharmony_ci *     AVStream.metadata accordingly
1090cabdff1aSopenharmony_ci * - muxing: the user updated AVStream.metadata and wishes the muxer to write
1091cabdff1aSopenharmony_ci *     it into the file
1092cabdff1aSopenharmony_ci */
1093cabdff1aSopenharmony_ci#define AVSTREAM_EVENT_FLAG_METADATA_UPDATED 0x0001
1094cabdff1aSopenharmony_ci/**
1095cabdff1aSopenharmony_ci * - demuxing: new packets for this stream were read from the file. This
1096cabdff1aSopenharmony_ci *   event is informational only and does not guarantee that new packets
1097cabdff1aSopenharmony_ci *   for this stream will necessarily be returned from av_read_frame().
1098cabdff1aSopenharmony_ci */
1099cabdff1aSopenharmony_ci#define AVSTREAM_EVENT_FLAG_NEW_PACKETS (1 << 1)
1100cabdff1aSopenharmony_ci
1101cabdff1aSopenharmony_ci    /**
1102cabdff1aSopenharmony_ci     * Real base framerate of the stream.
1103cabdff1aSopenharmony_ci     * This is the lowest framerate with which all timestamps can be
1104cabdff1aSopenharmony_ci     * represented accurately (it is the least common multiple of all
1105cabdff1aSopenharmony_ci     * framerates in the stream). Note, this value is just a guess!
1106cabdff1aSopenharmony_ci     * For example, if the time base is 1/90000 and all frames have either
1107cabdff1aSopenharmony_ci     * approximately 3600 or 1800 timer ticks, then r_frame_rate will be 50/1.
1108cabdff1aSopenharmony_ci     */
1109cabdff1aSopenharmony_ci    AVRational r_frame_rate;
1110cabdff1aSopenharmony_ci
1111cabdff1aSopenharmony_ci    /**
1112cabdff1aSopenharmony_ci     * Codec parameters associated with this stream. Allocated and freed by
1113cabdff1aSopenharmony_ci     * libavformat in avformat_new_stream() and avformat_free_context()
1114cabdff1aSopenharmony_ci     * respectively.
1115cabdff1aSopenharmony_ci     *
1116cabdff1aSopenharmony_ci     * - demuxing: filled by libavformat on stream creation or in
1117cabdff1aSopenharmony_ci     *             avformat_find_stream_info()
1118cabdff1aSopenharmony_ci     * - muxing: filled by the caller before avformat_write_header()
1119cabdff1aSopenharmony_ci     */
1120cabdff1aSopenharmony_ci    AVCodecParameters *codecpar;
1121cabdff1aSopenharmony_ci
1122cabdff1aSopenharmony_ci    /**
1123cabdff1aSopenharmony_ci     * Number of bits in timestamps. Used for wrapping control.
1124cabdff1aSopenharmony_ci     *
1125cabdff1aSopenharmony_ci     * - demuxing: set by libavformat
1126cabdff1aSopenharmony_ci     * - muxing: set by libavformat
1127cabdff1aSopenharmony_ci     *
1128cabdff1aSopenharmony_ci     */
1129cabdff1aSopenharmony_ci    int pts_wrap_bits;
1130cabdff1aSopenharmony_ci
1131cabdff1aSopenharmony_ci    /**
1132cabdff1aSopenharmony_ci     * Array derived from ffmpeg
1133cabdff1aSopenharmony_ci     *
1134cabdff1aSopenharmony_ci     * used to fetch stts_data and ctts_data of mov files
1135cabdff1aSopenharmony_ci     */
1136cabdff1aSopenharmony_ci    unsigned int stts_count;
1137cabdff1aSopenharmony_ci    AVMOVStts *stts_data;
1138cabdff1aSopenharmony_ci
1139cabdff1aSopenharmony_ci    unsigned int ctts_count;
1140cabdff1aSopenharmony_ci    AVMOVCtts *ctts_data;
1141cabdff1aSopenharmony_ci
1142cabdff1aSopenharmony_ci    int time_scale;
1143cabdff1aSopenharmony_ci} AVStream;
1144cabdff1aSopenharmony_ci
1145cabdff1aSopenharmony_cistruct AVCodecParserContext *av_stream_get_parser(const AVStream *s);
1146cabdff1aSopenharmony_ci
1147cabdff1aSopenharmony_ci/**
1148cabdff1aSopenharmony_ci * Returns the pts of the last muxed packet + its duration
1149cabdff1aSopenharmony_ci *
1150cabdff1aSopenharmony_ci * the retuned value is undefined when used with a demuxer.
1151cabdff1aSopenharmony_ci */
1152cabdff1aSopenharmony_ciint64_t    av_stream_get_end_pts(const AVStream *st);
1153cabdff1aSopenharmony_ci
1154cabdff1aSopenharmony_ci#define AV_PROGRAM_RUNNING 1
1155cabdff1aSopenharmony_ci
1156cabdff1aSopenharmony_ci/**
1157cabdff1aSopenharmony_ci * New fields can be added to the end with minor version bumps.
1158cabdff1aSopenharmony_ci * Removal, reordering and changes to existing fields require a major
1159cabdff1aSopenharmony_ci * version bump.
1160cabdff1aSopenharmony_ci * sizeof(AVProgram) must not be used outside libav*.
1161cabdff1aSopenharmony_ci */
1162cabdff1aSopenharmony_citypedef struct AVProgram {
1163cabdff1aSopenharmony_ci    int            id;
1164cabdff1aSopenharmony_ci    int            flags;
1165cabdff1aSopenharmony_ci    enum AVDiscard discard;        ///< selects which program to discard and which to feed to the caller
1166cabdff1aSopenharmony_ci    unsigned int   *stream_index;
1167cabdff1aSopenharmony_ci    unsigned int   nb_stream_indexes;
1168cabdff1aSopenharmony_ci    AVDictionary *metadata;
1169cabdff1aSopenharmony_ci
1170cabdff1aSopenharmony_ci    int program_num;
1171cabdff1aSopenharmony_ci    int pmt_pid;
1172cabdff1aSopenharmony_ci    int pcr_pid;
1173cabdff1aSopenharmony_ci    int pmt_version;
1174cabdff1aSopenharmony_ci
1175cabdff1aSopenharmony_ci    /*****************************************************************
1176cabdff1aSopenharmony_ci     * All fields below this line are not part of the public API. They
1177cabdff1aSopenharmony_ci     * may not be used outside of libavformat and can be changed and
1178cabdff1aSopenharmony_ci     * removed at will.
1179cabdff1aSopenharmony_ci     * New public fields should be added right above.
1180cabdff1aSopenharmony_ci     *****************************************************************
1181cabdff1aSopenharmony_ci     */
1182cabdff1aSopenharmony_ci    int64_t start_time;
1183cabdff1aSopenharmony_ci    int64_t end_time;
1184cabdff1aSopenharmony_ci
1185cabdff1aSopenharmony_ci    int64_t pts_wrap_reference;    ///< reference dts for wrap detection
1186cabdff1aSopenharmony_ci    int pts_wrap_behavior;         ///< behavior on wrap detection
1187cabdff1aSopenharmony_ci} AVProgram;
1188cabdff1aSopenharmony_ci
1189cabdff1aSopenharmony_ci#define AVFMTCTX_NOHEADER      0x0001 /**< signal that no header is present
1190cabdff1aSopenharmony_ci                                         (streams are added dynamically) */
1191cabdff1aSopenharmony_ci#define AVFMTCTX_UNSEEKABLE    0x0002 /**< signal that the stream is definitely
1192cabdff1aSopenharmony_ci                                         not seekable, and attempts to call the
1193cabdff1aSopenharmony_ci                                         seek function will fail. For some
1194cabdff1aSopenharmony_ci                                         network protocols (e.g. HLS), this can
1195cabdff1aSopenharmony_ci                                         change dynamically at runtime. */
1196cabdff1aSopenharmony_ci
1197cabdff1aSopenharmony_citypedef struct AVChapter {
1198cabdff1aSopenharmony_ci    int64_t id;             ///< unique ID to identify the chapter
1199cabdff1aSopenharmony_ci    AVRational time_base;   ///< time base in which the start/end timestamps are specified
1200cabdff1aSopenharmony_ci    int64_t start, end;     ///< chapter start/end time in time_base units
1201cabdff1aSopenharmony_ci    AVDictionary *metadata;
1202cabdff1aSopenharmony_ci} AVChapter;
1203cabdff1aSopenharmony_ci
1204cabdff1aSopenharmony_ci
1205cabdff1aSopenharmony_ci/**
1206cabdff1aSopenharmony_ci * Callback used by devices to communicate with application.
1207cabdff1aSopenharmony_ci */
1208cabdff1aSopenharmony_citypedef int (*av_format_control_message)(struct AVFormatContext *s, int type,
1209cabdff1aSopenharmony_ci                                         void *data, size_t data_size);
1210cabdff1aSopenharmony_ci
1211cabdff1aSopenharmony_citypedef int (*AVOpenCallback)(struct AVFormatContext *s, AVIOContext **pb, const char *url, int flags,
1212cabdff1aSopenharmony_ci                              const AVIOInterruptCB *int_cb, AVDictionary **options);
1213cabdff1aSopenharmony_ci
1214cabdff1aSopenharmony_ci/**
1215cabdff1aSopenharmony_ci * The duration of a video can be estimated through various ways, and this enum can be used
1216cabdff1aSopenharmony_ci * to know how the duration was estimated.
1217cabdff1aSopenharmony_ci */
1218cabdff1aSopenharmony_cienum AVDurationEstimationMethod {
1219cabdff1aSopenharmony_ci    AVFMT_DURATION_FROM_PTS,    ///< Duration accurately estimated from PTSes
1220cabdff1aSopenharmony_ci    AVFMT_DURATION_FROM_STREAM, ///< Duration estimated from a stream with a known duration
1221cabdff1aSopenharmony_ci    AVFMT_DURATION_FROM_BITRATE ///< Duration estimated from bitrate (less accurate)
1222cabdff1aSopenharmony_ci};
1223cabdff1aSopenharmony_ci
1224cabdff1aSopenharmony_ci/**
1225cabdff1aSopenharmony_ci * Format I/O context.
1226cabdff1aSopenharmony_ci * New fields can be added to the end with minor version bumps.
1227cabdff1aSopenharmony_ci * Removal, reordering and changes to existing fields require a major
1228cabdff1aSopenharmony_ci * version bump.
1229cabdff1aSopenharmony_ci * sizeof(AVFormatContext) must not be used outside libav*, use
1230cabdff1aSopenharmony_ci * avformat_alloc_context() to create an AVFormatContext.
1231cabdff1aSopenharmony_ci *
1232cabdff1aSopenharmony_ci * Fields can be accessed through AVOptions (av_opt*),
1233cabdff1aSopenharmony_ci * the name string used matches the associated command line parameter name and
1234cabdff1aSopenharmony_ci * can be found in libavformat/options_table.h.
1235cabdff1aSopenharmony_ci * The AVOption/command line parameter names differ in some cases from the C
1236cabdff1aSopenharmony_ci * structure field names for historic reasons or brevity.
1237cabdff1aSopenharmony_ci */
1238cabdff1aSopenharmony_citypedef struct AVFormatContext {
1239cabdff1aSopenharmony_ci    /**
1240cabdff1aSopenharmony_ci     * A class for logging and @ref avoptions. Set by avformat_alloc_context().
1241cabdff1aSopenharmony_ci     * Exports (de)muxer private options if they exist.
1242cabdff1aSopenharmony_ci     */
1243cabdff1aSopenharmony_ci    const AVClass *av_class;
1244cabdff1aSopenharmony_ci
1245cabdff1aSopenharmony_ci    /**
1246cabdff1aSopenharmony_ci     * The input container format.
1247cabdff1aSopenharmony_ci     *
1248cabdff1aSopenharmony_ci     * Demuxing only, set by avformat_open_input().
1249cabdff1aSopenharmony_ci     */
1250cabdff1aSopenharmony_ci    const struct AVInputFormat *iformat;
1251cabdff1aSopenharmony_ci
1252cabdff1aSopenharmony_ci    /**
1253cabdff1aSopenharmony_ci     * The output container format.
1254cabdff1aSopenharmony_ci     *
1255cabdff1aSopenharmony_ci     * Muxing only, must be set by the caller before avformat_write_header().
1256cabdff1aSopenharmony_ci     */
1257cabdff1aSopenharmony_ci    const struct AVOutputFormat *oformat;
1258cabdff1aSopenharmony_ci
1259cabdff1aSopenharmony_ci    /**
1260cabdff1aSopenharmony_ci     * Format private data. This is an AVOptions-enabled struct
1261cabdff1aSopenharmony_ci     * if and only if iformat/oformat.priv_class is not NULL.
1262cabdff1aSopenharmony_ci     *
1263cabdff1aSopenharmony_ci     * - muxing: set by avformat_write_header()
1264cabdff1aSopenharmony_ci     * - demuxing: set by avformat_open_input()
1265cabdff1aSopenharmony_ci     */
1266cabdff1aSopenharmony_ci    void *priv_data;
1267cabdff1aSopenharmony_ci
1268cabdff1aSopenharmony_ci    /**
1269cabdff1aSopenharmony_ci     * I/O context.
1270cabdff1aSopenharmony_ci     *
1271cabdff1aSopenharmony_ci     * - demuxing: either set by the user before avformat_open_input() (then
1272cabdff1aSopenharmony_ci     *             the user must close it manually) or set by avformat_open_input().
1273cabdff1aSopenharmony_ci     * - muxing: set by the user before avformat_write_header(). The caller must
1274cabdff1aSopenharmony_ci     *           take care of closing / freeing the IO context.
1275cabdff1aSopenharmony_ci     *
1276cabdff1aSopenharmony_ci     * Do NOT set this field if AVFMT_NOFILE flag is set in
1277cabdff1aSopenharmony_ci     * iformat/oformat.flags. In such a case, the (de)muxer will handle
1278cabdff1aSopenharmony_ci     * I/O in some other way and this field will be NULL.
1279cabdff1aSopenharmony_ci     */
1280cabdff1aSopenharmony_ci    AVIOContext *pb;
1281cabdff1aSopenharmony_ci
1282cabdff1aSopenharmony_ci    /* stream info */
1283cabdff1aSopenharmony_ci    /**
1284cabdff1aSopenharmony_ci     * Flags signalling stream properties. A combination of AVFMTCTX_*.
1285cabdff1aSopenharmony_ci     * Set by libavformat.
1286cabdff1aSopenharmony_ci     */
1287cabdff1aSopenharmony_ci    int ctx_flags;
1288cabdff1aSopenharmony_ci
1289cabdff1aSopenharmony_ci    /**
1290cabdff1aSopenharmony_ci     * Number of elements in AVFormatContext.streams.
1291cabdff1aSopenharmony_ci     *
1292cabdff1aSopenharmony_ci     * Set by avformat_new_stream(), must not be modified by any other code.
1293cabdff1aSopenharmony_ci     */
1294cabdff1aSopenharmony_ci    unsigned int nb_streams;
1295cabdff1aSopenharmony_ci    /**
1296cabdff1aSopenharmony_ci     * A list of all streams in the file. New streams are created with
1297cabdff1aSopenharmony_ci     * avformat_new_stream().
1298cabdff1aSopenharmony_ci     *
1299cabdff1aSopenharmony_ci     * - demuxing: streams are created by libavformat in avformat_open_input().
1300cabdff1aSopenharmony_ci     *             If AVFMTCTX_NOHEADER is set in ctx_flags, then new streams may also
1301cabdff1aSopenharmony_ci     *             appear in av_read_frame().
1302cabdff1aSopenharmony_ci     * - muxing: streams are created by the user before avformat_write_header().
1303cabdff1aSopenharmony_ci     *
1304cabdff1aSopenharmony_ci     * Freed by libavformat in avformat_free_context().
1305cabdff1aSopenharmony_ci     */
1306cabdff1aSopenharmony_ci    AVStream **streams;
1307cabdff1aSopenharmony_ci
1308cabdff1aSopenharmony_ci    /**
1309cabdff1aSopenharmony_ci     * input or output URL. Unlike the old filename field, this field has no
1310cabdff1aSopenharmony_ci     * length restriction.
1311cabdff1aSopenharmony_ci     *
1312cabdff1aSopenharmony_ci     * - demuxing: set by avformat_open_input(), initialized to an empty
1313cabdff1aSopenharmony_ci     *             string if url parameter was NULL in avformat_open_input().
1314cabdff1aSopenharmony_ci     * - muxing: may be set by the caller before calling avformat_write_header()
1315cabdff1aSopenharmony_ci     *           (or avformat_init_output() if that is called first) to a string
1316cabdff1aSopenharmony_ci     *           which is freeable by av_free(). Set to an empty string if it
1317cabdff1aSopenharmony_ci     *           was NULL in avformat_init_output().
1318cabdff1aSopenharmony_ci     *
1319cabdff1aSopenharmony_ci     * Freed by libavformat in avformat_free_context().
1320cabdff1aSopenharmony_ci     */
1321cabdff1aSopenharmony_ci    char *url;
1322cabdff1aSopenharmony_ci
1323cabdff1aSopenharmony_ci    /**
1324cabdff1aSopenharmony_ci     * Position of the first frame of the component, in
1325cabdff1aSopenharmony_ci     * AV_TIME_BASE fractional seconds. NEVER set this value directly:
1326cabdff1aSopenharmony_ci     * It is deduced from the AVStream values.
1327cabdff1aSopenharmony_ci     *
1328cabdff1aSopenharmony_ci     * Demuxing only, set by libavformat.
1329cabdff1aSopenharmony_ci     */
1330cabdff1aSopenharmony_ci    int64_t start_time;
1331cabdff1aSopenharmony_ci
1332cabdff1aSopenharmony_ci    /**
1333cabdff1aSopenharmony_ci     * Duration of the stream, in AV_TIME_BASE fractional
1334cabdff1aSopenharmony_ci     * seconds. Only set this value if you know none of the individual stream
1335cabdff1aSopenharmony_ci     * durations and also do not set any of them. This is deduced from the
1336cabdff1aSopenharmony_ci     * AVStream values if not set.
1337cabdff1aSopenharmony_ci     *
1338cabdff1aSopenharmony_ci     * Demuxing only, set by libavformat.
1339cabdff1aSopenharmony_ci     */
1340cabdff1aSopenharmony_ci    int64_t duration;
1341cabdff1aSopenharmony_ci
1342cabdff1aSopenharmony_ci    /**
1343cabdff1aSopenharmony_ci     * Total stream bitrate in bit/s, 0 if not
1344cabdff1aSopenharmony_ci     * available. Never set it directly if the file_size and the
1345cabdff1aSopenharmony_ci     * duration are known as FFmpeg can compute it automatically.
1346cabdff1aSopenharmony_ci     */
1347cabdff1aSopenharmony_ci    int64_t bit_rate;
1348cabdff1aSopenharmony_ci
1349cabdff1aSopenharmony_ci    unsigned int packet_size;
1350cabdff1aSopenharmony_ci    int max_delay;
1351cabdff1aSopenharmony_ci
1352cabdff1aSopenharmony_ci    /**
1353cabdff1aSopenharmony_ci     * Flags modifying the (de)muxer behaviour. A combination of AVFMT_FLAG_*.
1354cabdff1aSopenharmony_ci     * Set by the user before avformat_open_input() / avformat_write_header().
1355cabdff1aSopenharmony_ci     */
1356cabdff1aSopenharmony_ci    int flags;
1357cabdff1aSopenharmony_ci#define AVFMT_FLAG_GENPTS       0x0001 ///< Generate missing pts even if it requires parsing future frames.
1358cabdff1aSopenharmony_ci#define AVFMT_FLAG_IGNIDX       0x0002 ///< Ignore index.
1359cabdff1aSopenharmony_ci#define AVFMT_FLAG_NONBLOCK     0x0004 ///< Do not block when reading packets from input.
1360cabdff1aSopenharmony_ci#define AVFMT_FLAG_IGNDTS       0x0008 ///< Ignore DTS on frames that contain both DTS & PTS
1361cabdff1aSopenharmony_ci#define AVFMT_FLAG_NOFILLIN     0x0010 ///< Do not infer any values from other values, just return what is stored in the container
1362cabdff1aSopenharmony_ci#define AVFMT_FLAG_NOPARSE      0x0020 ///< Do not use AVParsers, you also must set AVFMT_FLAG_NOFILLIN as the fillin code works on frames and no parsing -> no frames. Also seeking to frames can not work if parsing to find frame boundaries has been disabled
1363cabdff1aSopenharmony_ci#define AVFMT_FLAG_NOBUFFER     0x0040 ///< Do not buffer frames when possible
1364cabdff1aSopenharmony_ci#define AVFMT_FLAG_CUSTOM_IO    0x0080 ///< The caller has supplied a custom AVIOContext, don't avio_close() it.
1365cabdff1aSopenharmony_ci#define AVFMT_FLAG_DISCARD_CORRUPT  0x0100 ///< Discard frames marked corrupted
1366cabdff1aSopenharmony_ci#define AVFMT_FLAG_FLUSH_PACKETS    0x0200 ///< Flush the AVIOContext every packet.
1367cabdff1aSopenharmony_ci/**
1368cabdff1aSopenharmony_ci * When muxing, try to avoid writing any random/volatile data to the output.
1369cabdff1aSopenharmony_ci * This includes any random IDs, real-time timestamps/dates, muxer version, etc.
1370cabdff1aSopenharmony_ci *
1371cabdff1aSopenharmony_ci * This flag is mainly intended for testing.
1372cabdff1aSopenharmony_ci */
1373cabdff1aSopenharmony_ci#define AVFMT_FLAG_BITEXACT         0x0400
1374cabdff1aSopenharmony_ci#define AVFMT_FLAG_SORT_DTS    0x10000 ///< try to interleave outputted packets by dts (using this flag can slow demuxing down)
1375cabdff1aSopenharmony_ci#if FF_API_LAVF_PRIV_OPT
1376cabdff1aSopenharmony_ci#define AVFMT_FLAG_PRIV_OPT    0x20000 ///< Enable use of private options by delaying codec open (deprecated, does nothing)
1377cabdff1aSopenharmony_ci#endif
1378cabdff1aSopenharmony_ci#define AVFMT_FLAG_FAST_SEEK   0x80000 ///< Enable fast, but inaccurate seeks for some formats
1379cabdff1aSopenharmony_ci#define AVFMT_FLAG_SHORTEST   0x100000 ///< Stop muxing when the shortest stream stops.
1380cabdff1aSopenharmony_ci#define AVFMT_FLAG_AUTO_BSF   0x200000 ///< Add bitstream filters as requested by the muxer
1381cabdff1aSopenharmony_ci
1382cabdff1aSopenharmony_ci    /**
1383cabdff1aSopenharmony_ci     * Maximum number of bytes read from input in order to determine stream
1384cabdff1aSopenharmony_ci     * properties. Used when reading the global header and in
1385cabdff1aSopenharmony_ci     * avformat_find_stream_info().
1386cabdff1aSopenharmony_ci     *
1387cabdff1aSopenharmony_ci     * Demuxing only, set by the caller before avformat_open_input().
1388cabdff1aSopenharmony_ci     *
1389cabdff1aSopenharmony_ci     * @note this is \e not  used for determining the \ref AVInputFormat
1390cabdff1aSopenharmony_ci     *       "input format"
1391cabdff1aSopenharmony_ci     * @sa format_probesize
1392cabdff1aSopenharmony_ci     */
1393cabdff1aSopenharmony_ci    int64_t probesize;
1394cabdff1aSopenharmony_ci
1395cabdff1aSopenharmony_ci    /**
1396cabdff1aSopenharmony_ci     * Maximum duration (in AV_TIME_BASE units) of the data read
1397cabdff1aSopenharmony_ci     * from input in avformat_find_stream_info().
1398cabdff1aSopenharmony_ci     * Demuxing only, set by the caller before avformat_find_stream_info().
1399cabdff1aSopenharmony_ci     * Can be set to 0 to let avformat choose using a heuristic.
1400cabdff1aSopenharmony_ci     */
1401cabdff1aSopenharmony_ci    int64_t max_analyze_duration;
1402cabdff1aSopenharmony_ci
1403cabdff1aSopenharmony_ci    const uint8_t *key;
1404cabdff1aSopenharmony_ci    int keylen;
1405cabdff1aSopenharmony_ci
1406cabdff1aSopenharmony_ci    unsigned int nb_programs;
1407cabdff1aSopenharmony_ci    AVProgram **programs;
1408cabdff1aSopenharmony_ci
1409cabdff1aSopenharmony_ci    /**
1410cabdff1aSopenharmony_ci     * Forced video codec_id.
1411cabdff1aSopenharmony_ci     * Demuxing: Set by user.
1412cabdff1aSopenharmony_ci     */
1413cabdff1aSopenharmony_ci    enum AVCodecID video_codec_id;
1414cabdff1aSopenharmony_ci
1415cabdff1aSopenharmony_ci    /**
1416cabdff1aSopenharmony_ci     * Forced audio codec_id.
1417cabdff1aSopenharmony_ci     * Demuxing: Set by user.
1418cabdff1aSopenharmony_ci     */
1419cabdff1aSopenharmony_ci    enum AVCodecID audio_codec_id;
1420cabdff1aSopenharmony_ci
1421cabdff1aSopenharmony_ci    /**
1422cabdff1aSopenharmony_ci     * Forced subtitle codec_id.
1423cabdff1aSopenharmony_ci     * Demuxing: Set by user.
1424cabdff1aSopenharmony_ci     */
1425cabdff1aSopenharmony_ci    enum AVCodecID subtitle_codec_id;
1426cabdff1aSopenharmony_ci
1427cabdff1aSopenharmony_ci    /**
1428cabdff1aSopenharmony_ci     * Maximum amount of memory in bytes to use for the index of each stream.
1429cabdff1aSopenharmony_ci     * If the index exceeds this size, entries will be discarded as
1430cabdff1aSopenharmony_ci     * needed to maintain a smaller size. This can lead to slower or less
1431cabdff1aSopenharmony_ci     * accurate seeking (depends on demuxer).
1432cabdff1aSopenharmony_ci     * Demuxers for which a full in-memory index is mandatory will ignore
1433cabdff1aSopenharmony_ci     * this.
1434cabdff1aSopenharmony_ci     * - muxing: unused
1435cabdff1aSopenharmony_ci     * - demuxing: set by user
1436cabdff1aSopenharmony_ci     */
1437cabdff1aSopenharmony_ci    unsigned int max_index_size;
1438cabdff1aSopenharmony_ci
1439cabdff1aSopenharmony_ci    /**
1440cabdff1aSopenharmony_ci     * Maximum amount of memory in bytes to use for buffering frames
1441cabdff1aSopenharmony_ci     * obtained from realtime capture devices.
1442cabdff1aSopenharmony_ci     */
1443cabdff1aSopenharmony_ci    unsigned int max_picture_buffer;
1444cabdff1aSopenharmony_ci
1445cabdff1aSopenharmony_ci    /**
1446cabdff1aSopenharmony_ci     * Number of chapters in AVChapter array.
1447cabdff1aSopenharmony_ci     * When muxing, chapters are normally written in the file header,
1448cabdff1aSopenharmony_ci     * so nb_chapters should normally be initialized before write_header
1449cabdff1aSopenharmony_ci     * is called. Some muxers (e.g. mov and mkv) can also write chapters
1450cabdff1aSopenharmony_ci     * in the trailer.  To write chapters in the trailer, nb_chapters
1451cabdff1aSopenharmony_ci     * must be zero when write_header is called and non-zero when
1452cabdff1aSopenharmony_ci     * write_trailer is called.
1453cabdff1aSopenharmony_ci     * - muxing: set by user
1454cabdff1aSopenharmony_ci     * - demuxing: set by libavformat
1455cabdff1aSopenharmony_ci     */
1456cabdff1aSopenharmony_ci    unsigned int nb_chapters;
1457cabdff1aSopenharmony_ci    AVChapter **chapters;
1458cabdff1aSopenharmony_ci
1459cabdff1aSopenharmony_ci    /**
1460cabdff1aSopenharmony_ci     * Metadata that applies to the whole file.
1461cabdff1aSopenharmony_ci     *
1462cabdff1aSopenharmony_ci     * - demuxing: set by libavformat in avformat_open_input()
1463cabdff1aSopenharmony_ci     * - muxing: may be set by the caller before avformat_write_header()
1464cabdff1aSopenharmony_ci     *
1465cabdff1aSopenharmony_ci     * Freed by libavformat in avformat_free_context().
1466cabdff1aSopenharmony_ci     */
1467cabdff1aSopenharmony_ci    AVDictionary *metadata;
1468cabdff1aSopenharmony_ci
1469cabdff1aSopenharmony_ci    /**
1470cabdff1aSopenharmony_ci     * Start time of the stream in real world time, in microseconds
1471cabdff1aSopenharmony_ci     * since the Unix epoch (00:00 1st January 1970). That is, pts=0 in the
1472cabdff1aSopenharmony_ci     * stream was captured at this real world time.
1473cabdff1aSopenharmony_ci     * - muxing: Set by the caller before avformat_write_header(). If set to
1474cabdff1aSopenharmony_ci     *           either 0 or AV_NOPTS_VALUE, then the current wall-time will
1475cabdff1aSopenharmony_ci     *           be used.
1476cabdff1aSopenharmony_ci     * - demuxing: Set by libavformat. AV_NOPTS_VALUE if unknown. Note that
1477cabdff1aSopenharmony_ci     *             the value may become known after some number of frames
1478cabdff1aSopenharmony_ci     *             have been received.
1479cabdff1aSopenharmony_ci     */
1480cabdff1aSopenharmony_ci    int64_t start_time_realtime;
1481cabdff1aSopenharmony_ci
1482cabdff1aSopenharmony_ci    /**
1483cabdff1aSopenharmony_ci     * The number of frames used for determining the framerate in
1484cabdff1aSopenharmony_ci     * avformat_find_stream_info().
1485cabdff1aSopenharmony_ci     * Demuxing only, set by the caller before avformat_find_stream_info().
1486cabdff1aSopenharmony_ci     */
1487cabdff1aSopenharmony_ci    int fps_probe_size;
1488cabdff1aSopenharmony_ci
1489cabdff1aSopenharmony_ci    /**
1490cabdff1aSopenharmony_ci     * Error recognition; higher values will detect more errors but may
1491cabdff1aSopenharmony_ci     * misdetect some more or less valid parts as errors.
1492cabdff1aSopenharmony_ci     * Demuxing only, set by the caller before avformat_open_input().
1493cabdff1aSopenharmony_ci     */
1494cabdff1aSopenharmony_ci    int error_recognition;
1495cabdff1aSopenharmony_ci
1496cabdff1aSopenharmony_ci    /**
1497cabdff1aSopenharmony_ci     * Custom interrupt callbacks for the I/O layer.
1498cabdff1aSopenharmony_ci     *
1499cabdff1aSopenharmony_ci     * demuxing: set by the user before avformat_open_input().
1500cabdff1aSopenharmony_ci     * muxing: set by the user before avformat_write_header()
1501cabdff1aSopenharmony_ci     * (mainly useful for AVFMT_NOFILE formats). The callback
1502cabdff1aSopenharmony_ci     * should also be passed to avio_open2() if it's used to
1503cabdff1aSopenharmony_ci     * open the file.
1504cabdff1aSopenharmony_ci     */
1505cabdff1aSopenharmony_ci    AVIOInterruptCB interrupt_callback;
1506cabdff1aSopenharmony_ci
1507cabdff1aSopenharmony_ci    /**
1508cabdff1aSopenharmony_ci     * Flags to enable debugging.
1509cabdff1aSopenharmony_ci     */
1510cabdff1aSopenharmony_ci    int debug;
1511cabdff1aSopenharmony_ci#define FF_FDEBUG_TS        0x0001
1512cabdff1aSopenharmony_ci
1513cabdff1aSopenharmony_ci    /**
1514cabdff1aSopenharmony_ci     * Maximum buffering duration for interleaving.
1515cabdff1aSopenharmony_ci     *
1516cabdff1aSopenharmony_ci     * To ensure all the streams are interleaved correctly,
1517cabdff1aSopenharmony_ci     * av_interleaved_write_frame() will wait until it has at least one packet
1518cabdff1aSopenharmony_ci     * for each stream before actually writing any packets to the output file.
1519cabdff1aSopenharmony_ci     * When some streams are "sparse" (i.e. there are large gaps between
1520cabdff1aSopenharmony_ci     * successive packets), this can result in excessive buffering.
1521cabdff1aSopenharmony_ci     *
1522cabdff1aSopenharmony_ci     * This field specifies the maximum difference between the timestamps of the
1523cabdff1aSopenharmony_ci     * first and the last packet in the muxing queue, above which libavformat
1524cabdff1aSopenharmony_ci     * will output a packet regardless of whether it has queued a packet for all
1525cabdff1aSopenharmony_ci     * the streams.
1526cabdff1aSopenharmony_ci     *
1527cabdff1aSopenharmony_ci     * Muxing only, set by the caller before avformat_write_header().
1528cabdff1aSopenharmony_ci     */
1529cabdff1aSopenharmony_ci    int64_t max_interleave_delta;
1530cabdff1aSopenharmony_ci
1531cabdff1aSopenharmony_ci    /**
1532cabdff1aSopenharmony_ci     * Allow non-standard and experimental extension
1533cabdff1aSopenharmony_ci     * @see AVCodecContext.strict_std_compliance
1534cabdff1aSopenharmony_ci     */
1535cabdff1aSopenharmony_ci    int strict_std_compliance;
1536cabdff1aSopenharmony_ci
1537cabdff1aSopenharmony_ci    /**
1538cabdff1aSopenharmony_ci     * Flags indicating events happening on the file, a combination of
1539cabdff1aSopenharmony_ci     * AVFMT_EVENT_FLAG_*.
1540cabdff1aSopenharmony_ci     *
1541cabdff1aSopenharmony_ci     * - demuxing: may be set by the demuxer in avformat_open_input(),
1542cabdff1aSopenharmony_ci     *   avformat_find_stream_info() and av_read_frame(). Flags must be cleared
1543cabdff1aSopenharmony_ci     *   by the user once the event has been handled.
1544cabdff1aSopenharmony_ci     * - muxing: may be set by the user after avformat_write_header() to
1545cabdff1aSopenharmony_ci     *   indicate a user-triggered event.  The muxer will clear the flags for
1546cabdff1aSopenharmony_ci     *   events it has handled in av_[interleaved]_write_frame().
1547cabdff1aSopenharmony_ci     */
1548cabdff1aSopenharmony_ci    int event_flags;
1549cabdff1aSopenharmony_ci/**
1550cabdff1aSopenharmony_ci * - demuxing: the demuxer read new metadata from the file and updated
1551cabdff1aSopenharmony_ci *   AVFormatContext.metadata accordingly
1552cabdff1aSopenharmony_ci * - muxing: the user updated AVFormatContext.metadata and wishes the muxer to
1553cabdff1aSopenharmony_ci *   write it into the file
1554cabdff1aSopenharmony_ci */
1555cabdff1aSopenharmony_ci#define AVFMT_EVENT_FLAG_METADATA_UPDATED 0x0001
1556cabdff1aSopenharmony_ci
1557cabdff1aSopenharmony_ci    /**
1558cabdff1aSopenharmony_ci     * Maximum number of packets to read while waiting for the first timestamp.
1559cabdff1aSopenharmony_ci     * Decoding only.
1560cabdff1aSopenharmony_ci     */
1561cabdff1aSopenharmony_ci    int max_ts_probe;
1562cabdff1aSopenharmony_ci
1563cabdff1aSopenharmony_ci    /**
1564cabdff1aSopenharmony_ci     * Avoid negative timestamps during muxing.
1565cabdff1aSopenharmony_ci     * Any value of the AVFMT_AVOID_NEG_TS_* constants.
1566cabdff1aSopenharmony_ci     * Note, this works better when using av_interleaved_write_frame().
1567cabdff1aSopenharmony_ci     * - muxing: Set by user
1568cabdff1aSopenharmony_ci     * - demuxing: unused
1569cabdff1aSopenharmony_ci     */
1570cabdff1aSopenharmony_ci    int avoid_negative_ts;
1571cabdff1aSopenharmony_ci#define AVFMT_AVOID_NEG_TS_AUTO             -1 ///< Enabled when required by target format
1572cabdff1aSopenharmony_ci#define AVFMT_AVOID_NEG_TS_DISABLED          0 ///< Do not shift timestamps even when they are negative.
1573cabdff1aSopenharmony_ci#define AVFMT_AVOID_NEG_TS_MAKE_NON_NEGATIVE 1 ///< Shift timestamps so they are non negative
1574cabdff1aSopenharmony_ci#define AVFMT_AVOID_NEG_TS_MAKE_ZERO         2 ///< Shift timestamps so that they start at 0
1575cabdff1aSopenharmony_ci
1576cabdff1aSopenharmony_ci    /**
1577cabdff1aSopenharmony_ci     * Transport stream id.
1578cabdff1aSopenharmony_ci     * This will be moved into demuxer private options. Thus no API/ABI compatibility
1579cabdff1aSopenharmony_ci     */
1580cabdff1aSopenharmony_ci    int ts_id;
1581cabdff1aSopenharmony_ci
1582cabdff1aSopenharmony_ci    /**
1583cabdff1aSopenharmony_ci     * Audio preload in microseconds.
1584cabdff1aSopenharmony_ci     * Note, not all formats support this and unpredictable things may happen if it is used when not supported.
1585cabdff1aSopenharmony_ci     * - encoding: Set by user
1586cabdff1aSopenharmony_ci     * - decoding: unused
1587cabdff1aSopenharmony_ci     */
1588cabdff1aSopenharmony_ci    int audio_preload;
1589cabdff1aSopenharmony_ci
1590cabdff1aSopenharmony_ci    /**
1591cabdff1aSopenharmony_ci     * Max chunk time in microseconds.
1592cabdff1aSopenharmony_ci     * Note, not all formats support this and unpredictable things may happen if it is used when not supported.
1593cabdff1aSopenharmony_ci     * - encoding: Set by user
1594cabdff1aSopenharmony_ci     * - decoding: unused
1595cabdff1aSopenharmony_ci     */
1596cabdff1aSopenharmony_ci    int max_chunk_duration;
1597cabdff1aSopenharmony_ci
1598cabdff1aSopenharmony_ci    /**
1599cabdff1aSopenharmony_ci     * Max chunk size in bytes
1600cabdff1aSopenharmony_ci     * Note, not all formats support this and unpredictable things may happen if it is used when not supported.
1601cabdff1aSopenharmony_ci     * - encoding: Set by user
1602cabdff1aSopenharmony_ci     * - decoding: unused
1603cabdff1aSopenharmony_ci     */
1604cabdff1aSopenharmony_ci    int max_chunk_size;
1605cabdff1aSopenharmony_ci
1606cabdff1aSopenharmony_ci    /**
1607cabdff1aSopenharmony_ci     * forces the use of wallclock timestamps as pts/dts of packets
1608cabdff1aSopenharmony_ci     * This has undefined results in the presence of B frames.
1609cabdff1aSopenharmony_ci     * - encoding: unused
1610cabdff1aSopenharmony_ci     * - decoding: Set by user
1611cabdff1aSopenharmony_ci     */
1612cabdff1aSopenharmony_ci    int use_wallclock_as_timestamps;
1613cabdff1aSopenharmony_ci
1614cabdff1aSopenharmony_ci    /**
1615cabdff1aSopenharmony_ci     * avio flags, used to force AVIO_FLAG_DIRECT.
1616cabdff1aSopenharmony_ci     * - encoding: unused
1617cabdff1aSopenharmony_ci     * - decoding: Set by user
1618cabdff1aSopenharmony_ci     */
1619cabdff1aSopenharmony_ci    int avio_flags;
1620cabdff1aSopenharmony_ci
1621cabdff1aSopenharmony_ci    /**
1622cabdff1aSopenharmony_ci     * The duration field can be estimated through various ways, and this field can be used
1623cabdff1aSopenharmony_ci     * to know how the duration was estimated.
1624cabdff1aSopenharmony_ci     * - encoding: unused
1625cabdff1aSopenharmony_ci     * - decoding: Read by user
1626cabdff1aSopenharmony_ci     */
1627cabdff1aSopenharmony_ci    enum AVDurationEstimationMethod duration_estimation_method;
1628cabdff1aSopenharmony_ci
1629cabdff1aSopenharmony_ci    /**
1630cabdff1aSopenharmony_ci     * Skip initial bytes when opening stream
1631cabdff1aSopenharmony_ci     * - encoding: unused
1632cabdff1aSopenharmony_ci     * - decoding: Set by user
1633cabdff1aSopenharmony_ci     */
1634cabdff1aSopenharmony_ci    int64_t skip_initial_bytes;
1635cabdff1aSopenharmony_ci
1636cabdff1aSopenharmony_ci    /**
1637cabdff1aSopenharmony_ci     * Correct single timestamp overflows
1638cabdff1aSopenharmony_ci     * - encoding: unused
1639cabdff1aSopenharmony_ci     * - decoding: Set by user
1640cabdff1aSopenharmony_ci     */
1641cabdff1aSopenharmony_ci    unsigned int correct_ts_overflow;
1642cabdff1aSopenharmony_ci
1643cabdff1aSopenharmony_ci    /**
1644cabdff1aSopenharmony_ci     * Force seeking to any (also non key) frames.
1645cabdff1aSopenharmony_ci     * - encoding: unused
1646cabdff1aSopenharmony_ci     * - decoding: Set by user
1647cabdff1aSopenharmony_ci     */
1648cabdff1aSopenharmony_ci    int seek2any;
1649cabdff1aSopenharmony_ci
1650cabdff1aSopenharmony_ci    /**
1651cabdff1aSopenharmony_ci     * Flush the I/O context after each packet.
1652cabdff1aSopenharmony_ci     * - encoding: Set by user
1653cabdff1aSopenharmony_ci     * - decoding: unused
1654cabdff1aSopenharmony_ci     */
1655cabdff1aSopenharmony_ci    int flush_packets;
1656cabdff1aSopenharmony_ci
1657cabdff1aSopenharmony_ci    /**
1658cabdff1aSopenharmony_ci     * format probing score.
1659cabdff1aSopenharmony_ci     * The maximal score is AVPROBE_SCORE_MAX, its set when the demuxer probes
1660cabdff1aSopenharmony_ci     * the format.
1661cabdff1aSopenharmony_ci     * - encoding: unused
1662cabdff1aSopenharmony_ci     * - decoding: set by avformat, read by user
1663cabdff1aSopenharmony_ci     */
1664cabdff1aSopenharmony_ci    int probe_score;
1665cabdff1aSopenharmony_ci
1666cabdff1aSopenharmony_ci    /**
1667cabdff1aSopenharmony_ci     * Maximum number of bytes read from input in order to identify the
1668cabdff1aSopenharmony_ci     * \ref AVInputFormat "input format". Only used when the format is not set
1669cabdff1aSopenharmony_ci     * explicitly by the caller.
1670cabdff1aSopenharmony_ci     *
1671cabdff1aSopenharmony_ci     * Demuxing only, set by the caller before avformat_open_input().
1672cabdff1aSopenharmony_ci     *
1673cabdff1aSopenharmony_ci     * @sa probesize
1674cabdff1aSopenharmony_ci     */
1675cabdff1aSopenharmony_ci    int format_probesize;
1676cabdff1aSopenharmony_ci
1677cabdff1aSopenharmony_ci    /**
1678cabdff1aSopenharmony_ci     * ',' separated list of allowed decoders.
1679cabdff1aSopenharmony_ci     * If NULL then all are allowed
1680cabdff1aSopenharmony_ci     * - encoding: unused
1681cabdff1aSopenharmony_ci     * - decoding: set by user
1682cabdff1aSopenharmony_ci     */
1683cabdff1aSopenharmony_ci    char *codec_whitelist;
1684cabdff1aSopenharmony_ci
1685cabdff1aSopenharmony_ci    /**
1686cabdff1aSopenharmony_ci     * ',' separated list of allowed demuxers.
1687cabdff1aSopenharmony_ci     * If NULL then all are allowed
1688cabdff1aSopenharmony_ci     * - encoding: unused
1689cabdff1aSopenharmony_ci     * - decoding: set by user
1690cabdff1aSopenharmony_ci     */
1691cabdff1aSopenharmony_ci    char *format_whitelist;
1692cabdff1aSopenharmony_ci
1693cabdff1aSopenharmony_ci    /**
1694cabdff1aSopenharmony_ci     * IO repositioned flag.
1695cabdff1aSopenharmony_ci     * This is set by avformat when the underlaying IO context read pointer
1696cabdff1aSopenharmony_ci     * is repositioned, for example when doing byte based seeking.
1697cabdff1aSopenharmony_ci     * Demuxers can use the flag to detect such changes.
1698cabdff1aSopenharmony_ci     */
1699cabdff1aSopenharmony_ci    int io_repositioned;
1700cabdff1aSopenharmony_ci
1701cabdff1aSopenharmony_ci    /**
1702cabdff1aSopenharmony_ci     * Forced video codec.
1703cabdff1aSopenharmony_ci     * This allows forcing a specific decoder, even when there are multiple with
1704cabdff1aSopenharmony_ci     * the same codec_id.
1705cabdff1aSopenharmony_ci     * Demuxing: Set by user
1706cabdff1aSopenharmony_ci     */
1707cabdff1aSopenharmony_ci    const AVCodec *video_codec;
1708cabdff1aSopenharmony_ci
1709cabdff1aSopenharmony_ci    /**
1710cabdff1aSopenharmony_ci     * Forced audio codec.
1711cabdff1aSopenharmony_ci     * This allows forcing a specific decoder, even when there are multiple with
1712cabdff1aSopenharmony_ci     * the same codec_id.
1713cabdff1aSopenharmony_ci     * Demuxing: Set by user
1714cabdff1aSopenharmony_ci     */
1715cabdff1aSopenharmony_ci    const AVCodec *audio_codec;
1716cabdff1aSopenharmony_ci
1717cabdff1aSopenharmony_ci    /**
1718cabdff1aSopenharmony_ci     * Forced subtitle codec.
1719cabdff1aSopenharmony_ci     * This allows forcing a specific decoder, even when there are multiple with
1720cabdff1aSopenharmony_ci     * the same codec_id.
1721cabdff1aSopenharmony_ci     * Demuxing: Set by user
1722cabdff1aSopenharmony_ci     */
1723cabdff1aSopenharmony_ci    const AVCodec *subtitle_codec;
1724cabdff1aSopenharmony_ci
1725cabdff1aSopenharmony_ci    /**
1726cabdff1aSopenharmony_ci     * Forced data codec.
1727cabdff1aSopenharmony_ci     * This allows forcing a specific decoder, even when there are multiple with
1728cabdff1aSopenharmony_ci     * the same codec_id.
1729cabdff1aSopenharmony_ci     * Demuxing: Set by user
1730cabdff1aSopenharmony_ci     */
1731cabdff1aSopenharmony_ci    const AVCodec *data_codec;
1732cabdff1aSopenharmony_ci
1733cabdff1aSopenharmony_ci    /**
1734cabdff1aSopenharmony_ci     * Number of bytes to be written as padding in a metadata header.
1735cabdff1aSopenharmony_ci     * Demuxing: Unused.
1736cabdff1aSopenharmony_ci     * Muxing: Set by user via av_format_set_metadata_header_padding.
1737cabdff1aSopenharmony_ci     */
1738cabdff1aSopenharmony_ci    int metadata_header_padding;
1739cabdff1aSopenharmony_ci
1740cabdff1aSopenharmony_ci    /**
1741cabdff1aSopenharmony_ci     * User data.
1742cabdff1aSopenharmony_ci     * This is a place for some private data of the user.
1743cabdff1aSopenharmony_ci     */
1744cabdff1aSopenharmony_ci    void *opaque;
1745cabdff1aSopenharmony_ci
1746cabdff1aSopenharmony_ci    /**
1747cabdff1aSopenharmony_ci     * Callback used by devices to communicate with application.
1748cabdff1aSopenharmony_ci     */
1749cabdff1aSopenharmony_ci    av_format_control_message control_message_cb;
1750cabdff1aSopenharmony_ci
1751cabdff1aSopenharmony_ci    /**
1752cabdff1aSopenharmony_ci     * Output timestamp offset, in microseconds.
1753cabdff1aSopenharmony_ci     * Muxing: set by user
1754cabdff1aSopenharmony_ci     */
1755cabdff1aSopenharmony_ci    int64_t output_ts_offset;
1756cabdff1aSopenharmony_ci
1757cabdff1aSopenharmony_ci    /**
1758cabdff1aSopenharmony_ci     * dump format separator.
1759cabdff1aSopenharmony_ci     * can be ", " or "\n      " or anything else
1760cabdff1aSopenharmony_ci     * - muxing: Set by user.
1761cabdff1aSopenharmony_ci     * - demuxing: Set by user.
1762cabdff1aSopenharmony_ci     */
1763cabdff1aSopenharmony_ci    uint8_t *dump_separator;
1764cabdff1aSopenharmony_ci
1765cabdff1aSopenharmony_ci    /**
1766cabdff1aSopenharmony_ci     * Forced Data codec_id.
1767cabdff1aSopenharmony_ci     * Demuxing: Set by user.
1768cabdff1aSopenharmony_ci     */
1769cabdff1aSopenharmony_ci    enum AVCodecID data_codec_id;
1770cabdff1aSopenharmony_ci
1771cabdff1aSopenharmony_ci    /**
1772cabdff1aSopenharmony_ci     * ',' separated list of allowed protocols.
1773cabdff1aSopenharmony_ci     * - encoding: unused
1774cabdff1aSopenharmony_ci     * - decoding: set by user
1775cabdff1aSopenharmony_ci     */
1776cabdff1aSopenharmony_ci    char *protocol_whitelist;
1777cabdff1aSopenharmony_ci
1778cabdff1aSopenharmony_ci    /**
1779cabdff1aSopenharmony_ci     * A callback for opening new IO streams.
1780cabdff1aSopenharmony_ci     *
1781cabdff1aSopenharmony_ci     * Whenever a muxer or a demuxer needs to open an IO stream (typically from
1782cabdff1aSopenharmony_ci     * avformat_open_input() for demuxers, but for certain formats can happen at
1783cabdff1aSopenharmony_ci     * other times as well), it will call this callback to obtain an IO context.
1784cabdff1aSopenharmony_ci     *
1785cabdff1aSopenharmony_ci     * @param s the format context
1786cabdff1aSopenharmony_ci     * @param pb on success, the newly opened IO context should be returned here
1787cabdff1aSopenharmony_ci     * @param url the url to open
1788cabdff1aSopenharmony_ci     * @param flags a combination of AVIO_FLAG_*
1789cabdff1aSopenharmony_ci     * @param options a dictionary of additional options, with the same
1790cabdff1aSopenharmony_ci     *                semantics as in avio_open2()
1791cabdff1aSopenharmony_ci     * @return 0 on success, a negative AVERROR code on failure
1792cabdff1aSopenharmony_ci     *
1793cabdff1aSopenharmony_ci     * @note Certain muxers and demuxers do nesting, i.e. they open one or more
1794cabdff1aSopenharmony_ci     * additional internal format contexts. Thus the AVFormatContext pointer
1795cabdff1aSopenharmony_ci     * passed to this callback may be different from the one facing the caller.
1796cabdff1aSopenharmony_ci     * It will, however, have the same 'opaque' field.
1797cabdff1aSopenharmony_ci     */
1798cabdff1aSopenharmony_ci    int (*io_open)(struct AVFormatContext *s, AVIOContext **pb, const char *url,
1799cabdff1aSopenharmony_ci                   int flags, AVDictionary **options);
1800cabdff1aSopenharmony_ci
1801cabdff1aSopenharmony_ci    /**
1802cabdff1aSopenharmony_ci     * A callback for closing the streams opened with AVFormatContext.io_open().
1803cabdff1aSopenharmony_ci     */
1804cabdff1aSopenharmony_ci    void (*io_close)(struct AVFormatContext *s, AVIOContext *pb);
1805cabdff1aSopenharmony_ci
1806cabdff1aSopenharmony_ci    /**
1807cabdff1aSopenharmony_ci     * ',' separated list of disallowed protocols.
1808cabdff1aSopenharmony_ci     * - encoding: unused
1809cabdff1aSopenharmony_ci     * - decoding: set by user
1810cabdff1aSopenharmony_ci     */
1811cabdff1aSopenharmony_ci    char *protocol_blacklist;
1812cabdff1aSopenharmony_ci
1813cabdff1aSopenharmony_ci    /**
1814cabdff1aSopenharmony_ci     * The maximum number of streams.
1815cabdff1aSopenharmony_ci     * - encoding: unused
1816cabdff1aSopenharmony_ci     * - decoding: set by user
1817cabdff1aSopenharmony_ci     */
1818cabdff1aSopenharmony_ci    int max_streams;
1819cabdff1aSopenharmony_ci
1820cabdff1aSopenharmony_ci    /**
1821cabdff1aSopenharmony_ci     * Skip duration calcuation in estimate_timings_from_pts.
1822cabdff1aSopenharmony_ci     * - encoding: unused
1823cabdff1aSopenharmony_ci     * - decoding: set by user
1824cabdff1aSopenharmony_ci     */
1825cabdff1aSopenharmony_ci    int skip_estimate_duration_from_pts;
1826cabdff1aSopenharmony_ci
1827cabdff1aSopenharmony_ci    /**
1828cabdff1aSopenharmony_ci     * Maximum number of packets that can be probed
1829cabdff1aSopenharmony_ci     * - encoding: unused
1830cabdff1aSopenharmony_ci     * - decoding: set by user
1831cabdff1aSopenharmony_ci     */
1832cabdff1aSopenharmony_ci    int max_probe_packets;
1833cabdff1aSopenharmony_ci
1834cabdff1aSopenharmony_ci    /**
1835cabdff1aSopenharmony_ci     * A callback for closing the streams opened with AVFormatContext.io_open().
1836cabdff1aSopenharmony_ci     *
1837cabdff1aSopenharmony_ci     * Using this is preferred over io_close, because this can return an error.
1838cabdff1aSopenharmony_ci     * Therefore this callback is used instead of io_close by the generic
1839cabdff1aSopenharmony_ci     * libavformat code if io_close is NULL or the default.
1840cabdff1aSopenharmony_ci     *
1841cabdff1aSopenharmony_ci     * @param s the format context
1842cabdff1aSopenharmony_ci     * @param pb IO context to be closed and freed
1843cabdff1aSopenharmony_ci     * @return 0 on success, a negative AVERROR code on failure
1844cabdff1aSopenharmony_ci     */
1845cabdff1aSopenharmony_ci    int (*io_close2)(struct AVFormatContext *s, AVIOContext *pb);
1846cabdff1aSopenharmony_ci} AVFormatContext;
1847cabdff1aSopenharmony_ci
1848cabdff1aSopenharmony_ci/**
1849cabdff1aSopenharmony_ci * This function will cause global side data to be injected in the next packet
1850cabdff1aSopenharmony_ci * of each stream as well as after any subsequent seek.
1851cabdff1aSopenharmony_ci */
1852cabdff1aSopenharmony_civoid av_format_inject_global_side_data(AVFormatContext *s);
1853cabdff1aSopenharmony_ci
1854cabdff1aSopenharmony_ci/**
1855cabdff1aSopenharmony_ci * Returns the method used to set ctx->duration.
1856cabdff1aSopenharmony_ci *
1857cabdff1aSopenharmony_ci * @return AVFMT_DURATION_FROM_PTS, AVFMT_DURATION_FROM_STREAM, or AVFMT_DURATION_FROM_BITRATE.
1858cabdff1aSopenharmony_ci */
1859cabdff1aSopenharmony_cienum AVDurationEstimationMethod av_fmt_ctx_get_duration_estimation_method(const AVFormatContext* ctx);
1860cabdff1aSopenharmony_ci
1861cabdff1aSopenharmony_ci/**
1862cabdff1aSopenharmony_ci * @defgroup lavf_core Core functions
1863cabdff1aSopenharmony_ci * @ingroup libavf
1864cabdff1aSopenharmony_ci *
1865cabdff1aSopenharmony_ci * Functions for querying libavformat capabilities, allocating core structures,
1866cabdff1aSopenharmony_ci * etc.
1867cabdff1aSopenharmony_ci * @{
1868cabdff1aSopenharmony_ci */
1869cabdff1aSopenharmony_ci
1870cabdff1aSopenharmony_ci/**
1871cabdff1aSopenharmony_ci * Return the LIBAVFORMAT_VERSION_INT constant.
1872cabdff1aSopenharmony_ci */
1873cabdff1aSopenharmony_ciunsigned avformat_version(void);
1874cabdff1aSopenharmony_ci
1875cabdff1aSopenharmony_ci/**
1876cabdff1aSopenharmony_ci * Return the libavformat build-time configuration.
1877cabdff1aSopenharmony_ci */
1878cabdff1aSopenharmony_ciconst char *avformat_configuration(void);
1879cabdff1aSopenharmony_ci
1880cabdff1aSopenharmony_ci/**
1881cabdff1aSopenharmony_ci * Return the libavformat license.
1882cabdff1aSopenharmony_ci */
1883cabdff1aSopenharmony_ciconst char *avformat_license(void);
1884cabdff1aSopenharmony_ci
1885cabdff1aSopenharmony_ci/**
1886cabdff1aSopenharmony_ci * Do global initialization of network libraries. This is optional,
1887cabdff1aSopenharmony_ci * and not recommended anymore.
1888cabdff1aSopenharmony_ci *
1889cabdff1aSopenharmony_ci * This functions only exists to work around thread-safety issues
1890cabdff1aSopenharmony_ci * with older GnuTLS or OpenSSL libraries. If libavformat is linked
1891cabdff1aSopenharmony_ci * to newer versions of those libraries, or if you do not use them,
1892cabdff1aSopenharmony_ci * calling this function is unnecessary. Otherwise, you need to call
1893cabdff1aSopenharmony_ci * this function before any other threads using them are started.
1894cabdff1aSopenharmony_ci *
1895cabdff1aSopenharmony_ci * This function will be deprecated once support for older GnuTLS and
1896cabdff1aSopenharmony_ci * OpenSSL libraries is removed, and this function has no purpose
1897cabdff1aSopenharmony_ci * anymore.
1898cabdff1aSopenharmony_ci */
1899cabdff1aSopenharmony_ciint avformat_network_init(void);
1900cabdff1aSopenharmony_ci
1901cabdff1aSopenharmony_ci/**
1902cabdff1aSopenharmony_ci * Undo the initialization done by avformat_network_init. Call it only
1903cabdff1aSopenharmony_ci * once for each time you called avformat_network_init.
1904cabdff1aSopenharmony_ci */
1905cabdff1aSopenharmony_ciint avformat_network_deinit(void);
1906cabdff1aSopenharmony_ci
1907cabdff1aSopenharmony_ci/**
1908cabdff1aSopenharmony_ci * Iterate over all registered muxers.
1909cabdff1aSopenharmony_ci *
1910cabdff1aSopenharmony_ci * @param opaque a pointer where libavformat will store the iteration state. Must
1911cabdff1aSopenharmony_ci *               point to NULL to start the iteration.
1912cabdff1aSopenharmony_ci *
1913cabdff1aSopenharmony_ci * @return the next registered muxer or NULL when the iteration is
1914cabdff1aSopenharmony_ci *         finished
1915cabdff1aSopenharmony_ci */
1916cabdff1aSopenharmony_ciconst AVOutputFormat *av_muxer_iterate(void **opaque);
1917cabdff1aSopenharmony_ci
1918cabdff1aSopenharmony_ci/**
1919cabdff1aSopenharmony_ci * Iterate over all registered demuxers.
1920cabdff1aSopenharmony_ci *
1921cabdff1aSopenharmony_ci * @param opaque a pointer where libavformat will store the iteration state. Must
1922cabdff1aSopenharmony_ci *               point to NULL to start the iteration.
1923cabdff1aSopenharmony_ci *
1924cabdff1aSopenharmony_ci * @return the next registered demuxer or NULL when the iteration is
1925cabdff1aSopenharmony_ci *         finished
1926cabdff1aSopenharmony_ci */
1927cabdff1aSopenharmony_ciconst AVInputFormat *av_demuxer_iterate(void **opaque);
1928cabdff1aSopenharmony_ci
1929cabdff1aSopenharmony_ci/**
1930cabdff1aSopenharmony_ci * Allocate an AVFormatContext.
1931cabdff1aSopenharmony_ci * avformat_free_context() can be used to free the context and everything
1932cabdff1aSopenharmony_ci * allocated by the framework within it.
1933cabdff1aSopenharmony_ci */
1934cabdff1aSopenharmony_ciAVFormatContext *avformat_alloc_context(void);
1935cabdff1aSopenharmony_ci
1936cabdff1aSopenharmony_ci/**
1937cabdff1aSopenharmony_ci * Free an AVFormatContext and all its streams.
1938cabdff1aSopenharmony_ci * @param s context to free
1939cabdff1aSopenharmony_ci */
1940cabdff1aSopenharmony_civoid avformat_free_context(AVFormatContext *s);
1941cabdff1aSopenharmony_ci
1942cabdff1aSopenharmony_ci/**
1943cabdff1aSopenharmony_ci * Get the AVClass for AVFormatContext. It can be used in combination with
1944cabdff1aSopenharmony_ci * AV_OPT_SEARCH_FAKE_OBJ for examining options.
1945cabdff1aSopenharmony_ci *
1946cabdff1aSopenharmony_ci * @see av_opt_find().
1947cabdff1aSopenharmony_ci */
1948cabdff1aSopenharmony_ciconst AVClass *avformat_get_class(void);
1949cabdff1aSopenharmony_ci
1950cabdff1aSopenharmony_ci/**
1951cabdff1aSopenharmony_ci * Get the AVClass for AVStream. It can be used in combination with
1952cabdff1aSopenharmony_ci * AV_OPT_SEARCH_FAKE_OBJ for examining options.
1953cabdff1aSopenharmony_ci *
1954cabdff1aSopenharmony_ci * @see av_opt_find().
1955cabdff1aSopenharmony_ci */
1956cabdff1aSopenharmony_ciconst AVClass *av_stream_get_class(void);
1957cabdff1aSopenharmony_ci
1958cabdff1aSopenharmony_ci/**
1959cabdff1aSopenharmony_ci * Add a new stream to a media file.
1960cabdff1aSopenharmony_ci *
1961cabdff1aSopenharmony_ci * When demuxing, it is called by the demuxer in read_header(). If the
1962cabdff1aSopenharmony_ci * flag AVFMTCTX_NOHEADER is set in s.ctx_flags, then it may also
1963cabdff1aSopenharmony_ci * be called in read_packet().
1964cabdff1aSopenharmony_ci *
1965cabdff1aSopenharmony_ci * When muxing, should be called by the user before avformat_write_header().
1966cabdff1aSopenharmony_ci *
1967cabdff1aSopenharmony_ci * User is required to call avformat_free_context() to clean up the allocation
1968cabdff1aSopenharmony_ci * by avformat_new_stream().
1969cabdff1aSopenharmony_ci *
1970cabdff1aSopenharmony_ci * @param s media file handle
1971cabdff1aSopenharmony_ci * @param c unused, does nothing
1972cabdff1aSopenharmony_ci *
1973cabdff1aSopenharmony_ci * @return newly created stream or NULL on error.
1974cabdff1aSopenharmony_ci */
1975cabdff1aSopenharmony_ciAVStream *avformat_new_stream(AVFormatContext *s, const AVCodec *c);
1976cabdff1aSopenharmony_ci
1977cabdff1aSopenharmony_ci/**
1978cabdff1aSopenharmony_ci * Wrap an existing array as stream side data.
1979cabdff1aSopenharmony_ci *
1980cabdff1aSopenharmony_ci * @param st stream
1981cabdff1aSopenharmony_ci * @param type side information type
1982cabdff1aSopenharmony_ci * @param data the side data array. It must be allocated with the av_malloc()
1983cabdff1aSopenharmony_ci *             family of functions. The ownership of the data is transferred to
1984cabdff1aSopenharmony_ci *             st.
1985cabdff1aSopenharmony_ci * @param size side information size
1986cabdff1aSopenharmony_ci * @return zero on success, a negative AVERROR code on failure. On failure,
1987cabdff1aSopenharmony_ci *         the stream is unchanged and the data remains owned by the caller.
1988cabdff1aSopenharmony_ci */
1989cabdff1aSopenharmony_ciint av_stream_add_side_data(AVStream *st, enum AVPacketSideDataType type,
1990cabdff1aSopenharmony_ci                            uint8_t *data, size_t size);
1991cabdff1aSopenharmony_ci
1992cabdff1aSopenharmony_ci/**
1993cabdff1aSopenharmony_ci * Allocate new information from stream.
1994cabdff1aSopenharmony_ci *
1995cabdff1aSopenharmony_ci * @param stream stream
1996cabdff1aSopenharmony_ci * @param type desired side information type
1997cabdff1aSopenharmony_ci * @param size side information size
1998cabdff1aSopenharmony_ci * @return pointer to fresh allocated data or NULL otherwise
1999cabdff1aSopenharmony_ci */
2000cabdff1aSopenharmony_ciuint8_t *av_stream_new_side_data(AVStream *stream,
2001cabdff1aSopenharmony_ci                                 enum AVPacketSideDataType type, size_t size);
2002cabdff1aSopenharmony_ci/**
2003cabdff1aSopenharmony_ci * Get side information from stream.
2004cabdff1aSopenharmony_ci *
2005cabdff1aSopenharmony_ci * @param stream stream
2006cabdff1aSopenharmony_ci * @param type desired side information type
2007cabdff1aSopenharmony_ci * @param size If supplied, *size will be set to the size of the side data
2008cabdff1aSopenharmony_ci *             or to zero if the desired side data is not present.
2009cabdff1aSopenharmony_ci * @return pointer to data if present or NULL otherwise
2010cabdff1aSopenharmony_ci */
2011cabdff1aSopenharmony_ciuint8_t *av_stream_get_side_data(const AVStream *stream,
2012cabdff1aSopenharmony_ci                                 enum AVPacketSideDataType type, size_t *size);
2013cabdff1aSopenharmony_ci
2014cabdff1aSopenharmony_ciAVProgram *av_new_program(AVFormatContext *s, int id);
2015cabdff1aSopenharmony_ci
2016cabdff1aSopenharmony_ci/**
2017cabdff1aSopenharmony_ci * @}
2018cabdff1aSopenharmony_ci */
2019cabdff1aSopenharmony_ci
2020cabdff1aSopenharmony_ci
2021cabdff1aSopenharmony_ci/**
2022cabdff1aSopenharmony_ci * Allocate an AVFormatContext for an output format.
2023cabdff1aSopenharmony_ci * avformat_free_context() can be used to free the context and
2024cabdff1aSopenharmony_ci * everything allocated by the framework within it.
2025cabdff1aSopenharmony_ci *
2026cabdff1aSopenharmony_ci * @param *ctx is set to the created format context, or to NULL in
2027cabdff1aSopenharmony_ci * case of failure
2028cabdff1aSopenharmony_ci * @param oformat format to use for allocating the context, if NULL
2029cabdff1aSopenharmony_ci * format_name and filename are used instead
2030cabdff1aSopenharmony_ci * @param format_name the name of output format to use for allocating the
2031cabdff1aSopenharmony_ci * context, if NULL filename is used instead
2032cabdff1aSopenharmony_ci * @param filename the name of the filename to use for allocating the
2033cabdff1aSopenharmony_ci * context, may be NULL
2034cabdff1aSopenharmony_ci * @return >= 0 in case of success, a negative AVERROR code in case of
2035cabdff1aSopenharmony_ci * failure
2036cabdff1aSopenharmony_ci */
2037cabdff1aSopenharmony_ciint avformat_alloc_output_context2(AVFormatContext **ctx, const AVOutputFormat *oformat,
2038cabdff1aSopenharmony_ci                                   const char *format_name, const char *filename);
2039cabdff1aSopenharmony_ci
2040cabdff1aSopenharmony_ci/**
2041cabdff1aSopenharmony_ci * @addtogroup lavf_decoding
2042cabdff1aSopenharmony_ci * @{
2043cabdff1aSopenharmony_ci */
2044cabdff1aSopenharmony_ci
2045cabdff1aSopenharmony_ci/**
2046cabdff1aSopenharmony_ci * Find AVInputFormat based on the short name of the input format.
2047cabdff1aSopenharmony_ci */
2048cabdff1aSopenharmony_ciconst AVInputFormat *av_find_input_format(const char *short_name);
2049cabdff1aSopenharmony_ci
2050cabdff1aSopenharmony_ci/**
2051cabdff1aSopenharmony_ci * Guess the file format.
2052cabdff1aSopenharmony_ci *
2053cabdff1aSopenharmony_ci * @param pd        data to be probed
2054cabdff1aSopenharmony_ci * @param is_opened Whether the file is already opened; determines whether
2055cabdff1aSopenharmony_ci *                  demuxers with or without AVFMT_NOFILE are probed.
2056cabdff1aSopenharmony_ci */
2057cabdff1aSopenharmony_ciconst AVInputFormat *av_probe_input_format(const AVProbeData *pd, int is_opened);
2058cabdff1aSopenharmony_ci
2059cabdff1aSopenharmony_ci/**
2060cabdff1aSopenharmony_ci * Guess the file format.
2061cabdff1aSopenharmony_ci *
2062cabdff1aSopenharmony_ci * @param pd        data to be probed
2063cabdff1aSopenharmony_ci * @param is_opened Whether the file is already opened; determines whether
2064cabdff1aSopenharmony_ci *                  demuxers with or without AVFMT_NOFILE are probed.
2065cabdff1aSopenharmony_ci * @param score_max A probe score larger that this is required to accept a
2066cabdff1aSopenharmony_ci *                  detection, the variable is set to the actual detection
2067cabdff1aSopenharmony_ci *                  score afterwards.
2068cabdff1aSopenharmony_ci *                  If the score is <= AVPROBE_SCORE_MAX / 4 it is recommended
2069cabdff1aSopenharmony_ci *                  to retry with a larger probe buffer.
2070cabdff1aSopenharmony_ci */
2071cabdff1aSopenharmony_ciconst AVInputFormat *av_probe_input_format2(const AVProbeData *pd,
2072cabdff1aSopenharmony_ci                                            int is_opened, int *score_max);
2073cabdff1aSopenharmony_ci
2074cabdff1aSopenharmony_ci/**
2075cabdff1aSopenharmony_ci * Guess the file format.
2076cabdff1aSopenharmony_ci *
2077cabdff1aSopenharmony_ci * @param is_opened Whether the file is already opened; determines whether
2078cabdff1aSopenharmony_ci *                  demuxers with or without AVFMT_NOFILE are probed.
2079cabdff1aSopenharmony_ci * @param score_ret The score of the best detection.
2080cabdff1aSopenharmony_ci */
2081cabdff1aSopenharmony_ciconst AVInputFormat *av_probe_input_format3(const AVProbeData *pd,
2082cabdff1aSopenharmony_ci                                            int is_opened, int *score_ret);
2083cabdff1aSopenharmony_ci
2084cabdff1aSopenharmony_ci/**
2085cabdff1aSopenharmony_ci * Probe a bytestream to determine the input format. Each time a probe returns
2086cabdff1aSopenharmony_ci * with a score that is too low, the probe buffer size is increased and another
2087cabdff1aSopenharmony_ci * attempt is made. When the maximum probe size is reached, the input format
2088cabdff1aSopenharmony_ci * with the highest score is returned.
2089cabdff1aSopenharmony_ci *
2090cabdff1aSopenharmony_ci * @param pb the bytestream to probe
2091cabdff1aSopenharmony_ci * @param fmt the input format is put here
2092cabdff1aSopenharmony_ci * @param url the url of the stream
2093cabdff1aSopenharmony_ci * @param logctx the log context
2094cabdff1aSopenharmony_ci * @param offset the offset within the bytestream to probe from
2095cabdff1aSopenharmony_ci * @param max_probe_size the maximum probe buffer size (zero for default)
2096cabdff1aSopenharmony_ci * @return the score in case of success, a negative value corresponding to an
2097cabdff1aSopenharmony_ci *         the maximal score is AVPROBE_SCORE_MAX
2098cabdff1aSopenharmony_ci * AVERROR code otherwise
2099cabdff1aSopenharmony_ci */
2100cabdff1aSopenharmony_ciint av_probe_input_buffer2(AVIOContext *pb, const AVInputFormat **fmt,
2101cabdff1aSopenharmony_ci                           const char *url, void *logctx,
2102cabdff1aSopenharmony_ci                           unsigned int offset, unsigned int max_probe_size);
2103cabdff1aSopenharmony_ci
2104cabdff1aSopenharmony_ci/**
2105cabdff1aSopenharmony_ci * Like av_probe_input_buffer2() but returns 0 on success
2106cabdff1aSopenharmony_ci */
2107cabdff1aSopenharmony_ciint av_probe_input_buffer(AVIOContext *pb, const AVInputFormat **fmt,
2108cabdff1aSopenharmony_ci                          const char *url, void *logctx,
2109cabdff1aSopenharmony_ci                          unsigned int offset, unsigned int max_probe_size);
2110cabdff1aSopenharmony_ci
2111cabdff1aSopenharmony_ci/**
2112cabdff1aSopenharmony_ci * Open an input stream and read the header. The codecs are not opened.
2113cabdff1aSopenharmony_ci * The stream must be closed with avformat_close_input().
2114cabdff1aSopenharmony_ci *
2115cabdff1aSopenharmony_ci * @param ps Pointer to user-supplied AVFormatContext (allocated by avformat_alloc_context).
2116cabdff1aSopenharmony_ci *           May be a pointer to NULL, in which case an AVFormatContext is allocated by this
2117cabdff1aSopenharmony_ci *           function and written into ps.
2118cabdff1aSopenharmony_ci *           Note that a user-supplied AVFormatContext will be freed on failure.
2119cabdff1aSopenharmony_ci * @param url URL of the stream to open.
2120cabdff1aSopenharmony_ci * @param fmt If non-NULL, this parameter forces a specific input format.
2121cabdff1aSopenharmony_ci *            Otherwise the format is autodetected.
2122cabdff1aSopenharmony_ci * @param options  A dictionary filled with AVFormatContext and demuxer-private options.
2123cabdff1aSopenharmony_ci *                 On return this parameter will be destroyed and replaced with a dict containing
2124cabdff1aSopenharmony_ci *                 options that were not found. May be NULL.
2125cabdff1aSopenharmony_ci *
2126cabdff1aSopenharmony_ci * @return 0 on success, a negative AVERROR on failure.
2127cabdff1aSopenharmony_ci *
2128cabdff1aSopenharmony_ci * @note If you want to use custom IO, preallocate the format context and set its pb field.
2129cabdff1aSopenharmony_ci */
2130cabdff1aSopenharmony_ciint avformat_open_input(AVFormatContext **ps, const char *url,
2131cabdff1aSopenharmony_ci                        const AVInputFormat *fmt, AVDictionary **options);
2132cabdff1aSopenharmony_ci
2133cabdff1aSopenharmony_ci/**
2134cabdff1aSopenharmony_ci * Read packets of a media file to get stream information. This
2135cabdff1aSopenharmony_ci * is useful for file formats with no headers such as MPEG. This
2136cabdff1aSopenharmony_ci * function also computes the real framerate in case of MPEG-2 repeat
2137cabdff1aSopenharmony_ci * frame mode.
2138cabdff1aSopenharmony_ci * The logical file position is not changed by this function;
2139cabdff1aSopenharmony_ci * examined packets may be buffered for later processing.
2140cabdff1aSopenharmony_ci *
2141cabdff1aSopenharmony_ci * @param ic media file handle
2142cabdff1aSopenharmony_ci * @param options  If non-NULL, an ic.nb_streams long array of pointers to
2143cabdff1aSopenharmony_ci *                 dictionaries, where i-th member contains options for
2144cabdff1aSopenharmony_ci *                 codec corresponding to i-th stream.
2145cabdff1aSopenharmony_ci *                 On return each dictionary will be filled with options that were not found.
2146cabdff1aSopenharmony_ci * @return >=0 if OK, AVERROR_xxx on error
2147cabdff1aSopenharmony_ci *
2148cabdff1aSopenharmony_ci * @note this function isn't guaranteed to open all the codecs, so
2149cabdff1aSopenharmony_ci *       options being non-empty at return is a perfectly normal behavior.
2150cabdff1aSopenharmony_ci *
2151cabdff1aSopenharmony_ci * @todo Let the user decide somehow what information is needed so that
2152cabdff1aSopenharmony_ci *       we do not waste time getting stuff the user does not need.
2153cabdff1aSopenharmony_ci */
2154cabdff1aSopenharmony_ciint avformat_find_stream_info(AVFormatContext *ic, AVDictionary **options);
2155cabdff1aSopenharmony_ci
2156cabdff1aSopenharmony_ci/**
2157cabdff1aSopenharmony_ci * Find the programs which belong to a given stream.
2158cabdff1aSopenharmony_ci *
2159cabdff1aSopenharmony_ci * @param ic    media file handle
2160cabdff1aSopenharmony_ci * @param last  the last found program, the search will start after this
2161cabdff1aSopenharmony_ci *              program, or from the beginning if it is NULL
2162cabdff1aSopenharmony_ci * @param s     stream index
2163cabdff1aSopenharmony_ci * @return the next program which belongs to s, NULL if no program is found or
2164cabdff1aSopenharmony_ci *         the last program is not among the programs of ic.
2165cabdff1aSopenharmony_ci */
2166cabdff1aSopenharmony_ciAVProgram *av_find_program_from_stream(AVFormatContext *ic, AVProgram *last, int s);
2167cabdff1aSopenharmony_ci
2168cabdff1aSopenharmony_civoid av_program_add_stream_index(AVFormatContext *ac, int progid, unsigned int idx);
2169cabdff1aSopenharmony_ci
2170cabdff1aSopenharmony_ci/**
2171cabdff1aSopenharmony_ci * Find the "best" stream in the file.
2172cabdff1aSopenharmony_ci * The best stream is determined according to various heuristics as the most
2173cabdff1aSopenharmony_ci * likely to be what the user expects.
2174cabdff1aSopenharmony_ci * If the decoder parameter is non-NULL, av_find_best_stream will find the
2175cabdff1aSopenharmony_ci * default decoder for the stream's codec; streams for which no decoder can
2176cabdff1aSopenharmony_ci * be found are ignored.
2177cabdff1aSopenharmony_ci *
2178cabdff1aSopenharmony_ci * @param ic                media file handle
2179cabdff1aSopenharmony_ci * @param type              stream type: video, audio, subtitles, etc.
2180cabdff1aSopenharmony_ci * @param wanted_stream_nb  user-requested stream number,
2181cabdff1aSopenharmony_ci *                          or -1 for automatic selection
2182cabdff1aSopenharmony_ci * @param related_stream    try to find a stream related (eg. in the same
2183cabdff1aSopenharmony_ci *                          program) to this one, or -1 if none
2184cabdff1aSopenharmony_ci * @param decoder_ret       if non-NULL, returns the decoder for the
2185cabdff1aSopenharmony_ci *                          selected stream
2186cabdff1aSopenharmony_ci * @param flags             flags; none are currently defined
2187cabdff1aSopenharmony_ci * @return  the non-negative stream number in case of success,
2188cabdff1aSopenharmony_ci *          AVERROR_STREAM_NOT_FOUND if no stream with the requested type
2189cabdff1aSopenharmony_ci *          could be found,
2190cabdff1aSopenharmony_ci *          AVERROR_DECODER_NOT_FOUND if streams were found but no decoder
2191cabdff1aSopenharmony_ci * @note  If av_find_best_stream returns successfully and decoder_ret is not
2192cabdff1aSopenharmony_ci *        NULL, then *decoder_ret is guaranteed to be set to a valid AVCodec.
2193cabdff1aSopenharmony_ci */
2194cabdff1aSopenharmony_ciint av_find_best_stream(AVFormatContext *ic,
2195cabdff1aSopenharmony_ci                        enum AVMediaType type,
2196cabdff1aSopenharmony_ci                        int wanted_stream_nb,
2197cabdff1aSopenharmony_ci                        int related_stream,
2198cabdff1aSopenharmony_ci                        const AVCodec **decoder_ret,
2199cabdff1aSopenharmony_ci                        int flags);
2200cabdff1aSopenharmony_ci
2201cabdff1aSopenharmony_ci/**
2202cabdff1aSopenharmony_ci * Return the next frame of a stream.
2203cabdff1aSopenharmony_ci * This function returns what is stored in the file, and does not validate
2204cabdff1aSopenharmony_ci * that what is there are valid frames for the decoder. It will split what is
2205cabdff1aSopenharmony_ci * stored in the file into frames and return one for each call. It will not
2206cabdff1aSopenharmony_ci * omit invalid data between valid frames so as to give the decoder the maximum
2207cabdff1aSopenharmony_ci * information possible for decoding.
2208cabdff1aSopenharmony_ci *
2209cabdff1aSopenharmony_ci * On success, the returned packet is reference-counted (pkt->buf is set) and
2210cabdff1aSopenharmony_ci * valid indefinitely. The packet must be freed with av_packet_unref() when
2211cabdff1aSopenharmony_ci * it is no longer needed. For video, the packet contains exactly one frame.
2212cabdff1aSopenharmony_ci * For audio, it contains an integer number of frames if each frame has
2213cabdff1aSopenharmony_ci * a known fixed size (e.g. PCM or ADPCM data). If the audio frames have
2214cabdff1aSopenharmony_ci * a variable size (e.g. MPEG audio), then it contains one frame.
2215cabdff1aSopenharmony_ci *
2216cabdff1aSopenharmony_ci * pkt->pts, pkt->dts and pkt->duration are always set to correct
2217cabdff1aSopenharmony_ci * values in AVStream.time_base units (and guessed if the format cannot
2218cabdff1aSopenharmony_ci * provide them). pkt->pts can be AV_NOPTS_VALUE if the video format
2219cabdff1aSopenharmony_ci * has B-frames, so it is better to rely on pkt->dts if you do not
2220cabdff1aSopenharmony_ci * decompress the payload.
2221cabdff1aSopenharmony_ci *
2222cabdff1aSopenharmony_ci * @return 0 if OK, < 0 on error or end of file. On error, pkt will be blank
2223cabdff1aSopenharmony_ci *         (as if it came from av_packet_alloc()).
2224cabdff1aSopenharmony_ci *
2225cabdff1aSopenharmony_ci * @note pkt will be initialized, so it may be uninitialized, but it must not
2226cabdff1aSopenharmony_ci *       contain data that needs to be freed.
2227cabdff1aSopenharmony_ci */
2228cabdff1aSopenharmony_ciint av_read_frame(AVFormatContext *s, AVPacket *pkt);
2229cabdff1aSopenharmony_ci
2230cabdff1aSopenharmony_ci/**
2231cabdff1aSopenharmony_ci * Seek to the keyframe at timestamp.
2232cabdff1aSopenharmony_ci * 'timestamp' in 'stream_index'.
2233cabdff1aSopenharmony_ci *
2234cabdff1aSopenharmony_ci * @param s media file handle
2235cabdff1aSopenharmony_ci * @param stream_index If stream_index is (-1), a default
2236cabdff1aSopenharmony_ci * stream is selected, and timestamp is automatically converted
2237cabdff1aSopenharmony_ci * from AV_TIME_BASE units to the stream specific time_base.
2238cabdff1aSopenharmony_ci * @param timestamp Timestamp in AVStream.time_base units
2239cabdff1aSopenharmony_ci *        or, if no stream is specified, in AV_TIME_BASE units.
2240cabdff1aSopenharmony_ci * @param flags flags which select direction and seeking mode
2241cabdff1aSopenharmony_ci * @return >= 0 on success
2242cabdff1aSopenharmony_ci */
2243cabdff1aSopenharmony_ciint av_seek_frame(AVFormatContext *s, int stream_index, int64_t timestamp,
2244cabdff1aSopenharmony_ci                  int flags);
2245cabdff1aSopenharmony_ci
2246cabdff1aSopenharmony_ci/**
2247cabdff1aSopenharmony_ci * Seek to timestamp ts.
2248cabdff1aSopenharmony_ci * Seeking will be done so that the point from which all active streams
2249cabdff1aSopenharmony_ci * can be presented successfully will be closest to ts and within min/max_ts.
2250cabdff1aSopenharmony_ci * Active streams are all streams that have AVStream.discard < AVDISCARD_ALL.
2251cabdff1aSopenharmony_ci *
2252cabdff1aSopenharmony_ci * If flags contain AVSEEK_FLAG_BYTE, then all timestamps are in bytes and
2253cabdff1aSopenharmony_ci * are the file position (this may not be supported by all demuxers).
2254cabdff1aSopenharmony_ci * If flags contain AVSEEK_FLAG_FRAME, then all timestamps are in frames
2255cabdff1aSopenharmony_ci * in the stream with stream_index (this may not be supported by all demuxers).
2256cabdff1aSopenharmony_ci * Otherwise all timestamps are in units of the stream selected by stream_index
2257cabdff1aSopenharmony_ci * or if stream_index is -1, in AV_TIME_BASE units.
2258cabdff1aSopenharmony_ci * If flags contain AVSEEK_FLAG_ANY, then non-keyframes are treated as
2259cabdff1aSopenharmony_ci * keyframes (this may not be supported by all demuxers).
2260cabdff1aSopenharmony_ci * If flags contain AVSEEK_FLAG_BACKWARD, it is ignored.
2261cabdff1aSopenharmony_ci *
2262cabdff1aSopenharmony_ci * @param s media file handle
2263cabdff1aSopenharmony_ci * @param stream_index index of the stream which is used as time base reference
2264cabdff1aSopenharmony_ci * @param min_ts smallest acceptable timestamp
2265cabdff1aSopenharmony_ci * @param ts target timestamp
2266cabdff1aSopenharmony_ci * @param max_ts largest acceptable timestamp
2267cabdff1aSopenharmony_ci * @param flags flags
2268cabdff1aSopenharmony_ci * @return >=0 on success, error code otherwise
2269cabdff1aSopenharmony_ci *
2270cabdff1aSopenharmony_ci * @note This is part of the new seek API which is still under construction.
2271cabdff1aSopenharmony_ci */
2272cabdff1aSopenharmony_ciint avformat_seek_file(AVFormatContext *s, int stream_index, int64_t min_ts, int64_t ts, int64_t max_ts, int flags);
2273cabdff1aSopenharmony_ci
2274cabdff1aSopenharmony_ci/**
2275cabdff1aSopenharmony_ci * Discard all internally buffered data. This can be useful when dealing with
2276cabdff1aSopenharmony_ci * discontinuities in the byte stream. Generally works only with formats that
2277cabdff1aSopenharmony_ci * can resync. This includes headerless formats like MPEG-TS/TS but should also
2278cabdff1aSopenharmony_ci * work with NUT, Ogg and in a limited way AVI for example.
2279cabdff1aSopenharmony_ci *
2280cabdff1aSopenharmony_ci * The set of streams, the detected duration, stream parameters and codecs do
2281cabdff1aSopenharmony_ci * not change when calling this function. If you want a complete reset, it's
2282cabdff1aSopenharmony_ci * better to open a new AVFormatContext.
2283cabdff1aSopenharmony_ci *
2284cabdff1aSopenharmony_ci * This does not flush the AVIOContext (s->pb). If necessary, call
2285cabdff1aSopenharmony_ci * avio_flush(s->pb) before calling this function.
2286cabdff1aSopenharmony_ci *
2287cabdff1aSopenharmony_ci * @param s media file handle
2288cabdff1aSopenharmony_ci * @return >=0 on success, error code otherwise
2289cabdff1aSopenharmony_ci */
2290cabdff1aSopenharmony_ciint avformat_flush(AVFormatContext *s);
2291cabdff1aSopenharmony_ci
2292cabdff1aSopenharmony_ci/**
2293cabdff1aSopenharmony_ci * Start playing a network-based stream (e.g. RTSP stream) at the
2294cabdff1aSopenharmony_ci * current position.
2295cabdff1aSopenharmony_ci */
2296cabdff1aSopenharmony_ciint av_read_play(AVFormatContext *s);
2297cabdff1aSopenharmony_ci
2298cabdff1aSopenharmony_ci/**
2299cabdff1aSopenharmony_ci * Pause a network-based stream (e.g. RTSP stream).
2300cabdff1aSopenharmony_ci *
2301cabdff1aSopenharmony_ci * Use av_read_play() to resume it.
2302cabdff1aSopenharmony_ci */
2303cabdff1aSopenharmony_ciint av_read_pause(AVFormatContext *s);
2304cabdff1aSopenharmony_ci
2305cabdff1aSopenharmony_ci/**
2306cabdff1aSopenharmony_ci * Close an opened input AVFormatContext. Free it and all its contents
2307cabdff1aSopenharmony_ci * and set *s to NULL.
2308cabdff1aSopenharmony_ci */
2309cabdff1aSopenharmony_civoid avformat_close_input(AVFormatContext **s);
2310cabdff1aSopenharmony_ci/**
2311cabdff1aSopenharmony_ci * @}
2312cabdff1aSopenharmony_ci */
2313cabdff1aSopenharmony_ci
2314cabdff1aSopenharmony_ci#define AVSEEK_FLAG_BACKWARD 1 ///< seek backward
2315cabdff1aSopenharmony_ci#define AVSEEK_FLAG_BYTE     2 ///< seeking based on position in bytes
2316cabdff1aSopenharmony_ci#define AVSEEK_FLAG_ANY      4 ///< seek to any frame, even non-keyframes
2317cabdff1aSopenharmony_ci#define AVSEEK_FLAG_FRAME    8 ///< seeking based on frame number
2318cabdff1aSopenharmony_ci
2319cabdff1aSopenharmony_ci/**
2320cabdff1aSopenharmony_ci * @addtogroup lavf_encoding
2321cabdff1aSopenharmony_ci * @{
2322cabdff1aSopenharmony_ci */
2323cabdff1aSopenharmony_ci
2324cabdff1aSopenharmony_ci#define AVSTREAM_INIT_IN_WRITE_HEADER 0 ///< stream parameters initialized in avformat_write_header
2325cabdff1aSopenharmony_ci#define AVSTREAM_INIT_IN_INIT_OUTPUT  1 ///< stream parameters initialized in avformat_init_output
2326cabdff1aSopenharmony_ci
2327cabdff1aSopenharmony_ci/**
2328cabdff1aSopenharmony_ci * Allocate the stream private data and write the stream header to
2329cabdff1aSopenharmony_ci * an output media file.
2330cabdff1aSopenharmony_ci *
2331cabdff1aSopenharmony_ci * @param s Media file handle, must be allocated with avformat_alloc_context().
2332cabdff1aSopenharmony_ci *          Its oformat field must be set to the desired output format;
2333cabdff1aSopenharmony_ci *          Its pb field must be set to an already opened AVIOContext.
2334cabdff1aSopenharmony_ci * @param options  An AVDictionary filled with AVFormatContext and muxer-private options.
2335cabdff1aSopenharmony_ci *                 On return this parameter will be destroyed and replaced with a dict containing
2336cabdff1aSopenharmony_ci *                 options that were not found. May be NULL.
2337cabdff1aSopenharmony_ci *
2338cabdff1aSopenharmony_ci * @return AVSTREAM_INIT_IN_WRITE_HEADER on success if the codec had not already been fully initialized in avformat_init,
2339cabdff1aSopenharmony_ci *         AVSTREAM_INIT_IN_INIT_OUTPUT  on success if the codec had already been fully initialized in avformat_init,
2340cabdff1aSopenharmony_ci *         negative AVERROR on failure.
2341cabdff1aSopenharmony_ci *
2342cabdff1aSopenharmony_ci * @see av_opt_find, av_dict_set, avio_open, av_oformat_next, avformat_init_output.
2343cabdff1aSopenharmony_ci */
2344cabdff1aSopenharmony_ciav_warn_unused_result
2345cabdff1aSopenharmony_ciint avformat_write_header(AVFormatContext *s, AVDictionary **options);
2346cabdff1aSopenharmony_ci
2347cabdff1aSopenharmony_ci/**
2348cabdff1aSopenharmony_ci * Allocate the stream private data and initialize the codec, but do not write the header.
2349cabdff1aSopenharmony_ci * May optionally be used before avformat_write_header to initialize stream parameters
2350cabdff1aSopenharmony_ci * before actually writing the header.
2351cabdff1aSopenharmony_ci * If using this function, do not pass the same options to avformat_write_header.
2352cabdff1aSopenharmony_ci *
2353cabdff1aSopenharmony_ci * @param s Media file handle, must be allocated with avformat_alloc_context().
2354cabdff1aSopenharmony_ci *          Its oformat field must be set to the desired output format;
2355cabdff1aSopenharmony_ci *          Its pb field must be set to an already opened AVIOContext.
2356cabdff1aSopenharmony_ci * @param options  An AVDictionary filled with AVFormatContext and muxer-private options.
2357cabdff1aSopenharmony_ci *                 On return this parameter will be destroyed and replaced with a dict containing
2358cabdff1aSopenharmony_ci *                 options that were not found. May be NULL.
2359cabdff1aSopenharmony_ci *
2360cabdff1aSopenharmony_ci * @return AVSTREAM_INIT_IN_WRITE_HEADER on success if the codec requires avformat_write_header to fully initialize,
2361cabdff1aSopenharmony_ci *         AVSTREAM_INIT_IN_INIT_OUTPUT  on success if the codec has been fully initialized,
2362cabdff1aSopenharmony_ci *         negative AVERROR on failure.
2363cabdff1aSopenharmony_ci *
2364cabdff1aSopenharmony_ci * @see av_opt_find, av_dict_set, avio_open, av_oformat_next, avformat_write_header.
2365cabdff1aSopenharmony_ci */
2366cabdff1aSopenharmony_ciav_warn_unused_result
2367cabdff1aSopenharmony_ciint avformat_init_output(AVFormatContext *s, AVDictionary **options);
2368cabdff1aSopenharmony_ci
2369cabdff1aSopenharmony_ci/**
2370cabdff1aSopenharmony_ci * Write a packet to an output media file.
2371cabdff1aSopenharmony_ci *
2372cabdff1aSopenharmony_ci * This function passes the packet directly to the muxer, without any buffering
2373cabdff1aSopenharmony_ci * or reordering. The caller is responsible for correctly interleaving the
2374cabdff1aSopenharmony_ci * packets if the format requires it. Callers that want libavformat to handle
2375cabdff1aSopenharmony_ci * the interleaving should call av_interleaved_write_frame() instead of this
2376cabdff1aSopenharmony_ci * function.
2377cabdff1aSopenharmony_ci *
2378cabdff1aSopenharmony_ci * @param s media file handle
2379cabdff1aSopenharmony_ci * @param pkt The packet containing the data to be written. Note that unlike
2380cabdff1aSopenharmony_ci *            av_interleaved_write_frame(), this function does not take
2381cabdff1aSopenharmony_ci *            ownership of the packet passed to it (though some muxers may make
2382cabdff1aSopenharmony_ci *            an internal reference to the input packet).
2383cabdff1aSopenharmony_ci *            <br>
2384cabdff1aSopenharmony_ci *            This parameter can be NULL (at any time, not just at the end), in
2385cabdff1aSopenharmony_ci *            order to immediately flush data buffered within the muxer, for
2386cabdff1aSopenharmony_ci *            muxers that buffer up data internally before writing it to the
2387cabdff1aSopenharmony_ci *            output.
2388cabdff1aSopenharmony_ci *            <br>
2389cabdff1aSopenharmony_ci *            Packet's @ref AVPacket.stream_index "stream_index" field must be
2390cabdff1aSopenharmony_ci *            set to the index of the corresponding stream in @ref
2391cabdff1aSopenharmony_ci *            AVFormatContext.streams "s->streams".
2392cabdff1aSopenharmony_ci *            <br>
2393cabdff1aSopenharmony_ci *            The timestamps (@ref AVPacket.pts "pts", @ref AVPacket.dts "dts")
2394cabdff1aSopenharmony_ci *            must be set to correct values in the stream's timebase (unless the
2395cabdff1aSopenharmony_ci *            output format is flagged with the AVFMT_NOTIMESTAMPS flag, then
2396cabdff1aSopenharmony_ci *            they can be set to AV_NOPTS_VALUE).
2397cabdff1aSopenharmony_ci *            The dts for subsequent packets passed to this function must be strictly
2398cabdff1aSopenharmony_ci *            increasing when compared in their respective timebases (unless the
2399cabdff1aSopenharmony_ci *            output format is flagged with the AVFMT_TS_NONSTRICT, then they
2400cabdff1aSopenharmony_ci *            merely have to be nondecreasing).  @ref AVPacket.duration
2401cabdff1aSopenharmony_ci *            "duration") should also be set if known.
2402cabdff1aSopenharmony_ci * @return < 0 on error, = 0 if OK, 1 if flushed and there is no more data to flush
2403cabdff1aSopenharmony_ci *
2404cabdff1aSopenharmony_ci * @see av_interleaved_write_frame()
2405cabdff1aSopenharmony_ci */
2406cabdff1aSopenharmony_ciint av_write_frame(AVFormatContext *s, AVPacket *pkt);
2407cabdff1aSopenharmony_ci
2408cabdff1aSopenharmony_ci/**
2409cabdff1aSopenharmony_ci * Write a packet to an output media file ensuring correct interleaving.
2410cabdff1aSopenharmony_ci *
2411cabdff1aSopenharmony_ci * This function will buffer the packets internally as needed to make sure the
2412cabdff1aSopenharmony_ci * packets in the output file are properly interleaved, usually ordered by
2413cabdff1aSopenharmony_ci * increasing dts. Callers doing their own interleaving should call
2414cabdff1aSopenharmony_ci * av_write_frame() instead of this function.
2415cabdff1aSopenharmony_ci *
2416cabdff1aSopenharmony_ci * Using this function instead of av_write_frame() can give muxers advance
2417cabdff1aSopenharmony_ci * knowledge of future packets, improving e.g. the behaviour of the mp4
2418cabdff1aSopenharmony_ci * muxer for VFR content in fragmenting mode.
2419cabdff1aSopenharmony_ci *
2420cabdff1aSopenharmony_ci * @param s media file handle
2421cabdff1aSopenharmony_ci * @param pkt The packet containing the data to be written.
2422cabdff1aSopenharmony_ci *            <br>
2423cabdff1aSopenharmony_ci *            If the packet is reference-counted, this function will take
2424cabdff1aSopenharmony_ci *            ownership of this reference and unreference it later when it sees
2425cabdff1aSopenharmony_ci *            fit. If the packet is not reference-counted, libavformat will
2426cabdff1aSopenharmony_ci *            make a copy.
2427cabdff1aSopenharmony_ci *            The returned packet will be blank (as if returned from
2428cabdff1aSopenharmony_ci *            av_packet_alloc()), even on error.
2429cabdff1aSopenharmony_ci *            <br>
2430cabdff1aSopenharmony_ci *            This parameter can be NULL (at any time, not just at the end), to
2431cabdff1aSopenharmony_ci *            flush the interleaving queues.
2432cabdff1aSopenharmony_ci *            <br>
2433cabdff1aSopenharmony_ci *            Packet's @ref AVPacket.stream_index "stream_index" field must be
2434cabdff1aSopenharmony_ci *            set to the index of the corresponding stream in @ref
2435cabdff1aSopenharmony_ci *            AVFormatContext.streams "s->streams".
2436cabdff1aSopenharmony_ci *            <br>
2437cabdff1aSopenharmony_ci *            The timestamps (@ref AVPacket.pts "pts", @ref AVPacket.dts "dts")
2438cabdff1aSopenharmony_ci *            must be set to correct values in the stream's timebase (unless the
2439cabdff1aSopenharmony_ci *            output format is flagged with the AVFMT_NOTIMESTAMPS flag, then
2440cabdff1aSopenharmony_ci *            they can be set to AV_NOPTS_VALUE).
2441cabdff1aSopenharmony_ci *            The dts for subsequent packets in one stream must be strictly
2442cabdff1aSopenharmony_ci *            increasing (unless the output format is flagged with the
2443cabdff1aSopenharmony_ci *            AVFMT_TS_NONSTRICT, then they merely have to be nondecreasing).
2444cabdff1aSopenharmony_ci *            @ref AVPacket.duration "duration" should also be set if known.
2445cabdff1aSopenharmony_ci *
2446cabdff1aSopenharmony_ci * @return 0 on success, a negative AVERROR on error.
2447cabdff1aSopenharmony_ci *
2448cabdff1aSopenharmony_ci * @see av_write_frame(), AVFormatContext.max_interleave_delta
2449cabdff1aSopenharmony_ci */
2450cabdff1aSopenharmony_ciint av_interleaved_write_frame(AVFormatContext *s, AVPacket *pkt);
2451cabdff1aSopenharmony_ci
2452cabdff1aSopenharmony_ci/**
2453cabdff1aSopenharmony_ci * Write an uncoded frame to an output media file.
2454cabdff1aSopenharmony_ci *
2455cabdff1aSopenharmony_ci * The frame must be correctly interleaved according to the container
2456cabdff1aSopenharmony_ci * specification; if not, av_interleaved_write_uncoded_frame() must be used.
2457cabdff1aSopenharmony_ci *
2458cabdff1aSopenharmony_ci * See av_interleaved_write_uncoded_frame() for details.
2459cabdff1aSopenharmony_ci */
2460cabdff1aSopenharmony_ciint av_write_uncoded_frame(AVFormatContext *s, int stream_index,
2461cabdff1aSopenharmony_ci                           AVFrame *frame);
2462cabdff1aSopenharmony_ci
2463cabdff1aSopenharmony_ci/**
2464cabdff1aSopenharmony_ci * Write an uncoded frame to an output media file.
2465cabdff1aSopenharmony_ci *
2466cabdff1aSopenharmony_ci * If the muxer supports it, this function makes it possible to write an AVFrame
2467cabdff1aSopenharmony_ci * structure directly, without encoding it into a packet.
2468cabdff1aSopenharmony_ci * It is mostly useful for devices and similar special muxers that use raw
2469cabdff1aSopenharmony_ci * video or PCM data and will not serialize it into a byte stream.
2470cabdff1aSopenharmony_ci *
2471cabdff1aSopenharmony_ci * To test whether it is possible to use it with a given muxer and stream,
2472cabdff1aSopenharmony_ci * use av_write_uncoded_frame_query().
2473cabdff1aSopenharmony_ci *
2474cabdff1aSopenharmony_ci * The caller gives up ownership of the frame and must not access it
2475cabdff1aSopenharmony_ci * afterwards.
2476cabdff1aSopenharmony_ci *
2477cabdff1aSopenharmony_ci * @return  >=0 for success, a negative code on error
2478cabdff1aSopenharmony_ci */
2479cabdff1aSopenharmony_ciint av_interleaved_write_uncoded_frame(AVFormatContext *s, int stream_index,
2480cabdff1aSopenharmony_ci                                       AVFrame *frame);
2481cabdff1aSopenharmony_ci
2482cabdff1aSopenharmony_ci/**
2483cabdff1aSopenharmony_ci * Test whether a muxer supports uncoded frame.
2484cabdff1aSopenharmony_ci *
2485cabdff1aSopenharmony_ci * @return  >=0 if an uncoded frame can be written to that muxer and stream,
2486cabdff1aSopenharmony_ci *          <0 if not
2487cabdff1aSopenharmony_ci */
2488cabdff1aSopenharmony_ciint av_write_uncoded_frame_query(AVFormatContext *s, int stream_index);
2489cabdff1aSopenharmony_ci
2490cabdff1aSopenharmony_ci/**
2491cabdff1aSopenharmony_ci * Write the stream trailer to an output media file and free the
2492cabdff1aSopenharmony_ci * file private data.
2493cabdff1aSopenharmony_ci *
2494cabdff1aSopenharmony_ci * May only be called after a successful call to avformat_write_header.
2495cabdff1aSopenharmony_ci *
2496cabdff1aSopenharmony_ci * @param s media file handle
2497cabdff1aSopenharmony_ci * @return 0 if OK, AVERROR_xxx on error
2498cabdff1aSopenharmony_ci */
2499cabdff1aSopenharmony_ciint av_write_trailer(AVFormatContext *s);
2500cabdff1aSopenharmony_ci
2501cabdff1aSopenharmony_ci/**
2502cabdff1aSopenharmony_ci * Return the output format in the list of registered output formats
2503cabdff1aSopenharmony_ci * which best matches the provided parameters, or return NULL if
2504cabdff1aSopenharmony_ci * there is no match.
2505cabdff1aSopenharmony_ci *
2506cabdff1aSopenharmony_ci * @param short_name if non-NULL checks if short_name matches with the
2507cabdff1aSopenharmony_ci * names of the registered formats
2508cabdff1aSopenharmony_ci * @param filename if non-NULL checks if filename terminates with the
2509cabdff1aSopenharmony_ci * extensions of the registered formats
2510cabdff1aSopenharmony_ci * @param mime_type if non-NULL checks if mime_type matches with the
2511cabdff1aSopenharmony_ci * MIME type of the registered formats
2512cabdff1aSopenharmony_ci */
2513cabdff1aSopenharmony_ciconst AVOutputFormat *av_guess_format(const char *short_name,
2514cabdff1aSopenharmony_ci                                      const char *filename,
2515cabdff1aSopenharmony_ci                                      const char *mime_type);
2516cabdff1aSopenharmony_ci
2517cabdff1aSopenharmony_ci/**
2518cabdff1aSopenharmony_ci * Guess the codec ID based upon muxer and filename.
2519cabdff1aSopenharmony_ci */
2520cabdff1aSopenharmony_cienum AVCodecID av_guess_codec(const AVOutputFormat *fmt, const char *short_name,
2521cabdff1aSopenharmony_ci                              const char *filename, const char *mime_type,
2522cabdff1aSopenharmony_ci                              enum AVMediaType type);
2523cabdff1aSopenharmony_ci
2524cabdff1aSopenharmony_ci/**
2525cabdff1aSopenharmony_ci * Get timing information for the data currently output.
2526cabdff1aSopenharmony_ci * The exact meaning of "currently output" depends on the format.
2527cabdff1aSopenharmony_ci * It is mostly relevant for devices that have an internal buffer and/or
2528cabdff1aSopenharmony_ci * work in real time.
2529cabdff1aSopenharmony_ci * @param s          media file handle
2530cabdff1aSopenharmony_ci * @param stream     stream in the media file
2531cabdff1aSopenharmony_ci * @param[out] dts   DTS of the last packet output for the stream, in stream
2532cabdff1aSopenharmony_ci *                   time_base units
2533cabdff1aSopenharmony_ci * @param[out] wall  absolute time when that packet whas output,
2534cabdff1aSopenharmony_ci *                   in microsecond
2535cabdff1aSopenharmony_ci * @return  0 if OK, AVERROR(ENOSYS) if the format does not support it
2536cabdff1aSopenharmony_ci * Note: some formats or devices may not allow to measure dts and wall
2537cabdff1aSopenharmony_ci * atomically.
2538cabdff1aSopenharmony_ci */
2539cabdff1aSopenharmony_ciint av_get_output_timestamp(struct AVFormatContext *s, int stream,
2540cabdff1aSopenharmony_ci                            int64_t *dts, int64_t *wall);
2541cabdff1aSopenharmony_ci
2542cabdff1aSopenharmony_ci
2543cabdff1aSopenharmony_ci/**
2544cabdff1aSopenharmony_ci * @}
2545cabdff1aSopenharmony_ci */
2546cabdff1aSopenharmony_ci
2547cabdff1aSopenharmony_ci
2548cabdff1aSopenharmony_ci/**
2549cabdff1aSopenharmony_ci * @defgroup lavf_misc Utility functions
2550cabdff1aSopenharmony_ci * @ingroup libavf
2551cabdff1aSopenharmony_ci * @{
2552cabdff1aSopenharmony_ci *
2553cabdff1aSopenharmony_ci * Miscellaneous utility functions related to both muxing and demuxing
2554cabdff1aSopenharmony_ci * (or neither).
2555cabdff1aSopenharmony_ci */
2556cabdff1aSopenharmony_ci
2557cabdff1aSopenharmony_ci/**
2558cabdff1aSopenharmony_ci * Send a nice hexadecimal dump of a buffer to the specified file stream.
2559cabdff1aSopenharmony_ci *
2560cabdff1aSopenharmony_ci * @param f The file stream pointer where the dump should be sent to.
2561cabdff1aSopenharmony_ci * @param buf buffer
2562cabdff1aSopenharmony_ci * @param size buffer size
2563cabdff1aSopenharmony_ci *
2564cabdff1aSopenharmony_ci * @see av_hex_dump_log, av_pkt_dump2, av_pkt_dump_log2
2565cabdff1aSopenharmony_ci */
2566cabdff1aSopenharmony_civoid av_hex_dump(FILE *f, const uint8_t *buf, int size);
2567cabdff1aSopenharmony_ci
2568cabdff1aSopenharmony_ci/**
2569cabdff1aSopenharmony_ci * Send a nice hexadecimal dump of a buffer to the log.
2570cabdff1aSopenharmony_ci *
2571cabdff1aSopenharmony_ci * @param avcl A pointer to an arbitrary struct of which the first field is a
2572cabdff1aSopenharmony_ci * pointer to an AVClass struct.
2573cabdff1aSopenharmony_ci * @param level The importance level of the message, lower values signifying
2574cabdff1aSopenharmony_ci * higher importance.
2575cabdff1aSopenharmony_ci * @param buf buffer
2576cabdff1aSopenharmony_ci * @param size buffer size
2577cabdff1aSopenharmony_ci *
2578cabdff1aSopenharmony_ci * @see av_hex_dump, av_pkt_dump2, av_pkt_dump_log2
2579cabdff1aSopenharmony_ci */
2580cabdff1aSopenharmony_civoid av_hex_dump_log(void *avcl, int level, const uint8_t *buf, int size);
2581cabdff1aSopenharmony_ci
2582cabdff1aSopenharmony_ci/**
2583cabdff1aSopenharmony_ci * Send a nice dump of a packet to the specified file stream.
2584cabdff1aSopenharmony_ci *
2585cabdff1aSopenharmony_ci * @param f The file stream pointer where the dump should be sent to.
2586cabdff1aSopenharmony_ci * @param pkt packet to dump
2587cabdff1aSopenharmony_ci * @param dump_payload True if the payload must be displayed, too.
2588cabdff1aSopenharmony_ci * @param st AVStream that the packet belongs to
2589cabdff1aSopenharmony_ci */
2590cabdff1aSopenharmony_civoid av_pkt_dump2(FILE *f, const AVPacket *pkt, int dump_payload, const AVStream *st);
2591cabdff1aSopenharmony_ci
2592cabdff1aSopenharmony_ci
2593cabdff1aSopenharmony_ci/**
2594cabdff1aSopenharmony_ci * Send a nice dump of a packet to the log.
2595cabdff1aSopenharmony_ci *
2596cabdff1aSopenharmony_ci * @param avcl A pointer to an arbitrary struct of which the first field is a
2597cabdff1aSopenharmony_ci * pointer to an AVClass struct.
2598cabdff1aSopenharmony_ci * @param level The importance level of the message, lower values signifying
2599cabdff1aSopenharmony_ci * higher importance.
2600cabdff1aSopenharmony_ci * @param pkt packet to dump
2601cabdff1aSopenharmony_ci * @param dump_payload True if the payload must be displayed, too.
2602cabdff1aSopenharmony_ci * @param st AVStream that the packet belongs to
2603cabdff1aSopenharmony_ci */
2604cabdff1aSopenharmony_civoid av_pkt_dump_log2(void *avcl, int level, const AVPacket *pkt, int dump_payload,
2605cabdff1aSopenharmony_ci                      const AVStream *st);
2606cabdff1aSopenharmony_ci
2607cabdff1aSopenharmony_ci/**
2608cabdff1aSopenharmony_ci * Get the AVCodecID for the given codec tag tag.
2609cabdff1aSopenharmony_ci * If no codec id is found returns AV_CODEC_ID_NONE.
2610cabdff1aSopenharmony_ci *
2611cabdff1aSopenharmony_ci * @param tags list of supported codec_id-codec_tag pairs, as stored
2612cabdff1aSopenharmony_ci * in AVInputFormat.codec_tag and AVOutputFormat.codec_tag
2613cabdff1aSopenharmony_ci * @param tag  codec tag to match to a codec ID
2614cabdff1aSopenharmony_ci */
2615cabdff1aSopenharmony_cienum AVCodecID av_codec_get_id(const struct AVCodecTag * const *tags, unsigned int tag);
2616cabdff1aSopenharmony_ci
2617cabdff1aSopenharmony_ci/**
2618cabdff1aSopenharmony_ci * Get the codec tag for the given codec id id.
2619cabdff1aSopenharmony_ci * If no codec tag is found returns 0.
2620cabdff1aSopenharmony_ci *
2621cabdff1aSopenharmony_ci * @param tags list of supported codec_id-codec_tag pairs, as stored
2622cabdff1aSopenharmony_ci * in AVInputFormat.codec_tag and AVOutputFormat.codec_tag
2623cabdff1aSopenharmony_ci * @param id   codec ID to match to a codec tag
2624cabdff1aSopenharmony_ci */
2625cabdff1aSopenharmony_ciunsigned int av_codec_get_tag(const struct AVCodecTag * const *tags, enum AVCodecID id);
2626cabdff1aSopenharmony_ci
2627cabdff1aSopenharmony_ci/**
2628cabdff1aSopenharmony_ci * Get the codec tag for the given codec id.
2629cabdff1aSopenharmony_ci *
2630cabdff1aSopenharmony_ci * @param tags list of supported codec_id - codec_tag pairs, as stored
2631cabdff1aSopenharmony_ci * in AVInputFormat.codec_tag and AVOutputFormat.codec_tag
2632cabdff1aSopenharmony_ci * @param id codec id that should be searched for in the list
2633cabdff1aSopenharmony_ci * @param tag A pointer to the found tag
2634cabdff1aSopenharmony_ci * @return 0 if id was not found in tags, > 0 if it was found
2635cabdff1aSopenharmony_ci */
2636cabdff1aSopenharmony_ciint av_codec_get_tag2(const struct AVCodecTag * const *tags, enum AVCodecID id,
2637cabdff1aSopenharmony_ci                      unsigned int *tag);
2638cabdff1aSopenharmony_ci
2639cabdff1aSopenharmony_ciint av_find_default_stream_index(AVFormatContext *s);
2640cabdff1aSopenharmony_ci
2641cabdff1aSopenharmony_ci/**
2642cabdff1aSopenharmony_ci * Get the index for a specific timestamp.
2643cabdff1aSopenharmony_ci *
2644cabdff1aSopenharmony_ci * @param st        stream that the timestamp belongs to
2645cabdff1aSopenharmony_ci * @param timestamp timestamp to retrieve the index for
2646cabdff1aSopenharmony_ci * @param flags if AVSEEK_FLAG_BACKWARD then the returned index will correspond
2647cabdff1aSopenharmony_ci *                 to the timestamp which is <= the requested one, if backward
2648cabdff1aSopenharmony_ci *                 is 0, then it will be >=
2649cabdff1aSopenharmony_ci *              if AVSEEK_FLAG_ANY seek to any frame, only keyframes otherwise
2650cabdff1aSopenharmony_ci * @return < 0 if no such timestamp could be found
2651cabdff1aSopenharmony_ci */
2652cabdff1aSopenharmony_ciint av_index_search_timestamp(AVStream *st, int64_t timestamp, int flags);
2653cabdff1aSopenharmony_ci
2654cabdff1aSopenharmony_ci/**
2655cabdff1aSopenharmony_ci * Get the index entry count for the given AVStream.
2656cabdff1aSopenharmony_ci *
2657cabdff1aSopenharmony_ci * @param st stream
2658cabdff1aSopenharmony_ci * @return the number of index entries in the stream
2659cabdff1aSopenharmony_ci */
2660cabdff1aSopenharmony_ciint avformat_index_get_entries_count(const AVStream *st);
2661cabdff1aSopenharmony_ci
2662cabdff1aSopenharmony_ci/**
2663cabdff1aSopenharmony_ci * Get the AVIndexEntry corresponding to the given index.
2664cabdff1aSopenharmony_ci *
2665cabdff1aSopenharmony_ci * @param st          Stream containing the requested AVIndexEntry.
2666cabdff1aSopenharmony_ci * @param idx         The desired index.
2667cabdff1aSopenharmony_ci * @return A pointer to the requested AVIndexEntry if it exists, NULL otherwise.
2668cabdff1aSopenharmony_ci *
2669cabdff1aSopenharmony_ci * @note The pointer returned by this function is only guaranteed to be valid
2670cabdff1aSopenharmony_ci *       until any function that takes the stream or the parent AVFormatContext
2671cabdff1aSopenharmony_ci *       as input argument is called.
2672cabdff1aSopenharmony_ci */
2673cabdff1aSopenharmony_ciconst AVIndexEntry *avformat_index_get_entry(AVStream *st, int idx);
2674cabdff1aSopenharmony_ci
2675cabdff1aSopenharmony_ci/**
2676cabdff1aSopenharmony_ci * Get the AVIndexEntry corresponding to the given timestamp.
2677cabdff1aSopenharmony_ci *
2678cabdff1aSopenharmony_ci * @param st          Stream containing the requested AVIndexEntry.
2679cabdff1aSopenharmony_ci * @param timestamp   Timestamp to retrieve the index entry for.
2680cabdff1aSopenharmony_ci * @param flags       If AVSEEK_FLAG_BACKWARD then the returned entry will correspond
2681cabdff1aSopenharmony_ci *                    to the timestamp which is <= the requested one, if backward
2682cabdff1aSopenharmony_ci *                    is 0, then it will be >=
2683cabdff1aSopenharmony_ci *                    if AVSEEK_FLAG_ANY seek to any frame, only keyframes otherwise.
2684cabdff1aSopenharmony_ci * @return A pointer to the requested AVIndexEntry if it exists, NULL otherwise.
2685cabdff1aSopenharmony_ci *
2686cabdff1aSopenharmony_ci * @note The pointer returned by this function is only guaranteed to be valid
2687cabdff1aSopenharmony_ci *       until any function that takes the stream or the parent AVFormatContext
2688cabdff1aSopenharmony_ci *       as input argument is called.
2689cabdff1aSopenharmony_ci */
2690cabdff1aSopenharmony_ciconst AVIndexEntry *avformat_index_get_entry_from_timestamp(AVStream *st,
2691cabdff1aSopenharmony_ci                                                            int64_t wanted_timestamp,
2692cabdff1aSopenharmony_ci                                                            int flags);
2693cabdff1aSopenharmony_ci/**
2694cabdff1aSopenharmony_ci * Add an index entry into a sorted list. Update the entry if the list
2695cabdff1aSopenharmony_ci * already contains it.
2696cabdff1aSopenharmony_ci *
2697cabdff1aSopenharmony_ci * @param timestamp timestamp in the time base of the given stream
2698cabdff1aSopenharmony_ci */
2699cabdff1aSopenharmony_ciint av_add_index_entry(AVStream *st, int64_t pos, int64_t timestamp,
2700cabdff1aSopenharmony_ci                       int size, int distance, int flags);
2701cabdff1aSopenharmony_ci
2702cabdff1aSopenharmony_ci
2703cabdff1aSopenharmony_ci/**
2704cabdff1aSopenharmony_ci * Split a URL string into components.
2705cabdff1aSopenharmony_ci *
2706cabdff1aSopenharmony_ci * The pointers to buffers for storing individual components may be null,
2707cabdff1aSopenharmony_ci * in order to ignore that component. Buffers for components not found are
2708cabdff1aSopenharmony_ci * set to empty strings. If the port is not found, it is set to a negative
2709cabdff1aSopenharmony_ci * value.
2710cabdff1aSopenharmony_ci *
2711cabdff1aSopenharmony_ci * @param proto the buffer for the protocol
2712cabdff1aSopenharmony_ci * @param proto_size the size of the proto buffer
2713cabdff1aSopenharmony_ci * @param authorization the buffer for the authorization
2714cabdff1aSopenharmony_ci * @param authorization_size the size of the authorization buffer
2715cabdff1aSopenharmony_ci * @param hostname the buffer for the host name
2716cabdff1aSopenharmony_ci * @param hostname_size the size of the hostname buffer
2717cabdff1aSopenharmony_ci * @param port_ptr a pointer to store the port number in
2718cabdff1aSopenharmony_ci * @param path the buffer for the path
2719cabdff1aSopenharmony_ci * @param path_size the size of the path buffer
2720cabdff1aSopenharmony_ci * @param url the URL to split
2721cabdff1aSopenharmony_ci */
2722cabdff1aSopenharmony_civoid av_url_split(char *proto,         int proto_size,
2723cabdff1aSopenharmony_ci                  char *authorization, int authorization_size,
2724cabdff1aSopenharmony_ci                  char *hostname,      int hostname_size,
2725cabdff1aSopenharmony_ci                  int *port_ptr,
2726cabdff1aSopenharmony_ci                  char *path,          int path_size,
2727cabdff1aSopenharmony_ci                  const char *url);
2728cabdff1aSopenharmony_ci
2729cabdff1aSopenharmony_ci
2730cabdff1aSopenharmony_ci/**
2731cabdff1aSopenharmony_ci * Print detailed information about the input or output format, such as
2732cabdff1aSopenharmony_ci * duration, bitrate, streams, container, programs, metadata, side data,
2733cabdff1aSopenharmony_ci * codec and time base.
2734cabdff1aSopenharmony_ci *
2735cabdff1aSopenharmony_ci * @param ic        the context to analyze
2736cabdff1aSopenharmony_ci * @param index     index of the stream to dump information about
2737cabdff1aSopenharmony_ci * @param url       the URL to print, such as source or destination file
2738cabdff1aSopenharmony_ci * @param is_output Select whether the specified context is an input(0) or output(1)
2739cabdff1aSopenharmony_ci */
2740cabdff1aSopenharmony_civoid av_dump_format(AVFormatContext *ic,
2741cabdff1aSopenharmony_ci                    int index,
2742cabdff1aSopenharmony_ci                    const char *url,
2743cabdff1aSopenharmony_ci                    int is_output);
2744cabdff1aSopenharmony_ci
2745cabdff1aSopenharmony_ci
2746cabdff1aSopenharmony_ci#define AV_FRAME_FILENAME_FLAGS_MULTIPLE 1 ///< Allow multiple %d
2747cabdff1aSopenharmony_ci
2748cabdff1aSopenharmony_ci/**
2749cabdff1aSopenharmony_ci * Return in 'buf' the path with '%d' replaced by a number.
2750cabdff1aSopenharmony_ci *
2751cabdff1aSopenharmony_ci * Also handles the '%0nd' format where 'n' is the total number
2752cabdff1aSopenharmony_ci * of digits and '%%'.
2753cabdff1aSopenharmony_ci *
2754cabdff1aSopenharmony_ci * @param buf destination buffer
2755cabdff1aSopenharmony_ci * @param buf_size destination buffer size
2756cabdff1aSopenharmony_ci * @param path numbered sequence string
2757cabdff1aSopenharmony_ci * @param number frame number
2758cabdff1aSopenharmony_ci * @param flags AV_FRAME_FILENAME_FLAGS_*
2759cabdff1aSopenharmony_ci * @return 0 if OK, -1 on format error
2760cabdff1aSopenharmony_ci */
2761cabdff1aSopenharmony_ciint av_get_frame_filename2(char *buf, int buf_size,
2762cabdff1aSopenharmony_ci                          const char *path, int number, int flags);
2763cabdff1aSopenharmony_ci
2764cabdff1aSopenharmony_ciint av_get_frame_filename(char *buf, int buf_size,
2765cabdff1aSopenharmony_ci                          const char *path, int number);
2766cabdff1aSopenharmony_ci
2767cabdff1aSopenharmony_ci/**
2768cabdff1aSopenharmony_ci * Check whether filename actually is a numbered sequence generator.
2769cabdff1aSopenharmony_ci *
2770cabdff1aSopenharmony_ci * @param filename possible numbered sequence string
2771cabdff1aSopenharmony_ci * @return 1 if a valid numbered sequence string, 0 otherwise
2772cabdff1aSopenharmony_ci */
2773cabdff1aSopenharmony_ciint av_filename_number_test(const char *filename);
2774cabdff1aSopenharmony_ci
2775cabdff1aSopenharmony_ci/**
2776cabdff1aSopenharmony_ci * Generate an SDP for an RTP session.
2777cabdff1aSopenharmony_ci *
2778cabdff1aSopenharmony_ci * Note, this overwrites the id values of AVStreams in the muxer contexts
2779cabdff1aSopenharmony_ci * for getting unique dynamic payload types.
2780cabdff1aSopenharmony_ci *
2781cabdff1aSopenharmony_ci * @param ac array of AVFormatContexts describing the RTP streams. If the
2782cabdff1aSopenharmony_ci *           array is composed by only one context, such context can contain
2783cabdff1aSopenharmony_ci *           multiple AVStreams (one AVStream per RTP stream). Otherwise,
2784cabdff1aSopenharmony_ci *           all the contexts in the array (an AVCodecContext per RTP stream)
2785cabdff1aSopenharmony_ci *           must contain only one AVStream.
2786cabdff1aSopenharmony_ci * @param n_files number of AVCodecContexts contained in ac
2787cabdff1aSopenharmony_ci * @param buf buffer where the SDP will be stored (must be allocated by
2788cabdff1aSopenharmony_ci *            the caller)
2789cabdff1aSopenharmony_ci * @param size the size of the buffer
2790cabdff1aSopenharmony_ci * @return 0 if OK, AVERROR_xxx on error
2791cabdff1aSopenharmony_ci */
2792cabdff1aSopenharmony_ciint av_sdp_create(AVFormatContext *ac[], int n_files, char *buf, int size);
2793cabdff1aSopenharmony_ci
2794cabdff1aSopenharmony_ci/**
2795cabdff1aSopenharmony_ci * Return a positive value if the given filename has one of the given
2796cabdff1aSopenharmony_ci * extensions, 0 otherwise.
2797cabdff1aSopenharmony_ci *
2798cabdff1aSopenharmony_ci * @param filename   file name to check against the given extensions
2799cabdff1aSopenharmony_ci * @param extensions a comma-separated list of filename extensions
2800cabdff1aSopenharmony_ci */
2801cabdff1aSopenharmony_ciint av_match_ext(const char *filename, const char *extensions);
2802cabdff1aSopenharmony_ci
2803cabdff1aSopenharmony_ci/**
2804cabdff1aSopenharmony_ci * Test if the given container can store a codec.
2805cabdff1aSopenharmony_ci *
2806cabdff1aSopenharmony_ci * @param ofmt           container to check for compatibility
2807cabdff1aSopenharmony_ci * @param codec_id       codec to potentially store in container
2808cabdff1aSopenharmony_ci * @param std_compliance standards compliance level, one of FF_COMPLIANCE_*
2809cabdff1aSopenharmony_ci *
2810cabdff1aSopenharmony_ci * @return 1 if codec with ID codec_id can be stored in ofmt, 0 if it cannot.
2811cabdff1aSopenharmony_ci *         A negative number if this information is not available.
2812cabdff1aSopenharmony_ci */
2813cabdff1aSopenharmony_ciint avformat_query_codec(const AVOutputFormat *ofmt, enum AVCodecID codec_id,
2814cabdff1aSopenharmony_ci                         int std_compliance);
2815cabdff1aSopenharmony_ci
2816cabdff1aSopenharmony_ci/**
2817cabdff1aSopenharmony_ci * @defgroup riff_fourcc RIFF FourCCs
2818cabdff1aSopenharmony_ci * @{
2819cabdff1aSopenharmony_ci * Get the tables mapping RIFF FourCCs to libavcodec AVCodecIDs. The tables are
2820cabdff1aSopenharmony_ci * meant to be passed to av_codec_get_id()/av_codec_get_tag() as in the
2821cabdff1aSopenharmony_ci * following code:
2822cabdff1aSopenharmony_ci * @code
2823cabdff1aSopenharmony_ci * uint32_t tag = MKTAG('H', '2', '6', '4');
2824cabdff1aSopenharmony_ci * const struct AVCodecTag *table[] = { avformat_get_riff_video_tags(), 0 };
2825cabdff1aSopenharmony_ci * enum AVCodecID id = av_codec_get_id(table, tag);
2826cabdff1aSopenharmony_ci * @endcode
2827cabdff1aSopenharmony_ci */
2828cabdff1aSopenharmony_ci/**
2829cabdff1aSopenharmony_ci * @return the table mapping RIFF FourCCs for video to libavcodec AVCodecID.
2830cabdff1aSopenharmony_ci */
2831cabdff1aSopenharmony_ciconst struct AVCodecTag *avformat_get_riff_video_tags(void);
2832cabdff1aSopenharmony_ci/**
2833cabdff1aSopenharmony_ci * @return the table mapping RIFF FourCCs for audio to AVCodecID.
2834cabdff1aSopenharmony_ci */
2835cabdff1aSopenharmony_ciconst struct AVCodecTag *avformat_get_riff_audio_tags(void);
2836cabdff1aSopenharmony_ci/**
2837cabdff1aSopenharmony_ci * @return the table mapping MOV FourCCs for video to libavcodec AVCodecID.
2838cabdff1aSopenharmony_ci */
2839cabdff1aSopenharmony_ciconst struct AVCodecTag *avformat_get_mov_video_tags(void);
2840cabdff1aSopenharmony_ci/**
2841cabdff1aSopenharmony_ci * @return the table mapping MOV FourCCs for audio to AVCodecID.
2842cabdff1aSopenharmony_ci */
2843cabdff1aSopenharmony_ciconst struct AVCodecTag *avformat_get_mov_audio_tags(void);
2844cabdff1aSopenharmony_ci
2845cabdff1aSopenharmony_ci/**
2846cabdff1aSopenharmony_ci * @}
2847cabdff1aSopenharmony_ci */
2848cabdff1aSopenharmony_ci
2849cabdff1aSopenharmony_ci/**
2850cabdff1aSopenharmony_ci * Guess the sample aspect ratio of a frame, based on both the stream and the
2851cabdff1aSopenharmony_ci * frame aspect ratio.
2852cabdff1aSopenharmony_ci *
2853cabdff1aSopenharmony_ci * Since the frame aspect ratio is set by the codec but the stream aspect ratio
2854cabdff1aSopenharmony_ci * is set by the demuxer, these two may not be equal. This function tries to
2855cabdff1aSopenharmony_ci * return the value that you should use if you would like to display the frame.
2856cabdff1aSopenharmony_ci *
2857cabdff1aSopenharmony_ci * Basic logic is to use the stream aspect ratio if it is set to something sane
2858cabdff1aSopenharmony_ci * otherwise use the frame aspect ratio. This way a container setting, which is
2859cabdff1aSopenharmony_ci * usually easy to modify can override the coded value in the frames.
2860cabdff1aSopenharmony_ci *
2861cabdff1aSopenharmony_ci * @param format the format context which the stream is part of
2862cabdff1aSopenharmony_ci * @param stream the stream which the frame is part of
2863cabdff1aSopenharmony_ci * @param frame the frame with the aspect ratio to be determined
2864cabdff1aSopenharmony_ci * @return the guessed (valid) sample_aspect_ratio, 0/1 if no idea
2865cabdff1aSopenharmony_ci */
2866cabdff1aSopenharmony_ciAVRational av_guess_sample_aspect_ratio(AVFormatContext *format, AVStream *stream, AVFrame *frame);
2867cabdff1aSopenharmony_ci
2868cabdff1aSopenharmony_ci/**
2869cabdff1aSopenharmony_ci * Guess the frame rate, based on both the container and codec information.
2870cabdff1aSopenharmony_ci *
2871cabdff1aSopenharmony_ci * @param ctx the format context which the stream is part of
2872cabdff1aSopenharmony_ci * @param stream the stream which the frame is part of
2873cabdff1aSopenharmony_ci * @param frame the frame for which the frame rate should be determined, may be NULL
2874cabdff1aSopenharmony_ci * @return the guessed (valid) frame rate, 0/1 if no idea
2875cabdff1aSopenharmony_ci */
2876cabdff1aSopenharmony_ciAVRational av_guess_frame_rate(AVFormatContext *ctx, AVStream *stream, AVFrame *frame);
2877cabdff1aSopenharmony_ci
2878cabdff1aSopenharmony_ci/**
2879cabdff1aSopenharmony_ci * Check if the stream st contained in s is matched by the stream specifier
2880cabdff1aSopenharmony_ci * spec.
2881cabdff1aSopenharmony_ci *
2882cabdff1aSopenharmony_ci * See the "stream specifiers" chapter in the documentation for the syntax
2883cabdff1aSopenharmony_ci * of spec.
2884cabdff1aSopenharmony_ci *
2885cabdff1aSopenharmony_ci * @return  >0 if st is matched by spec;
2886cabdff1aSopenharmony_ci *          0  if st is not matched by spec;
2887cabdff1aSopenharmony_ci *          AVERROR code if spec is invalid
2888cabdff1aSopenharmony_ci *
2889cabdff1aSopenharmony_ci * @note  A stream specifier can match several streams in the format.
2890cabdff1aSopenharmony_ci */
2891cabdff1aSopenharmony_ciint avformat_match_stream_specifier(AVFormatContext *s, AVStream *st,
2892cabdff1aSopenharmony_ci                                    const char *spec);
2893cabdff1aSopenharmony_ci
2894cabdff1aSopenharmony_ciint avformat_queue_attached_pictures(AVFormatContext *s);
2895cabdff1aSopenharmony_ci
2896cabdff1aSopenharmony_cienum AVTimebaseSource {
2897cabdff1aSopenharmony_ci    AVFMT_TBCF_AUTO = -1,
2898cabdff1aSopenharmony_ci    AVFMT_TBCF_DECODER,
2899cabdff1aSopenharmony_ci    AVFMT_TBCF_DEMUXER,
2900cabdff1aSopenharmony_ci#if FF_API_R_FRAME_RATE
2901cabdff1aSopenharmony_ci    AVFMT_TBCF_R_FRAMERATE,
2902cabdff1aSopenharmony_ci#endif
2903cabdff1aSopenharmony_ci};
2904cabdff1aSopenharmony_ci
2905cabdff1aSopenharmony_ci/**
2906cabdff1aSopenharmony_ci * Transfer internal timing information from one stream to another.
2907cabdff1aSopenharmony_ci *
2908cabdff1aSopenharmony_ci * This function is useful when doing stream copy.
2909cabdff1aSopenharmony_ci *
2910cabdff1aSopenharmony_ci * @param ofmt     target output format for ost
2911cabdff1aSopenharmony_ci * @param ost      output stream which needs timings copy and adjustments
2912cabdff1aSopenharmony_ci * @param ist      reference input stream to copy timings from
2913cabdff1aSopenharmony_ci * @param copy_tb  define from where the stream codec timebase needs to be imported
2914cabdff1aSopenharmony_ci */
2915cabdff1aSopenharmony_ciint avformat_transfer_internal_stream_timing_info(const AVOutputFormat *ofmt,
2916cabdff1aSopenharmony_ci                                                  AVStream *ost, const AVStream *ist,
2917cabdff1aSopenharmony_ci                                                  enum AVTimebaseSource copy_tb);
2918cabdff1aSopenharmony_ci
2919cabdff1aSopenharmony_ci/**
2920cabdff1aSopenharmony_ci * Get the internal codec timebase from a stream.
2921cabdff1aSopenharmony_ci *
2922cabdff1aSopenharmony_ci * @param st  input stream to extract the timebase from
2923cabdff1aSopenharmony_ci */
2924cabdff1aSopenharmony_ciAVRational av_stream_get_codec_timebase(const AVStream *st);
2925cabdff1aSopenharmony_ci
2926cabdff1aSopenharmony_cistruct KeyFrameNode
2927cabdff1aSopenharmony_ci{
2928cabdff1aSopenharmony_ci    int pos;
2929cabdff1aSopenharmony_ci    struct KeyFrameNode *next;
2930cabdff1aSopenharmony_ci};
2931cabdff1aSopenharmony_ci
2932cabdff1aSopenharmony_ci/**
2933cabdff1aSopenharmony_ci * Get the frame position for every key frame.
2934cabdff1aSopenharmony_ci *
2935cabdff1aSopenharmony_ci * @param st                  input stream to extract the position for every key frame
2936cabdff1aSopenharmony_ci * @param key_frame_pos_list  output list which carry the frame position for every key frame
2937cabdff1aSopenharmony_ci */
2938cabdff1aSopenharmony_ci
2939cabdff1aSopenharmony_ciint av_get_key_frame_pos_from_stream(const AVStream *st, struct KeyFrameNode **key_frame_pos_list);
2940cabdff1aSopenharmony_ci
2941cabdff1aSopenharmony_ci/**
2942cabdff1aSopenharmony_ci * Destroy the list which is created by av_get_key_frame_pos_from_stream function.
2943cabdff1aSopenharmony_ci *
2944cabdff1aSopenharmony_ci * This function is useful after doing av_get_key_frame_pos_from_stream to release resource.
2945cabdff1aSopenharmony_ci *
2946cabdff1aSopenharmony_ci * @param key_frame_pos_list  input list which carry the frame position for every key frame
2947cabdff1aSopenharmony_ci */
2948cabdff1aSopenharmony_civoid av_destory_key_frame_pos_list(struct KeyFrameNode *key_frame_pos_list);
2949cabdff1aSopenharmony_ci
2950cabdff1aSopenharmony_ci/**
2951cabdff1aSopenharmony_ci * @}
2952cabdff1aSopenharmony_ci */
2953cabdff1aSopenharmony_ci
2954cabdff1aSopenharmony_ci#endif /* AVFORMAT_AVFORMAT_H */
2955