• Main Page
  • Related Pages
  • Modules
  • Data Structures
  • Files
  • File List
  • Globals

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 
00031 #include <stdint.h>
00032 
00033 #include "libavutil/common.h"
00034 
00035 /* unbuffered I/O */
00036 
00044 typedef struct URLContext {
00045 #if LIBAVFORMAT_VERSION_MAJOR >= 53
00046     const AVClass *av_class; 
00047 #endif
00048     struct URLProtocol *prot;
00049     int flags;
00050     int is_streamed;  
00051     int max_packet_size;  
00052     void *priv_data;
00053     char *filename; 
00054 } URLContext;
00055 
00056 typedef struct URLPollEntry {
00057     URLContext *handle;
00058     int events;
00059     int revents;
00060 } URLPollEntry;
00061 
00062 #define URL_RDONLY 0
00063 #define URL_WRONLY 1
00064 #define URL_RDWR   2
00065 
00066 typedef int URLInterruptCB(void);
00067 
00079 int url_open_protocol (URLContext **puc, struct URLProtocol *up,
00080                        const char *url, int flags);
00081 
00093 int url_open(URLContext **h, const char *url, int flags);
00094 
00104 int url_read(URLContext *h, unsigned char *buf, int size);
00105 
00114 int url_read_complete(URLContext *h, unsigned char *buf, int size);
00115 int url_write(URLContext *h, unsigned char *buf, int size);
00116 
00131 int64_t url_seek(URLContext *h, int64_t pos, int whence);
00132 
00140 int url_close(URLContext *h);
00141 
00146 int url_exist(const char *url);
00147 
00148 int64_t url_filesize(URLContext *h);
00149 
00157 int url_get_file_handle(URLContext *h);
00158 
00167 int url_get_max_packet_size(URLContext *h);
00168 void url_get_filename(URLContext *h, char *buf, int buf_size);
00169 
00176 void url_set_interrupt_cb(URLInterruptCB *interrupt_cb);
00177 
00178 /* not implemented */
00179 int url_poll(URLPollEntry *poll_table, int n, int timeout);
00180 
00186 int av_url_read_pause(URLContext *h, int pause);
00187 
00205 int64_t av_url_read_seek(URLContext *h, int stream_index,
00206                          int64_t timestamp, int flags);
00207 
00213 #define AVSEEK_SIZE 0x10000
00214 
00221 #define AVSEEK_FORCE 0x20000
00222 
00223 typedef struct URLProtocol {
00224     const char *name;
00225     int (*url_open)(URLContext *h, const char *url, int flags);
00226     int (*url_read)(URLContext *h, unsigned char *buf, int size);
00227     int (*url_write)(URLContext *h, unsigned char *buf, int size);
00228     int64_t (*url_seek)(URLContext *h, int64_t pos, int whence);
00229     int (*url_close)(URLContext *h);
00230     struct URLProtocol *next;
00231     int (*url_read_pause)(URLContext *h, int pause);
00232     int64_t (*url_read_seek)(URLContext *h, int stream_index,
00233                              int64_t timestamp, int flags);
00234     int (*url_get_file_handle)(URLContext *h);
00235 } URLProtocol;
00236 
00237 #if LIBAVFORMAT_VERSION_MAJOR < 53
00238 extern URLProtocol *first_protocol;
00239 #endif
00240 
00241 extern URLInterruptCB *url_interrupt_cb;
00242 
00248 URLProtocol *av_protocol_next(URLProtocol *p);
00249 
00250 #if LIBAVFORMAT_VERSION_MAJOR < 53
00251 
00254 attribute_deprecated int register_protocol(URLProtocol *protocol);
00255 #endif
00256 
00260 int av_register_protocol(URLProtocol *protocol);
00261 
00269 typedef struct {
00270     unsigned char *buffer;
00271     int buffer_size;
00272     unsigned char *buf_ptr, *buf_end;
00273     void *opaque;
00274     int (*read_packet)(void *opaque, uint8_t *buf, int buf_size);
00275     int (*write_packet)(void *opaque, uint8_t *buf, int buf_size);
00276     int64_t (*seek)(void *opaque, int64_t offset, int whence);
00277     int64_t pos; 
00278     int must_flush; 
00279     int eof_reached; 
00280     int write_flag;  
00281     int is_streamed;
00282     int max_packet_size;
00283     unsigned long checksum;
00284     unsigned char *checksum_ptr;
00285     unsigned long (*update_checksum)(unsigned long checksum, const uint8_t *buf, unsigned int size);
00286     int error;         
00287     int (*read_pause)(void *opaque, int pause);
00288     int64_t (*read_seek)(void *opaque, int stream_index,
00289                          int64_t timestamp, int flags);
00290 } ByteIOContext;
00291 
00292 int init_put_byte(ByteIOContext *s,
00293                   unsigned char *buffer,
00294                   int buffer_size,
00295                   int write_flag,
00296                   void *opaque,
00297                   int (*read_packet)(void *opaque, uint8_t *buf, int buf_size),
00298                   int (*write_packet)(void *opaque, uint8_t *buf, int buf_size),
00299                   int64_t (*seek)(void *opaque, int64_t offset, int whence));
00300 ByteIOContext *av_alloc_put_byte(
00301                   unsigned char *buffer,
00302                   int buffer_size,
00303                   int write_flag,
00304                   void *opaque,
00305                   int (*read_packet)(void *opaque, uint8_t *buf, int buf_size),
00306                   int (*write_packet)(void *opaque, uint8_t *buf, int buf_size),
00307                   int64_t (*seek)(void *opaque, int64_t offset, int whence));
00308 
00309 void put_byte(ByteIOContext *s, int b);
00310 void put_buffer(ByteIOContext *s, const unsigned char *buf, int size);
00311 void put_le64(ByteIOContext *s, uint64_t val);
00312 void put_be64(ByteIOContext *s, uint64_t val);
00313 void put_le32(ByteIOContext *s, unsigned int val);
00314 void put_be32(ByteIOContext *s, unsigned int val);
00315 void put_le24(ByteIOContext *s, unsigned int val);
00316 void put_be24(ByteIOContext *s, unsigned int val);
00317 void put_le16(ByteIOContext *s, unsigned int val);
00318 void put_be16(ByteIOContext *s, unsigned int val);
00319 void put_tag(ByteIOContext *s, const char *tag);
00320 
00321 void put_strz(ByteIOContext *s, const char *buf);
00322 
00327 int64_t url_fseek(ByteIOContext *s, int64_t offset, int whence);
00328 
00333 void url_fskip(ByteIOContext *s, int64_t offset);
00334 
00339 int64_t url_ftell(ByteIOContext *s);
00340 
00345 int64_t url_fsize(ByteIOContext *s);
00346 
00351 int url_feof(ByteIOContext *s);
00352 
00353 int url_ferror(ByteIOContext *s);
00354 
00355 int av_url_read_fpause(ByteIOContext *h, int pause);
00356 int64_t av_url_read_fseek(ByteIOContext *h, int stream_index,
00357                           int64_t timestamp, int flags);
00358 
00359 #define URL_EOF (-1)
00360 
00361 int url_fgetc(ByteIOContext *s);
00362 
00364 #ifdef __GNUC__
00365 int url_fprintf(ByteIOContext *s, const char *fmt, ...) __attribute__ ((__format__ (__printf__, 2, 3)));
00366 #else
00367 int url_fprintf(ByteIOContext *s, const char *fmt, ...);
00368 #endif
00369 
00372 char *url_fgets(ByteIOContext *s, char *buf, int buf_size);
00373 
00374 void put_flush_packet(ByteIOContext *s);
00375 
00376 
00381 int get_buffer(ByteIOContext *s, unsigned char *buf, int size);
00382 
00389 int get_partial_buffer(ByteIOContext *s, unsigned char *buf, int size);
00390 
00393 int get_byte(ByteIOContext *s);
00394 unsigned int get_le24(ByteIOContext *s);
00395 unsigned int get_le32(ByteIOContext *s);
00396 uint64_t get_le64(ByteIOContext *s);
00397 unsigned int get_le16(ByteIOContext *s);
00398 
00399 char *get_strz(ByteIOContext *s, char *buf, int maxlen);
00400 unsigned int get_be16(ByteIOContext *s);
00401 unsigned int get_be24(ByteIOContext *s);
00402 unsigned int get_be32(ByteIOContext *s);
00403 uint64_t get_be64(ByteIOContext *s);
00404 
00405 uint64_t ff_get_v(ByteIOContext *bc);
00406 
00407 static inline int url_is_streamed(ByteIOContext *s)
00408 {
00409     return s->is_streamed;
00410 }
00411 
00423 int url_fdopen(ByteIOContext **s, URLContext *h);
00424 
00426 int url_setbufsize(ByteIOContext *s, int buf_size);
00427 #if LIBAVFORMAT_VERSION_MAJOR < 53
00428 
00432 int url_resetbuf(ByteIOContext *s, int flags);
00433 #endif
00434 
00448 int ff_rewind_with_probe_data(ByteIOContext *s, unsigned char *buf, int buf_size);
00449 
00463 int url_fopen(ByteIOContext **s, const char *url, int flags);
00464 
00465 int url_fclose(ByteIOContext *s);
00466 URLContext *url_fileno(ByteIOContext *s);
00467 
00476 int url_fget_max_packet_size(ByteIOContext *s);
00477 
00478 int url_open_buf(ByteIOContext **s, uint8_t *buf, int buf_size, int flags);
00479 
00481 int url_close_buf(ByteIOContext *s);
00482 
00489 int url_open_dyn_buf(ByteIOContext **s);
00490 
00500 int url_open_dyn_packet_buf(ByteIOContext **s, int max_packet_size);
00501 
00509 int url_close_dyn_buf(ByteIOContext *s, uint8_t **pbuffer);
00510 
00511 unsigned long ff_crc04C11DB7_update(unsigned long checksum, const uint8_t *buf,
00512                                     unsigned int len);
00513 unsigned long get_checksum(ByteIOContext *s);
00514 void init_checksum(ByteIOContext *s,
00515                    unsigned long (*update_checksum)(unsigned long c, const uint8_t *p, unsigned int len),
00516                    unsigned long checksum);
00517 
00518 /* udp.c */
00519 int udp_set_remote_url(URLContext *h, const char *uri);
00520 int udp_get_local_port(URLContext *h);
00521 #if (LIBAVFORMAT_VERSION_MAJOR <= 52)
00522 int udp_get_file_handle(URLContext *h);
00523 #endif
00524 
00525 #endif /* AVFORMAT_AVIO_H */

Generated on Fri Sep 16 2011 17:17:48 for FFmpeg by  doxygen 1.7.1