Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Generate appendix with flatten hierarchy of stats #580

Merged
merged 1 commit into from
Sep 4, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions webrtc-stats.css
Original file line number Diff line number Diff line change
Expand Up @@ -405,3 +405,10 @@ table.exceptions table {
border-collapse: collapse;
width: 100%;
}
#summary table {
border-spacing: 0;
border-collapse: collapse;
}
#summary table td, #summary table th {
border: thin solid black;
}
90 changes: 90 additions & 0 deletions webrtc-stats.html
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@
// keep this comment
//]]>
</script>
<!-- TODO Redundant since webidl2.js is already loaded in ReSpec, but not sure how to access it -->
<script src="https://w3c.github.io/webidl2.js/dist/webidl2.js"></script>
</head>
<body>
<section id="abstract">
Expand Down Expand Up @@ -5330,6 +5332,94 @@ <h3>
{{RTCRtpContributingSourceStats}} (the whole dictionary).
</li>
</ul>
</section>
<section class="appendix" id=summary>
<h2>Summary of WebRTC stats fields per type</h2>
<table>
<thead>
<tr>
<th>{{RTCStatsType}}</th><th>Dictionary</th><th>Fields</th>
</tr>
</thead>
<tbody>
<tr>
<th class="row">{{RTCStatsType/"codec"}}</th>
<td>{{RTCCodecStats}}</td>
</tr>
<tr>
<th class="row">{{RTCStatsType/"inbound-rtp"}}</th>
<td>{{RTCInboundRtpStreamStats}}</td>
</tr>
<tr>
<th class="row">{{RTCStatsType/"outbound-rtp"}}</th>
<td>{{RTCOutboundRtpStreamStats}}</td>
</tr>
<tr>
<th class="row">{{RTCStatsType/"remote-inbound-rtp"}}</th>
<td>{{RTCRemoteInboundRtpStreamStats}}</td>
</tr>
<tr>
<th class="row">{{RTCStatsType/"remote-outbound-rtp"}}</th>
<td>{{RTCRemoteOutboundRtpStreamStats}}</td>
</tr>
<tr>
<th class="row">{{RTCStatsType/"media-source"}}</th>
<td>{{RTCAudioSourceStats}} {{RTCVideoSourceStats}}</td>
</tr>
<tr>
<th class="row">{{RTCStatsType/"csrc"}}</th>
<td>{{RTCRtpContributingSourceStats}}</td>
</tr>
<tr>
<th class="row">{{RTCStatsType/"peer-connection"}}</th>
<td>{{RTCPeerConnectionStats}}</td>
</tr>
<tr>
<th class="row">{{RTCStatsType/"data-channel"}}</th>
<td>{{RTCDataChannelStats}}</td>
</tr>
<tr>
<th class="row">{{RTCStatsType/"transceiver"}}</th>
<td>{{RTCRtpTransceiverStats}}</td>
</tr>
<tr>
<th class="row">{{RTCStatsType/"sender"}}</th>
<td>{{RTCAudioSenderStats}} {{RTCVideoSenderStats}}</td>
</tr>
<tr>
<th class="row">{{RTCStatsType/"receiver"}}</th>
<td>{{RTCAudioReceiverStats}} {{RTCVideoReceiverStats}}</td>
</tr>
<tr>
<th class="row">{{RTCStatsType/"transport"}}</th>
<td>{{RTCTransportStats}}</td>
</tr>
<tr>
<th class="row">{{RTCStatsType/"sctp-transport"}}</th>
<td>{{RTCSctpTransportStats}}</td>
</tr>
<tr>
<th class="row">{{RTCStatsType/"candidate-pair"}}</th>
<td>{{RTCIceCandidatePairStats}}</td>
</tr>
<tr>
<th class="row">{{RTCStatsType/"local-candidate"}}</th>
<td>{{RTCIceCandidateStats}}</td>
</tr>
<tr>
<th class="row">{{RTCStatsType/"remote-candidate"}}</th>
<td>{{RTCIceCandidateStats}}</td>
</tr>
<tr>
<th class="row">{{RTCStatsType/"certificate"}}</th>
<td>{{RTCCertificateStats}}</td>
</tr>
<tr>
<th class="row">{{RTCStatsType/"ice-server"}}</th>
<td>{{RTCIceServerStats}}</td>
</tr>
</tbody>
</table>
</section>
<section class="appendix">
<h2>
Expand Down
68 changes: 64 additions & 4 deletions webrtc-stats.js
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,67 @@ var respecConfig = {
"date": "16 January 2017"
}
},
afterEnd: function markFingerprinting () {
postProcess: [
function generateStatsHierarchy(config, doc) {
const statsIdl = [...document.querySelectorAll("pre.idl")].map(n => n.textContent.slice(6)).join("\n");
const parsedIdl = WebIDL2.parse(statsIdl);
const tbody = doc.querySelector("#summary tbody");
[... tbody.querySelectorAll("tr")].forEach(tr => {
const dictionaries = [...tr.querySelectorAll("td a")].map(n => Object.assign({}, {href: n.getAttribute("href"), name: n.textContent, level: 0}));
// add fields, and recursively look up parent dictionaries
while(dictionaries.find(d => !d.members)) {
dict = dictionaries.find(d => !d.members);
if (!dict.href) {
dict.href = "#dom-" + dict.name.toLowerCase();
}
const idlDict = parsedIdl.find(t => t.type === "dictionary" && t.name === dict.name)
if (!idlDict) {
console.error("can't find " + dict.name);
break;
}
if (idlDict.inheritance && !dictionaries.find(d => d.name === idlDict.inheritance)) {
dictionaries.push({name:idlDict.inheritance, level: dict.level + 1})
}
dict.members = idlDict.members.map(m => m.name);
}
const newTr = document.createElement("tr");
const th = tr.querySelector("th");
const allDict = dictionaries.sort((a, b) => b.level - a.level).filter(d => d.members.length);
th.setAttribute("rowspan", allDict.length);
newTr.appendChild(th);
tr.remove();
let curTr = newTr, i = 0;
do {
const dict = allDict[i];
const dictTd = document.createElement("td");
const link = document.createElement("a");
const code = document.createElement("code");
link.href = dict.href;
code.textContent = dict.name;
link.appendChild(code);
dictTd.appendChild(link);
const fieldTd = document.createElement("td");
dict.members.forEach(m => {
const link = document.createElement("a");
link.href = dict.href + "-" + m.toLowerCase();
const code = document.createElement("code");
code.textContent = m;
link.appendChild(code);
fieldTd.appendChild(link);
fieldTd.appendChild(document.createElement("br"));
});
curTr.appendChild(dictTd);
curTr.appendChild(fieldTd);
i++;
tbody.appendChild(curTr);
curTr = doc.createElement("tr");
} while(i < allDict.length);
tbody.appendChild(curTr);

});
},

function markFingerprinting () {
var self = this;
Array.prototype.forEach.call(
document.querySelectorAll(".fingerprint"),
Expand All @@ -143,6 +203,6 @@ var respecConfig = {
}
});

}

};
}
]
};