[FFmpeg-cvslog] r11110 - in trunk/libavformat: avio.h aviobuf.c
andoma
subversion
Wed Nov 28 20:46:50 CET 2007
Author: andoma
Date: Wed Nov 28 20:46:49 2007
New Revision: 11110
Log:
Extend ByteIOContext and add the buffered IO functions:
url_read_fplay(), url_read_fpause() and url_read_fseek().
patch by: Bj?rn Axelsson, bjorn d axelsson a intinor d se
Modified:
trunk/libavformat/avio.h
trunk/libavformat/aviobuf.c
Modified: trunk/libavformat/avio.h
==============================================================================
--- trunk/libavformat/avio.h (original)
+++ trunk/libavformat/avio.h Wed Nov 28 20:46:49 2007
@@ -156,6 +156,10 @@ typedef struct {
unsigned char *checksum_ptr;
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_play)(void *opaque);
+ int (*read_pause)(void *opaque);
+ int (*read_seek)(void *opaque,
+ int stream_index, int64_t timestamp, int flags);
} ByteIOContext;
int init_put_byte(ByteIOContext *s,
@@ -188,6 +192,11 @@ offset_t url_fsize(ByteIOContext *s);
int url_feof(ByteIOContext *s);
int url_ferror(ByteIOContext *s);
+int av_url_read_fplay(ByteIOContext *h);
+int av_url_read_fpause(ByteIOContext *h);
+int 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 */
int url_fgetc(ByteIOContext *s);
Modified: trunk/libavformat/aviobuf.c
==============================================================================
--- trunk/libavformat/aviobuf.c (original)
+++ trunk/libavformat/aviobuf.c Wed Nov 28 20:46:49 2007
@@ -55,6 +55,9 @@ int init_put_byte(ByteIOContext *s,
s->pos = buffer_size;
s->buf_end = s->buffer + buffer_size;
}
+ s->read_play = NULL;
+ s->read_pause = NULL;
+ s->read_seek = NULL;
return 0;
}
@@ -551,6 +554,11 @@ int url_fdopen(ByteIOContext **s, URLCon
}
(*s)->is_streamed = h->is_streamed;
(*s)->max_packet_size = max_packet_size;
+ if(h->prot) {
+ (*s)->read_play = (int (*)(void *))h->prot->url_read_play;
+ (*s)->read_pause = (int (*)(void *))h->prot->url_read_pause;
+ (*s)->read_seek = (int (*)(void *, int, int64_t, int))h->prot->url_read_seek;
+ }
return 0;
}
@@ -656,6 +664,35 @@ int url_fget_max_packet_size(ByteIOConte
return s->max_packet_size;
}
+int av_url_read_fplay(ByteIOContext *s)
+{
+ if (!s->read_play)
+ return AVERROR(ENOSYS);
+ return s->read_play(s->opaque);
+}
+
+int av_url_read_fpause(ByteIOContext *s)
+{
+ if (!s->read_pause)
+ return AVERROR(ENOSYS);
+ return s->read_pause(s->opaque);
+}
+
+int av_url_read_fseek(ByteIOContext *s,
+ int stream_index, int64_t timestamp, int flags)
+{
+ URLContext *h = s->opaque;
+ int ret;
+ if (!s->read_seek)
+ return AVERROR(ENOSYS);
+ ret = s->read_seek(h, stream_index, timestamp, flags);
+ if(ret >= 0) {
+ s->buf_ptr = s->buf_end; // Flush buffer
+ s->pos = s->seek(h, 0, SEEK_CUR);
+ }
+ return ret;
+}
+
/* url_open_dyn_buf and url_close_dyn_buf are used in rtp.c to send a response
* back to the server even if CONFIG_MUXERS is not set. */
#if defined(CONFIG_MUXERS) || defined(CONFIG_NETWORK)
More information about the ffmpeg-cvslog
mailing list