aboutsummaryrefslogtreecommitdiffstats
path: root/libavformat
diff options
context:
space:
mode:
authorStephan Holljes <klaxa1337@googlemail.com>2015-07-03 02:24:18 +0200
committerStephan Holljes <klaxa1337@googlemail.com>2015-08-01 00:58:31 +0200
commit5125e4b53f71ca3c7d34c5812425f6f2fb963375 (patch)
tree7392ae20b74db1bc86323f2847a897fb142ed2e8 /libavformat
parentcf6c871beec9039dc6d7ebda57358161d64062c3 (diff)
downloadffmpeg-5125e4b53f71ca3c7d34c5812425f6f2fb963375.tar.gz
lavf/avio: add ffurl_accept and ffurl_handshake
Signed-off-by: Stephan Holljes <klaxa1337@googlemail.com>
Diffstat (limited to 'libavformat')
-rw-r--r--libavformat/avio.c20
-rw-r--r--libavformat/url.h25
2 files changed, 45 insertions, 0 deletions
diff --git a/libavformat/avio.c b/libavformat/avio.c
index c188adcce1..21713d9d5e 100644
--- a/libavformat/avio.c
+++ b/libavformat/avio.c
@@ -211,6 +211,26 @@ int ffurl_connect(URLContext *uc, AVDictionary **options)
return 0;
}
+int ffurl_accept(URLContext *s, URLContext **c)
+{
+ av_assert0(!*c);
+ if (s->prot->url_accept)
+ return s->prot->url_accept(s, c);
+ return AVERROR(EBADF);
+}
+
+int ffurl_handshake(URLContext *c)
+{
+ int ret;
+ if (c->prot->url_handshake) {
+ ret = c->prot->url_handshake(c);
+ if (ret)
+ return ret;
+ }
+ c->is_connected = 1;
+ return 0;
+}
+
#define URL_SCHEME_CHARS \
"abcdefghijklmnopqrstuvwxyz" \
"ABCDEFGHIJKLMNOPQRSTUVWXYZ" \
diff --git a/libavformat/url.h b/libavformat/url.h
index 99a3201cf6..391e3bca2a 100644
--- a/libavformat/url.h
+++ b/libavformat/url.h
@@ -58,6 +58,8 @@ typedef struct URLProtocol {
* for those nested protocols.
*/
int (*url_open2)(URLContext *h, const char *url, int flags, AVDictionary **options);
+ int (*url_accept)(URLContext *s, URLContext **c);
+ int (*url_handshake)(URLContext *c);
/**
* Read data from the protocol.
@@ -140,6 +142,29 @@ int ffurl_open(URLContext **puc, const char *filename, int flags,
const AVIOInterruptCB *int_cb, AVDictionary **options);
/**
+ * Accept an URLContext c on an URLContext s
+ *
+ * @param s server context
+ * @param c client context, must be unallocated.
+ * @return >= 0 on success, ff_neterrno() on failure.
+ */
+int ffurl_accept(URLContext *s, URLContext **c);
+
+/**
+ * Perform one step of the protocol handshake to accept a new client.
+ * See avio_handshake() for details.
+ * Implementations should try to return decreasing values.
+ * If the protocol uses an underlying protocol, the underlying handshake is
+ * usually the first step, and the return value can be:
+ * (largest value for this protocol) + (return value from other protocol)
+ *
+ * @param c the client context
+ * @return >= 0 on success or a negative value corresponding
+ * to an AVERROR code on failure
+ */
+int ffurl_handshake(URLContext *c);
+
+/**
* Read up to size bytes from the resource accessed by h, and store
* the read bytes in buf.
*