Cleanup: over-engineering pass

- merge /api/uptime + /api/version into /api/health and /api/stats
- collapse RTMP per-codec dispatch into a single CodecParser path
- dedupe STUN attribute walking (ufrag_pair / parse_xor_mapped_address)
- dedupe StreamCodec <-> str0m Codec mapping via StreamCodec::from_str0m
- dedupe bearer token extraction in WHIP handlers
- replace regex charset validation with stdlib checks
- flatten one-field wrappers (WebRtcProxyConfig, HttpServerConfig, ServerInfo)
- remove SessionCookie extractor (only fed debug logs)
- delete dead code: entity ActiveModel helpers, get_stream_session,
  WebrtcProxy::local_addr, _connected flag, commented-out blocks
- drop unused deps: futures, rand, regex, serde_json
This commit is contained in:
2026-08-21 11:39:02 +01:00
parent 0a039a97c4
commit 98dbb3d36d
11 changed files with 113 additions and 353 deletions
+8 -51
View File
@@ -14,7 +14,7 @@ use tokio::{
net::{TcpListener, TcpStream},
time::timeout,
};
use tracing::{debug, info, trace, warn};
use tracing::{debug, info, warn};
use uuid::Uuid;
use crate::{
@@ -134,7 +134,6 @@ impl Rtmp {
// ponytail: fixed 512; per-stream dynamic sizing if memory ever matters.
let (mut video_tx, video_rx) = broadcast::<Arc<VideoFrame>>(512);
let (mut audio_tx, audio_rx) = broadcast::<Arc<OpusAudioFrame>>(512);
// video_rx.cycle
video_tx.set_overflow(true);
audio_tx.set_overflow(true);
@@ -369,9 +368,6 @@ impl Rtmp {
}
current_stream_key_id = None;
}
// TODO: We can totally replace the broadcast with a
// circular_buff
// Arc<Vec<ArcSwap<Frame>>>
ServerSessionEvent::VideoDataReceived {
data, timestamp, ..
} => match Self::parse_video_codec(&data) {
@@ -385,52 +381,13 @@ impl Rtmp {
}
codec_stamped = true;
}
match codec {
StreamCodec::H264 => {
let p = parser.get_or_insert_with(|| {
Box::new(H264CodecParser::new())
});
if let Some(frame) = p.parse(&data, timestamp.value)
{
video_tx.broadcast(Arc::new(frame)).await.ok();
}
}
StreamCodec::H265 => {
let p = parser.get_or_insert_with(|| {
Box::new(H265CodecParser::new())
});
if let Some(frame) = p.parse(&data, timestamp.value)
{
video_tx.broadcast(Arc::new(frame)).await.ok();
}
}
StreamCodec::AV1 => {
let p = parser.get_or_insert_with(|| {
Box::new(Av1CodecParser::new())
});
let pkt_type = data[0] & 0x0F;
match p.parse(&data, timestamp.value) {
Some(frame) => {
trace!(
pkt_type,
is_keyframe = frame.is_keyframe,
ts = frame.timestamp_ms,
bytes = frame.data.len(),
"AV1 frame → broadcast"
);
video_tx
.broadcast(Arc::new(frame))
.await
.ok();
}
None => {
trace!(
pkt_type,
"AV1 packet produced no frame (seq header or unknown type)"
);
}
}
}
let p = parser.get_or_insert_with(|| match codec {
StreamCodec::H264 => Box::new(H264CodecParser::new()),
StreamCodec::H265 => Box::new(H265CodecParser::new()),
StreamCodec::AV1 => Box::new(Av1CodecParser::new()),
});
if let Some(frame) = p.parse(&data, timestamp.value) {
video_tx.broadcast(Arc::new(frame)).await.ok();
}
}
Err(_err) => {