Skip to content

Commit dd91f21

Browse files
committedOct 1, 2015
Merge pull request #301 from jan-ivar/fixgetstats
fix RTCStatsReport with object and maplike instead of getter This is a breaking change; @stefhak will notify the list that it is made.
2 parents b886f8b + b19fa95 commit dd91f21

File tree

1 file changed

+22
-24
lines changed

1 file changed

+22
-24
lines changed
 

‎webrtc.html

+22-24
Original file line numberDiff line numberDiff line change
@@ -4995,35 +4995,34 @@ <h3>RTCStatsReport Object</h3>
49954995

49964996
<p>The <code><a href="#widl-RTCPeerConnection-getStats-Promise-RTCStatsReport--MediaStreamTrack-selector">
49974997
getStats()</a></code>
4998-
method delivers a successful result in the form of a
4999-
<code><a>RTCStatsReport</a></code> object. A
5000-
<code><a>RTCStatsReport</a></code> object represents a map between
5001-
strings, identifying the inspected objects (<a href=
4998+
method delivers a successful result in the form of an
4999+
<code><a>RTCStatsReport</a></code> object. An
5000+
<code><a>RTCStatsReport</a></code> object is a map between
5001+
strings that identify the inspected objects (<a href=
50025002
"#dom-rtcstats-id">RTCStats.id</a>), and their corresponding
5003-
<code><a>RTCStats</a></code> objects.</p>
5003+
<code><a>RTCStats</a></code>-derived dictionaries.</p>
50045004

50055005
<p>An <code><a>RTCStatsReport</a></code> may be composed of several
5006-
<code><a>RTCStats</a></code> objects, each reporting stats for one
5006+
<code><a>RTCStats</a></code>-derived dictionaries, each reporting stats for one
50075007
underlying object that the implementation thinks is relevant for the
50085008
<a href="#stats-selector">selector</a>. One achieves the total for the
50095009
<a href="#stats-selector">selector</a> by summing over all the stats of a
50105010
certain type; for instance, if a <code>MediaStreamTrack</code> is carried
50115011
by multiple SSRCs over the network, the
5012-
<code><a>RTCStatsReport</a></code> may contain one <code>RTCStats</code>
5013-
object per SSRC (which can be distinguished by the value of the "ssrc"
5012+
<code><a>RTCStatsReport</a></code> may contain one <code>RTCStats</code>-derived
5013+
dictionary per SSRC (which can be distinguished by the value of the "ssrc"
50145014
stats attribute).</p>
50155015

50165016
<dl class="idl" title="interface RTCStatsReport">
5017-
<dt>getter RTCStats (DOMString id)</dt>
5017+
<dt>readonly maplike&lt;DOMString, object&gt;</dt>
50185018

50195019
<dd>
5020-
<p>Getter to retrieve the <code><a>RTCStats</a></code> objects that
5021-
this stats report is composed of.</p>
5022-
5023-
<p>The set of supported property names [[!WEBIDL]] is defined as the
5024-
ids of all the <code><a>RTCStats</a></code> objects that has been
5025-
generated for this stats report. The order of the property names is
5026-
left to the user agent.</p>
5020+
Use these to retrieve the various dictionaries
5021+
descended from <code><a>RTCStats</a></code> that
5022+
this stats report is composed of.
5023+
The set of supported property names [[!WEBIDL]] is defined as the
5024+
ids of all the <code><a>RTCStats</a></code>-derived dictionaries that
5025+
have been generated for this stats report.
50275026
</dd>
50285027
</dl>
50295028
</section>
@@ -5054,8 +5053,8 @@ <h3>RTCStats Dictionary</h3>
50545053
"packetsSent" are both reported, they both need to be reported over the
50555054
same interval, so that "average packet size" can be computed as "bytes /
50565055
packets" - if the intervals are different, this will yield errors. Thus
5057-
implementations MUST return synchronized values for all stats in a
5058-
<code><a>RTCStats</a></code> object.</p>
5056+
implementations MUST return synchronized values for all stats in an
5057+
<code><a>RTCStats</a></code>-derived dictionary.</p>
50595058

50605059
<dl class="idl" title="dictionary RTCStats">
50615060
<dt>DOMHiResTimeStamp timestamp</dt>
@@ -5190,17 +5189,16 @@ <h3>Example</h3>
51905189

51915190
function processStats() {
51925191
// compare the elements from the current report with the baseline
5193-
for (var i in currentReport) {
5194-
var now = currentReport[i];
5192+
currentReport.forEach (now => {
51955193
if (now.type != "outboundrtp")
5196-
continue;
5194+
return;
51975195

51985196
// get the corresponding stats from the baseline report
5199-
base = baselineReport[now.id];
5197+
base = baselineReport.get(now.id);
52005198

52015199
if (base) {
5202-
remoteNow = currentReport[now.remoteId];
5203-
remoteBase = baselineReport[base.remoteId];
5200+
remoteNow = currentReport.get(now.remoteId);
5201+
remoteBase = baselineReport.get(base.remoteId);
52045202

52055203
var packetsSent = now.packetsSent - base.packetsSent;
52065204
var packetsReceived = remoteNow.packetsReceived - remoteBase.packetsReceived;

0 commit comments

Comments
 (0)