Skip to content

Commit 11d5fd2

Browse files
committed
[RTP] call writer.flush()? at the end of marshal
1 parent b01aabb commit 11d5fd2

File tree

3 files changed

+6
-9
lines changed

3 files changed

+6
-9
lines changed

rtp/src/header.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -391,6 +391,8 @@ impl Header {
391391
}
392392
}
393393

394+
writer.flush()?;
395+
394396
Ok(())
395397
}
396398
}

rtp/src/packet.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@ impl Packet {
5151
pub fn marshal<W: Write>(&self, writer: &mut W) -> Result<(), Error> {
5252
self.header.marshal(writer)?;
5353
writer.write_all(&self.payload)?;
54+
writer.flush()?;
5455

5556
Ok(())
5657
}

rtp/src/packet/packet_test.rs

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -288,7 +288,7 @@ fn test_rfc8285_one_byte_multiple_extensions_with_padding() {
288288
let ext3_expect: [u8; 4] = [0xCC, 0xCC, 0xCC, 0xCC];
289289
assert_eq!(ext3, ext3_expect);
290290

291-
let mut dst_buf: Vec<Vec<u8>> = vec![vec![0u8; 1000], vec![0xFF; 1000], vec![0xAA; 20]];
291+
let mut dst_buf: Vec<Vec<u8>> = vec![vec![0u8; 1000], vec![0xFF; 1000], vec![0xAA; 2]];
292292

293293
let raw_pkg_marshal: [u8; 33] = [
294294
0x90, 0xe0, 0x69, 0x8f, 0xd9, 0xc2, 0x93, 0xda, 0x1c, 0x64, 0x27, 0x82, 0xBE, 0xDE, 0x00,
@@ -323,15 +323,9 @@ fn test_rfc8285_one_byte_multiple_extensions_with_padding() {
323323
// NOTE: buf.as_mut_slice() won't increase buf size.
324324
// If buf size is not big enough, it will be silent and won't report error
325325
let mut writer = BufWriter::new(dst_buf[2].as_mut_slice());
326-
packet.marshal(&mut writer).expect("Error marshalling byte");
326+
let result = packet.marshal(&mut writer);
327+
assert!(result.is_err());
327328
}
328-
//println!("{:?}", &dst_buf[2]);
329-
assert_ne!(dst_buf[2].len(), packet.size());
330-
assert_eq!(
331-
&dst_buf[2][..],
332-
&raw_pkg_marshal[..dst_buf[2].len()],
333-
"Marshalled fields are not equal.",
334-
);
335329
}
336330

337331
//TODO: ADD more tests in https://github.com/pion/rtp/blob/master/packet_test.go

0 commit comments

Comments
 (0)