1 /*
2 * This file is part of FFmpeg.
3 *
4 * FFmpeg is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Lesser General Public
6 * License as published by the Free Software Foundation; either
7 * version 2.1 of the License, or (at your option) any later version.
8 *
9 * FFmpeg is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * Lesser General Public License for more details.
13 *
14 * You should have received a copy of the GNU Lesser General Public
15 * License along with FFmpeg; if not, write to the Free Software
16 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
17 */
18
19 #ifndef AVFORMAT_AVIO_INTERNAL_H
20 #define AVFORMAT_AVIO_INTERNAL_H
21
24
26
28
31 /**
32 * A callback that is used instead of short_seek_threshold.
33 */
35
36 /**
37 * Threshold to favor readahead over seek.
38 */
40
43
44 /**
45 * max filesize, used to limit allocations
46 */
48
49 /**
50 * Bytes read statistic
51 */
53
54 /**
55 * Bytes written statistic
56 */
58
59 /**
60 * seek statistic
61 */
63
64 /**
65 * writeout statistic
66 */
68
69 /**
70 * Original buffer size
71 * used after probing to ensure seekback and to reset the buffer size
72 */
74
75 /**
76 * Written output size
77 * is updated each time a successful writeout ends up further position-wise
78 */
81
83 {
85 }
86
89 int buffer_size,
90 int write_flag,
91 void *opaque,
92 int (*
read_packet)(
void *opaque, uint8_t *buf,
int buf_size),
93 int (*
write_packet)(
void *opaque, uint8_t *buf,
int buf_size),
94 int64_t (*seek)(
void *opaque, int64_t
offset,
int whence));
95
96
97 /**
98 * Read size bytes from AVIOContext, returning a pointer.
99 * Note that the data pointed at by the returned pointer is only
100 * valid until the next call that references the same IO context.
101 * @param s IO context
102 * @param buf pointer to buffer into which to assemble the requested
103 * data if it is not available in contiguous addresses in the
104 * underlying buffer
105 * @param size number of bytes requested
106 * @param data address at which to store pointer: this will be a
107 * a direct pointer into the underlying buffer if the requested
108 * number of bytes are available at contiguous addresses, otherwise
109 * will be a copy of buf
110 * @return number of bytes read or AVERROR
111 */
113
115
117 {
119 }
120
121 /**
122 * Rewind the AVIOContext using the specified buffer containing the first buf_size bytes of the file.
123 * Used after probing to avoid seeking.
124 * Joins buf and s->buffer, taking any overlap into consideration.
125 * @note s->buffer must overlap with buf or they can't be joined and the function fails
126 *
127 * @param s The read-only AVIOContext to rewind
128 * @param buf The probe buffer containing the first buf_size bytes of the file
129 * @param buf_size The size of buf
130 * @return >= 0 in case of success, a negative value corresponding to an
131 * AVERROR code in case of failure
132 */
134
136
137 /**
138 * Read size bytes from AVIOContext into buf.
139 * Check that exactly size bytes have been read.
140 * @return number of bytes read or AVERROR
141 */
143
144 /**
145 * Reallocate a given buffer for AVIOContext.
146 *
147 * @param s the AVIOContext to realloc.
148 * @param buf_size required new buffer size.
149 * @return 0 on success, a negative AVERROR on failure.
150 */
152
153 /**
154 * Ensures that the requested seekback buffer size will be available
155 *
156 * Will ensure that when reading sequentially up to buf_size, seeking
157 * within the current pos and pos+buf_size is possible.
158 * Once the stream position moves outside this window or another
159 * ffio_ensure_seekback call requests a buffer outside this window this
160 * guarantee is lost.
161 */
163
165
176
177 /**
178 * Open a write only packetized memory stream with a maximum packet
179 * size of 'max_packet_size'. The stream is stored in a memory buffer
180 * with a big-endian 4 byte header giving the packet size in bytes.
181 *
182 * @param s new IO context
183 * @param max_packet_size maximum packet size (must be > 0)
184 * @return zero if no error.
185 */
187
188 /**
189 * Create and initialize a AVIOContext for accessing the
190 * resource referenced by the URLContext h.
191 * @note When the URLContext h has been opened in read+write mode, the
192 * AVIOContext can be used only for writing.
193 *
194 * @param s Used to return the pointer to the created AVIOContext.
195 * In case of failure the pointed to value is set to NULL.
196 * @return >= 0 in case of success, a negative value corresponding to an
197 * AVERROR code in case of failure
198 */
200
201 /**
202 * Return the URLContext associated with the AVIOContext
203 *
204 * @param s IO context
205 * @return pointer to URLContext or NULL.
206 */
208
209
210 /**
211 * Read url related dictionary options from the AVIOContext and write to the given dictionary
212 */
214
215 /**
216 * Open a write-only fake memory stream. The written data is not stored
217 * anywhere - this is only used for measuring the amount of data
218 * written.
219 *
220 * @param s new IO context
221 * @return zero if no error.
222 */
224
227 const char *whitelist, const char *blacklist);
228
229 /**
230 * Close a null buffer.
231 *
232 * @param s an IO context opened by ffio_open_null_buf
233 * @return the number of bytes written to the null buffer
234 */
236
237 /**
238 * Reset a dynamic buffer.
239 *
240 * Resets everything, but keeps the allocated buffer for later use.
241 */
243
244 /**
245 * Free a dynamic buffer.
246 *
247 * @param s a pointer to an IO context opened by avio_open_dyn_buf()
248 */
250
251 struct AVBPrint;
252 /**
253 * Read a whole line of text from AVIOContext to an AVBPrint buffer overwriting
254 * its contents. Stop reading after reaching a \\r, a \\n, a \\r\\n, a \0円 or
255 * EOF. The line ending characters are NOT included in the buffer, but they
256 * are skipped on the input.
257 *
258 * @param s the read-only AVIOContext
259 * @param bp the AVBPrint buffer
260 * @return the length of the read line not including the line endings,
261 * negative on error, or if the buffer becomes truncated.
262 */
264
265 /**
266 * Read a whole null-terminated string of text from AVIOContext to an AVBPrint
267 * buffer overwriting its contents. Stop reading after reaching the maximum
268 * length, a \0円 or EOF.
269 *
270 * @param s the read-only AVIOContext
271 * @param bp the AVBPrint buffer
272 * @param max_len the maximum length to be read from the AVIOContext.
273 * Negative (< 0) values signal that there is no known maximum
274 * length applicable. A maximum length of zero means that the
275 * AVIOContext is not touched, and the function returns
276 * with a read length of zero. In all cases the AVBprint
277 * is cleared.
278 * @return the length of the read string not including the terminating null,
279 * negative on error, or if the buffer becomes truncated.
280 */
282 int64_t max_len);
283
284 #endif /* AVFORMAT_AVIO_INTERNAL_H */