padding included in payload
scottlamb opened this issue · 7 comments
impl Marshaller for Packet
doesn't consider padding:
unmarshal
shouldn't include the padding bytes in the newPacket
'spayload
marshal_size
andmarshal_to
then also need to change to add in padding bytes
Lines 33 to 52 in 54d1579
I'll be taking this up @scottlamb @rainliu. This might be a breaking change, which is a fun thing :))
@scottlamb mind sharing a test that fails due to this issue?
Here's an H.264 SPS packet I got from a Hikvision camera:
#[test]
fn test_padding() -> Result<(), Error> {
let raw_pkt = Bytes::from_static(&[
0xa0, 0x60, 0x19, 0x58, 0x63, 0xff, 0x7d, 0x7c, 0x4b, 0x98, 0xd4, 0x0a, 0x67, 0x4d, 0x00,
0x29, 0x9a, 0x64, 0x03, 0xc0, 0x11, 0x3f, 0x2c, 0xd4, 0x04, 0x04, 0x05, 0x00, 0x00, 0x03,
0x03, 0xe8, 0x00, 0x00, 0xea, 0x60, 0x04, 0x00, 0x00, 0x03,
]);
let packet = Packet::unmarshal(&raw_pkt)?;
assert_eq!(packet.payload, &raw_pkt[12..12+25]);
Ok(())
}
The trailing 0x03 indicates the length of the padding (including itself), so the final three bytes should be omitted from payload.
@scottlamb @rainliu I really don't think this issue has been fixed completely so I'll be reopening, do indicate if its been solved.
do indicate if its been solved
I don't know, sorry. I switched to the rtp-rs
crate after hitting this. rtp-rs
already had correct padding handling and looked more efficient (less reference-counting due to Bytes
cloning, no Vec
allocations) although I didn't actually benchmark.
🥲 too bad. Should work on a fix and also improve performance this weekend. Do hope you get to using this library again when it's fixed!.