[FFmpeg-devel] [PATCH 1/2] avformat/http: Added a library-internal API for signalling end of chunk

wm4 nfxjfg at googlemail.com
Fri Dec 22 09:43:36 EET 2017


On Fri, 22 Dec 2017 12:34:41 +0530
Karthick J <kjeyapal at akamai.com> wrote:

> From: Karthick Jeyapal <kjeyapal at akamai.com>
> 
> Right now there is no explicit way to signal end of chunk, when http_multiple is set.
> ff_http_do_new_request() function implicitly signals end of chunk. But that could be too late for certain applications.
> Hence added a new function ff_http_signal_end_of_chunk() which could be used internally within libavformat.
> ---
>  libavformat/http.c | 17 ++++++++++++++---
>  libavformat/http.h |  9 +++++++++
>  2 files changed, 23 insertions(+), 3 deletions(-)
> 
> diff --git a/libavformat/http.c b/libavformat/http.c
> index cf86adc..d8224de 100644
> --- a/libavformat/http.c
> +++ b/libavformat/http.c
> @@ -307,9 +307,11 @@ int ff_http_do_new_request(URLContext *h, const char *uri)
>      AVDictionary *options = NULL;
>      int ret;
>  
> -    ret = http_shutdown(h, h->flags);
> -    if (ret < 0)
> -        return ret;
> +    if (!s->end_chunked_post) {
> +        ret = http_shutdown(h, h->flags);
> +        if (ret < 0)
> +            return ret;
> +    }
>  
>      s->end_chunked_post = 0;
>      s->chunkend      = 0;
> @@ -325,6 +327,15 @@ int ff_http_do_new_request(URLContext *h, const char *uri)
>      return ret;
>  }
>  
> +int ff_http_signal_end_of_chunk(URLContext *h) {
> +    HTTPContext *s = h->priv_data;
> +    int ret = 0;
> +    if (!s->end_chunked_post) {
> +        ret = http_shutdown(h, h->flags);
> +    }
> +    return ret;
> +}
> +
>  int ff_http_averror(int status_code, int default_averror)
>  {
>      switch (status_code) {
> diff --git a/libavformat/http.h b/libavformat/http.h
> index 7d02713..0eaeb48 100644
> --- a/libavformat/http.h
> +++ b/libavformat/http.h
> @@ -47,6 +47,15 @@ void ff_http_init_auth_state(URLContext *dest, const URLContext *src);
>   */
>  int ff_http_do_new_request(URLContext *h, const char *uri);
>  
> +/**
> + * Send a end of chunk signal(sends a string "0\r\n\r\n"), if applicable.
> + *
> + * @param h pointer to the resource
> + * @return a negative value if an error condition occurred, 0
> + * otherwise
> + */
> +int ff_http_signal_end_of_chunk(URLContext *h);
> +
>  int ff_http_averror(int status_code, int default_averror);
>  
>  #endif /* AVFORMAT_HTTP_H */

I'd really prefer if this HTTP stuff would be added in a much cleaner
way, such as making it part of the AVIO API, or at least the
URLContext API. (Why are there 2 APIs anyway...)



More information about the ffmpeg-devel mailing list