[FFmpeg-soc] [PATCH] rtsp tunneling

Ronald S. Bultje rsbultje at gmail.com
Sun Jun 6 22:44:11 CEST 2010


Hi,

On Sat, Jun 5, 2010 at 6:05 PM, Josh Allmann <joshua.allmann at gmail.com> wrote:
> +    HTTPContext *s = h->priv_data;
> +    int len = strlen(headers);
> +
> +    if (len && strcmp("\r\n", headers+len-2))
> +        av_log(NULL, AV_LOG_ERROR, "No trailing CRLF found in HTTP header.\n");
> +
> +    snprintf(s->headers, sizeof(s->headers), "%s", headers);

av_strlcpy().

> +     /* set default headers if needed */
> +     if(!strstr(s->headers, "\r\nUser-Agent:"))
> +        len += snprintf(headers+len, sizeof(headers)-len, "User-Agent: %s\r\n", LIBAVFORMAT_IDENT);
> +    if(!strstr(s->headers, "\r\nAccept:"))

if (strncmp(.., "Accept:", 7) && !strstr(.., "\r\nAccept:"))
..

Same for the others. Otherwise you'll miss the first header. A macro
or utility function for this would of course be OK:

#define has_header(str, hdr, size) \
    (strncmp(str, hdr, size) && !strstr(.., "\r\n" hdr))

Something like that should compile.

> +    /* now add in custom headers */
> +    snprintf(headers+len, sizeof(headers)-len, "%s", s->headers);

Maybe use av_strlcat(). Also the "%s" is again not needed, and this
might need an if (s->headers[0]).

#3 is OK.

You have two #5 patches, which one is right?

Ronald


More information about the FFmpeg-soc mailing list