forked from w3c/webrtc-stats
-
Notifications
You must be signed in to change notification settings - Fork 0
/
webrtc-stats.html
5114 lines (5108 loc) · 212 KB
/
webrtc-stats.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<link href="webrtc-stats.css" rel="stylesheet" type="text/css">
<title>
Identifiers for WebRTC's Statistics API
</title>
<script class="remove" src="https://www.w3.org/Tools/respec/respec-w3c-common">
//<![CDATA[
// keep this comment
//]]>
</script>
<script class="remove" src="webrtc-stats.js" type="text/javascript">
//<![CDATA[
// keep this comment
//]]>
</script>
</head>
<body>
<section id="abstract">
<p>
This document defines a set of WebIDL objects that allow access to the statistical
information about a RTCPeerConnection.
</p>
<p>
These objects are returned from the getStats API that is specified in [[WEBRTC]].
</p>
</section>
<section id="sotd">
<!-- Status of the draft -->
<p>
This document is incomplete, and as such is not yet suitable for implementation. However,
early experimentation is encouraged.
</p>
</section><!-- NB: [[!..]] normative refs, [[..]] informative refs-->
<!-- based on the wiki page https://www.w3.org/2011/04/webrtc/wiki/Stats -->
<section class="informative">
<h2>
Introduction
</h2>
<p>
Audio, video, or data packets transmitted over a peer-connection can be lost, and
experience varying amounts of network delay. A web application implementing WebRTC expects
to monitor the performance of the underlying network and media pipeline.
</p>
<p>
This document defines the statistic identifiers used by the web application to extract
metrics from the user agent.
</p>
</section>
<section id="conformance">
<p>
This specification defines the conformance criteria that applies to a single product: the
<em>user agent</em>.
</p>
<p>
Implementations that use ECMAScript to implement the objects defined in this specification
<em class="rfc2119" title="MUST">MUST</em> implement them in a manner consistent with the
ECMAScript Bindings defined in the Web IDL specification [[WEBIDL]], as this document uses
that specification and terminology.
</p>
<p>
This specification does not define what objects a conforming implementation should
generate. Specifications that refer to this specification have the need to specify
conformance. They should put in their document text that could like this (EXAMPLE ONLY):
</p>
<ul>
<li>An implementation MUST support generating statistics for the type
RTCInboundRtpStreamStats, with attributes packetsReceived, bytesReceived, packetsLost, and
jitter.
</li>
<li>It MUST support generating statistics for the type RTCOutboundRtpStreamStats, with
attributes packetsSent, bytesSent.
</li>
<li>For all subclasses of RTCRtpStreamStats, it MUST include ssrc and kind. When stats
exist for both sides of a connection, in the form of an inbound-rtp / remote-outbound-rtp
pair or an outbound-rtp / remote-inbound-rtp pair, the members remoteId and localId MUST
also be present.
</li>
<li>It MAY support generating other stats.
</li>
</ul>
</section>
<section>
<h2>
Terminology
</h2>
<p>
The concepts <dfn><a href=
"https://www.w3.org/TR/2014/REC-html5-20141028/webappapis.html#queue-a-task">queue a
task</a></dfn>, and <dfn><a href=
"https://www.w3.org/TR/2014/REC-html5-20141028/webappapis.html#fire-a-simple-event">fires a
simple event</a></dfn> are defined in [[!HTML5]].
</p>
<p>
The terms <dfn>event</dfn>, <dfn><a href=
"https://www.w3.org/TR/2014/REC-html5-20141028/webappapis.html#event-handlers">event
handlers</a></dfn>, and <dfn><a href=
"https://www.w3.org/TR/2014/REC-html5-20141028/webappapis.html#event-handler-event-type">event
handler event types</a></dfn> are defined in [[!HTML5]].
</p>
<p>
The terms <dfn>MediaStream</dfn>, <dfn>MediaStreamTrack</dfn>, and <dfn>Consumer</dfn> are
defined in [[!GETUSERMEDIA]].
</p>
<p>
The terms <dfn>RTCPeerConnection</dfn>, <dfn>RTCDataChannel</dfn>,
<dfn>RTCDtlsTransport</dfn>, <dfn>RTCDtlsTransportState</dfn>, <dfn>RTCIceTransport</dfn>,
<dfn>RTCIceRole</dfn>, <dfn>RTCDataChannelState</dfn>, <dfn>RTCIceCandidateType</dfn> and
<dfn>RTCPriorityType</dfn> are defined in [[!WEBRTC]].
</p>
<p>
The term <dfn>RTP stream</dfn> is defined in [[RFC7656]] section 2.1.10.
</p>
<p>
The terms
<code><dfn data-dfn-for="" data-dfn-type="dfn" id="dom-rtcstats" data-idl="" data-title="RTCStats"><a href="https://www.w3.org/TR/webrtc/#dom-rtcstats">RTCStats</a></dfn></code>,
<code><dfn data-dfn-for="rtcstats" data-dfn-type="dfn" data-lt="timestamp" id="dom-rtcstats-timestamp" data-idl="" data-title="RTCStats.timestamp"><a href="https://www.w3.org/TR/webrtc/#dom-rtcstats-timestamp">RTCStats.timestamp</a></dfn></code>,
<code><dfn data-dfn-for="rtcstats" data-dfn-type="dfn" data-lt="type" id="dom-rtcstats-type" data-idl="" data-title="RTCStats.type"><a href="https://www.w3.org/TR/webrtc/#dom-rtcstats-type">RTCStats.type</a></dfn></code>,
<code><dfn data-dfn-for="rtcstats" data-dfn-type="dfn" data-lt="id" id="dom-rtcstats-id" data-idl="" data-title="RTCStats.id"><a href="https://www.w3.org/TR/webrtc/#dom-rtcstats-id">RTCStats.id</a></dfn></code>,
<code><dfn data-cite="!WEBRTC#dom-rtccertificate">RTCCertificate</dfn></code> and
<code><dfn data-cite="!WEBRTC#event-statsended">statsended</dfn></code> are defined in
[[!WEBRTC]].
</p>
<p>
The terms <code><dfn data-cite=
"!HIGHRES-TIME#sec-domhighrestimestamp">DOMHighResTimeStamp</dfn></code>
<code><dfn data-cite=
"!HIGHRES-TIME#dom-performance-timeOrigin">performance.timeOrigin</dfn></code> and
<code><dfn data-cite="!HIGHRES-TIME#dom-performance-now">performance.now()</dfn></code> are
defined in [[!HIGHRES-TIME]].
</p>
</section>
<section class="informative">
<h2>
Basic concepts
</h2>
<p>
The basic object of the stats model is the <a>stats object</a>. The following terms are
defined to describe it:
</p>
<dl>
<dt>
<dfn>Monitored object</dfn>
</dt>
<dd>
<p>
An internal object that keeps a set of data values. Most monitored objects are object
defined in the WebRTC API; they may be thought of as being internal properties of those
objects.
</p>
</dd>
<dt>
<dfn>Stats object</dfn>
</dt>
<dd>
This is a set of values, copied out from a monitored object at a specific moment in time.
It is returned as a WebIDL dictionary through the getStats API call.
</dd>
<dt>
<dfn>Stats object reference</dfn>
</dt>
<dd>
<p>
A monitored object has a stable identifier "id", which is reflected in all stats
objects produced from the monitored object. Stats objects may contain references to
other stats objects using this "id" value. In a <a>stats object</a>, these references
are represented by a DOMString containing "id" value of the referenced stats object.
</p>
<p>
All stats object references have type DOMString and attribute names ending in 'Id', or
they have type sequence<DOMString> and attribute names ending in 'Ids'.
</p>
</dd>
<dt>
<dfn>Stats value</dfn>
</dt>
<dd>
Refers to a single value within a stats object.
</dd>
</dl>
<p>
A monitored object changes the values it contains continuously over its lifetime, but is
never visible through the getStats API call. A stats object, once returned, never changes.
</p>
<p>
The stats API is defined in [[!WEBRTC]]. It is defined to return a collection of <a>stats
object</a>s, each of which is a dictionary inheriting directly or indirectly from the
<a>RTCStats</a> dictionary. This API is normatively defined in [[!WEBRTC]], but is
reproduced here for ease of reference.
</p>
<pre class="idl">
dictionary RTCStats {
DOMHighResTimeStamp timestamp;
RTCStatsType type;
DOMString id;
};
</pre>
<p>
Timestamps are expressed with DOMHighResTimeStamp [[!HIGHRES-TIME]], and are defined as
<a>performance.timeOrigin</a> + <a>performance.now()</a> at the time the information is
collected.
</p>
<section>
<h3>
Guidelines for design of stats objects
</h3>
<p>
When introducing a new stats object, the following principles should be followed:
</p>
<ul>
<li>An RTCStats object should correspond to an object defined in the specification it
supports.
</li>
<li>The object MUST define a new value in the <a>RTCStatsType</a> enum, and MUST define the
syntax of the <a>stats object</a> it returns either by reference to an existing
sub-dictionary of <a>RTCStats</a> or by defining a new sub-dictionary of <a>RTCStats</a>.
</li>
<li>All members of the new object need to have definitions that make them consistently
implementable. References to other specifications are a good way of doing this.
</li>
<li>All members need to have defined behavior for what happens before the thing it counts
happens, or when the information it's supposed to show is not available. Usually, this
will be "start at zero" or "do not populate the value".
</li>
</ul>
<p>
The new members of the stats dictionary need to be named according to standard practice
(camelCase), as per [[API-DESIGN-PRINCIPLES]].
</p>
<p>
Names ending in "Id" (such as "transportId") are always a <a>stats object reference</a>;
names ending in "Ids" (such as "trackIds") are always of type sequence<DOMString>,
where each DOMString is a <a>stats object reference</a>.
</p>
<p>
If the natural name for a stats value would end in "id" (such as when the stats value is
an in-protocol identifier for the monitored object), the recommended practice is to let
the name end in "identifier", such as "ssrcIdentifier" or "dataChannelIdentifier".
</p>
<p>
Stats are sampled by Javascript. In general, an application will not have overall control
over how often stats are sampled, and the implementation cannot know what the intended
use of the stats is. There is, by design, no control surface for the application to
influence how stats are generated.
</p>
<p>
Therefore, letting the implementation compute "average" rates is not a good idea, since
that implies some averaging time interval that can't be set beforehand. Instead, the
recommended approach is to count the number of measurements of a value and sum the
measurements given even if the sum is meaningless in itself; the JS application can then
compute averages over any desired time interval by calling getStats() twice, taking the
difference of the two sums and dividing by the difference of the two counts.
</p>
<p>
For stats that are measured against time, such as byte counts, no separate counter is
needed; one can instead divide by the difference in the timestamps.
</p>
</section>
<section>
<h3>
Guidelines for implementing stats objects
</h3>
<p>
When implementing stats objects, the following guidelines should be adhered to:
</p>
<ul>
<li>When a feature is not implemented on the platform, omit the dictionary member that is
tracking usage of the feature.
</li>
<li>When a feature is not applicable to an instance of an object (for example audioLevel
on a video stream), omit the dictionary member. Do NOT report a count of zero, -1 or
"empty string".
</li>
<li>When a counted feature hasn't been used yet, but may happen in the future, report a
count of zero.
</li>
</ul>
</section>
<section>
<h3>
Lifetime considerations for monitored objects
</h3>
<p>
The object descriptions will say what the lifetime of a <a>monitored object</a> from the
perspective of stats is. When a monitored object is <dfn>deleted</dfn>, it no longer appears in
stats; until this happens, it will appear. This may or may not correspond to the actual
lifetime of an object in an implementation; what matters for this specification is what
appears in stats.
</p>
<p>
If a monitored object can only exist in a few instances over the lifetime of a
RTCPeerConnection, it may be simplest to consider it "eternal" and never delete it from
the set of objects reported on in stats. This type of object will remain visible until
the RTCPeerConnection is no longer available; it is also visible in getStats() after
pc.close(). This is the default when no lifetime is mentioned in its specification.
</p>
<p>
Objects that might exist in many instances over time should have a defined time at which
they are <a>deleted</a>, at which time a <a>statsended</a> event is fired on their behalf. Each
event that causes deletions to happen MUST fire only one <a>statsended</a> event, but
there are cases where one action causes multiple deletion events; for instance, an ICE
restart will fire only one event containing the stats for all the discarded candidates
and pairs, but will also cause a later event to be fired when the currently-in-use
candidate pair and its candidates are discarded.
</p>
<p>
When a <a>monitored object</a> is <a>deleted</a>, a final stats object is produced, carrying the
values current at the time of deletion. This object will be made available using the
<code><a>statsended</a></code> event on the associated RTCPeerConnection. This is
important in order to report consistently on short-lived objects and to be able to
consistently report totals over the lifetime of a RTCPeerConnection.
</p>
<p>
When an object is <a>deleted</a>, we can guarantee that no subsequent getStats() call will
contain a <a>stats object reference</a> that references the deleted object. We also
guarantee that the stats id of the deleted object will never be reused for another
object. This ensures that an application that collects <a>stats object</a>s for deleted
<a>monitored object</a>s will always be able to uniquely identify the object pointed to
in the result of any getStats() call.
</p>
</section>
<section>
<h3>
Guidelines for getStats() results caching/throttling
</h3>
<p>
A call to getStats() touches many components of WebRTC and may take significant time to
execute. The implementation may or may not utilize caching or throttling of getStats()
calls for performance benefits, however any implementation must adhere to the following:
</p>
<p>
When the state of the RTCPeerConnection visibly changes as a result of an API call, a
promise resolving or an event firing, subsequent new getStats() calls must return
up-to-date dictionaries for the affected objects. For example, if a track is added with
addTrack() subsequent getStats() calls must resolve with a corresponding
RTCMediaHandlerStats object. If you call setRemoteDescription() removing a remote track,
upon the promise resolving or an associated event (stream's onremovetrack or track's
onmute) firing, calling getStats() must resolve with an up-to-date RTCMediaHandlerStats
object.
</p>
<p>
When the <a>statsended</a> event is fired, subsequent getStats() calls MUST NOT return
stats for the <a>monitored object</a> that was reported on in the <a>statsended</a>
event.
</p>
</section>
</section><!-- VS: getStats() remains in base spec! -->
<section>
<h2>
Maintenance procedures for stats object types
</h2>
<section>
<h3>
Adding new stats objects
</h3>
<p class="status-ED">
This document, in its editors' draft form, serves as the repository for the currently
defined set of stats object types including proposals for new standard types.
</p>
<p class="status-not-ED">
This document specifies the interoperable stats object types. Proposals for new object
types may be made in <a href="https://github.com/w3c/webrtc-stats/">the editors draft
maintained on GitHub</a>. New standard types may appear in future revisions of the W3C
Recommendation.
</p>
<p>
If a need for a new stats object type or stats value within a stats object is found, an
issue should be <a href="https://github.com/w3c/webrtc-stats/issues">raised on
Github</a>, and a review process will decide on whether the stat should be added to the
editors draft or not.
</p>
<p>
A pull request for a change to the editors draft may serve as guidance for the
discussion, but the eventual merge is dependent on the review process.
</p>
<p>
While the WebRTC WG exists, it will serve as the review body; once it has disbanded, the
W3C will have to establish appropriate review.
</p>
<p>
The level of review sought is that of the IETF process' "expert review", as defined in
[[RFC5226]] section 4.1. The documentation needed includes the names of the new stats,
their data types, and the definitions they are based on, specified to a level that allows
interoperable implementation. The specification may consist of references to other
documents.
</p>
<p>
Another specification that wishes to refer to a specific version (for instance for
conformance) should refer to a dated version; these will be produced regularly when
updates happen.
</p>
</section>
<section>
<h3>
Retiring stats objects
</h3>
<p>
At times, it makes sense to retire the definition for a stats object or a stats value.
When this happens, it is not advisable to simply delete it from the spec, since there may
be implementations out there that use it, and it is important that the name is reserved
from re-use for another, incompatible definition.
</p>
<p>
Therefore, retired stats objects are moved to a separate section in this document.
Retired stats objects are moved there in their entirety; retired stats values are moved
to a "partial dictionary".
</p>
<p>
If there is no evidence that the retired object definition has ever been used (such as an
object that is added to the spec and renamed, redefined or removed prior to
implementation), the editors can decide to just remove the object from the spec.
</p>
</section>
</section>
<section id="rtctatstype-*">
<h2>
RTCStatsType
</h2>
<p>
The <code>type</code> element, of type <a>RTCStatsType</a>, indicates the type of the
object that the <code>RTCStats</code> object represents. An object with a given "type" can
have only one IDL dictionary type, but multiple "type" values may indicate the same IDL
dictionary type; for example, "local-candidate" and "remote-candidate" both use the IDL
dictionary type <a>RTCIceCandidateStats</a>.
</p>
<p>
This specification is normative for the allowed values of <a>RTCStatsType</a>.
</p>
<section id="rtcstatstype-str*">
<h3>
<dfn>RTCStatsType</dfn> enum
</h3>
<pre class="idl">
enum RTCStatsType {
"codec",
"inbound-rtp",
"outbound-rtp",
"remote-inbound-rtp",
"remote-outbound-rtp",
"media-source",
"csrc",
"peer-connection",
"data-channel",
"stream",
"track",
"sender",
"receiver",
"transport",
"candidate-pair",
"local-candidate",
"remote-candidate",
"certificate",
"stunserverconnection"
};
</pre>
<p>
The following strings are valid values for <var>RTCStatsType</var>:
</p>
<dl data-link-for="RTCStatsType" data-dfn-for="RTCStatsType">
<dt>
<dfn><code>codec</code></dfn>
</dt>
<dd>
<p>
Statistics for a codec that is currently being used by RTP streams being sent or
received by this <code>RTCPeerConnection</code> object. It is accessed by the
<code><a>RTCCodecStats</a></code>.
</p>
</dd>
<dt>
<dfn><code>inbound-rtp</code></dfn>
</dt>
<dd>
<p>
Statistics for an inbound RTP stream that is currently received with this
<code>RTCPeerConnection</code> object. It is accessed by the
<code><a>RTCInboundRtpStreamStats</a></code>.
</p>
</dd>
<dt>
<dfn><code>outbound-rtp</code></dfn>
</dt>
<dd>
<p>
Statistics for an outbound RTP stream that is currently sent with this
<code>RTCPeerConnection</code> object. It is accessed by the
<code><a>RTCOutboundRtpStreamStats</a></code>.
</p>
<p>
When there are multiple RTP streams connected to the same sender, such as when using
simulcast or RTX, there will be one <a>RTCOutboundRtpStreamStats</a> per RTP stream,
with distinct values of the "ssrc" attribute, and all these senders will have a
reference to the same "sender" object (of type <a>RTCAudioSenderStats</a> or
<a>RTCVideoSenderStats</a>) and "track" object (of type
<a>RTCSenderAudioTrackAttachmentStats</a> or
<a>RTCSenderVideoTrackAttachmentStats</a>).
</p>
</dd>
<dt>
<dfn><code>remote-inbound-rtp</code></dfn>
</dt>
<dd>
<p>
Statistics for the remote endpoint's inbound RTP stream corresponding to an outbound
stream that is currently sent with this <code>RTCPeerConnection</code> object. It is
measured at the remote endpoint and reported in an RTCP Receiver Report (RR) or RTCP
Extended Report (XR). It is accessed by the
<code><a>RTCRemoteInboundRtpStreamStats</a></code>.
</p>
</dd>
<dt>
<dfn><code>remote-outbound-rtp</code></dfn>
</dt>
<dd>
<p>
Statistics for the remote endpoint's outbound RTP stream corresponding to an inbound
stream that is currently received with this <code>RTCPeerConnection</code> object. It
is measured at the remote endpoint and reported in an RTCP Sender Report (SR). It is
accessed by the <code><a>RTCRemoteOutboundRtpStreamStats</a></code>.
</p>
</dd>
<dt>
<dfn><code>media-source</code></dfn>
</dt>
<dd>
<p>
Statistics for the media produced by a <code>MediaStreamTrack</code> that is
currently attached to an <code>RTCRtpSender</code>. This reflects the media that is
fed to the encoder; after <code>getUserMedia()</code> constraints have been applied
(i.e. not the raw media produced by the camera). It is either an
<code><a>RTCAudioSourceStats</a></code> or <code><a>RTCVideoSourceStats</a></code>
depending on its <code>kind</code>.
</p>
</dd>
<dt>
<dfn><code>csrc</code></dfn>
</dt>
<dd>
<p>
Statistics for a contributing source (CSRC) that contributed to an inbound RTP
stream. It is accessed by the <code><a>RTCRtpContributingSourceStats</a></code>.
</p>
</dd>
<dt>
<dfn><code>peer-connection</code></dfn>
</dt>
<dd>
<p>
Statistics related to the <code>RTCPeerConnection</code> object. It is accessed by
the <code><a>RTCPeerConnectionStats</a></code>.
</p>
</dd>
<dt>
<dfn><code>data-channel</code></dfn>
</dt>
<dd>
<p>
Statistics related to each <code>RTCDataChannel</code> id. It is accessed by the
<code><a>RTCDataChannelStats</a></code>.
</p>
</dd>
<dt>
<dfn><code>stream</code></dfn>
</dt>
<dd>
<p>
Contains statistics related to a specific MediaStream. It is accessed by the
<code><a>RTCMediaStreamStats</a></code>.
</p>
</dd>
<dt>
<dfn><code>track</code></dfn>
</dt>
<dd>
<p>
Statistics related to a specific MediaStreamTrack's attachment to an
RTCRtpSender and the corresponding media-level metrics. It is accessed by either
<code><a>RTCSenderVideoTrackAttachmentStats</a></code> or
<code><a>RTCSenderAudioTrackAttachmentStats</a></code>, both inherited from
<code><a>RTCMediaHandlerStats</a></code>.
</p>
<p>
The monitored "track" object is <a>deleted</a> when the sender it reports on has its "track"
value changed to no longer refer to the same track.
</p>
</dd>
<dt>
<dfn><code>sender</code></dfn>
</dt>
<dd>
<p>
Statistics related to a specific RTCRtpSender and the corresponding
media-level metrics. It is accessed by the <code><a>RTCAudioSenderStats</a></code> or
the <code><a>RTCVideoSenderStats</a></code> depending on <code>kind</code>.
</p>
</dd>
<dt>
<dfn><code>receiver</code></dfn>
</dt>
<dd>
<p>
Statistics related to a specific receiver and the corresponding media-level
metrics. It is accessed by the <code><a>RTCAudioReceiverStats</a></code> or the
<code><a>RTCVideoReceiverStats</a></code> depending on <code>kind</code>.
</p>
</dd>
<dt>
<dfn><code>transport</code></dfn>
</dt>
<dd>
<p>
Transport statistics related to the <code>RTCPeerConnection</code> object. It is
accessed by the <code><a>RTCTransportStats</a></code>.
</p>
</dd>
<dt>
<dfn><code>candidate-pair</code></dfn>
</dt>
<dd>
<p>
ICE candidate pair statistics related to the <code>RTCIceTransport</code> objects. It
is accessed by the <code><a>RTCIceCandidatePairStats</a></code>.
</p>
<p>
A candidate pair that is not the current pair for a transport is <a>deleted</a> when the
RTCIceTransport does an ICE restart, at the time the state changes to "new". The
candidate pair that is the current pair for a transport is <a>deleted</a> after an ICE
restart when the RTCIceTransport switches to using a candidate pair generated from
the new candidates; this time doesn't correspond to any other externally observable
event.
</p>
</dd>
<dt>
<dfn><code>local-candidate</code></dfn>
</dt>
<dd>
<p>
ICE local candidate statistics related to the <code>RTCIceTransport</code> objects.
It is accessed by the <code><a>RTCIceCandidateStats</a></code> for the local
candidate.
</p>
<p>
A local candidate is <a>deleted</a> when the RTCIceTransport does an ICE restart, and the
candidate is no longer a member of any non-deleted candidate pair.
</p>
</dd>
<dt>
<dfn><code>remote-candidate</code></dfn>
</dt>
<dd>
<p>
ICE remote candidate statistics related to the <code>RTCIceTransport</code> objects.
It is accessed by the <code><a>RTCIceCandidateStats</a></code> for the remote
candidate.
</p>
<p>
A remote candidate is <a>deleted</a> when the RTCIceTransport does an ICE restart, and the
candidate is no longer a member of any non-deleted candidate pair.
</p>
</dd>
<dt>
<dfn><code>certificate</code></dfn>
</dt>
<dd>
<p>
Information about a certificate used by an RTCIceTransport. It is accessed by the
<code><a>RTCCertificateStats</a></code>.
</p>
</dd>
<dt>
<dfn><code>stunserverconnection</code></dfn>
</dt>
<dd>
<p>
Information about the connection to a STUN or TURN server. It is accessed by the
<code><a>RTCStunServerConnectionStats</a></code>.
</p>
</dd>
</dl>
</section>
</section>
<section>
<h2>
Stats dictionaries
</h2>
<section>
<h3>
The RTP statistics hierarchy
</h3>
<p>
The dictionaries for RTP statistics are structured as a hierarchy, so that those stats
that make sense in many different contexts are represented just once in IDL.
</p>
<p>
The lifetime of all RTP <a>monitored object</a>s starts when the RTP stream is first
used: When the first RTP packet is sent or received on the SSRC it represents, or when
the first RTCP packet is sent or received that refers to the SSRC of the RTP stream.
</p>
<p>
RTP monitored objects are not <a>deleted</a>.
</p>
<p>
The hierarchy is as follows:
</p>
<p>
<a>RTCRtpStreamStats</a>: Stats that apply to any end of any RTP stream
</p>
<ul>
<li>
<p>
<a>RTCReceivedRtpStreamStats</a>: Stats measured at the receiving end of an RTP
stream, known either because they're measured locally or transmitted via an RTCP
Receiver Report (RR) or Extended Report (XR).
</p>
<ul>
<li>
<p>
<a>RTCInboundRtpStreamStats</a>: Stats that can only be measured at the local
receiving end of an RTP stream.
</p>
</li>
<li>
<p>
<a>RTCRemoteInboundRtpStreamStats</a>: Stats relevant to the remote receiving end
of an RTP stream - usually computed by combining local data with data received
via an RTCP RR or XR.
</p>
</li>
</ul>
</li>
<li>
<p>
<a>RTCSentRtpStreamStats</a>: Stats measured at the sending end of an RTP stream,
known either because they're measured locally or because they're received via RTCP,
usually in an RTCP Sender Report (SR).
</p>
<ul>
<li>
<a>RTCOutboundRtpStreamStats</a>: Stats measured locally.
</li>
<li>
<p>
<a>RTCRemoteOutboundRtpStreamStats</a>: Stats relevant to the remote sending end
of an RTP stream, usually computed based on an RTCP SR.
</p>
</li>
</ul>
</li>
</ul>
</section>
<section id="streamstats-dict*">
<h3>
<dfn>RTCRtpStreamStats</dfn> dictionary
</h3>
<div>
<pre class="idl">dictionary RTCRtpStreamStats : RTCStats {
unsigned long ssrc;
DOMString kind;
DOMString transportId;
DOMString codecId;
};</pre>
<section>
<h2>
Dictionary <a class="idlType">RTCRtpStreamStats</a> Members
</h2>
<dl data-link-for="RTCRtpStreamStats" data-dfn-for="RTCRtpStreamStats" class=
"dictionary-members">
<dt>
<dfn><code>ssrc</code></dfn> of type <span class="idlMemberType">unsigned
long</span>
</dt>
<dd>
<p>
The 32-bit unsigned integer value per [[RFC3550]] used to identify the source of
the stream of RTP packets that this stats object concerns.
</p>
</dd>
<dt>
<dfn><code>kind</code></dfn> of type <span class="idlMemberType">DOMString</span>
</dt>
<dd>
<p>
Either "<code>audio</code>" or "<code>video</code>". This MUST match the media
type part of the information in the corresponding <code><a data-link-for=
"RTCCodecStats">codecType</a></code> member of <code>RTCCodecStats</code>, and
MUST match the "kind" attribute of the related MediaStreamTrack.
</p>
</dd>
<dt>
<dfn><code>transportId</code></dfn> of type <span class=
"idlMemberType">DOMString</span>
</dt>
<dd>
<p>
It is a unique identifier that is associated to the object that was inspected to
produce the <code>RTCTransportStats</code> associated with this RTP stream.
</p>
</dd>
<dt>
<dfn><code>codecId</code></dfn> of type <span class=
"idlMemberType">DOMString</span>
</dt>
<dd>
<p>
It is a unique identifier that is associated to the object that was inspected to
produce the <code>RTCCodecStats</code> associated with this RTP stream.
</p>
</dd>
</dl>
</section>
</div>
</section>
<section id="codec-dict*">
<h3>
<dfn>RTCCodecStats</dfn> dictionary
</h3>
<div>
<pre class="idl">dictionary RTCCodecStats : RTCStats {
unsigned long payloadType;
RTCCodecType codecType;
DOMString transportId;
DOMString mimeType;
unsigned long clockRate;
unsigned long channels;
DOMString sdpFmtpLine;
};</pre>
<section>
<h2>
Dictionary <a class="idlType">RTCCodecStats</a> Members
</h2>
<dl data-link-for="RTCCodecStats" data-dfn-for="RTCCodecStats" class=
"dictionary-members">
<dt>
<dfn><code>payloadType</code></dfn> of type <span class="idlMemberType">unsigned
long</span>
</dt>
<dd>
<p>
Payload type as used in RTP encoding or decoding.
</p>
</dd>
<dt>
<dfn><code>codecType</code></dfn> of type <span class=
"idlMemberType"><a>RTCCodecType</a></span>
</dt>
<dd>
<p>
<code>"encode"</code> or <code>"decode"</code>, depending on whether this object
represents a media format that the implementation is prepared to encode or
decode.
</p>
</dd>
<dt>
<dfn><code>transportId</code></dfn> of type <span class=
"idlMemberType">DOMString</span>
</dt>
<dd>
<p>
The unique identifier of the transport on which this codec is being used, which
can be used to look up the corresponding <code><a>RTCTransportStats</a></code>
object.
</p>
</dd>
<dt>
<dfn><code>mimeType</code></dfn> of type <span class=
"idlMemberType">DOMString</span>
</dt>
<dd>
<p>
The codec MIME media type/subtype. e.g., video/vp8 or equivalent.
</p>
</dd>
<dt>
<dfn><code>clockRate</code></dfn> of type <span class="idlMemberType">unsigned
long</span>
</dt>
<dd>
<p>
Represents the media sampling rate.
</p>
</dd>
<dt>
<dfn><code>channels</code></dfn> of type <span class="idlMemberType">unsigned
long</span>
</dt>
<dd>
<p>
Use 2 for stereo, missing for most other cases.
</p>
</dd>
<dt>
<dfn><code>sdpFmtpLine</code></dfn> of type <span class=
"idlMemberType">DOMString</span>
</dt>
<dd>
<p>
The a=fmtp line in the SDP corresponding to the codec, i.e., after the colon
following the PT. This defined by [[!JSEP]] in Section 5.7.
</p>
</dd>
</dl>
</section>
</div>
<section>
<h3>
<dfn>RTCCodecType</dfn> enum
</h3>
<div>
<pre class="idl">enum RTCCodecType {
"encode",
"decode",
};</pre>
<table data-link-for="RTCCodecType" data-dfn-for="RTCCodecType" class="simple">
<tbody>
<tr>
<th colspan="2">
Enumeration description
</th>
</tr>
<tr>
<td>
<dfn><code>encode</code></dfn>
</td>
<td>
<p>
The attached <code><a>RTCCodecStats</a></code> represents a media format that
is being encoded, or that the implementation is prepared to encode.
</p>
</td>
</tr>
<tr>
<td>
<dfn><code>decode</code></dfn>
</td>
<td>
<p>
The attached <code><a>RTCCodecStats</a></code> represents a media format that
the implementation is prepared to decode.
</p>
</td>
</tr>
</tbody>
</table>
</div>
</section>
</section>
<section id="receivedrtpstats-dict*">
<h3>
<dfn>RTCReceivedRtpStreamStats</dfn> dictionary
</h3>
<div>
<pre class="idl">dictionary RTCReceivedRtpStreamStats : RTCRtpStreamStats {
unsigned long packetsReceived;
long packetsLost;
double jitter;
unsigned long packetsDiscarded;
unsigned long packetsRepaired;
unsigned long burstPacketsLost;
unsigned long burstPacketsDiscarded;
unsigned long burstLossCount;
unsigned long burstDiscardCount;
double burstLossRate;
double burstDiscardRate;
double gapLossRate;
double gapDiscardRate;
};</pre>
<section>
<h2>
Dictionary <a class="idlType">RTCReceivedRtpStreamStats</a> Members
</h2>
<dl data-link-for="RTCReceivedRtpStreamStats" data-dfn-for="RTCReceivedRtpStreamStats"
class="dictionary-members">
<dt>
<dfn><code>packetsReceived</code></dfn> of type <span class=
"idlMemberType">unsigned long</span>
</dt>
<dd>
<p>
Total number of RTP packets received for this SSRC. At the receiving endpoint,
this is calculated as defined in [[!RFC3550]] section 6.4.1. At the sending
endpoint the packetsReceived can be calculated by subtracting the packets lost
from the expected Highest Sequence Number reported in the RTCP Sender Report as
discussed in Appendix A.3. in [[!RFC3550]].
</p>
</dd>
<dt>
<dfn><code>packetsLost</code></dfn> of type <span class="idlMemberType">long</span>
</dt>
<dd>
<p>
Total number of RTP packets lost for this SSRC. Calculated as defined in
[[!RFC3550]] section 6.4.1. Note that because of how this is estimated, it can be
negative if more packets are received than sent.
</p>
</dd>
<dt>
<dfn><code>jitter</code></dfn> of type <span class="idlMemberType">double</span>
</dt>