File
Blob: firmware/vendor/str0m/src/packet/null.rs
| 1 | use super::{CodecExtra, Depacketizer, PacketError, Packetizer}; |
| 2 | |
| 3 | #[derive(Debug)] |
| 4 | pub struct NullPacketizer; |
| 5 | |
| 6 | #[derive(Debug)] |
| 7 | pub struct NullDepacketizer; |
| 8 | |
| 9 | impl Packetizer for NullPacketizer { |
| 10 | fn packetize(&mut self, _mtu: usize, b: &[u8]) -> Result<Vec<Vec<u8>>, PacketError> { |
| 11 | Ok(vec![b.to_vec()]) |
| 12 | } |
| 13 | |
| 14 | fn is_marker(&mut self, _data: &[u8], _previous: Option<&[u8]>, _last: bool) -> bool { |
| 15 | unreachable!("rtp_mode doesn't use is_marker") |
| 16 | } |
| 17 | } |
| 18 | |
| 19 | impl Depacketizer for NullDepacketizer { |
| 20 | fn out_size_hint(&self, packets_size: usize) -> Option<usize> { |
| 21 | Some(packets_size) |
| 22 | } |
| 23 | |
| 24 | fn depacketize( |
| 25 | &mut self, |
| 26 | packet: &[u8], |
| 27 | out: &mut Vec<u8>, |
| 28 | _codec_extra: &mut CodecExtra, |
| 29 | ) -> Result<(), PacketError> { |
| 30 | out.extend_from_slice(packet); |
| 31 | Ok(()) |
| 32 | } |
| 33 | |
| 34 | fn is_partition_head(&self, _packet: &[u8]) -> bool { |
| 35 | // For rtp-mode since each packet is stand alone, it is both a partition head and tail. |
| 36 | true |
| 37 | } |
| 38 | |
| 39 | fn is_partition_tail(&self, _marker: bool, _packet: &[u8]) -> bool { |
| 40 | // For rtp-mode since each packet is stand alone, it is both a partition head and tail. |
| 41 | true |
| 42 | } |
| 43 | } |