libavformat/avio.h

Go to the documentation of this file.
00001 /*
00002  * copyright (c) 2001 Fabrice Bellard
00003  *
00004  * This file is part of FFmpeg.
00005  *
00006  * FFmpeg is free software; you can redistribute it and/or
00007  * modify it under the terms of the GNU Lesser General Public
00008  * License as published by the Free Software Foundation; either
00009  * version 2.1 of the License, or (at your option) any later version.
00010  *
00011  * FFmpeg is distributed in the hope that it will be useful,
00012  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00013  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
00014  * Lesser General Public License for more details.
00015  *
00016  * You should have received a copy of the GNU Lesser General Public
00017  * License along with FFmpeg; if not, write to the Free Software
00018  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
00019  */
00020 #ifndef AVFORMAT_AVIO_H
00021 #define AVFORMAT_AVIO_H
00022 
00028 #include <stdint.h>
00029 
00030 #include "libavutil/common.h"
00031 #include "libavutil/log.h"
00032 
00033 #include "libavformat/version.h"
00034 
00035 
00036 #define AVIO_SEEKABLE_NORMAL 0x0001 
00050 typedef struct {
00051 unsigned char *buffer; 
00052 int buffer_size; 
00053 unsigned char *buf_ptr; 
00054 unsigned char *buf_end; 
00058 void *opaque; 
00060 int (*read_packet)(void *opaque, uint8_t *buf, int buf_size);
00061 int (*write_packet)(void *opaque, uint8_t *buf, int buf_size);
00062 int64_t (*seek)(void *opaque, int64_t offset, int whence);
00063 int64_t pos; 
00064 int must_flush; 
00065 int eof_reached; 
00066 int write_flag; 
00067 #if FF_API_OLD_AVIO
00068 attribute_deprecated int is_streamed;
00069 #endif
00070 int max_packet_size;
00071 unsigned long checksum;
00072 unsigned char *checksum_ptr;
00073 unsigned long (*update_checksum)(unsigned long checksum, const uint8_t *buf, unsigned int size);
00074 int error; 
00078 int (*read_pause)(void *opaque, int pause);
00084 int64_t (*read_seek)(void *opaque, int stream_index,
00085 int64_t timestamp, int flags);
00089 int seekable;
00090 } AVIOContext;
00091 
00092 /* unbuffered I/O */
00093 
00094 #if FF_API_OLD_AVIO
00095 
00103 typedef struct URLContext {
00104 const AVClass *av_class; 
00105 struct URLProtocol *prot;
00106 int flags;
00107 int is_streamed; 
00108 int max_packet_size; 
00109 void *priv_data;
00110 char *filename; 
00111 int is_connected;
00112 } URLContext;
00113 
00114 #define URL_PROTOCOL_FLAG_NESTED_SCHEME 1 /*< The protocol name can be the first part of a nested protocol scheme */
00115 
00120 typedef struct URLProtocol {
00121 const char *name;
00122 int (*url_open)(URLContext *h, const char *url, int flags);
00123 int (*url_read)(URLContext *h, unsigned char *buf, int size);
00124 int (*url_write)(URLContext *h, const unsigned char *buf, int size);
00125 int64_t (*url_seek)(URLContext *h, int64_t pos, int whence);
00126 int (*url_close)(URLContext *h);
00127 struct URLProtocol *next;
00128 int (*url_read_pause)(URLContext *h, int pause);
00129 int64_t (*url_read_seek)(URLContext *h, int stream_index,
00130 int64_t timestamp, int flags);
00131 int (*url_get_file_handle)(URLContext *h);
00132 int priv_data_size;
00133 const AVClass *priv_data_class;
00134 int flags;
00135 int (*url_check)(URLContext *h, int mask);
00136 } URLProtocol;
00137 
00138 typedef struct URLPollEntry {
00139 URLContext *handle;
00140 int events;
00141 int revents;
00142 } URLPollEntry;
00143 
00144 /* not implemented */
00145 attribute_deprecated int url_poll(URLPollEntry *poll_table, int n, int timeout);
00146 
00153 #define URL_RDONLY 1 
00154 #define URL_WRONLY 2 
00155 #define URL_RDWR (URL_RDONLY|URL_WRONLY) 
00172 #define URL_FLAG_NONBLOCK 4
00173 
00174 typedef int URLInterruptCB(void);
00175 extern URLInterruptCB *url_interrupt_cb;
00176 
00182 attribute_deprecated int url_open_protocol (URLContext **puc, struct URLProtocol *up,
00183 const char *url, int flags);
00184 attribute_deprecated int url_alloc(URLContext **h, const char *url, int flags);
00185 attribute_deprecated int url_connect(URLContext *h);
00186 attribute_deprecated int url_open(URLContext **h, const char *url, int flags);
00187 attribute_deprecated int url_read(URLContext *h, unsigned char *buf, int size);
00188 attribute_deprecated int url_read_complete(URLContext *h, unsigned char *buf, int size);
00189 attribute_deprecated int url_write(URLContext *h, const unsigned char *buf, int size);
00190 attribute_deprecated int64_t url_seek(URLContext *h, int64_t pos, int whence);
00191 attribute_deprecated int url_close(URLContext *h);
00192 attribute_deprecated int64_t url_filesize(URLContext *h);
00193 attribute_deprecated int url_get_file_handle(URLContext *h);
00194 attribute_deprecated int url_get_max_packet_size(URLContext *h);
00195 attribute_deprecated void url_get_filename(URLContext *h, char *buf, int buf_size);
00196 attribute_deprecated int av_url_read_pause(URLContext *h, int pause);
00197 attribute_deprecated int64_t av_url_read_seek(URLContext *h, int stream_index,
00198 int64_t timestamp, int flags);
00199 attribute_deprecated void url_set_interrupt_cb(int (*interrupt_cb)(void));
00200 
00205 URLProtocol *av_protocol_next(URLProtocol *p);
00206 
00212 attribute_deprecated int av_register_protocol2(URLProtocol *protocol, int size);
00218 typedef attribute_deprecated AVIOContext ByteIOContext;
00219 
00220 attribute_deprecated int init_put_byte(AVIOContext *s,
00221 unsigned char *buffer,
00222 int buffer_size,
00223 int write_flag,
00224 void *opaque,
00225 int (*read_packet)(void *opaque, uint8_t *buf, int buf_size),
00226 int (*write_packet)(void *opaque, uint8_t *buf, int buf_size),
00227 int64_t (*seek)(void *opaque, int64_t offset, int whence));
00228 attribute_deprecated AVIOContext *av_alloc_put_byte(
00229 unsigned char *buffer,
00230 int buffer_size,
00231 int write_flag,
00232 void *opaque,
00233 int (*read_packet)(void *opaque, uint8_t *buf, int buf_size),
00234 int (*write_packet)(void *opaque, uint8_t *buf, int buf_size),
00235 int64_t (*seek)(void *opaque, int64_t offset, int whence));
00236 
00242 attribute_deprecated int get_buffer(AVIOContext *s, unsigned char *buf, int size);
00243 attribute_deprecated int get_partial_buffer(AVIOContext *s, unsigned char *buf, int size);
00244 attribute_deprecated int get_byte(AVIOContext *s);
00245 attribute_deprecated unsigned int get_le16(AVIOContext *s);
00246 attribute_deprecated unsigned int get_le24(AVIOContext *s);
00247 attribute_deprecated unsigned int get_le32(AVIOContext *s);
00248 attribute_deprecated uint64_t get_le64(AVIOContext *s);
00249 attribute_deprecated unsigned int get_be16(AVIOContext *s);
00250 attribute_deprecated unsigned int get_be24(AVIOContext *s);
00251 attribute_deprecated unsigned int get_be32(AVIOContext *s);
00252 attribute_deprecated uint64_t get_be64(AVIOContext *s);
00253 
00254 attribute_deprecated void put_byte(AVIOContext *s, int b);
00255 attribute_deprecated void put_nbyte(AVIOContext *s, int b, int count);
00256 attribute_deprecated void put_buffer(AVIOContext *s, const unsigned char *buf, int size);
00257 attribute_deprecated void put_le64(AVIOContext *s, uint64_t val);
00258 attribute_deprecated void put_be64(AVIOContext *s, uint64_t val);
00259 attribute_deprecated void put_le32(AVIOContext *s, unsigned int val);
00260 attribute_deprecated void put_be32(AVIOContext *s, unsigned int val);
00261 attribute_deprecated void put_le24(AVIOContext *s, unsigned int val);
00262 attribute_deprecated void put_be24(AVIOContext *s, unsigned int val);
00263 attribute_deprecated void put_le16(AVIOContext *s, unsigned int val);
00264 attribute_deprecated void put_be16(AVIOContext *s, unsigned int val);
00265 attribute_deprecated void put_tag(AVIOContext *s, const char *tag);
00270 attribute_deprecated int av_url_read_fpause(AVIOContext *h, int pause);
00271 attribute_deprecated int64_t av_url_read_fseek (AVIOContext *h, int stream_index,
00272 int64_t timestamp, int flags);
00273 
00279 attribute_deprecated int url_fopen( AVIOContext **s, const char *url, int flags);
00280 attribute_deprecated int url_fclose(AVIOContext *s);
00281 attribute_deprecated int64_t url_fseek(AVIOContext *s, int64_t offset, int whence);
00282 attribute_deprecated int url_fskip(AVIOContext *s, int64_t offset);
00283 attribute_deprecated int64_t url_ftell(AVIOContext *s);
00284 attribute_deprecated int64_t url_fsize(AVIOContext *s);
00285 #define URL_EOF (-1)
00286 attribute_deprecated int url_fgetc(AVIOContext *s);
00287 attribute_deprecated int url_setbufsize(AVIOContext *s, int buf_size);
00288 #ifdef __GNUC__
00289 attribute_deprecated int url_fprintf(AVIOContext *s, const char *fmt, ...) __attribute__ ((__format__ (__printf__, 2, 3)));
00290 #else
00291 attribute_deprecated int url_fprintf(AVIOContext *s, const char *fmt, ...);
00292 #endif
00293 attribute_deprecated void put_flush_packet(AVIOContext *s);
00294 attribute_deprecated int url_open_dyn_buf(AVIOContext **s);
00295 attribute_deprecated int url_open_dyn_packet_buf(AVIOContext **s, int max_packet_size);
00296 attribute_deprecated int url_close_dyn_buf(AVIOContext *s, uint8_t **pbuffer);
00297 attribute_deprecated int url_fdopen(AVIOContext **s, URLContext *h);
00302 attribute_deprecated int url_ferror(AVIOContext *s);
00303 
00304 attribute_deprecated int udp_set_remote_url(URLContext *h, const char *uri);
00305 attribute_deprecated int udp_get_local_port(URLContext *h);
00306 
00307 attribute_deprecated void init_checksum(AVIOContext *s,
00308 unsigned long (*update_checksum)(unsigned long c, const uint8_t *p, unsigned int len),
00309 unsigned long checksum);
00310 attribute_deprecated unsigned long get_checksum(AVIOContext *s);
00311 attribute_deprecated void put_strz(AVIOContext *s, const char *buf);
00314 attribute_deprecated char *url_fgets(AVIOContext *s, char *buf, int buf_size);
00318 attribute_deprecated char *get_strz(AVIOContext *s, char *buf, int maxlen);
00322 attribute_deprecated static inline int url_is_streamed(AVIOContext *s)
00323 {
00324 return !s->seekable;
00325 }
00326 attribute_deprecated URLContext *url_fileno(AVIOContext *s);
00327 
00331 attribute_deprecated int url_fget_max_packet_size(AVIOContext *s);
00332 
00333 attribute_deprecated int url_open_buf(AVIOContext **s, uint8_t *buf, int buf_size, int flags);
00334 
00336 attribute_deprecated int url_close_buf(AVIOContext *s);
00337 
00343 attribute_deprecated int url_exist(const char *url);
00344 #endif // FF_API_OLD_AVIO
00345 
00358 int avio_check(const char *url, int flags);
00359 
00366 void avio_set_interrupt_cb(int (*interrupt_cb)(void));
00367 
00385 AVIOContext *avio_alloc_context(
00386 unsigned char *buffer,
00387 int buffer_size,
00388 int write_flag,
00389 void *opaque,
00390 int (*read_packet)(void *opaque, uint8_t *buf, int buf_size),
00391 int (*write_packet)(void *opaque, uint8_t *buf, int buf_size),
00392 int64_t (*seek)(void *opaque, int64_t offset, int whence));
00393 
00394 void avio_w8(AVIOContext *s, int b);
00395 void avio_write(AVIOContext *s, const unsigned char *buf, int size);
00396 void avio_wl64(AVIOContext *s, uint64_t val);
00397 void avio_wb64(AVIOContext *s, uint64_t val);
00398 void avio_wl32(AVIOContext *s, unsigned int val);
00399 void avio_wb32(AVIOContext *s, unsigned int val);
00400 void avio_wl24(AVIOContext *s, unsigned int val);
00401 void avio_wb24(AVIOContext *s, unsigned int val);
00402 void avio_wl16(AVIOContext *s, unsigned int val);
00403 void avio_wb16(AVIOContext *s, unsigned int val);
00404 
00409 int avio_put_str(AVIOContext *s, const char *str);
00410 
00415 int avio_put_str16le(AVIOContext *s, const char *str);
00416 
00422 #define AVSEEK_SIZE 0x10000
00423 
00430 #define AVSEEK_FORCE 0x20000
00431 
00436 int64_t avio_seek(AVIOContext *s, int64_t offset, int whence);
00437 
00442 int64_t avio_skip(AVIOContext *s, int64_t offset);
00443 
00448 static av_always_inline int64_t avio_tell(AVIOContext *s)
00449 {
00450 return avio_seek(s, 0, SEEK_CUR);
00451 }
00452 
00457 int64_t avio_size(AVIOContext *s);
00458 
00463 int url_feof(AVIOContext *s);
00464 
00466 #ifdef __GNUC__
00467 int avio_printf(AVIOContext *s, const char *fmt, ...) __attribute__ ((__format__ (__printf__, 2, 3)));
00468 #else
00469 int avio_printf(AVIOContext *s, const char *fmt, ...);
00470 #endif
00471 
00472 void avio_flush(AVIOContext *s);
00473 
00474 
00479 int avio_read(AVIOContext *s, unsigned char *buf, int size);
00480 
00488 int avio_r8 (AVIOContext *s);
00489 unsigned int avio_rl16(AVIOContext *s);
00490 unsigned int avio_rl24(AVIOContext *s);
00491 unsigned int avio_rl32(AVIOContext *s);
00492 uint64_t avio_rl64(AVIOContext *s);
00493 unsigned int avio_rb16(AVIOContext *s);
00494 unsigned int avio_rb24(AVIOContext *s);
00495 unsigned int avio_rb32(AVIOContext *s);
00496 uint64_t avio_rb64(AVIOContext *s);
00513 int avio_get_str(AVIOContext *pb, int maxlen, char *buf, int buflen);
00514 
00521 int avio_get_str16le(AVIOContext *pb, int maxlen, char *buf, int buflen);
00522 int avio_get_str16be(AVIOContext *pb, int maxlen, char *buf, int buflen);
00523 
00524 
00531 #define AVIO_FLAG_READ 1 
00532 #define AVIO_FLAG_WRITE 2 
00533 #define AVIO_FLAG_READ_WRITE (AVIO_FLAG_READ|AVIO_FLAG_WRITE) 
00550 #define AVIO_FLAG_NONBLOCK 8
00551 
00565 int avio_open(AVIOContext **s, const char *url, int flags);
00566 
00573 int avio_close(AVIOContext *s);
00574 
00581 int avio_open_dyn_buf(AVIOContext **s);
00582 
00592 int avio_close_dyn_buf(AVIOContext *s, uint8_t **pbuffer);
00593 
00606 const char *avio_enum_protocols(void **opaque, int output);
00607 
00613 int avio_pause(AVIOContext *h, int pause);
00614 
00632 int64_t avio_seek_time(AVIOContext *h, int stream_index,
00633 int64_t timestamp, int flags);
00634 
00635 #endif /* AVFORMAT_AVIO_H */

Generated on Fri Oct 26 02:39:40 2012 for FFmpeg by doxygen 1.5.8

AltStyle によって変換されたページ (->オリジナル) /