[FFmpeg-devel] [PATCH 3/8] lavf/avio: add avio_accept and avio_handshake

Stephan Holljes klaxa1337 at googlemail.com
Tue Jul 21 05:45:12 CEST 2015


Signed-off-by: Stephan Holljes <klaxa1337 at googlemail.com>
---
 libavformat/avio.h    | 16 ++++++++++++++++
 libavformat/aviobuf.c | 17 +++++++++++++++++
 2 files changed, 33 insertions(+)

diff --git a/libavformat/avio.h b/libavformat/avio.h
index d3d9bbd..b7a4fa8 100644
--- a/libavformat/avio.h
+++ b/libavformat/avio.h
@@ -648,4 +648,20 @@ struct AVBPrint;
  */
 int avio_read_to_bprint(AVIOContext *h, struct AVBPrint *pb, size_t max_size);
 
+/**
+ * Accept and allocate a client context on a server context.
+ * @param  s the server context
+ * @param  c the client context
+ * @return   >= 0 on success or a negative value corresponding
+ *           to an AVERROR on failure
+ */
+int avio_accept(AVIOContext *s, AVIOContext **c);
+
+/**
+ * Perform a protocol dependent handshake
+ * @param  c the client context to perform the handshake on
+ * @return   >= 0 on success or a negative value corresponding
+ *           to an AVERROR on failure
+ */
+int avio_handshake(AVIOContext *c);
 #endif /* AVFORMAT_AVIO_H */
diff --git a/libavformat/aviobuf.c b/libavformat/aviobuf.c
index ff85081..ce05c5d 100644
--- a/libavformat/aviobuf.c
+++ b/libavformat/aviobuf.c
@@ -1021,6 +1021,23 @@ int avio_read_to_bprint(AVIOContext *h, AVBPrint *pb, size_t max_size)
     return 0;
 }
 
+int avio_accept(AVIOContext *s, AVIOContext **c)
+{
+    int ret;
+    URLContext *sc = s->opaque;
+    URLContext *cc;
+    ret = ffurl_accept(sc, &cc);
+    if (ret < 0)
+        return ret;
+    return ffio_fdopen(c, cc);
+}
+
+int avio_handshake(AVIOContext *c)
+{
+    URLContext *cc = c->opaque;
+    return ffurl_handshake(cc);
+}
+
 /* output in a dynamic buffer */
 
 typedef struct DynBuffer {
-- 
2.1.0



More information about the ffmpeg-devel mailing list