Browse code

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.

wm4 authored on 2017/08/17 22:01:44
Showing 7 changed files
... ...
@@ -15,6 +15,9 @@ libavutil:     2015-08-28
15 15
 
16 16
 API changes, most recent first:
17 17
 
18
+2017-09-01 - xxxxxxx - lavf 57.81.100 - avio.h
19
+  Add avio_read_partial().
20
+
18 21
 2017-09-01 - xxxxxxx - lavf 57.80.100 / 57.11.0 - avio.h
19 22
   Add avio_context_free(). From now on it must be used for freeing AVIOContext.
20 23
 
... ...
@@ -599,6 +599,15 @@ void avio_flush(AVIOContext *s);
599 599
 int avio_read(AVIOContext *s, unsigned char *buf, int size);
600 600
 
601 601
 /**
602
+ * Read size bytes from AVIOContext into buf. Unlike avio_read(), this is allowed
603
+ * to read fewer bytes than requested. The missing bytes can be read in the next
604
+ * call. This always tries to read at least 1 byte.
605
+ * Useful to reduce latency in certain cases.
606
+ * @return number of bytes read or AVERROR
607
+ */
608
+int avio_read_partial(AVIOContext *s, unsigned char *buf, int size);
609
+
610
+/**
602 611
  * @name Functions for reading from AVIOContext
603 612
  * @{
604 613
  *
... ...
@@ -53,14 +53,6 @@ int ffio_init_context(AVIOContext *s,
53 53
  */
54 54
 int ffio_read_indirect(AVIOContext *s, unsigned char *buf, int size, const unsigned char **data);
55 55
 
56
-/**
57
- * Read size bytes from AVIOContext into buf.
58
- * This reads at most 1 packet. If that is not enough fewer bytes will be
59
- * returned.
60
- * @return number of bytes read or AVERROR
61
- */
62
-int ffio_read_partial(AVIOContext *s, unsigned char *buf, int size);
63
-
64 56
 void ffio_fill(AVIOContext *s, int b, int count);
65 57
 
66 58
 static av_always_inline void ffio_wfourcc(AVIOContext *pb, const uint8_t *s)
... ...
@@ -703,7 +703,7 @@ int ffio_read_indirect(AVIOContext *s, unsigned char *buf, int size, const unsig
703 703
     }
704 704
 }
705 705
 
706
-int ffio_read_partial(AVIOContext *s, unsigned char *buf, int size)
706
+int avio_read_partial(AVIOContext *s, unsigned char *buf, int size)
707 707
 {
708 708
     int len;
709 709
 
... ...
@@ -43,7 +43,7 @@ int ff_raw_read_partial_packet(AVFormatContext *s, AVPacket *pkt)
43 43
 
44 44
     pkt->pos= avio_tell(s->pb);
45 45
     pkt->stream_index = 0;
46
-    ret = ffio_read_partial(s->pb, pkt->data, size);
46
+    ret = avio_read_partial(s->pb, pkt->data, size);
47 47
     if (ret < 0) {
48 48
         av_packet_unref(pkt);
49 49
         return ret;
... ...
@@ -2136,7 +2136,7 @@ redo:
2136 2136
             wait_end && wait_end < av_gettime_relative())
2137 2137
             len = AVERROR(EAGAIN);
2138 2138
         else
2139
-            len = ffio_read_partial(s->pb, rt->recvbuf, RECVBUF_SIZE);
2139
+            len = avio_read_partial(s->pb, rt->recvbuf, RECVBUF_SIZE);
2140 2140
         len = pick_stream(s, &rtsp_st, rt->recvbuf, len);
2141 2141
         if (len > 0 && rtsp_st->transport_priv && rt->transport == RTSP_TRANSPORT_RTP)
2142 2142
             ff_rtp_check_and_send_back_rr(rtsp_st->transport_priv, NULL, s->pb, len);
... ...
@@ -32,7 +32,7 @@
32 32
 // Major bumping may affect Ticket5467, 5421, 5451(compatibility with Chromium)
33 33
 // Also please add any ticket numbers that you believe might be affected here
34 34
 #define LIBAVFORMAT_VERSION_MAJOR  57
35
-#define LIBAVFORMAT_VERSION_MINOR  80
35
+#define LIBAVFORMAT_VERSION_MINOR  81
36 36
 #define LIBAVFORMAT_VERSION_MICRO 100
37 37
 
38 38
 #define LIBAVFORMAT_VERSION_INT AV_VERSION_INT(LIBAVFORMAT_VERSION_MAJOR, \