From 719738ddb05399ad879ae98f0d6f3a3a3a424176 Mon Sep 17 00:00:00 2001 From: Ramyak Mehra Date: Sun, 13 Oct 2024 17:24:57 +0530 Subject: [PATCH] feat: add marker bit when packetizing opus. incase of silence opus rtp payload sets the marker bit after a talking spurt. usually the data in silence pacekts are empty, just use 1-2 bytes for header. fixes #125 --- src/packet/opus.rs | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/packet/opus.rs b/src/packet/opus.rs index 365da501..29a37c94 100644 --- a/src/packet/opus.rs +++ b/src/packet/opus.rs @@ -23,8 +23,12 @@ impl Packetizer for OpusPacketizer { } fn is_marker(&mut self, data: &[u8], previous: Option<&[u8]>, last: bool) -> bool { - // TODO: dtx - false + match previous { + // silence packets are usually empty with 1-2 bytes header + Some(previous) => previous.len() < 3 && data.len() >= 3, + // first packet can always be considered as start of talk spurt + None => true, + } } }