From 502bdf68937d71006d55aebd9da98e750bce4010 Mon Sep 17 00:00:00 2001 From: Michael Niedermayer Date: Wed, 19 Dec 2007 20:57:13 +0000 Subject: [PATCH] Merge recently added and still unused play and pause functions. Originally committed as revision 11273 to svn://svn.ffmpeg.org/ffmpeg/trunk --- libavformat/avio.c | 11 ++--------- libavformat/avio.h | 21 +++++++++------------ libavformat/aviobuf.c | 15 +++------------ libavformat/utils.c | 6 +++--- 4 files changed, 17 insertions(+), 36 deletions(-) diff --git a/libavformat/avio.c b/libavformat/avio.c index 6a08a5e07e..8466cd5ee8 100644 --- a/libavformat/avio.c +++ b/libavformat/avio.c @@ -192,18 +192,11 @@ void url_set_interrupt_cb(URLInterruptCB *interrupt_cb) url_interrupt_cb = interrupt_cb; } -int av_url_read_play(URLContext *h) -{ - if (!h->prot->url_read_play) - return AVERROR(ENOSYS); - return h->prot->url_read_play(h); -} - -int av_url_read_pause(URLContext *h) +int av_url_read_pause(URLContext *h, int pause) { if (!h->prot->url_read_pause) return AVERROR(ENOSYS); - return h->prot->url_read_pause(h); + return h->prot->url_read_pause(h, pause); } int av_url_read_seek(URLContext *h, diff --git a/libavformat/avio.h b/libavformat/avio.h index d3fa10f006..bdeb502611 100644 --- a/libavformat/avio.h +++ b/libavformat/avio.h @@ -82,12 +82,12 @@ void url_set_interrupt_cb(URLInterruptCB *interrupt_cb); /* not implemented */ int url_poll(URLPollEntry *poll_table, int n, int timeout); -/** Start playing or resume paused playout. Only meaningful if using a network - * streaming protocol (e.g. MMS). */ -int av_url_read_play(URLContext *h); -/** Pause playing - only meaningful if using a network streaming protocol - * (e.g. MMS). */ -int av_url_read_pause(URLContext *h); +/** + * Pause and resume playing - only meaningful if using a network streaming + * protocol (e.g. MMS). + * @param pause 1 for pause, 0 for resume + */ +int av_url_read_pause(URLContext *h, int pause); /** * Seek to a given timestamp relative to some component stream. * Only meaningful if using a network streaming protocol (e.g. MMS.) @@ -123,8 +123,7 @@ typedef struct URLProtocol { offset_t (*url_seek)(URLContext *h, offset_t pos, int whence); int (*url_close)(URLContext *h); struct URLProtocol *next; - int (*url_read_play)(URLContext *h); - int (*url_read_pause)(URLContext *h); + int (*url_read_pause)(URLContext *h, int pause); int (*url_read_seek)(URLContext *h, int stream_index, int64_t timestamp, int flags); } URLProtocol; @@ -154,8 +153,7 @@ 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_pause)(void *opaque, int pause); int (*read_seek)(void *opaque, int stream_index, int64_t timestamp, int flags); } ByteIOContext; @@ -190,8 +188,7 @@ 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_fpause(ByteIOContext *h, int pause); int av_url_read_fseek(ByteIOContext *h, int stream_index, int64_t timestamp, int flags); diff --git a/libavformat/aviobuf.c b/libavformat/aviobuf.c index d3777d15c0..025e0b6980 100644 --- a/libavformat/aviobuf.c +++ b/libavformat/aviobuf.c @@ -55,7 +55,6 @@ 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; @@ -532,8 +531,7 @@ int url_fdopen(ByteIOContext **s, URLContext *h) (*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_pause = (int (*)(void *, int))h->prot->url_read_pause; (*s)->read_seek = (int (*)(void *, int, int64_t, int))h->prot->url_read_seek; } return 0; @@ -641,18 +639,11 @@ int url_fget_max_packet_size(ByteIOContext *s) 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) +int av_url_read_fpause(ByteIOContext *s, int pause) { if (!s->read_pause) return AVERROR(ENOSYS); - return s->read_pause(s->opaque); + return s->read_pause(s->opaque, pause); } int av_url_read_fseek(ByteIOContext *s, diff --git a/libavformat/utils.c b/libavformat/utils.c index f4cf10f14d..e5e04bf745 100644 --- a/libavformat/utils.c +++ b/libavformat/utils.c @@ -2042,8 +2042,8 @@ int av_read_play(AVFormatContext *s) { if (s->iformat->read_play) return s->iformat->read_play(s); - if (s->pb && s->pb->read_play) - return av_url_read_fplay(s->pb); + if (s->pb && s->pb->read_pause) + return av_url_read_fpause(s->pb, 0); return AVERROR(ENOSYS); } @@ -2052,7 +2052,7 @@ int av_read_pause(AVFormatContext *s) if (s->iformat->read_pause) return s->iformat->read_pause(s); if (s->pb && s->pb->read_pause) - return av_url_read_fpause(s->pb); + return av_url_read_fpause(s->pb, 1); return AVERROR(ENOSYS); }