From 36eb5372e54b34721410b271dfb2e05da8ba5810 Mon Sep 17 00:00:00 2001 From: "Alfred E. Heggestad" Date: Thu, 22 Nov 2018 14:39:21 +0100 Subject: [PATCH] Rtmp dechunk fix (#169) --- src/rtmp/dechunk.c | 20 ++++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) diff --git a/src/rtmp/dechunk.c b/src/rtmp/dechunk.c index f48d1c0e..21fe548c 100644 --- a/src/rtmp/dechunk.c +++ b/src/rtmp/dechunk.c @@ -143,8 +143,6 @@ int rtmp_dechunker_receive(struct rtmp_dechunker *rd, struct mbuf *mb) return ENOENT; } - /* only types 0-2 can create a new buffer */ - switch (hdr.format) { case 0: @@ -192,8 +190,19 @@ int rtmp_dechunker_receive(struct rtmp_dechunker *rd, struct mbuf *mb) break; case 3: - if (!chunk->mb) - return EPROTO; + if (!chunk->mb) { + + chunk->mb = mbuf_alloc(chunk->hdr.length); + if (!chunk->mb) + return ENOMEM; + + if (chunk->hdr.format == 0) { + chunk->hdr.timestamp_delta = + chunk->hdr.timestamp; + } + + chunk->hdr.timestamp += chunk->hdr.timestamp_delta; + } left = mbuf_get_space(chunk->mb); @@ -209,6 +218,9 @@ int rtmp_dechunker_receive(struct rtmp_dechunker *rd, struct mbuf *mb) chunk->mb->pos += chunk_sz; chunk->mb->end += chunk_sz; break; + + default: + return EPROTO; } if (chunk->mb->pos >= chunk->mb->size) {