rtc_rtp/codec/opus/
mod.rs1#[cfg(test)]
2mod opus_test;
3
4use crate::packetizer::{Depacketizer, Payloader};
5use shared::error::{Error, Result};
6
7use bytes::Bytes;
8
9#[derive(Default, Debug, Copy, Clone)]
10pub struct OpusPayloader;
12
13impl Payloader for OpusPayloader {
14 fn payload(&mut self, mtu: usize, payload: &Bytes) -> Result<Vec<Bytes>> {
15 if payload.is_empty() || mtu == 0 {
16 return Ok(vec![]);
17 }
18
19 Ok(vec![payload.clone()])
20 }
21
22 fn clone_to(&self) -> Box<dyn Payloader> {
23 Box::new(*self)
24 }
25}
26
27#[derive(PartialEq, Eq, Debug, Default, Clone)]
29pub struct OpusPacket;
30
31impl Depacketizer for OpusPacket {
32 fn depacketize(&mut self, packet: &Bytes) -> Result<Bytes> {
33 if packet.is_empty() {
34 Err(Error::ErrShortPacket)
35 } else {
36 Ok(packet.clone())
37 }
38 }
39
40 fn is_partition_head(&self, _payload: &Bytes) -> bool {
41 true
42 }
43
44 fn is_partition_tail(&self, _marker: bool, _payload: &Bytes) -> bool {
45 true
46 }
47}