feat(diagnostics): record video admission at each peer output
This commit is contained in:
1 parent
551e2dd762
commit
6ef82fc558
5 files changed
+87
No files matched your search
@@ -92,3 +92,18 @@ control from simulated Core readiness and the older unaligned logs.
|
||||
Beta.75's additional pixel readback also matched its synthetic source's
|
||||
background and moving marker. The acceptance record and private package notes
|
||||
were updated without changing the frozen binaries.
|
||||
|
||||
## Native frame evidence
|
||||
|
||||
The implementing line now records complete video access units accepted by each
|
||||
Native peer-output queue, per output instance and RID. Samples join the existing
|
||||
pair alias, use the SDK's normal 500 ms statistics cadence, and mark retirement.
|
||||
A new output starts a new count when the negotiated MID is reused. These facts
|
||||
stay in the local diagnostic ZIP; no room protocol, UI or adaptation policy changes.
|
||||
|
||||
The production-writer regression covers blocked admission, retry, separate RIDs,
|
||||
retirement and MID reuse. With probes disabled, it opens an actual ZIP and checks
|
||||
both live and retired samples. The complete no-default-features Native library
|
||||
suite passed: 250 tests, with three ignored. Capture-wide encoding totals still
|
||||
cover multiple outputs; this counter marks queue admission, not network sending,
|
||||
decoding or presentation. The three measured boundaries remain distinct.
|
||||
@@ -167,6 +167,19 @@ pub(crate) fn rtc_pair(pair: Uuid, event: RtcPairEvent) {
|
||||
RECORDER.rtc_pair(pair, event);
|
||||
}
|
||||
|
||||
pub(crate) fn video_admission(pair: Uuid, output: Uuid, rid: &str, count: u64, elapsed: std::time::Duration, retired: bool) {
|
||||
let mut state = RECORDER.0.lock().unwrap();
|
||||
if let Some(buffer) = state.buffer.as_mut() {
|
||||
buffer.push(
|
||||
&Record::builder()
|
||||
.level(log::Level::Info)
|
||||
.args(format_args!("Video output: pair={} output={output} rid={rid} elapsed_ms={} admitted_video_aus={count} retired={retired}", pair_alias(pair), elapsed.as_millis()))
|
||||
.build(),
|
||||
"piik.rtc",
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
/// Record one terminal App control or page lifetime event.
|
||||
pub fn app_retired(owner: Uuid, page: Option<Uuid>, reason: &'static str) {
|
||||
let mut state = RECORDER.0.lock().unwrap();
|
||||
|
||||
@@ -74,6 +74,7 @@ pub async fn run() -> Result<serde_json::Value> {
|
||||
.context("unready sender admitted media")?;
|
||||
}
|
||||
tx.call(move |e| {
|
||||
ensure!(e.outputs[&id].admitted_video_aus.is_empty());
|
||||
let mid = e.outputs[&id].mid.unwrap();
|
||||
ensure!(
|
||||
!e.rtc.is_connected(),
|
||||
@@ -158,6 +159,7 @@ pub async fn run() -> Result<serde_json::Value> {
|
||||
Ok::<_, anyhow::Error>(())
|
||||
})
|
||||
.await??;
|
||||
crate::diagnostics::install()?;
|
||||
let output_id = output.id;
|
||||
let h_ssrc = tx
|
||||
.call(move |e| {
|
||||
@@ -243,6 +245,8 @@ pub async fn run() -> Result<serde_json::Value> {
|
||||
let withheld = tx.offer().await?.context("missing withheld signaling offer")?;
|
||||
let (retired_ssrcs, queued_before, rtx_enabled) = tx
|
||||
.call(move |e| {
|
||||
ensure!(e.outputs[&output_id].admitted_video_aus.get("q") == Some(&1));
|
||||
ensure!(e.outputs[&output_id].admitted_video_aus.get("h") == Some(&1));
|
||||
ensure!(e.pending.is_some(), "offer was not withheld");
|
||||
let mid = e.outputs[&output_id].mid.unwrap();
|
||||
let mut direct = e.rtc.direct_api();
|
||||
@@ -265,12 +269,14 @@ pub async fn run() -> Result<serde_json::Value> {
|
||||
"gate did not own an admitted queue/RTX sender before retirement"
|
||||
);
|
||||
tokio::time::timeout(Duration::from_secs(2), output.close(&tx)).await?;
|
||||
ensure!(tx.write_au(output_id, "q".into(), format(), vec![packet()], Instant::now()).await.is_err());
|
||||
let retired = retired_ssrcs.clone();
|
||||
tx.call(move |e| {
|
||||
ensure!(
|
||||
e.pending.is_some() && e.outputs[&output_id].retired,
|
||||
"retirement depended on SDP answer"
|
||||
);
|
||||
ensure!(e.outputs[&output_id].admitted_video_aus.get("q") == Some(&1));
|
||||
let sibling_mid = e.outputs[&sibling_id].mid.unwrap();
|
||||
let mut direct = e.rtc.direct_api();
|
||||
ensure!(
|
||||
@@ -325,6 +331,34 @@ pub async fn run() -> Result<serde_json::Value> {
|
||||
.await?;
|
||||
send(&tx, sibling_id, &sibling_writable, 93_000).await?;
|
||||
receive(&survivor, 93_000).await?;
|
||||
let (mid, rids) = tx.call(move |e| {
|
||||
let old = &e.outputs[&output_id];
|
||||
Ok((old.mid, old.rids.clone()))
|
||||
}).await?;
|
||||
let replacement = Uuid::new_v4();
|
||||
tx.add_output(replacement, format(), MediaKind::Video, "queue-output".into(), rids).await?;
|
||||
tx.call(move |e| {
|
||||
let new = &e.outputs[&replacement];
|
||||
ensure!(mid.is_some() && new.mid == mid && new.admitted_video_aus.is_empty());
|
||||
Ok(())
|
||||
}).await?;
|
||||
let alias = crate::diagnostics::pair_alias(pair);
|
||||
tokio::time::timeout(Duration::from_secs(5), async {
|
||||
loop {
|
||||
let mut bytes = Vec::new();
|
||||
crate::diagnostics::snapshot().write_archive(&mut bytes, "test", "revision", "fixture", None)?;
|
||||
let mut archive = zip::ZipArchive::new(std::io::Cursor::new(bytes))?;
|
||||
let mut records = String::new();
|
||||
std::io::Read::read_to_string(&mut archive.by_name("events.ndjson")?, &mut records)?;
|
||||
let retired = format!("pair={alias} output={output_id} rid=q ");
|
||||
ensure!(records.lines().any(|line| line.contains(&retired) && line.contains("admitted_video_aus=1 retired=true")));
|
||||
let live = format!("pair={alias} output={sibling_id} rid= ");
|
||||
if records.lines().any(|line| line.contains(&live) && line.contains("admitted_video_aus=2 retired=false")) {
|
||||
return Ok::<_, anyhow::Error>(());
|
||||
}
|
||||
tokio::time::sleep(Duration::from_millis(100)).await;
|
||||
}
|
||||
}).await??;
|
||||
tx.close().await?;
|
||||
rx.close().await?;
|
||||
left.close().await;
|
||||
|
||||
@@ -317,6 +317,7 @@ struct Outgoing {
|
||||
reusable: bool,
|
||||
feedback: mpsc::Sender<String>,
|
||||
seq: HashMap<String, SeqNo>,
|
||||
admitted_video_aus: HashMap<String, u64>,
|
||||
writable: Arc<Notify>,
|
||||
waiting: HashSet<String>,
|
||||
}
|
||||
@@ -1593,6 +1594,7 @@ impl Transport {
|
||||
reusable: false,
|
||||
feedback: tx,
|
||||
seq: HashMap::new(),
|
||||
admitted_video_aus: HashMap::new(),
|
||||
writable: writable.clone(),
|
||||
waiting: HashSet::new(),
|
||||
},
|
||||
@@ -1640,6 +1642,12 @@ impl Transport {
|
||||
if e.outputs.get(&id).is_some_and(|out| out.mid.is_none()) {
|
||||
e.outputs.remove(&id);
|
||||
} else if let Some(out) = e.outputs.get_mut(&id) {
|
||||
if !out.retired && out.kind == MediaKind::Video {
|
||||
for rid in &out.rids {
|
||||
let count = out.admitted_video_aus.get(rid).copied().unwrap_or(0);
|
||||
crate::diagnostics::video_admission(e.handle.pair, id, rid, count, out.since.elapsed(), true);
|
||||
}
|
||||
}
|
||||
out.retired = true;
|
||||
if let Some(mid) = out.mid {
|
||||
let mut direct = e.rtc.direct_api();
|
||||
@@ -1724,6 +1732,7 @@ impl Transport {
|
||||
out.waiting.insert(rid);
|
||||
return Ok(Some(packets));
|
||||
}
|
||||
let count_video = out.kind == MediaKind::Video && !packets.is_empty();
|
||||
for packet in packets {
|
||||
let seq = out
|
||||
.seq
|
||||
@@ -1743,6 +1752,9 @@ impl Transport {
|
||||
.nackable(out.kind == MediaKind::Video),
|
||||
);
|
||||
}
|
||||
if count_video {
|
||||
*out.admitted_video_aus.entry(rid).or_default() += 1;
|
||||
}
|
||||
Ok(None)
|
||||
})
|
||||
.await
|
||||
@@ -2389,6 +2401,13 @@ impl Engine {
|
||||
}
|
||||
RtcEvent::MediaEgressStats(stats) => {
|
||||
if self.active_egress(&stats) {
|
||||
if let Some((id, out)) = self.outputs.iter().find(|(_, out)| {
|
||||
!out.retired && out.mid == Some(stats.mid) && out.kind == MediaKind::Video
|
||||
}) {
|
||||
let rid = stats.rid.map(|rid| rid.to_string()).unwrap_or_default();
|
||||
let count = out.admitted_video_aus.get(&rid).copied().unwrap_or(0);
|
||||
crate::diagnostics::video_admission(self.handle.pair, *id, &rid, count, out.since.elapsed(), false);
|
||||
}
|
||||
self.egress_stats.insert((stats.mid, stats.rid), stats);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -566,6 +566,12 @@ count covers all encoder outputs attached to that source. Counting starts with
|
||||
the capture. When the source ends, its final counters appear under the same
|
||||
number in `events.ndjson`.
|
||||
|
||||
Video-output samples in `events.ndjson` count complete access units accepted
|
||||
by the RTC sender queue for each output and RID. The pair alias joins the
|
||||
connection record; a new output starts a fresh count even when it reuses a MID.
|
||||
The final sample marks retirement. Network transmission, decoding and
|
||||
presentation use their respective sender and Viewer measurements.
|
||||
|
||||
Pair preparation records its existing stages and terminal outcome. A single
|
||||
check summary also records opened and primed pool sockets, sent checks and
|
||||
search targets, Ready sent and received, and a matched authenticated reply.
|
||||
|
||||
Reference in new issue
Block a user