On 21/01/15 14:41, Martin Storsjö wrote:
Since R/W AVIOContexts aren't fully supported (it only
supports one single buffer, either for reading or writing),
we open this with the read flag only, and keep doing all the writes
directly to the underlying URLContext, bypassing the read buffer.
---
This may potentially help utilize the underlying network better,
by reading larger buffers from the socket at a time into the
buffer, instead of consuming one single byte at a time (when
reading rtsp reply headers).

I'm not sure if this actually does help significantly or not
- testing of that is appreciated.

The idea looks nice, some notes below.

---
  libavformat/avio_internal.h |  2 ++
  libavformat/aviobuf.c       |  5 +++++
  libavformat/rtsp.c          | 45 ++++++++++++++++++++++++++++++---------------
  libavformat/rtsp.h          |  2 +-
  libavformat/rtspdec.c       | 15 ++++++++-------
  libavformat/rtspenc.c       |  4 ++--
  6 files changed, 48 insertions(+), 25 deletions(-)

diff --git a/libavformat/avio_internal.h b/libavformat/avio_internal.h
index a8bcadd..2a6dac3 100644
--- a/libavformat/avio_internal.h
+++ b/libavformat/avio_internal.h
@@ -85,6 +85,8 @@ int ffio_rewind_with_probe_data(AVIOContext *s, unsigned char 
*buf, int buf_size

  uint64_t ffio_read_varlen(AVIOContext *bc);

+int ffio_has_buffered(AVIOContext *s);
+
  /** @warning must be called before any I/O */
  int ffio_set_buf_size(AVIOContext *s, int buf_size);

diff --git a/libavformat/aviobuf.c b/libavformat/aviobuf.c
index 6923b78..9015648 100644
--- a/libavformat/aviobuf.c
+++ b/libavformat/aviobuf.c
@@ -496,6 +496,11 @@ int avio_read(AVIOContext *s, unsigned char *buf, int size)
      return size1 - size;
  }

+int ffio_has_buffered(AVIOContext *s)
+{
+    return s->buf_end > s->buf_ptr;
+}

if buf_ptr is equal to buf_start the condition would be true as well.


-        ffurl_read_complete(rt->rtsp_hd, content, content_length);
+        avio_read(rt->rtsp_hd, content, content_length);

We should check the return value I guess.

          content[content_length] = '\0';


The rest seems workable, might be interesting wrapping the check in something like url_poll()/avio_poll() later.

I'll try to think something about it.

Julius, may I rely on you regarding additional testing?

lu

_______________________________________________
libav-devel mailing list
[email protected]
https://lists.libav.org/mailman/listinfo/libav-devel

Reply via email to