Skip to content

Commit 1c16e21

Browse files
committed
fix: #367 mpeg4 es rtp deserialize au length check
1 parent 87d503b commit 1c16e21

File tree

2 files changed

+17
-5
lines changed

2 files changed

+17
-5
lines changed

librtp/payload/rtp-mpeg4-generic-pack.c

+5
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,11 @@ static int rtp_mpeg4_generic_pack_input(void* pack, const void* data, int bytes,
9393
// SDP fmtp: mode=AAC-hbr;sizeLength=13;indexLength=3;indexDeltaLength=3;
9494
header[0] = 0;
9595
header[1] = 16; // 16-bits AU headers-length
96+
// When the AU-size is associated with an AU fragment, the AU size indicates
97+
// the size of the entire AU and not the size of the fragment.
98+
// This can be exploited to determine whether a
99+
// packet contains an entire AU or a fragment, which is particularly
100+
// useful after losing a packet carrying the last fragment of an AU.
96101
header[2] = (uint8_t)(size >> 5);
97102
header[3] = (uint8_t)(size & 0x1f) << 3;
98103

librtp/payload/rtp-mpeg4-generic-unpack.c

+12-5
Original file line numberDiff line numberDiff line change
@@ -57,11 +57,12 @@ static int rtp_decode_mpeg4_generic(void* p, const void* packet, int bytes)
5757
size = size >> 3; // bit -> byte
5858
if (pau + size > pend)
5959
{
60-
assert(0);
61-
//helper->size = 0;
62-
helper->lost = 1;
63-
//helper->flags |= RTP_PAYLOAD_FLAG_PACKET_LOST;
64-
return -1; // invalid packet
60+
// fragment ?
61+
assert(1 == au_numbers);
62+
pkt.payload = pau;
63+
pkt.payloadlen = size;
64+
rtp_payload_write(helper, &pkt);
65+
return 1;
6566
}
6667

6768
// TODO: add ADTS/ASC ???
@@ -74,6 +75,12 @@ static int rtp_decode_mpeg4_generic(void* p, const void* packet, int bytes)
7475

7576
if (au_numbers > 1 || pkt.rtp.m)
7677
{
78+
if (helper->size != size)
79+
{
80+
//helper->size = 0;
81+
helper->lost = 1;
82+
//helper->flags |= RTP_PAYLOAD_FLAG_PACKET_LOST;
83+
}
7784
rtp_payload_onframe(helper);
7885
}
7986
}

0 commit comments

Comments
 (0)