[FFmpeg-devel] [PATCH] libavformat/http.c: Make http-listen work as an input stream.

Michael Niedermayer michaelni at gmx.at
Mon Apr 6 13:30:51 CEST 2015


On Mon, Apr 06, 2015 at 05:17:09AM +0200, Stephan Holljes wrote:
> On Mon, Apr 6, 2015 at 1:02 AM, Michael Niedermayer <michaelni at gmx.at> wrote:
> > On Sun, Apr 05, 2015 at 05:58:39PM +0200, Stephan Holljes 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 <klaxa1337 at googlemail.com>
> >> ---
> >>  libavformat/http.c | 7 +++++--
> >>  1 file changed, 5 insertions(+), 2 deletions(-)
> >>
> >> diff --git a/libavformat/http.c b/libavformat/http.c
> >> index 3276737..8961981 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)
> >
> > this looks like it is missing some () around the =
> 
> The other two if-statements are missing them too then.
> I added the fixes for those to the patch or should it be a separate patch?

bugs should be fixed before adding more features, this can help
with future debuging
also patchsets should not contain a patch that introduces a bug with
a subsequent patch fixing it
so best would be a first patch that fixes the 2 currently in git
existing bugs and then a second patch which would be free of the
issue

thanks
[...]

-- 
Michael     GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB

The worst form of inequality is to try to make unequal things equal.
-- Aristotle
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 181 bytes
Desc: Digital signature
URL: <https://ffmpeg.org/pipermail/ffmpeg-devel/attachments/20150406/bf711e51/attachment.asc>


More information about the ffmpeg-devel mailing list