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>tags/n4.0
@@ -13,6 +13,9 @@ libavutil: 2017-03-23 | |||||
API changes, most recent first: | API changes, most recent first: | ||||
2016-xx-xx - xxxxxxx - lavf 58.1.0 - avio.h | |||||
Add avio_read_partial(). | |||||
2017-xx-xx - xxxxxxx - lavu 56.4.0 - imgutils.h | 2017-xx-xx - xxxxxxx - lavu 56.4.0 - imgutils.h | ||||
Add av_image_fill_black(). | Add av_image_fill_black(). | ||||
@@ -331,6 +331,15 @@ void avio_flush(AVIOContext *s); | |||||
*/ | */ | ||||
int avio_read(AVIOContext *s, unsigned char *buf, int size); | 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 | * @name Functions for reading from AVIOContext | ||||
* @{ | * @{ | ||||
@@ -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); | 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); | void ffio_fill(AVIOContext *s, int b, int count); | ||||
static av_always_inline void ffio_wfourcc(AVIOContext *pb, const uint8_t *s) | static av_always_inline void ffio_wfourcc(AVIOContext *pb, const uint8_t *s) | ||||
@@ -621,7 +621,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; | int len; | ||||
@@ -42,7 +42,7 @@ int ff_raw_read_partial_packet(AVFormatContext *s, AVPacket *pkt) | |||||
pkt->pos= avio_tell(s->pb); | pkt->pos= avio_tell(s->pb); | ||||
pkt->stream_index = 0; | 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) { | if (ret < 0) { | ||||
av_packet_unref(pkt); | av_packet_unref(pkt); | ||||
return ret; | return ret; | ||||
@@ -2077,7 +2077,7 @@ static int read_packet(AVFormatContext *s, | |||||
wait_end && wait_end < av_gettime_relative()) | wait_end && wait_end < av_gettime_relative()) | ||||
len = AVERROR(EAGAIN); | len = AVERROR(EAGAIN); | ||||
else | 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); | len = pick_stream(s, rtsp_st, rt->recvbuf, len); | ||||
if (len > 0 && (*rtsp_st)->transport_priv && rt->transport == RTSP_TRANSPORT_RTP) | 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); | ff_rtp_check_and_send_back_rr((*rtsp_st)->transport_priv, NULL, s->pb, len); | ||||
@@ -30,7 +30,7 @@ | |||||
#include "libavutil/version.h" | #include "libavutil/version.h" | ||||
#define LIBAVFORMAT_VERSION_MAJOR 58 | #define LIBAVFORMAT_VERSION_MAJOR 58 | ||||
#define LIBAVFORMAT_VERSION_MINOR 0 | |||||
#define LIBAVFORMAT_VERSION_MINOR 1 | |||||
#define LIBAVFORMAT_VERSION_MICRO 0 | #define LIBAVFORMAT_VERSION_MICRO 0 | ||||
#define LIBAVFORMAT_VERSION_INT AV_VERSION_INT(LIBAVFORMAT_VERSION_MAJOR, \ | #define LIBAVFORMAT_VERSION_INT AV_VERSION_INT(LIBAVFORMAT_VERSION_MAJOR, \ | ||||