MCPcopy Create free account
hub / github.com/NativeScript/SimDeck / collectDirectWebRtcStats

Function collectDirectWebRtcStats

scripts/e2e-webrtc-reliability.mjs:970–1008  ·  view source on GitHub ↗
(cdp)

Source from the content-addressed store, hash-verified

968}
969
970async function collectDirectWebRtcStats(cdp) {
971 return evaluate(
972 cdp,
973 `
974 (async () => {
975 const totals = {
976 framesDecoded: 0,
977 framesDropped: 0,
978 jitter: 0,
979 packetsLost: 0,
980 packetsReceived: 0,
981 timestampMs: Date.now(),
982 totalVideoFrames: 0,
983 videoHeight: 0,
984 videoWidth: 0,
985 };
986 for (const pc of window.__simdeckPeerConnections || []) {
987 const reports = await pc.getStats();
988 for (const report of reports.values()) {
989 if (report.type === "inbound-rtp" && (report.kind === "video" || report.mediaType === "video")) {
990 totals.framesDecoded += report.framesDecoded || 0;
991 totals.framesDropped += report.framesDropped || 0;
992 totals.jitter = Math.max(totals.jitter, report.jitter || 0);
993 totals.packetsLost += report.packetsLost || 0;
994 totals.packetsReceived += report.packetsReceived || 0;
995 }
996 }
997 }
998 for (const video of document.querySelectorAll("video.stream-video")) {
999 const quality = video.getVideoPlaybackQuality?.();
1000 totals.totalVideoFrames += quality?.totalVideoFrames || 0;
1001 totals.videoWidth = Math.max(totals.videoWidth, video.videoWidth || 0);
1002 totals.videoHeight = Math.max(totals.videoHeight, video.videoHeight || 0);
1003 }
1004 return totals;
1005 })()
1006 `,
1007 );
1008}
1009
1010async function waitForDecodedFrameAfterInteraction(
1011 cdp,

Calls 1

evaluateFunction · 0.85

Tested by

no test coverage detected