Skip to content

Commit

Permalink
Rtmp dechunk fix (#169)
Browse files Browse the repository at this point in the history
  • Loading branch information
alfredh authored and richaas committed Nov 22, 2018
1 parent 05a2359 commit 36eb537
Showing 1 changed file with 16 additions and 4 deletions.
20 changes: 16 additions & 4 deletions src/rtmp/dechunk.c
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down Expand Up @@ -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);

Expand All @@ -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) {
Expand Down

0 comments on commit 36eb537

Please sign in to comment.