diff options
author | wm4 <nfxjfg@googlemail.com> | 2017-08-17 15:01:44 +0200 |
---|---|---|
committer | wm4 <nfxjfg@googlemail.com> | 2017-09-01 17:56:33 +0200 |
commit | 5d76674756806e3b458e484788775fcee34aac2a (patch) | |
tree | 8565294bfa35d9205266e12d55fadf86926f0de4 /libavformat | |
parent | 877076ffa17bcf56badedc036cdc1adcd9f38b24 (diff) |
lavf: make avio_read_partial() public
Main use-case is proxying avio through a foreign I/O layer and a custom
AVIO context, without losing latency and performance characteristics.
Signed-off-by: Luca Barbato <lu_zero@gentoo.org>
Merged from Libav commit 173b56218f39c64.
Diffstat (limited to 'libavformat')
-rw-r--r-- | libavformat/avio.h | 9 | ||||
-rw-r--r-- | libavformat/avio_internal.h | 8 | ||||
-rw-r--r-- | libavformat/aviobuf.c | 2 | ||||
-rw-r--r-- | libavformat/rawdec.c | 2 | ||||
-rw-r--r-- | libavformat/rtsp.c | 2 | ||||
-rw-r--r-- | libavformat/version.h | 2 |
6 files changed, 13 insertions, 12 deletions
diff --git a/libavformat/avio.h b/libavformat/avio.h index 89ad5c04ea..f9c5972ada 100644 --- a/libavformat/avio.h +++ b/libavformat/avio.h @@ -599,6 +599,15 @@ void avio_flush(AVIOContext *s); int avio_read(AVIOContext *s, unsigned char *buf, int size); /** + * Read size bytes from AVIOContext into buf. Unlike avio_read(), this is allowed + * to read fewer bytes than requested. The missing bytes can be read in the next + * call. This always tries to read at least 1 byte. + * Useful to reduce latency in certain cases. + * @return number of bytes read or AVERROR + */ +int avio_read_partial(AVIOContext *s, unsigned char *buf, int size); + +/** * @name Functions for reading from AVIOContext * @{ * diff --git a/libavformat/avio_internal.h b/libavformat/avio_internal.h index fdb323c8f1..c01835df96 100644 --- a/libavformat/avio_internal.h +++ b/libavformat/avio_internal.h @@ -53,14 +53,6 @@ int ffio_init_context(AVIOContext *s, */ int ffio_read_indirect(AVIOContext *s, unsigned char *buf, int size, const unsigned char **data); -/** - * Read size bytes from AVIOContext into buf. - * This reads at most 1 packet. If that is not enough fewer bytes will be - * returned. - * @return number of bytes read or AVERROR - */ -int ffio_read_partial(AVIOContext *s, unsigned char *buf, int size); - void ffio_fill(AVIOContext *s, int b, int count); static av_always_inline void ffio_wfourcc(AVIOContext *pb, const uint8_t *s) diff --git a/libavformat/aviobuf.c b/libavformat/aviobuf.c index 716c42eda9..636cb46161 100644 --- a/libavformat/aviobuf.c +++ b/libavformat/aviobuf.c @@ -703,7 +703,7 @@ int ffio_read_indirect(AVIOContext *s, unsigned char *buf, int size, const unsig } } -int ffio_read_partial(AVIOContext *s, unsigned char *buf, int size) +int avio_read_partial(AVIOContext *s, unsigned char *buf, int size) { int len; diff --git a/libavformat/rawdec.c b/libavformat/rawdec.c index 876a6e6a75..e926549a60 100644 --- a/libavformat/rawdec.c +++ b/libavformat/rawdec.c @@ -43,7 +43,7 @@ int ff_raw_read_partial_packet(AVFormatContext *s, AVPacket *pkt) pkt->pos= avio_tell(s->pb); pkt->stream_index = 0; - ret = ffio_read_partial(s->pb, pkt->data, size); + ret = avio_read_partial(s->pb, pkt->data, size); if (ret < 0) { av_packet_unref(pkt); return ret; diff --git a/libavformat/rtsp.c b/libavformat/rtsp.c index 261e970b75..0bd72dc5ce 100644 --- a/libavformat/rtsp.c +++ b/libavformat/rtsp.c @@ -2136,7 +2136,7 @@ redo: wait_end && wait_end < av_gettime_relative()) len = AVERROR(EAGAIN); else - len = ffio_read_partial(s->pb, rt->recvbuf, RECVBUF_SIZE); + len = avio_read_partial(s->pb, rt->recvbuf, RECVBUF_SIZE); len = pick_stream(s, &rtsp_st, rt->recvbuf, len); if (len > 0 && rtsp_st->transport_priv && rt->transport == RTSP_TRANSPORT_RTP) ff_rtp_check_and_send_back_rr(rtsp_st->transport_priv, NULL, s->pb, len); diff --git a/libavformat/version.h b/libavformat/version.h index 0af524c16b..9cca76ee00 100644 --- a/libavformat/version.h +++ b/libavformat/version.h @@ -32,7 +32,7 @@ // Major bumping may affect Ticket5467, 5421, 5451(compatibility with Chromium) // Also please add any ticket numbers that you believe might be affected here #define LIBAVFORMAT_VERSION_MAJOR 57 -#define LIBAVFORMAT_VERSION_MINOR 80 +#define LIBAVFORMAT_VERSION_MINOR 81 #define LIBAVFORMAT_VERSION_MICRO 100 #define LIBAVFORMAT_VERSION_INT AV_VERSION_INT(LIBAVFORMAT_VERSION_MAJOR, \ |