Compare commits
2
Commits
266e149233
...
9606187861
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
9606187861 | ||
|
|
b423d21b23 |
@@ -62,7 +62,7 @@ interface WatchState {
|
|||||||
bytesWritten: number;
|
bytesWritten: number;
|
||||||
lastPacketAt: number;
|
lastPacketAt: number;
|
||||||
startedAt: number;
|
startedAt: number;
|
||||||
_diagCount?: number;
|
_diag?: { video: number; maxLen: number; pts: Set<number> };
|
||||||
_diagNext?: number;
|
_diagNext?: number;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -455,32 +455,49 @@ function handleUdpMessage(
|
|||||||
const conn = net.state.connectionData ?? {};
|
const conn = net.state.connectionData ?? {};
|
||||||
// Diagnose: is a DAVE session actually attached, and is it ready to decrypt?
|
// Diagnose: is a DAVE session actually attached, and is it ready to decrypt?
|
||||||
const dave = net.state.dave;
|
const dave = net.state.dave;
|
||||||
const daveReady = Boolean(
|
const s = (dave as { session?: { ready?: boolean } } | undefined)?.session;
|
||||||
dave &&
|
const daveReady = Boolean(s?.ready);
|
||||||
(dave as { session?: { ready?: boolean } }).session &&
|
|
||||||
(dave as unknown as { session?: { ready?: boolean } }).session?.ready,
|
|
||||||
);
|
|
||||||
const haveKey = Boolean(
|
const haveKey = Boolean(
|
||||||
conn.encryptionMode && conn.nonceBuffer && conn.secretKey,
|
conn.encryptionMode && conn.nonceBuffer && conn.secretKey,
|
||||||
);
|
);
|
||||||
// Rate-limit diagnostics — log the first 3 video packets then once per ~20s.
|
// Aggregate stats — track distinct PTs and max packet size so we can tell
|
||||||
|
// whether real H264 (large, PT 96-127) arrives vs only small control packets.
|
||||||
const now = Date.now();
|
const now = Date.now();
|
||||||
const diagCount = watch._diagCount ?? 0;
|
const stat =
|
||||||
watch._diagCount = diagCount + 1;
|
watch._diag ??
|
||||||
|
({ video: 0, maxLen: 0, pts: new Set<number>() } as {
|
||||||
|
video: number;
|
||||||
|
maxLen: number;
|
||||||
|
pts: Set<number>;
|
||||||
|
});
|
||||||
|
stat.video += 1;
|
||||||
|
if (msg.length > stat.maxLen) stat.maxLen = msg.length;
|
||||||
|
stat.pts.add(payloadType);
|
||||||
|
watch._diag = stat;
|
||||||
|
const diagCount = stat.video;
|
||||||
const dueAt = watch._diagNext ?? 0;
|
const dueAt = watch._diagNext ?? 0;
|
||||||
if (diagCount < 3 || now >= dueAt) {
|
if (diagCount === 1 || now >= dueAt) {
|
||||||
watch._diagNext = now + 20_000;
|
watch._diagNext = now + 20_000;
|
||||||
|
const pts = [...stat.pts].join(",");
|
||||||
|
const ssrc = msg.readUInt32BE(8);
|
||||||
|
const first = msg[0];
|
||||||
|
const flags = msg[1];
|
||||||
logger.info(
|
logger.info(
|
||||||
{
|
{
|
||||||
userId: uid,
|
userId: uid,
|
||||||
payloadType,
|
video: stat.video,
|
||||||
len: msg.length,
|
maxLen: stat.maxLen,
|
||||||
|
pts,
|
||||||
haveKey,
|
haveKey,
|
||||||
daveAttached: !!dave?.session,
|
daveAttached: !!dave?.session,
|
||||||
daveReady,
|
daveReady,
|
||||||
watchesSize: watches.size,
|
ssrc,
|
||||||
|
firstByte: first,
|
||||||
|
flagsByte: flags,
|
||||||
|
seq: msg.readUInt16BE(2),
|
||||||
|
hex: msg.subarray(0, 32).toString("hex"),
|
||||||
},
|
},
|
||||||
`VIDEO-PKT diag video=${diagCount} haveKey=${haveKey} dave=${!!dave?.session} ready=${daveReady}`,
|
`VIDEO-PKT diag video=${stat.video} maxLen=${stat.maxLen} pts=[${pts}] haveKey=${haveKey} dave=${!!dave?.session} ready=${daveReady} ssrc=${ssrc} first=${first} flags=${flags} hex=${msg.subarray(0, 32).toString("hex")}`,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
const decrypted = decryptVideoPacket(
|
const decrypted = decryptVideoPacket(
|
||||||
@@ -492,7 +509,10 @@ function handleUdpMessage(
|
|||||||
net.state.dave,
|
net.state.dave,
|
||||||
uid,
|
uid,
|
||||||
);
|
);
|
||||||
if (!decrypted) return;
|
if (!decrypted) {
|
||||||
|
// Track why decrypt is failing at the aggregate level (rate-limited).
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
if (!watch.out) {
|
if (!watch.out) {
|
||||||
// First successful decrypt — open output file.
|
// First successful decrypt — open output file.
|
||||||
|
|||||||
Reference in new issue
Block a user