• Main Page
  • Related Pages
  • Modules
  • Data Structures
  • Files
  • Examples
  • 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 Libav.
00005  *
00006  * Libav 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  * Libav 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 Libav; 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 
00029 #include <stdint.h>
00030 
00031 #include "libavutil/common.h"
00032 #include "libavutil/dict.h"
00033 #include "libavutil/log.h"
00034 
00035 #include "libavformat/version.h"
00036 
00037 
00038 #define AVIO_SEEKABLE_NORMAL 0x0001 
00051 typedef struct {
00052     int (*callback)(void*);
00053     void *opaque;
00054 } AVIOInterruptCB;
00055 
00068 typedef struct {
00069 #if !FF_API_OLD_AVIO
00070 
00082     AVClass *av_class;
00083 #endif
00084     unsigned char *buffer;  
00085     int buffer_size;        
00086     unsigned char *buf_ptr; 
00087     unsigned char *buf_end; 
00091     void *opaque;           
00093     int (*read_packet)(void *opaque, uint8_t *buf, int buf_size);
00094     int (*write_packet)(void *opaque, uint8_t *buf, int buf_size);
00095     int64_t (*seek)(void *opaque, int64_t offset, int whence);
00096     int64_t pos;            
00097     int must_flush;         
00098     int eof_reached;        
00099     int write_flag;         
00100 #if FF_API_OLD_AVIO
00101     attribute_deprecated int is_streamed;
00102 #endif
00103     int max_packet_size;
00104     unsigned long checksum;
00105     unsigned char *checksum_ptr;
00106     unsigned long (*update_checksum)(unsigned long checksum, const uint8_t *buf, unsigned int size);
00107     int error;              
00111     int (*read_pause)(void *opaque, int pause);
00117     int64_t (*read_seek)(void *opaque, int stream_index,
00118                          int64_t timestamp, int flags);
00122     int seekable;
00123 } AVIOContext;
00124 
00125 /* unbuffered I/O */
00126 
00127 #if FF_API_OLD_AVIO
00128 
00136 typedef struct URLContext {
00137     const AVClass *av_class; 
00138     struct URLProtocol *prot;
00139     int flags;
00140     int is_streamed;  
00141     int max_packet_size;  
00142     void *priv_data;
00143     char *filename; 
00144     int is_connected;
00145     AVIOInterruptCB interrupt_callback;
00146 } URLContext;
00147 
00148 #define URL_PROTOCOL_FLAG_NESTED_SCHEME 1 /*< The protocol name can be the first part of a nested protocol scheme */
00149 #define URL_PROTOCOL_FLAG_NETWORK       2 /*< The protocol uses network */
00150 
00155 typedef struct URLProtocol {
00156     const char *name;
00157     int (*url_open)(URLContext *h, const char *url, int flags);
00158     int (*url_read)(URLContext *h, unsigned char *buf, int size);
00159     int (*url_write)(URLContext *h, const unsigned char *buf, int size);
00160     int64_t (*url_seek)(URLContext *h, int64_t pos, int whence);
00161     int (*url_close)(URLContext *h);
00162     struct URLProtocol *next;
00163     int (*url_read_pause)(URLContext *h, int pause);
00164     int64_t (*url_read_seek)(URLContext *h, int stream_index,
00165                              int64_t timestamp, int flags);
00166     int (*url_get_file_handle)(URLContext *h);
00167     int priv_data_size;
00168     const AVClass *priv_data_class;
00169     int flags;
00170     int (*url_check)(URLContext *h, int mask);
00171 } URLProtocol;
00172 
00173 typedef struct URLPollEntry {
00174     URLContext *handle;
00175     int events;
00176     int revents;
00177 } URLPollEntry;
00178 
00179 /* not implemented */
00180 attribute_deprecated int url_poll(URLPollEntry *poll_table, int n, int timeout);
00181 
00188 #define URL_RDONLY 1  
00189 #define URL_WRONLY 2  
00190 #define URL_RDWR   (URL_RDONLY|URL_WRONLY)  
00207 #define URL_FLAG_NONBLOCK 8
00208 
00209 typedef int URLInterruptCB(void);
00210 extern URLInterruptCB *url_interrupt_cb;
00211 
00218 attribute_deprecated int url_open_protocol (URLContext **puc, struct URLProtocol *up,
00219                                             const char *url, int flags);
00220 attribute_deprecated int url_alloc(URLContext **h, const char *url, int flags);
00221 attribute_deprecated int url_connect(URLContext *h);
00222 attribute_deprecated int url_open(URLContext **h, const char *url, int flags);
00223 attribute_deprecated int url_read(URLContext *h, unsigned char *buf, int size);
00224 attribute_deprecated int url_read_complete(URLContext *h, unsigned char *buf, int size);
00225 attribute_deprecated int url_write(URLContext *h, const unsigned char *buf, int size);
00226 attribute_deprecated int64_t url_seek(URLContext *h, int64_t pos, int whence);
00227 attribute_deprecated int url_close(URLContext *h);
00228 attribute_deprecated int64_t url_filesize(URLContext *h);
00229 attribute_deprecated int url_get_file_handle(URLContext *h);
00230 attribute_deprecated int url_get_max_packet_size(URLContext *h);
00231 attribute_deprecated void url_get_filename(URLContext *h, char *buf, int buf_size);
00232 attribute_deprecated int av_url_read_pause(URLContext *h, int pause);
00233 attribute_deprecated int64_t av_url_read_seek(URLContext *h, int stream_index,
00234                                               int64_t timestamp, int flags);
00235 attribute_deprecated void url_set_interrupt_cb(int (*interrupt_cb)(void));
00241 attribute_deprecated URLProtocol *av_protocol_next(URLProtocol *p);
00247 attribute_deprecated int av_register_protocol2(URLProtocol *protocol, int size);
00253 typedef attribute_deprecated AVIOContext ByteIOContext;
00254 
00255 attribute_deprecated int init_put_byte(AVIOContext *s,
00256                   unsigned char *buffer,
00257                   int buffer_size,
00258                   int write_flag,
00259                   void *opaque,
00260                   int (*read_packet)(void *opaque, uint8_t *buf, int buf_size),
00261                   int (*write_packet)(void *opaque, uint8_t *buf, int buf_size),
00262                   int64_t (*seek)(void *opaque, int64_t offset, int whence));
00263 attribute_deprecated AVIOContext *av_alloc_put_byte(
00264                   unsigned char *buffer,
00265                   int buffer_size,
00266                   int write_flag,
00267                   void *opaque,
00268                   int (*read_packet)(void *opaque, uint8_t *buf, int buf_size),
00269                   int (*write_packet)(void *opaque, uint8_t *buf, int buf_size),
00270                   int64_t (*seek)(void *opaque, int64_t offset, int whence));
00271 
00278 attribute_deprecated int          get_buffer(AVIOContext *s, unsigned char *buf, int size);
00279 attribute_deprecated int          get_partial_buffer(AVIOContext *s, unsigned char *buf, int size);
00280 attribute_deprecated int          get_byte(AVIOContext *s);
00281 attribute_deprecated unsigned int get_le16(AVIOContext *s);
00282 attribute_deprecated unsigned int get_le24(AVIOContext *s);
00283 attribute_deprecated unsigned int get_le32(AVIOContext *s);
00284 attribute_deprecated uint64_t     get_le64(AVIOContext *s);
00285 attribute_deprecated unsigned int get_be16(AVIOContext *s);
00286 attribute_deprecated unsigned int get_be24(AVIOContext *s);
00287 attribute_deprecated unsigned int get_be32(AVIOContext *s);
00288 attribute_deprecated uint64_t     get_be64(AVIOContext *s);
00289 
00290 attribute_deprecated void         put_byte(AVIOContext *s, int b);
00291 attribute_deprecated void         put_nbyte(AVIOContext *s, int b, int count);
00292 attribute_deprecated void         put_buffer(AVIOContext *s, const unsigned char *buf, int size);
00293 attribute_deprecated void         put_le64(AVIOContext *s, uint64_t val);
00294 attribute_deprecated void         put_be64(AVIOContext *s, uint64_t val);
00295 attribute_deprecated void         put_le32(AVIOContext *s, unsigned int val);
00296 attribute_deprecated void         put_be32(AVIOContext *s, unsigned int val);
00297 attribute_deprecated void         put_le24(AVIOContext *s, unsigned int val);
00298 attribute_deprecated void         put_be24(AVIOContext *s, unsigned int val);
00299 attribute_deprecated void         put_le16(AVIOContext *s, unsigned int val);
00300 attribute_deprecated void         put_be16(AVIOContext *s, unsigned int val);
00301 attribute_deprecated void         put_tag(AVIOContext *s, const char *tag);
00306 attribute_deprecated int     av_url_read_fpause(AVIOContext *h,    int pause);
00307 attribute_deprecated int64_t av_url_read_fseek (AVIOContext *h,    int stream_index,
00308                                                 int64_t timestamp, int flags);
00309 
00316 attribute_deprecated int url_fopen( AVIOContext **s, const char *url, int flags);
00317 attribute_deprecated int url_fclose(AVIOContext *s);
00318 attribute_deprecated int64_t url_fseek(AVIOContext *s, int64_t offset, int whence);
00319 attribute_deprecated int url_fskip(AVIOContext *s, int64_t offset);
00320 attribute_deprecated int64_t url_ftell(AVIOContext *s);
00321 attribute_deprecated int64_t url_fsize(AVIOContext *s);
00322 #define URL_EOF (-1)
00323 attribute_deprecated int url_fgetc(AVIOContext *s);
00324 attribute_deprecated int url_setbufsize(AVIOContext *s, int buf_size);
00325 attribute_deprecated int url_fprintf(AVIOContext *s, const char *fmt, ...) av_printf_format(2, 3);
00326 attribute_deprecated void put_flush_packet(AVIOContext *s);
00327 attribute_deprecated int url_open_dyn_buf(AVIOContext **s);
00328 attribute_deprecated int url_open_dyn_packet_buf(AVIOContext **s, int max_packet_size);
00329 attribute_deprecated int url_close_dyn_buf(AVIOContext *s, uint8_t **pbuffer);
00330 attribute_deprecated int url_fdopen(AVIOContext **s, URLContext *h);
00338 attribute_deprecated int url_feof(AVIOContext *s);
00339 attribute_deprecated int url_ferror(AVIOContext *s);
00340 
00341 attribute_deprecated int udp_set_remote_url(URLContext *h, const char *uri);
00342 attribute_deprecated int udp_get_local_port(URLContext *h);
00343 
00344 attribute_deprecated void init_checksum(AVIOContext *s,
00345                    unsigned long (*update_checksum)(unsigned long c, const uint8_t *p, unsigned int len),
00346                    unsigned long checksum);
00347 attribute_deprecated unsigned long get_checksum(AVIOContext *s);
00348 attribute_deprecated void put_strz(AVIOContext *s, const char *buf);
00351 attribute_deprecated char *url_fgets(AVIOContext *s, char *buf, int buf_size);
00355 attribute_deprecated char *get_strz(AVIOContext *s, char *buf, int maxlen);
00359 attribute_deprecated static inline int url_is_streamed(AVIOContext *s)
00360 {
00361     return !s->seekable;
00362 }
00363 attribute_deprecated URLContext *url_fileno(AVIOContext *s);
00364 
00368 attribute_deprecated int url_fget_max_packet_size(AVIOContext *s);
00369 
00370 attribute_deprecated int url_open_buf(AVIOContext **s, uint8_t *buf, int buf_size, int flags);
00371 
00373 attribute_deprecated int url_close_buf(AVIOContext *s);
00374 
00380 attribute_deprecated int url_exist(const char *url);
00381 #endif // FF_API_OLD_AVIO
00382 
00395 int avio_check(const char *url, int flags);
00396 
00397 #if FF_API_OLD_INTERRUPT_CB
00398 
00406 attribute_deprecated void avio_set_interrupt_cb(int (*interrupt_cb)(void));
00407 #endif
00408 
00426 AVIOContext *avio_alloc_context(
00427                   unsigned char *buffer,
00428                   int buffer_size,
00429                   int write_flag,
00430                   void *opaque,
00431                   int (*read_packet)(void *opaque, uint8_t *buf, int buf_size),
00432                   int (*write_packet)(void *opaque, uint8_t *buf, int buf_size),
00433                   int64_t (*seek)(void *opaque, int64_t offset, int whence));
00434 
00435 void avio_w8(AVIOContext *s, int b);
00436 void avio_write(AVIOContext *s, const unsigned char *buf, int size);
00437 void avio_wl64(AVIOContext *s, uint64_t val);
00438 void avio_wb64(AVIOContext *s, uint64_t val);
00439 void avio_wl32(AVIOContext *s, unsigned int val);
00440 void avio_wb32(AVIOContext *s, unsigned int val);
00441 void avio_wl24(AVIOContext *s, unsigned int val);
00442 void avio_wb24(AVIOContext *s, unsigned int val);
00443 void avio_wl16(AVIOContext *s, unsigned int val);
00444 void avio_wb16(AVIOContext *s, unsigned int val);
00445 
00450 int avio_put_str(AVIOContext *s, const char *str);
00451 
00456 int avio_put_str16le(AVIOContext *s, const char *str);
00457 
00463 #define AVSEEK_SIZE 0x10000
00464 
00471 #define AVSEEK_FORCE 0x20000
00472 
00477 int64_t avio_seek(AVIOContext *s, int64_t offset, int whence);
00478 
00483 static av_always_inline int64_t avio_skip(AVIOContext *s, int64_t offset)
00484 {
00485     return avio_seek(s, offset, SEEK_CUR);
00486 }
00487 
00492 static av_always_inline int64_t avio_tell(AVIOContext *s)
00493 {
00494     return avio_seek(s, 0, SEEK_CUR);
00495 }
00496 
00501 int64_t avio_size(AVIOContext *s);
00502 
00504 int avio_printf(AVIOContext *s, const char *fmt, ...) av_printf_format(2, 3);
00505 
00506 void avio_flush(AVIOContext *s);
00507 
00508 
00513 int avio_read(AVIOContext *s, unsigned char *buf, int size);
00514 
00522 int          avio_r8  (AVIOContext *s);
00523 unsigned int avio_rl16(AVIOContext *s);
00524 unsigned int avio_rl24(AVIOContext *s);
00525 unsigned int avio_rl32(AVIOContext *s);
00526 uint64_t     avio_rl64(AVIOContext *s);
00527 unsigned int avio_rb16(AVIOContext *s);
00528 unsigned int avio_rb24(AVIOContext *s);
00529 unsigned int avio_rb32(AVIOContext *s);
00530 uint64_t     avio_rb64(AVIOContext *s);
00547 int avio_get_str(AVIOContext *pb, int maxlen, char *buf, int buflen);
00548 
00555 int avio_get_str16le(AVIOContext *pb, int maxlen, char *buf, int buflen);
00556 int avio_get_str16be(AVIOContext *pb, int maxlen, char *buf, int buflen);
00557 
00558 
00565 #define AVIO_FLAG_READ  1                                      
00566 #define AVIO_FLAG_WRITE 2                                      
00567 #define AVIO_FLAG_READ_WRITE (AVIO_FLAG_READ|AVIO_FLAG_WRITE)  
00584 #define AVIO_FLAG_NONBLOCK 8
00585 
00599 int avio_open(AVIOContext **s, const char *url, int flags);
00600 
00618 int avio_open2(AVIOContext **s, const char *url, int flags,
00619                const AVIOInterruptCB *int_cb, AVDictionary **options);
00620 
00627 int avio_close(AVIOContext *s);
00628 
00635 int avio_open_dyn_buf(AVIOContext **s);
00636 
00646 int avio_close_dyn_buf(AVIOContext *s, uint8_t **pbuffer);
00647 
00659 const char *avio_enum_protocols(void **opaque, int output);
00660 
00666 int     avio_pause(AVIOContext *h, int pause);
00667 
00685 int64_t avio_seek_time(AVIOContext *h, int stream_index,
00686                        int64_t timestamp, int flags);
00687 
00688 #endif /* AVFORMAT_AVIO_H */
Generated on Sat Mar 17 2012 12:57:53 for Libav by doxygen 1.7.1