diff options
author | Stephan Soller <stephan.soller@helionweb.de> | 2014-04-13 01:06:22 +0200 |
---|---|---|
committer | Martin Storsjö <martin@martin.st> | 2014-04-14 11:09:26 +0300 |
commit | 4d40e073dcdef335215c124d340ea156bc4bdf13 (patch) | |
tree | f20b3ace0d4fa6225d386c2ae0270e329a7d583e | |
parent | 6477139721f559b26eafd415e23e13ea2b0c27e1 (diff) | |
download | ffmpeg-4d40e073dcdef335215c124d340ea156bc4bdf13.tar.gz |
rtmpproto: Handle RTMP chunk size packets before the connect packet
In all other cases where ff_rtmp_packet_read is used, the packet returned
is passed to rtmp_parse_result more or less immediately. In this single
case, the content of the packet was required to be a connect packet.
Some clients, e.g. Open Broadcaster Software, send a chunk size packet
before the connect packet. If the first packet is a chunk size packet,
handle it and read another one, requiring this to be a connect packet
instead.
Signed-off-by: Martin Storsjö <martin@martin.st>
-rw-r--r-- | libavformat/rtmpproto.c | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/libavformat/rtmpproto.c b/libavformat/rtmpproto.c index bc6a4fef69..8d8aabc60a 100644 --- a/libavformat/rtmpproto.c +++ b/libavformat/rtmpproto.c @@ -150,6 +150,8 @@ static const uint8_t rtmp_server_key[] = { 0xE6, 0x36, 0xCF, 0xEB, 0x31, 0xAE }; +static int handle_chunk_size(URLContext *s, RTMPPacket *pkt); + static int add_tracked_method(RTMPContext *rt, const char *name, int id) { int err; @@ -411,6 +413,16 @@ 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) { + if ((ret = handle_chunk_size(s, &pkt)) < 0) + return ret; + 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)) { |