25 #include "libavformat/avformat.h"
26 #include "libavutil/avstring.h"
35 #undef avformat_close_input
38 #undef avformat_open_input
41 return read(*(
int*)opaque, buf, buf_size);
45 return write(*(
int*)opaque, buf, buf_size);
48 static int64_t
fd_seek(
void *opaque, int64_t offset,
int whence) {
52 return AVERROR(EINVAL);
56 if (whence == AVSEEK_SIZE) {
58 ret = fstat(*fd, &st);
59 return ret < 0 ? AVERROR(errno) : (S_ISFIFO(st.st_mode) ? 0 : st.st_size);
62 ret = lseek(*fd, offset, whence);
64 return ret < 0 ? AVERROR(errno) : ret;
72 const char* fd_ptr = NULL;
74 if (av_strstart(filename,
"saf:", &fd_ptr)) {
76 fd = strtol(fd_ptr, &
final, 10);
77 if (fd_ptr ==
final) {
83 int *opaque = av_mallocz(
sizeof(
int));
85 int write_flag = flags & AVIO_FLAG_WRITE ? 1 : 0;
94 if (
fd_seek(ctx->opaque, 0, AVSEEK_SIZE) >= 0) {
95 int *fd = ctx->opaque;
104 ff_const59 AVInputFormat *fmt, AVDictionary **options) {
105 if (!(*ps) && !(*ps = avformat_alloc_context()))
106 return AVERROR(ENOMEM);
114 const AVIOInterruptCB *
int_cb, AVDictionary **options) {
135 if (*ps && (*ps)->pb) {
int android_avformat_open_input(AVFormatContext **ps, const char *filename, ff_const59 AVInputFormat *fmt, AVDictionary **options)
static AVIOContext * create_fd_avio_context(const char *filename, int flags)
int android_avio_closep(AVIOContext **s)
int android_avio_open2(AVIOContext **s, const char *filename, int flags, const AVIOInterruptCB *int_cb, AVDictionary **options)
void android_avformat_close_input(AVFormatContext **ps)
static void close_fd_avio_context(AVIOContext *ctx)
static int fd_read_packet(void *opaque, uint8_t *buf, int buf_size)
int android_avio_open(AVIOContext **s, const char *url, int flags)
static int64_t fd_seek(void *opaque, int64_t offset, int whence)
static int fd_write_packet(void *opaque, uint8_t *buf, int buf_size)
void closeParcelFileDescriptor(int fd)
#define avformat_open_input
#define avformat_close_input