• 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 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 };
00055 
00056 typedef struct URLContext URLContext;
00057 
00058 typedef struct URLPollEntry {
00059     URLContext *handle;
00060     int events;
00061     int revents;
00062 } URLPollEntry;
00063 
00064 #define URL_RDONLY 0
00065 #define URL_WRONLY 1
00066 #define URL_RDWR   2
00067 
00068 typedef int URLInterruptCB(void);
00069 
00070 int url_open_protocol (URLContext **puc, struct URLProtocol *up,
00071                        const char *filename, int flags);
00072 int url_open(URLContext **h, const char *filename, int flags);
00073 int url_read(URLContext *h, unsigned char *buf, int size);
00074 int url_write(URLContext *h, unsigned char *buf, int size);
00075 int64_t url_seek(URLContext *h, int64_t pos, int whence);
00076 int url_close(URLContext *h);
00077 int url_exist(const char *filename);
00078 int64_t url_filesize(URLContext *h);
00079 
00088 int url_get_max_packet_size(URLContext *h);
00089 void url_get_filename(URLContext *h, char *buf, int buf_size);
00090 
00097 void url_set_interrupt_cb(URLInterruptCB *interrupt_cb);
00098 
00099 /* not implemented */
00100 int url_poll(URLPollEntry *poll_table, int n, int timeout);
00101 
00107 int av_url_read_pause(URLContext *h, int pause);
00108 
00126 int64_t av_url_read_seek(URLContext *h, int stream_index,
00127                          int64_t timestamp, int flags);
00128 
00134 #define AVSEEK_SIZE 0x10000
00135 
00136 typedef struct URLProtocol {
00137     const char *name;
00138     int (*url_open)(URLContext *h, const char *filename, int flags);
00139     int (*url_read)(URLContext *h, unsigned char *buf, int size);
00140     int (*url_write)(URLContext *h, unsigned char *buf, int size);
00141     int64_t (*url_seek)(URLContext *h, int64_t pos, int whence);
00142     int (*url_close)(URLContext *h);
00143     struct URLProtocol *next;
00144     int (*url_read_pause)(URLContext *h, int pause);
00145     int64_t (*url_read_seek)(URLContext *h, int stream_index,
00146                              int64_t timestamp, int flags);
00147 } URLProtocol;
00148 
00149 #if LIBAVFORMAT_VERSION_MAJOR < 53
00150 extern URLProtocol *first_protocol;
00151 #endif
00152 
00153 extern URLInterruptCB *url_interrupt_cb;
00154 
00160 URLProtocol *av_protocol_next(URLProtocol *p);
00161 
00162 #if LIBAVFORMAT_VERSION_MAJOR < 53
00163 
00166 attribute_deprecated int register_protocol(URLProtocol *protocol);
00167 #endif
00168 
00169 int av_register_protocol(URLProtocol *protocol);
00170 
00178 typedef struct {
00179     unsigned char *buffer;
00180     int buffer_size;
00181     unsigned char *buf_ptr, *buf_end;
00182     void *opaque;
00183     int (*read_packet)(void *opaque, uint8_t *buf, int buf_size);
00184     int (*write_packet)(void *opaque, uint8_t *buf, int buf_size);
00185     int64_t (*seek)(void *opaque, int64_t offset, int whence);
00186     int64_t pos; 
00187     int must_flush; 
00188     int eof_reached; 
00189     int write_flag;  
00190     int is_streamed;
00191     int max_packet_size;
00192     unsigned long checksum;
00193     unsigned char *checksum_ptr;
00194     unsigned long (*update_checksum)(unsigned long checksum, const uint8_t *buf, unsigned int size);
00195     int error;         
00196     int (*read_pause)(void *opaque, int pause);
00197     int64_t (*read_seek)(void *opaque, int stream_index,
00198                          int64_t timestamp, int flags);
00199 } ByteIOContext;
00200 
00201 int init_put_byte(ByteIOContext *s,
00202                   unsigned char *buffer,
00203                   int buffer_size,
00204                   int write_flag,
00205                   void *opaque,
00206                   int (*read_packet)(void *opaque, uint8_t *buf, int buf_size),
00207                   int (*write_packet)(void *opaque, uint8_t *buf, int buf_size),
00208                   int64_t (*seek)(void *opaque, int64_t offset, int whence));
00209 ByteIOContext *av_alloc_put_byte(
00210                   unsigned char *buffer,
00211                   int buffer_size,
00212                   int write_flag,
00213                   void *opaque,
00214                   int (*read_packet)(void *opaque, uint8_t *buf, int buf_size),
00215                   int (*write_packet)(void *opaque, uint8_t *buf, int buf_size),
00216                   int64_t (*seek)(void *opaque, int64_t offset, int whence));
00217 
00218 void put_byte(ByteIOContext *s, int b);
00219 void put_buffer(ByteIOContext *s, const unsigned char *buf, int size);
00220 void put_le64(ByteIOContext *s, uint64_t val);
00221 void put_be64(ByteIOContext *s, uint64_t val);
00222 void put_le32(ByteIOContext *s, unsigned int val);
00223 void put_be32(ByteIOContext *s, unsigned int val);
00224 void put_le24(ByteIOContext *s, unsigned int val);
00225 void put_be24(ByteIOContext *s, unsigned int val);
00226 void put_le16(ByteIOContext *s, unsigned int val);
00227 void put_be16(ByteIOContext *s, unsigned int val);
00228 void put_tag(ByteIOContext *s, const char *tag);
00229 
00230 void put_strz(ByteIOContext *s, const char *buf);
00231 
00236 int64_t url_fseek(ByteIOContext *s, int64_t offset, int whence);
00237 
00242 void url_fskip(ByteIOContext *s, int64_t offset);
00243 
00248 int64_t url_ftell(ByteIOContext *s);
00249 
00254 int64_t url_fsize(ByteIOContext *s);
00255 
00260 int url_feof(ByteIOContext *s);
00261 
00262 int url_ferror(ByteIOContext *s);
00263 
00264 int av_url_read_fpause(ByteIOContext *h, int pause);
00265 int64_t av_url_read_fseek(ByteIOContext *h, int stream_index,
00266                           int64_t timestamp, int flags);
00267 
00268 #define URL_EOF (-1)
00269 
00270 int url_fgetc(ByteIOContext *s);
00271 
00273 #ifdef __GNUC__
00274 int url_fprintf(ByteIOContext *s, const char *fmt, ...) __attribute__ ((__format__ (__printf__, 2, 3)));
00275 #else
00276 int url_fprintf(ByteIOContext *s, const char *fmt, ...);
00277 #endif
00278 
00281 char *url_fgets(ByteIOContext *s, char *buf, int buf_size);
00282 
00283 void put_flush_packet(ByteIOContext *s);
00284 
00285 
00290 int get_buffer(ByteIOContext *s, unsigned char *buf, int size);
00291 
00298 int get_partial_buffer(ByteIOContext *s, unsigned char *buf, int size);
00299 
00302 int get_byte(ByteIOContext *s);
00303 unsigned int get_le24(ByteIOContext *s);
00304 unsigned int get_le32(ByteIOContext *s);
00305 uint64_t get_le64(ByteIOContext *s);
00306 unsigned int get_le16(ByteIOContext *s);
00307 
00308 char *get_strz(ByteIOContext *s, char *buf, int maxlen);
00309 unsigned int get_be16(ByteIOContext *s);
00310 unsigned int get_be24(ByteIOContext *s);
00311 unsigned int get_be32(ByteIOContext *s);
00312 uint64_t get_be64(ByteIOContext *s);
00313 
00314 uint64_t ff_get_v(ByteIOContext *bc);
00315 
00316 static inline int url_is_streamed(ByteIOContext *s)
00317 {
00318     return s->is_streamed;
00319 }
00320 
00323 int url_fdopen(ByteIOContext **s, URLContext *h);
00324 
00326 int url_setbufsize(ByteIOContext *s, int buf_size);
00331 int url_resetbuf(ByteIOContext *s, int flags);
00332 
00335 int url_fopen(ByteIOContext **s, const char *filename, int flags);
00336 int url_fclose(ByteIOContext *s);
00337 URLContext *url_fileno(ByteIOContext *s);
00338 
00347 int url_fget_max_packet_size(ByteIOContext *s);
00348 
00349 int url_open_buf(ByteIOContext **s, uint8_t *buf, int buf_size, int flags);
00350 
00352 int url_close_buf(ByteIOContext *s);
00353 
00360 int url_open_dyn_buf(ByteIOContext **s);
00361 
00371 int url_open_dyn_packet_buf(ByteIOContext **s, int max_packet_size);
00372 
00380 int url_close_dyn_buf(ByteIOContext *s, uint8_t **pbuffer);
00381 
00382 unsigned long ff_crc04C11DB7_update(unsigned long checksum, const uint8_t *buf,
00383                                     unsigned int len);
00384 unsigned long get_checksum(ByteIOContext *s);
00385 void init_checksum(ByteIOContext *s,
00386                    unsigned long (*update_checksum)(unsigned long c, const uint8_t *p, unsigned int len),
00387                    unsigned long checksum);
00388 
00389 /* udp.c */
00390 int udp_set_remote_url(URLContext *h, const char *uri);
00391 int udp_get_local_port(URLContext *h);
00392 int udp_get_file_handle(URLContext *h);
00393 
00394 #endif /* AVFORMAT_AVIO_H */

Generated on Tue Nov 4 2014 12:59:23 for ffmpeg by  doxygen 1.7.1