[FFmpeg-soc] [PATCH] rtsp tunneling

Josh Allmann joshua.allmann at gmail.com
Mon Jun 7 04:10:00 CEST 2010


On 6 June 2010 13:44, Ronald S. Bultje <rsbultje at gmail.com> wrote:
> 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().

Fixed. I also changed all of my other calls to use av_str* equivalents.

>
>> +     /* 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.
>

Good catch. Used av_stristart(...) || av_stristr(...) in an inlined function.

>> +    /* 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]).
>

Changed to av_strcpy since we know where we're starting from (avoids a
call to strlen). Copying a null string should yield a null string
without any problems.

> #3 is OK.
>

Do you think a more generic ff_http_ignore_header function would be
better at avoiding API sprawl? We can special-case "Transfer-Encoding"
in there and set the flag then.

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

Whoops, I attached #5 instead of #1.

> Ronald
> _______________________________________________
> FFmpeg-soc mailing list
> FFmpeg-soc at mplayerhq.hu
> https://lists.mplayerhq.hu/mailman/listinfo/ffmpeg-soc
>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: 0001-Modified-behavior-of-http_open-to-implicitly-delay-c.patch
Type: text/x-patch
Size: 2602 bytes
Desc: not available
URL: <http://lists.mplayerhq.hu/pipermail/ffmpeg-soc/attachments/20100606/02bcd634/attachment.bin>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: 0002-Added-in-capability-to-write-custom-HTTP-headers.patch
Type: text/x-patch
Size: 5899 bytes
Desc: not available
URL: <http://lists.mplayerhq.hu/pipermail/ffmpeg-soc/attachments/20100606/02bcd634/attachment-0001.bin>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: 0005-Added-in-RTSP-tunneling-over-HTTP.patch
Type: text/x-patch
Size: 6857 bytes
Desc: not available
URL: <http://lists.mplayerhq.hu/pipermail/ffmpeg-soc/attachments/20100606/02bcd634/attachment-0002.bin>


More information about the FFmpeg-soc mailing list