• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * copyright (c) 2001 Fabrice Bellard
3  *
4  * This file is part of FFmpeg.
5  *
6  * FFmpeg is free software; you can redistribute it and/or
7  * modify it under the terms of the GNU Lesser General Public
8  * License as published by the Free Software Foundation; either
9  * version 2.1 of the License, or (at your option) any later version.
10  *
11  * FFmpeg is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
14  * Lesser General Public License for more details.
15  *
16  * You should have received a copy of the GNU Lesser General Public
17  * License along with FFmpeg; if not, write to the Free Software
18  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
19  */
20 
21 #ifndef AVFORMAT_MUX_H
22 #define AVFORMAT_MUX_H
23 
24 #include <stdint.h>
25 #include "libavcodec/packet.h"
26 #include "avformat.h"
27 
28 /**
29  * Add packet to an AVFormatContext's packet_buffer list, determining its
30  * interleaved position using compare() function argument.
31  * @return 0 on success, < 0 on error. pkt will always be blank on return.
32  */
33 int ff_interleave_add_packet(AVFormatContext *s, AVPacket *pkt,
34                              int (*compare)(AVFormatContext *, const AVPacket *, const AVPacket *));
35 
36 /**
37  * Interleave an AVPacket per dts so it can be muxed.
38  * See the documentation of AVOutputFormat.interleave_packet for details.
39  */
40 int ff_interleave_packet_per_dts(AVFormatContext *s, AVPacket *pkt,
41                                  int flush, int has_packet);
42 
43 /**
44  * Interleave packets directly in the order in which they arrive
45  * without any sort of buffering.
46  */
47 int ff_interleave_packet_passthrough(AVFormatContext *s, AVPacket *pkt,
48                                      int flush, int has_packet);
49 
50 /**
51  * Find the next packet in the interleaving queue for the given stream.
52  *
53  * @return a pointer to a packet if one was found, NULL otherwise.
54  */
55 const AVPacket *ff_interleaved_peek(AVFormatContext *s, int stream);
56 
57 int ff_get_muxer_ts_offset(AVFormatContext *s, int stream_index, int64_t *offset);
58 
59 /**
60  * Add a bitstream filter to a stream.
61  *
62  * @param st output stream to add a filter to
63  * @param name the name of the filter to add
64  * @param args filter-specific argument string
65  * @return  >0 on success;
66  *          AVERROR code on failure
67  */
68 int ff_stream_add_bitstream_filter(AVStream *st, const char *name, const char *args);
69 
70 /**
71  * Write a packet to another muxer than the one the user originally
72  * intended. Useful when chaining muxers, where one muxer internally
73  * writes a received packet to another muxer.
74  *
75  * @param dst the muxer to write the packet to
76  * @param dst_stream the stream index within dst to write the packet to
77  * @param pkt the packet to be written. It will be returned blank when
78  *            av_interleaved_write_frame() is used, unchanged otherwise.
79  * @param src the muxer the packet originally was intended for
80  * @param interleave 0->use av_write_frame, 1->av_interleaved_write_frame
81  * @return the value av_write_frame returned
82  */
83 int ff_write_chained(AVFormatContext *dst, int dst_stream, AVPacket *pkt,
84                      AVFormatContext *src, int interleave);
85 
86 /**
87  * Flags for AVFormatContext.write_uncoded_frame()
88  */
89 enum AVWriteUncodedFrameFlags {
90 
91     /**
92      * Query whether the feature is possible on this stream.
93      * The frame argument is ignored.
94      */
95     AV_WRITE_UNCODED_FRAME_QUERY           = 0x0001,
96 
97 };
98 
99 /**
100  * Make shift_size amount of space at read_start by shifting data in the output
101  * at read_start until the current IO position. The underlying IO context must
102  * be seekable.
103  */
104 int ff_format_shift_data(AVFormatContext *s, int64_t read_start, int shift_size);
105 
106 /**
107  * Utility function to open IO stream of output format.
108  *
109  * @param s AVFormatContext
110  * @param url URL or file name to open for writing
111  * @options optional options which will be passed to io_open callback
112  * @return >=0 on success, negative AVERROR in case of failure
113  */
114 int ff_format_output_open(AVFormatContext *s, const char *url, AVDictionary **options);
115 
116 /**
117  * Copy encoding parameters from source to destination stream
118  *
119  * @param dst pointer to destination AVStream
120  * @param src pointer to source AVStream
121  * @return >=0 on success, AVERROR code on error
122  */
123 int ff_stream_encode_params_copy(AVStream *dst, const AVStream *src);
124 
125 /**
126  * Parse creation_time in AVFormatContext metadata if exists and warn if the
127  * parsing fails.
128  *
129  * @param s AVFormatContext
130  * @param timestamp parsed timestamp in microseconds, only set on successful parsing
131  * @param return_seconds set this to get the number of seconds in timestamp instead of microseconds
132  * @return 1 if OK, 0 if the metadata was not present, AVERROR(EINVAL) on parse error
133  */
134 int ff_parse_creation_time_metadata(AVFormatContext *s, int64_t *timestamp, int return_seconds);
135 
136 /**
137  * Standardize creation_time metadata in AVFormatContext to an ISO-8601
138  * timestamp string.
139  *
140  * @param s AVFormatContext
141  * @return <0 on error
142  */
143 int ff_standardize_creation_time(AVFormatContext *s);
144 
145 #endif /* AVFORMAT_MUX_H */
146