Bug 1754611 - Show codec stats in about:webrtc. r=ng,fluent-reviewers,flod

Differential Revision: https://phabricator.services.mozilla.com/D138376
This commit is contained in:
Jan-Ivar Bruaroey 2022-02-10 14:57:32 +00:00
parent 12b78e2102
commit 2f7d8322c5
3 changed files with 66 additions and 17 deletions

View File

@ -259,6 +259,7 @@ static void WriteRTCRtpStreamStats(
WriteParam(aMsg, aParam.mMediaType); WriteParam(aMsg, aParam.mMediaType);
WriteParam(aMsg, aParam.mKind); WriteParam(aMsg, aParam.mKind);
WriteParam(aMsg, aParam.mTransportId); WriteParam(aMsg, aParam.mTransportId);
WriteParam(aMsg, aParam.mCodecId);
WriteRTCStats(aMsg, aParam); WriteRTCStats(aMsg, aParam);
} }
@ -268,6 +269,7 @@ static bool ReadRTCRtpStreamStats(const Message* aMsg, PickleIterator* aIter,
ReadParam(aMsg, aIter, &(aResult->mMediaType)) && ReadParam(aMsg, aIter, &(aResult->mMediaType)) &&
ReadParam(aMsg, aIter, &(aResult->mKind)) && ReadParam(aMsg, aIter, &(aResult->mKind)) &&
ReadParam(aMsg, aIter, &(aResult->mTransportId)) && ReadParam(aMsg, aIter, &(aResult->mTransportId)) &&
ReadParam(aMsg, aIter, &(aResult->mCodecId)) &&
ReadRTCStats(aMsg, aIter, aResult); ReadRTCStats(aMsg, aIter, aResult);
} }

View File

@ -618,16 +618,18 @@ function renderRTPStats(report, history) {
for (const stat of rtpStats.filter(s => "remoteId" in s)) { for (const stat of rtpStats.filter(s => "remoteId" in s)) {
stat.remoteRtpStats = remoteRtpStatsMap[stat.remoteId]; stat.remoteRtpStats = remoteRtpStatsMap[stat.remoteId];
} }
const stats = [...rtpStats, ...remoteRtpStats]; for (const stat of rtpStats.filter(s => "codecId" in s)) {
stat.codecStat = report.codecStats.find(({ id }) => id == stat.codecId);
}
// Render stats set // Render stats set
return renderElements("div", { id: "rtp-stats: " + report.pcid }, [ return renderElements("div", { id: "rtp-stats: " + report.pcid }, [
renderElement("h4", {}, "about-webrtc-rtp-stats-heading"), renderElement("h4", {}, "about-webrtc-rtp-stats-heading"),
...stats.map(stat => { ...rtpStats.map(stat => {
const { id, remoteId, remoteRtpStats } = stat; const { ssrc, remoteId, remoteRtpStats } = stat;
const div = renderElements("div", {}, [ const div = renderElements("div", {}, [
renderText("h5", id), renderText("h5", `SSRC ${ssrc}`),
renderCoderStats(stat), renderCodecStats(stat),
renderTransportStats(stat, true, history), renderTransportStats(stat, true, history),
]); ]);
if (remoteId && remoteRtpStats) { if (remoteId && remoteRtpStats) {
@ -638,25 +640,53 @@ function renderRTPStats(report, history) {
]); ]);
} }
function renderCoderStats({ function renderCodecStats({
framesPerSecond, codecStat,
framesEncoded,
framesDecoded,
framesDropped, framesDropped,
discardedPackets, discardedPackets,
packetsReceived, packetsReceived,
}) { }) {
let elements = []; let elements = [];
if (framesPerSecond) { if (codecStat) {
elements.push( elements.push(
renderElement( renderText("span", `${codecStat.payloadType} ${codecStat.mimeType}`, {})
);
if (framesEncoded !== undefined || framesDecoded !== undefined) {
elements.push(
renderElement(
"span",
{ className: "stat-label" },
"about-webrtc-frames",
{
frames: framesEncoded || framesDecoded || 0,
}
)
);
}
if (codecStat.channels !== undefined) {
elements.push(
renderElement(
"span",
{ className: "stat-label" },
"about-webrtc-channels",
{
channels: codecStat.channels,
}
)
);
}
elements.push(
renderText(
"span", "span",
{ className: "stat-label" }, ` ${codecStat.clockRate} ${codecStat.sdpFmtpLine || ""}`,
"about-webrtc-current-framerate-label" {}
) )
); );
elements.push(renderText("span", ` ${framesPerSecond.toFixed(2)} fps`, {}));
} }
if (framesDropped) { if (framesDropped !== undefined) {
elements.push( elements.push(
renderElement( renderElement(
"span", "span",
@ -666,7 +696,7 @@ function renderCoderStats({
); );
elements.push(renderText("span", ` ${framesDropped}`, {})); elements.push(renderText("span", ` ${framesDropped}`, {}));
} }
if (discardedPackets) { if (discardedPackets !== undefined) {
elements.push( elements.push(
renderElement( renderElement(
"span", "span",
@ -677,7 +707,7 @@ function renderCoderStats({
elements.push(renderText("span", ` ${discardedPackets}`, {})); elements.push(renderText("span", ` ${discardedPackets}`, {}));
} }
if (elements.length) { if (elements.length) {
if (packetsReceived) { if (packetsReceived !== undefined) {
elements.unshift( elements.unshift(
renderElement("span", {}, "about-webrtc-decoder-label"), renderElement("span", {}, "about-webrtc-decoder-label"),
renderText("span", ": ") renderText("span", ": ")
@ -697,7 +727,6 @@ function renderTransportStats(
id, id,
timestamp, timestamp,
type, type,
ssrc,
packetsReceived, packetsReceived,
bytesReceived, bytesReceived,
packetsLost, packetsLost,
@ -741,7 +770,7 @@ function renderTransportStats(
} }
const time = new Date(timestamp).toTimeString(); const time = new Date(timestamp).toTimeString();
elements.push(renderText("span", `${time} ${type} SSRC: ${ssrc}`)); elements.push(renderText("span", `${time} ${type}`));
if (packetsReceived) { if (packetsReceived) {
elements.push( elements.push(

View File

@ -193,6 +193,24 @@ about-webrtc-aec-logging-off-state-msg = captured log files can be found in: { $
## ##
# This is the total number of frames encoded or decoded over an RTP stream.
# Variables:
# $frames (Number) - The number of frames encoded or decoded.
about-webrtc-frames =
{ $frames ->
[one] { $frames } frame
*[other] { $frames } frames
}
# This is the number of audio channels encoded or decoded over an RTP stream.
# Variables:
# $channels (Number) - The number of channels encoded or decoded.
about-webrtc-channels =
{ $channels ->
[one] { $channels } channel
*[other] { $channels } channels
}
# This is the total number of packets received on the PeerConnection. # This is the total number of packets received on the PeerConnection.
# Variables: # Variables:
# $packets (Number) - The number of packets received. # $packets (Number) - The number of packets received.