/*
- * unbuffered io for ffmpeg system
* copyright (c) 2001 Fabrice Bellard
*
* This file is part of FFmpeg.
#ifndef AVFORMAT_AVIO_H
#define AVFORMAT_AVIO_H
+/**
+ * @file libavformat/avio.h
+ * unbuffered I/O operations
+ *
+ * @warning This file has to be considered an internal but installed
+ * header, so it should not be directly included in your projects.
+ */
+
#include <stdint.h>
+#include "libavutil/common.h"
+
/* unbuffered I/O */
/**
#define URL_RDONLY 0
#define URL_WRONLY 1
#define URL_RDWR 2
+#define URL_DIRECT 4
typedef int URLInterruptCB(void);
int url_exist(const char *filename);
int64_t url_filesize(URLContext *h);
+/**
+ * Return the file descriptor associated with this URL. For RTP, this
+ * will return only the RTP file descriptor, not the RTCP file descriptor.
+ * To get both, use rtp_get_file_handles().
+ *
+ * @return the file descriptor associated with this URL, or <0 on error.
+ */
+int url_get_file_handle(URLContext *h);
+
/**
* Return the maximum packet size associated to packetized file
* handle. If the file is not packetized (stream like HTTP or file on
* @return >= 0 on success
* @see AVInputFormat::read_seek
*/
-int64_t av_url_read_seek(URLContext *h,
- int stream_index, int64_t timestamp, int flags);
+int64_t av_url_read_seek(URLContext *h, int stream_index,
+ int64_t timestamp, int flags);
/**
* Passing this as the "whence" parameter to a seek function causes it to
int (*url_close)(URLContext *h);
struct URLProtocol *next;
int (*url_read_pause)(URLContext *h, int pause);
- int64_t (*url_read_seek)(URLContext *h,
- int stream_index, int64_t timestamp, int flags);
+ int64_t (*url_read_seek)(URLContext *h, int stream_index,
+ int64_t timestamp, int flags);
+ int (*url_get_file_handle)(URLContext *h);
} URLProtocol;
+#if LIBAVFORMAT_VERSION_MAJOR < 53
extern URLProtocol *first_protocol;
+#endif
+
extern URLInterruptCB *url_interrupt_cb;
+/**
+ * If protocol is NULL, returns the first registered protocol,
+ * if protocol is non-NULL, returns the next registered protocol after protocol,
+ * or NULL if protocol is the last one.
+ */
URLProtocol *av_protocol_next(URLProtocol *p);
-int register_protocol(URLProtocol *protocol);
+#if LIBAVFORMAT_VERSION_MAJOR < 53
+/**
+ * @deprecated Use av_register_protocol() instead.
+ */
+attribute_deprecated int register_protocol(URLProtocol *protocol);
+#endif
+
+int av_register_protocol(URLProtocol *protocol);
/**
* Bytestream IO Context.
int must_flush; /**< true if the next seek should flush */
int eof_reached; /**< true if eof reached */
int write_flag; /**< true if open for writing */
+ int o_direct_flag; /**< true if the underlaying file is open with O_DIRECT */
+ int flush_all; /**< Used during seek when o_direct_flag is set */
int is_streamed;
int max_packet_size;
unsigned long checksum;
unsigned long (*update_checksum)(unsigned long checksum, const uint8_t *buf, unsigned int size);
int error; ///< contains the error code or 0 if no error happened
int (*read_pause)(void *opaque, int pause);
- int64_t (*read_seek)(void *opaque,
- int stream_index, int64_t timestamp, int flags);
+ int64_t (*read_seek)(void *opaque, int stream_index,
+ int64_t timestamp, int flags);
} ByteIOContext;
int init_put_byte(ByteIOContext *s,
int url_ferror(ByteIOContext *s);
int av_url_read_fpause(ByteIOContext *h, int pause);
-int64_t av_url_read_fseek(ByteIOContext *h,
- int stream_index, int64_t timestamp, int flags);
+int64_t av_url_read_fseek(ByteIOContext *h, int stream_index,
+ int64_t timestamp, int flags);
#define URL_EOF (-1)
/** @note return URL_EOF (-1) if EOF */
#endif
/** @note unlike fgets, the EOL character is not returned and a whole
- line is parsed. return NULL if first char read was EOF */
+ line is parsed. return NULL if first char read was EOF */
char *url_fgets(ByteIOContext *s, char *buf, int buf_size);
void put_flush_packet(ByteIOContext *s);
int get_partial_buffer(ByteIOContext *s, unsigned char *buf, int size);
/** @note return 0 if EOF, so you cannot use it if EOF handling is
- necessary */
+ necessary */
int get_byte(ByteIOContext *s);
unsigned int get_le24(ByteIOContext *s);
unsigned int get_le32(ByteIOContext *s);
}
/** @note when opened as read/write, the buffers are only used for
- writing */
+ writing */
int url_fdopen(ByteIOContext **s, URLContext *h);
/** @warning must be called before any I/O */
int url_resetbuf(ByteIOContext *s, int flags);
/** @note when opened as read/write, the buffers are only used for
- writing */
+ writing */
int url_fopen(ByteIOContext **s, const char *filename, int flags);
int url_fclose(ByteIOContext *s);
URLContext *url_fileno(ByteIOContext *s);
*/
int url_close_dyn_buf(ByteIOContext *s, uint8_t **pbuffer);
-unsigned long ff_crc04C11DB7_update(unsigned long checksum, const uint8_t *buf, unsigned int len);
+unsigned long ff_crc04C11DB7_update(unsigned long checksum, const uint8_t *buf,
+ unsigned int len);
unsigned long get_checksum(ByteIOContext *s);
-void init_checksum(ByteIOContext *s, unsigned long (*update_checksum)(unsigned long c, const uint8_t *p, unsigned int len), unsigned long checksum);
+void init_checksum(ByteIOContext *s,
+ unsigned long (*update_checksum)(unsigned long c, const uint8_t *p, unsigned int len),
+ unsigned long checksum);
/* udp.c */
int udp_set_remote_url(URLContext *h, const char *uri);
int udp_get_local_port(URLContext *h);
+#if (LIBAVFORMAT_VERSION_MAJOR <= 52)
int udp_get_file_handle(URLContext *h);
+#endif
#endif /* AVFORMAT_AVIO_H */