[FFmpeg-devel] [PATCH] Handle initial RTMP chunk size packet

Stephan Soller stephan.soller at helionweb.de
Sun Apr 13 13:24:00 CEST 2014


On 04/13/2014 12:04 PM, Nicolas George wrote:
> Le quartidi 24 germinal, an CCXXII, Stephan Soller a écrit :
>> >From ff1c93e55fff3e162e2599c1f61ca683f504439f Mon Sep 17 00:00:00 2001
>> From: Stephan Soller <stephan.soller at helionweb.de>
>> Date: Sun, 13 Apr 2014 01:06:22 +0200
>> Subject: [PATCH] avformat/rtmpproto: Added handling of an initial RTMP chunk
>>   size packet.
>>
>> Fixes ticket #2911.
>> ---
>>   libavformat/rtmpproto.c |   11 +++++++++++
>>   1 file changed, 11 insertions(+)
>>
>> diff --git a/libavformat/rtmpproto.c b/libavformat/rtmpproto.c
>> index 9a80c2f..9c62164 100644
>> --- a/libavformat/rtmpproto.c
>> +++ b/libavformat/rtmpproto.c
>> @@ -408,6 +408,17 @@ static int read_connect(URLContext *s, RTMPContext *rt)
>>       if ((ret = ff_rtmp_packet_read(rt->stream, &pkt, rt->in_chunk_size,
>>                                      &rt->prev_pkt[0], &rt->nb_prev_pkt[0])) < 0)
>>           return ret;
>> +
>> +    if (pkt.type == RTMP_PT_CHUNK_SIZE) {
>> +        cp = pkt.data;
>
>> +        rt->in_chunk_size = bytestream_get_be32(&cp);
>
> Should you not validate this value? The handle_chunk_size() function does at
> least a check for negative values.
>
>> +
>> +        ff_rtmp_packet_destroy(&pkt);
>> +        if ((ret = ff_rtmp_packet_read(rt->stream, &pkt, rt->in_chunk_size,
>> +                                       &rt->prev_pkt[0], &rt->nb_prev_pkt[0])) < 0)
>> +            return ret;
>> +    }
>> +
>>       cp = pkt.data;
>>       bytestream2_init(&gbc, cp, pkt.size);
>>       if (ff_amf_read_string(&gbc, command, sizeof(command), &stringlen)) {
>
> Regards,

Good point. I didn't notice the handle_chunk_size() function before. 
Changed the code to use that function and it works quite well. However 
the handle_chunk_size() function is declared further down in the C file 
so I either need to add a forward declaration or move the read_connect() 
function downwards. Which of the two would be the preferred way?

Happy programming
Stephan


More information about the ffmpeg-devel mailing list