On Mon, Apr 6, 2015 at 1:47 PM, Lukasz Marek <lukasz.m.lu...@gmail.com> wrote:
> On Apr 5, 2015 6:02 PM, "Stephan Holljes" <klaxa1...@googlemail.com> wrote:
>>
>> With this patch http can be used to listen for POST data to be used as an
> input stream.
>>
>> Signed-off-by: Stephan Holljes <klaxa1...@googlemail.com>
>> ---
>>  libavformat/http.c | 7 +++++--
>>  1 file changed, 5 insertions(+), 2 deletions(-)
>
> This should be documented I guess.
I added a short description in doc/protocols.texi.
> _______________________________________________
> ffmpeg-devel mailing list
> ffmpeg-devel@ffmpeg.org
> http://ffmpeg.org/mailman/listinfo/ffmpeg-devel

Now attached two patches. The first one fixes the parenthesis and the
second one adds the original patch.

Regards,
Stephan Holljes
From bbd8fc4e700968a977b30850b7be3ec39bad3531 Mon Sep 17 00:00:00 2001
From: Stephan Holljes <klaxa1...@googlemail.com>
Date: Mon, 6 Apr 2015 20:23:01 +0200
Subject: [PATCH 2/2] libavformat/http.c: Make http-listen work as an input
 stream.

With this patch http can be used to listen for POST data to be used as an input stream.

Signed-off-by: Stephan Holljes <klaxa1...@googlemail.com>
---
 doc/protocols.texi | 4 +++-
 libavformat/http.c | 7 +++++--
 2 files changed, 8 insertions(+), 3 deletions(-)

diff --git a/doc/protocols.texi b/doc/protocols.texi
index 5b7b6cf..5e9173f 100644
--- a/doc/protocols.texi
+++ b/doc/protocols.texi
@@ -279,7 +279,9 @@ Set initial byte offset.
 Try to limit the request to bytes preceding this offset.
 
 @item listen
-If set to 1 enables experimental HTTP server.
+If set to 1 enables experimental HTTP server. This can be used to send data when
+used as an output option, or read data from a client with HTTP POST when used as
+an input option.
 @end table
 
 @subsection HTTP Cookies
diff --git a/libavformat/http.c b/libavformat/http.c
index 0993546..e4acf75 100644
--- a/libavformat/http.c
+++ b/libavformat/http.c
@@ -128,13 +128,14 @@ static const AVOption options[] = {
     { "end_offset", "try to limit the request to bytes preceding this offset", OFFSET(end_off), AV_OPT_TYPE_INT64, { .i64 = 0 }, 0, INT64_MAX, D },
     { "method", "Override the HTTP method", OFFSET(method), AV_OPT_TYPE_STRING, { .str = NULL }, 0, 0, E },
     { "reconnect", "auto reconnect after disconnect before EOF", OFFSET(reconnect), AV_OPT_TYPE_INT, { .i64 = 0 }, 0, 1, D },
-    { "listen", "listen on HTTP", OFFSET(listen), AV_OPT_TYPE_INT, { .i64 = 0 }, 0, 1, E },
+    { "listen", "listen on HTTP", OFFSET(listen), AV_OPT_TYPE_INT, { .i64 = 0 }, 0, 1, D | E },
     { NULL }
 };
 
 static int http_connect(URLContext *h, const char *path, const char *local_path,
                         const char *hoststr, const char *auth,
                         const char *proxyauth, int *new_location);
+static int http_read_header(URLContext *h, int *new_location);
 
 void ff_http_init_auth_state(URLContext *dest, const URLContext *src)
 {
@@ -305,7 +306,7 @@ static int http_listen(URLContext *h, const char *uri, int flags,
     static const char header[] = "HTTP/1.1 200 OK\r\nContent-Type: application/octet-stream\r\nTransfer-Encoding: chunked\r\n\r\n";
     char hostname[1024];
     char lower_url[100];
-    int port;
+    int port, new_location;
     av_url_split(NULL, 0, NULL, 0, hostname, sizeof(hostname), &port,
                  NULL, 0, uri);
     ff_url_join(lower_url, sizeof(lower_url), "tcp", NULL, hostname, port,
@@ -316,6 +317,8 @@ static int http_listen(URLContext *h, const char *uri, int flags,
         goto fail;
     if ((ret = ffurl_write(s->hd, header, strlen(header))) < 0)
         goto fail;
+    if ((ret = http_read_header(h, &new_location)) < 0)
+         goto fail;
     return 0;
 
 fail:
-- 
2.3.3

From 8aedd2767d825307fc0d9f6e5b461e2ef68ebe6d Mon Sep 17 00:00:00 2001
From: Stephan Holljes <klaxa1...@googlemail.com>
Date: Mon, 6 Apr 2015 19:26:34 +0200
Subject: [PATCH 1/2] libavformat/http.c: Fix missing parenthesis in
 http_listen()

Signed-off-by: Stephan Holljes <klaxa1...@googlemail.com>
---
 libavformat/http.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/libavformat/http.c b/libavformat/http.c
index 3276737..0993546 100644
--- a/libavformat/http.c
+++ b/libavformat/http.c
@@ -311,10 +311,10 @@ static int http_listen(URLContext *h, const char *uri, int flags,
     ff_url_join(lower_url, sizeof(lower_url), "tcp", NULL, hostname, port,
                 NULL);
     av_dict_set(options, "listen", "1", 0);
-    if (ret = ffurl_open(&s->hd, lower_url, AVIO_FLAG_READ_WRITE,
-                         &h->interrupt_callback, options) < 0)
+    if ((ret = ffurl_open(&s->hd, lower_url, AVIO_FLAG_READ_WRITE,
+                          &h->interrupt_callback, options)) < 0)
         goto fail;
-    if (ret = ffurl_write(s->hd, header, strlen(header)) < 0)
+    if ((ret = ffurl_write(s->hd, header, strlen(header))) < 0)
         goto fail;
     return 0;
 
-- 
2.3.3

_______________________________________________
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel

Reply via email to