Skip to content

Commit

Permalink
Move debug logging into RtpPacket event
Browse files Browse the repository at this point in the history
  • Loading branch information
tazz4843 committed Oct 8, 2024
1 parent 272026d commit 551899f
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 34 deletions.
5 changes: 5 additions & 0 deletions scripty_audio_handler/src/audio_handler.rs
Original file line number Diff line number Diff line change
Expand Up @@ -276,6 +276,11 @@ impl EventHandler for AudioHandler {
self.seen_users.clone(),
self.ephemeral,
)),
EventContext::RtpPacket(rtp_data) => {
rtp_packet(rtp_data, self.guild_id);
return None;
}

_ => return None,
};
None
Expand Down
2 changes: 2 additions & 0 deletions scripty_audio_handler/src/events/mod.rs
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
mod client_disconnect;
mod driver_connect;
mod driver_disconnect;
mod rtp_packet;
mod speaking_state_update;
mod voice_tick;

pub use client_disconnect::client_disconnect;
pub use driver_connect::driver_connect;
pub use driver_disconnect::driver_disconnect;
pub use rtp_packet::rtp_packet;
pub use speaking_state_update::speaking_state_update;
pub use voice_tick::{voice_tick, VoiceTickContext};
17 changes: 17 additions & 0 deletions scripty_audio_handler/src/events/rtp_packet.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
use serenity::model::id::GuildId;
use songbird::events::context_data::RtpData;

pub fn rtp_packet(rtp_packet: &RtpData, guild_id: GuildId) {
let rtp_packet = rtp_packet.rtp();
let ssrc = rtp_packet.get_ssrc();
let timestamp = rtp_packet.get_timestamp().0;
let sequence = rtp_packet.get_sequence().0;

trace!(
%guild_id,
%ssrc,
"debug_log_audio_data: RTP packet data: sequence {}, timestamp {}",
sequence,
timestamp,
);
}
34 changes: 0 additions & 34 deletions scripty_audio_handler/src/events/voice_tick.rs
Original file line number Diff line number Diff line change
Expand Up @@ -66,8 +66,6 @@ pub async fn voice_tick(
kiai_client,
}: VoiceTickContext,
) {
debug_log_audio_data(&voice_data, guild_id);

let metrics = scripty_metrics::get_metrics();
let tick_start_time = Instant::now();

Expand Down Expand Up @@ -117,38 +115,6 @@ pub async fn voice_tick(
metrics.audio_tick_time.observe(total_tick_time);
}

fn debug_log_audio_data(VoiceTick { speaking, .. }: &VoiceTick, guild_id: GuildId) {
for (
ssrc,
VoiceData {
packet,
decoded_voice,
..
},
) in speaking.iter()
{
let voice_is_empty = if let Some(decoded_voice) = decoded_voice {
decoded_voice.iter().all(|x| *x == 0)
} else {
warn!(%guild_id, %ssrc, "debug_log_audio_data: packet for this voice tick lost");
true
};
if let Some(packet) = packet {
let rtp = packet.rtp();
trace!(
%guild_id,
%ssrc,
"debug_log_audio_data: RTP packet data: sequence {}, timestamp {}, voice_is_empty {}",
rtp.get_sequence().0,
rtp.get_timestamp().0,
voice_is_empty
);
} else {
trace!(%guild_id, %ssrc, "debug_log_audio_data: no RTP packet for this tick: voice_is_empty {}", voice_is_empty);
}
}
}

struct SilentSpeakersContext {
ssrc_state: Arc<SsrcMaps>,
last_tick_speakers: DashSet<u32, RandomState>,
Expand Down

0 comments on commit 551899f

Please sign in to comment.