xref: /aosp_15_r20/external/webrtc/stats/rtcstats_objects.cc (revision d9f758449e529ab9291ac668be2861e7a55c2422)
1 /*
2  *  Copyright 2016 The WebRTC Project Authors. All rights reserved.
3  *
4  *  Use of this source code is governed by a BSD-style license
5  *  that can be found in the LICENSE file in the root of the source
6  *  tree. An additional intellectual property rights grant can be found
7  *  in the file PATENTS.  All contributing project authors may
8  *  be found in the AUTHORS file in the root of the source tree.
9  */
10 
11 #include "api/stats/rtcstats_objects.h"
12 
13 #include <utility>
14 
15 #include "api/stats/rtc_stats.h"
16 #include "rtc_base/checks.h"
17 
18 namespace webrtc {
19 
20 const char* const RTCDataChannelState::kConnecting = "connecting";
21 const char* const RTCDataChannelState::kOpen = "open";
22 const char* const RTCDataChannelState::kClosing = "closing";
23 const char* const RTCDataChannelState::kClosed = "closed";
24 
25 const char* const RTCStatsIceCandidatePairState::kFrozen = "frozen";
26 const char* const RTCStatsIceCandidatePairState::kWaiting = "waiting";
27 const char* const RTCStatsIceCandidatePairState::kInProgress = "in-progress";
28 const char* const RTCStatsIceCandidatePairState::kFailed = "failed";
29 const char* const RTCStatsIceCandidatePairState::kSucceeded = "succeeded";
30 
31 // Strings defined in https://tools.ietf.org/html/rfc5245.
32 const char* const RTCIceCandidateType::kHost = "host";
33 const char* const RTCIceCandidateType::kSrflx = "srflx";
34 const char* const RTCIceCandidateType::kPrflx = "prflx";
35 const char* const RTCIceCandidateType::kRelay = "relay";
36 
37 const char* const RTCDtlsTransportState::kNew = "new";
38 const char* const RTCDtlsTransportState::kConnecting = "connecting";
39 const char* const RTCDtlsTransportState::kConnected = "connected";
40 const char* const RTCDtlsTransportState::kClosed = "closed";
41 const char* const RTCDtlsTransportState::kFailed = "failed";
42 
43 const char* const RTCMediaStreamTrackKind::kAudio = "audio";
44 const char* const RTCMediaStreamTrackKind::kVideo = "video";
45 
46 // https://w3c.github.io/webrtc-stats/#dom-rtcnetworktype
47 const char* const RTCNetworkType::kBluetooth = "bluetooth";
48 const char* const RTCNetworkType::kCellular = "cellular";
49 const char* const RTCNetworkType::kEthernet = "ethernet";
50 const char* const RTCNetworkType::kWifi = "wifi";
51 const char* const RTCNetworkType::kWimax = "wimax";
52 const char* const RTCNetworkType::kVpn = "vpn";
53 const char* const RTCNetworkType::kUnknown = "unknown";
54 
55 // https://w3c.github.io/webrtc-stats/#dom-rtcqualitylimitationreason
56 const char* const RTCQualityLimitationReason::kNone = "none";
57 const char* const RTCQualityLimitationReason::kCpu = "cpu";
58 const char* const RTCQualityLimitationReason::kBandwidth = "bandwidth";
59 const char* const RTCQualityLimitationReason::kOther = "other";
60 
61 // https://webrtc.org/experiments/rtp-hdrext/video-content-type/
62 const char* const RTCContentType::kUnspecified = "unspecified";
63 const char* const RTCContentType::kScreenshare = "screenshare";
64 
65 // https://w3c.github.io/webrtc-stats/#dom-rtcdtlsrole
66 const char* const RTCDtlsRole::kUnknown = "unknown";
67 const char* const RTCDtlsRole::kClient = "client";
68 const char* const RTCDtlsRole::kServer = "server";
69 
70 // https://www.w3.org/TR/webrtc/#rtcicerole
71 const char* const RTCIceRole::kUnknown = "unknown";
72 const char* const RTCIceRole::kControlled = "controlled";
73 const char* const RTCIceRole::kControlling = "controlling";
74 
75 // https://www.w3.org/TR/webrtc/#dom-rtcicetransportstate
76 const char* const RTCIceTransportState::kNew = "new";
77 const char* const RTCIceTransportState::kChecking = "checking";
78 const char* const RTCIceTransportState::kConnected = "connected";
79 const char* const RTCIceTransportState::kCompleted = "completed";
80 const char* const RTCIceTransportState::kDisconnected = "disconnected";
81 const char* const RTCIceTransportState::kFailed = "failed";
82 const char* const RTCIceTransportState::kClosed = "closed";
83 
84 // clang-format off
85 WEBRTC_RTCSTATS_IMPL(RTCCertificateStats, RTCStats, "certificate",
86     &fingerprint,
87     &fingerprint_algorithm,
88     &base64_certificate,
89     &issuer_certificate_id)
90 // clang-format on
91 
RTCCertificateStats(const std::string & id,int64_t timestamp_us)92 RTCCertificateStats::RTCCertificateStats(const std::string& id,
93                                          int64_t timestamp_us)
94     : RTCCertificateStats(std::string(id), timestamp_us) {}
95 
RTCCertificateStats(std::string && id,int64_t timestamp_us)96 RTCCertificateStats::RTCCertificateStats(std::string&& id, int64_t timestamp_us)
97     : RTCStats(std::move(id), timestamp_us),
98       fingerprint("fingerprint"),
99       fingerprint_algorithm("fingerprintAlgorithm"),
100       base64_certificate("base64Certificate"),
101       issuer_certificate_id("issuerCertificateId") {}
102 
103 RTCCertificateStats::RTCCertificateStats(const RTCCertificateStats& other) =
104     default;
~RTCCertificateStats()105 RTCCertificateStats::~RTCCertificateStats() {}
106 
107 // clang-format off
108 WEBRTC_RTCSTATS_IMPL(RTCCodecStats, RTCStats, "codec",
109     &transport_id,
110     &payload_type,
111     &mime_type,
112     &clock_rate,
113     &channels,
114     &sdp_fmtp_line)
115 // clang-format on
116 
RTCCodecStats(const std::string & id,int64_t timestamp_us)117 RTCCodecStats::RTCCodecStats(const std::string& id, int64_t timestamp_us)
118     : RTCCodecStats(std::string(id), timestamp_us) {}
119 
RTCCodecStats(std::string && id,int64_t timestamp_us)120 RTCCodecStats::RTCCodecStats(std::string&& id, int64_t timestamp_us)
121     : RTCStats(std::move(id), timestamp_us),
122       transport_id("transportId"),
123       payload_type("payloadType"),
124       mime_type("mimeType"),
125       clock_rate("clockRate"),
126       channels("channels"),
127       sdp_fmtp_line("sdpFmtpLine") {}
128 
129 RTCCodecStats::RTCCodecStats(const RTCCodecStats& other) = default;
130 
~RTCCodecStats()131 RTCCodecStats::~RTCCodecStats() {}
132 
133 // clang-format off
134 WEBRTC_RTCSTATS_IMPL(RTCDataChannelStats, RTCStats, "data-channel",
135     &label,
136     &protocol,
137     &data_channel_identifier,
138     &state,
139     &messages_sent,
140     &bytes_sent,
141     &messages_received,
142     &bytes_received)
143 // clang-format on
144 
RTCDataChannelStats(const std::string & id,int64_t timestamp_us)145 RTCDataChannelStats::RTCDataChannelStats(const std::string& id,
146                                          int64_t timestamp_us)
147     : RTCDataChannelStats(std::string(id), timestamp_us) {}
148 
RTCDataChannelStats(std::string && id,int64_t timestamp_us)149 RTCDataChannelStats::RTCDataChannelStats(std::string&& id, int64_t timestamp_us)
150     : RTCStats(std::move(id), timestamp_us),
151       label("label"),
152       protocol("protocol"),
153       data_channel_identifier("dataChannelIdentifier"),
154       state("state"),
155       messages_sent("messagesSent"),
156       bytes_sent("bytesSent"),
157       messages_received("messagesReceived"),
158       bytes_received("bytesReceived") {}
159 
160 RTCDataChannelStats::RTCDataChannelStats(const RTCDataChannelStats& other) =
161     default;
162 
~RTCDataChannelStats()163 RTCDataChannelStats::~RTCDataChannelStats() {}
164 
165 // clang-format off
166 WEBRTC_RTCSTATS_IMPL(RTCIceCandidatePairStats, RTCStats, "candidate-pair",
167     &transport_id,
168     &local_candidate_id,
169     &remote_candidate_id,
170     &state,
171     &priority,
172     &nominated,
173     &writable,
174     &packets_sent,
175     &packets_received,
176     &bytes_sent,
177     &bytes_received,
178     &total_round_trip_time,
179     &current_round_trip_time,
180     &available_outgoing_bitrate,
181     &available_incoming_bitrate,
182     &requests_received,
183     &requests_sent,
184     &responses_received,
185     &responses_sent,
186     &consent_requests_sent,
187     &packets_discarded_on_send,
188     &bytes_discarded_on_send,
189     &last_packet_received_timestamp,
190     &last_packet_sent_timestamp)
191 // clang-format on
192 
RTCIceCandidatePairStats(const std::string & id,int64_t timestamp_us)193 RTCIceCandidatePairStats::RTCIceCandidatePairStats(const std::string& id,
194                                                    int64_t timestamp_us)
195     : RTCIceCandidatePairStats(std::string(id), timestamp_us) {}
196 
RTCIceCandidatePairStats(std::string && id,int64_t timestamp_us)197 RTCIceCandidatePairStats::RTCIceCandidatePairStats(std::string&& id,
198                                                    int64_t timestamp_us)
199     : RTCStats(std::move(id), timestamp_us),
200       transport_id("transportId"),
201       local_candidate_id("localCandidateId"),
202       remote_candidate_id("remoteCandidateId"),
203       state("state"),
204       priority("priority"),
205       nominated("nominated"),
206       writable("writable"),
207       packets_sent("packetsSent"),
208       packets_received("packetsReceived"),
209       bytes_sent("bytesSent"),
210       bytes_received("bytesReceived"),
211       total_round_trip_time("totalRoundTripTime"),
212       current_round_trip_time("currentRoundTripTime"),
213       available_outgoing_bitrate("availableOutgoingBitrate"),
214       available_incoming_bitrate("availableIncomingBitrate"),
215       requests_received("requestsReceived"),
216       requests_sent("requestsSent"),
217       responses_received("responsesReceived"),
218       responses_sent("responsesSent"),
219       consent_requests_sent("consentRequestsSent"),
220       packets_discarded_on_send("packetsDiscardedOnSend"),
221       bytes_discarded_on_send("bytesDiscardedOnSend"),
222       last_packet_received_timestamp("lastPacketReceivedTimestamp"),
223       last_packet_sent_timestamp("lastPacketSentTimestamp") {}
224 
225 RTCIceCandidatePairStats::RTCIceCandidatePairStats(
226     const RTCIceCandidatePairStats& other) = default;
227 
~RTCIceCandidatePairStats()228 RTCIceCandidatePairStats::~RTCIceCandidatePairStats() {}
229 
230 // clang-format off
231 WEBRTC_RTCSTATS_IMPL(RTCIceCandidateStats, RTCStats, "abstract-ice-candidate",
232     &transport_id,
233     &is_remote,
234     &network_type,
235     &ip,
236     &address,
237     &port,
238     &protocol,
239     &relay_protocol,
240     &candidate_type,
241     &priority,
242     &url,
243     &foundation,
244     &related_address,
245     &related_port,
246     &username_fragment,
247     &tcp_type,
248     &vpn,
249     &network_adapter_type)
250 // clang-format on
251 
RTCIceCandidateStats(const std::string & id,int64_t timestamp_us,bool is_remote)252 RTCIceCandidateStats::RTCIceCandidateStats(const std::string& id,
253                                            int64_t timestamp_us,
254                                            bool is_remote)
255     : RTCIceCandidateStats(std::string(id), timestamp_us, is_remote) {}
256 
RTCIceCandidateStats(std::string && id,int64_t timestamp_us,bool is_remote)257 RTCIceCandidateStats::RTCIceCandidateStats(std::string&& id,
258                                            int64_t timestamp_us,
259                                            bool is_remote)
260     : RTCStats(std::move(id), timestamp_us),
261       transport_id("transportId"),
262       is_remote("isRemote", is_remote),
263       network_type("networkType"),
264       ip("ip"),
265       address("address"),
266       port("port"),
267       protocol("protocol"),
268       relay_protocol("relayProtocol"),
269       candidate_type("candidateType"),
270       priority("priority"),
271       url("url"),
272       foundation("foundation"),
273       related_address("relatedAddress"),
274       related_port("relatedPort"),
275       username_fragment("usernameFragment"),
276       tcp_type("tcpType"),
277       vpn("vpn"),
278       network_adapter_type("networkAdapterType") {}
279 
280 RTCIceCandidateStats::RTCIceCandidateStats(const RTCIceCandidateStats& other) =
281     default;
282 
~RTCIceCandidateStats()283 RTCIceCandidateStats::~RTCIceCandidateStats() {}
284 
285 const char RTCLocalIceCandidateStats::kType[] = "local-candidate";
286 
RTCLocalIceCandidateStats(const std::string & id,int64_t timestamp_us)287 RTCLocalIceCandidateStats::RTCLocalIceCandidateStats(const std::string& id,
288                                                      int64_t timestamp_us)
289     : RTCIceCandidateStats(id, timestamp_us, false) {}
290 
RTCLocalIceCandidateStats(std::string && id,int64_t timestamp_us)291 RTCLocalIceCandidateStats::RTCLocalIceCandidateStats(std::string&& id,
292                                                      int64_t timestamp_us)
293     : RTCIceCandidateStats(std::move(id), timestamp_us, false) {}
294 
copy() const295 std::unique_ptr<RTCStats> RTCLocalIceCandidateStats::copy() const {
296   return std::make_unique<RTCLocalIceCandidateStats>(*this);
297 }
298 
type() const299 const char* RTCLocalIceCandidateStats::type() const {
300   return kType;
301 }
302 
303 const char RTCRemoteIceCandidateStats::kType[] = "remote-candidate";
304 
RTCRemoteIceCandidateStats(const std::string & id,int64_t timestamp_us)305 RTCRemoteIceCandidateStats::RTCRemoteIceCandidateStats(const std::string& id,
306                                                        int64_t timestamp_us)
307     : RTCIceCandidateStats(id, timestamp_us, true) {}
308 
RTCRemoteIceCandidateStats(std::string && id,int64_t timestamp_us)309 RTCRemoteIceCandidateStats::RTCRemoteIceCandidateStats(std::string&& id,
310                                                        int64_t timestamp_us)
311     : RTCIceCandidateStats(std::move(id), timestamp_us, true) {}
312 
copy() const313 std::unique_ptr<RTCStats> RTCRemoteIceCandidateStats::copy() const {
314   return std::make_unique<RTCRemoteIceCandidateStats>(*this);
315 }
316 
type() const317 const char* RTCRemoteIceCandidateStats::type() const {
318   return kType;
319 }
320 
321 // clang-format off
322 WEBRTC_RTCSTATS_IMPL(DEPRECATED_RTCMediaStreamStats, RTCStats, "stream",
323     &stream_identifier,
324     &track_ids)
325 // clang-format on
326 
DEPRECATED_RTCMediaStreamStats(const std::string & id,int64_t timestamp_us)327 DEPRECATED_RTCMediaStreamStats::DEPRECATED_RTCMediaStreamStats(
328     const std::string& id,
329     int64_t timestamp_us)
330     : DEPRECATED_RTCMediaStreamStats(std::string(id), timestamp_us) {}
331 
DEPRECATED_RTCMediaStreamStats(std::string && id,int64_t timestamp_us)332 DEPRECATED_RTCMediaStreamStats::DEPRECATED_RTCMediaStreamStats(
333     std::string&& id,
334     int64_t timestamp_us)
335     : RTCStats(std::move(id), timestamp_us),
336       stream_identifier("streamIdentifier"),
337       track_ids("trackIds") {}
338 
339 DEPRECATED_RTCMediaStreamStats::DEPRECATED_RTCMediaStreamStats(
340     const DEPRECATED_RTCMediaStreamStats& other) = default;
341 
~DEPRECATED_RTCMediaStreamStats()342 DEPRECATED_RTCMediaStreamStats::~DEPRECATED_RTCMediaStreamStats() {}
343 
344 // clang-format off
345 WEBRTC_RTCSTATS_IMPL(DEPRECATED_RTCMediaStreamTrackStats, RTCStats, "track",
346                      &track_identifier,
347                      &media_source_id,
348                      &remote_source,
349                      &ended,
350                      &detached,
351                      &kind,
352                      &jitter_buffer_delay,
353                      &jitter_buffer_emitted_count,
354                      &frame_width,
355                      &frame_height,
356                      &frames_sent,
357                      &huge_frames_sent,
358                      &frames_received,
359                      &frames_decoded,
360                      &frames_dropped,
361                      &audio_level,
362                      &total_audio_energy,
363                      &echo_return_loss,
364                      &echo_return_loss_enhancement,
365                      &total_samples_received,
366                      &total_samples_duration,
367                      &concealed_samples,
368                      &silent_concealed_samples,
369                      &concealment_events,
370                      &inserted_samples_for_deceleration,
371                      &removed_samples_for_acceleration)
372 // clang-format on
373 
DEPRECATED_RTCMediaStreamTrackStats(const std::string & id,int64_t timestamp_us,const char * kind)374 DEPRECATED_RTCMediaStreamTrackStats::DEPRECATED_RTCMediaStreamTrackStats(
375     const std::string& id,
376     int64_t timestamp_us,
377     const char* kind)
378     : DEPRECATED_RTCMediaStreamTrackStats(std::string(id), timestamp_us, kind) {
379 }
380 
DEPRECATED_RTCMediaStreamTrackStats(std::string && id,int64_t timestamp_us,const char * kind)381 DEPRECATED_RTCMediaStreamTrackStats::DEPRECATED_RTCMediaStreamTrackStats(
382     std::string&& id,
383     int64_t timestamp_us,
384     const char* kind)
385     : RTCStats(std::move(id), timestamp_us),
386       track_identifier("trackIdentifier"),
387       media_source_id("mediaSourceId"),
388       remote_source("remoteSource"),
389       ended("ended"),
390       detached("detached"),
391       kind("kind", kind),
392       jitter_buffer_delay("jitterBufferDelay"),
393       jitter_buffer_emitted_count("jitterBufferEmittedCount"),
394       frame_width("frameWidth"),
395       frame_height("frameHeight"),
396       frames_sent("framesSent"),
397       huge_frames_sent("hugeFramesSent"),
398       frames_received("framesReceived"),
399       frames_decoded("framesDecoded"),
400       frames_dropped("framesDropped"),
401       audio_level("audioLevel"),
402       total_audio_energy("totalAudioEnergy"),
403       echo_return_loss("echoReturnLoss"),
404       echo_return_loss_enhancement("echoReturnLossEnhancement"),
405       total_samples_received("totalSamplesReceived"),
406       total_samples_duration("totalSamplesDuration"),
407       concealed_samples("concealedSamples"),
408       silent_concealed_samples("silentConcealedSamples"),
409       concealment_events("concealmentEvents"),
410       inserted_samples_for_deceleration("insertedSamplesForDeceleration"),
411       removed_samples_for_acceleration("removedSamplesForAcceleration") {
412   RTC_DCHECK(kind == RTCMediaStreamTrackKind::kAudio ||
413              kind == RTCMediaStreamTrackKind::kVideo);
414 }
415 
416 DEPRECATED_RTCMediaStreamTrackStats::DEPRECATED_RTCMediaStreamTrackStats(
417     const DEPRECATED_RTCMediaStreamTrackStats& other) = default;
418 
~DEPRECATED_RTCMediaStreamTrackStats()419 DEPRECATED_RTCMediaStreamTrackStats::~DEPRECATED_RTCMediaStreamTrackStats() {}
420 
421 // clang-format off
422 WEBRTC_RTCSTATS_IMPL(RTCPeerConnectionStats, RTCStats, "peer-connection",
423     &data_channels_opened,
424     &data_channels_closed)
425 // clang-format on
426 
RTCPeerConnectionStats(const std::string & id,int64_t timestamp_us)427 RTCPeerConnectionStats::RTCPeerConnectionStats(const std::string& id,
428                                                int64_t timestamp_us)
429     : RTCPeerConnectionStats(std::string(id), timestamp_us) {}
430 
RTCPeerConnectionStats(std::string && id,int64_t timestamp_us)431 RTCPeerConnectionStats::RTCPeerConnectionStats(std::string&& id,
432                                                int64_t timestamp_us)
433     : RTCStats(std::move(id), timestamp_us),
434       data_channels_opened("dataChannelsOpened"),
435       data_channels_closed("dataChannelsClosed") {}
436 
437 RTCPeerConnectionStats::RTCPeerConnectionStats(
438     const RTCPeerConnectionStats& other) = default;
439 
~RTCPeerConnectionStats()440 RTCPeerConnectionStats::~RTCPeerConnectionStats() {}
441 
442 // clang-format off
443 WEBRTC_RTCSTATS_IMPL(RTCRTPStreamStats, RTCStats, "rtp",
444     &ssrc,
445     &kind,
446     &track_id,
447     &transport_id,
448     &codec_id,
449     &media_type)
450 // clang-format on
451 
RTCRTPStreamStats(const std::string & id,int64_t timestamp_us)452 RTCRTPStreamStats::RTCRTPStreamStats(const std::string& id,
453                                      int64_t timestamp_us)
454     : RTCRTPStreamStats(std::string(id), timestamp_us) {}
455 
RTCRTPStreamStats(std::string && id,int64_t timestamp_us)456 RTCRTPStreamStats::RTCRTPStreamStats(std::string&& id, int64_t timestamp_us)
457     : RTCStats(std::move(id), timestamp_us),
458       ssrc("ssrc"),
459       kind("kind"),
460       track_id("trackId"),
461       transport_id("transportId"),
462       codec_id("codecId"),
463       media_type("mediaType") {}
464 
465 RTCRTPStreamStats::RTCRTPStreamStats(const RTCRTPStreamStats& other) = default;
466 
~RTCRTPStreamStats()467 RTCRTPStreamStats::~RTCRTPStreamStats() {}
468 
469 // clang-format off
470 WEBRTC_RTCSTATS_IMPL(
471     RTCReceivedRtpStreamStats, RTCRTPStreamStats, "received-rtp",
472     &jitter,
473     &packets_lost)
474 // clang-format on
475 
RTCReceivedRtpStreamStats(const std::string && id,int64_t timestamp_us)476 RTCReceivedRtpStreamStats::RTCReceivedRtpStreamStats(const std::string&& id,
477                                                      int64_t timestamp_us)
478     : RTCReceivedRtpStreamStats(std::string(id), timestamp_us) {}
479 
RTCReceivedRtpStreamStats(std::string && id,int64_t timestamp_us)480 RTCReceivedRtpStreamStats::RTCReceivedRtpStreamStats(std::string&& id,
481                                                      int64_t timestamp_us)
482     : RTCRTPStreamStats(std::move(id), timestamp_us),
483       jitter("jitter"),
484       packets_lost("packetsLost") {}
485 
486 RTCReceivedRtpStreamStats::RTCReceivedRtpStreamStats(
487     const RTCReceivedRtpStreamStats& other) = default;
488 
~RTCReceivedRtpStreamStats()489 RTCReceivedRtpStreamStats::~RTCReceivedRtpStreamStats() {}
490 
491 // clang-format off
492 WEBRTC_RTCSTATS_IMPL(
493     RTCSentRtpStreamStats, RTCRTPStreamStats, "sent-rtp",
494     &packets_sent,
495     &bytes_sent)
496 // clang-format on
497 
RTCSentRtpStreamStats(const std::string && id,int64_t timestamp_us)498 RTCSentRtpStreamStats::RTCSentRtpStreamStats(const std::string&& id,
499                                              int64_t timestamp_us)
500     : RTCSentRtpStreamStats(std::string(id), timestamp_us) {}
501 
RTCSentRtpStreamStats(std::string && id,int64_t timestamp_us)502 RTCSentRtpStreamStats::RTCSentRtpStreamStats(std::string&& id,
503                                              int64_t timestamp_us)
504     : RTCRTPStreamStats(std::move(id), timestamp_us),
505       packets_sent("packetsSent"),
506       bytes_sent("bytesSent") {}
507 
508 RTCSentRtpStreamStats::RTCSentRtpStreamStats(
509     const RTCSentRtpStreamStats& other) = default;
510 
~RTCSentRtpStreamStats()511 RTCSentRtpStreamStats::~RTCSentRtpStreamStats() {}
512 
513 // clang-format off
514 WEBRTC_RTCSTATS_IMPL(
515     RTCInboundRTPStreamStats, RTCReceivedRtpStreamStats, "inbound-rtp",
516     &track_identifier,
517     &mid,
518     &remote_id,
519     &packets_received,
520     &packets_discarded,
521     &fec_packets_received,
522     &fec_packets_discarded,
523     &bytes_received,
524     &header_bytes_received,
525     &last_packet_received_timestamp,
526     &jitter_buffer_delay,
527     &jitter_buffer_target_delay,
528     &jitter_buffer_minimum_delay,
529     &jitter_buffer_emitted_count,
530     &total_samples_received,
531     &concealed_samples,
532     &silent_concealed_samples,
533     &concealment_events,
534     &inserted_samples_for_deceleration,
535     &removed_samples_for_acceleration,
536     &audio_level,
537     &total_audio_energy,
538     &total_samples_duration,
539     &frames_received,
540     &frame_width,
541     &frame_height,
542     &frames_per_second,
543     &frames_decoded,
544     &key_frames_decoded,
545     &frames_dropped,
546     &total_decode_time,
547     &total_processing_delay,
548     &total_assembly_time,
549     &frames_assembled_from_multiple_packets,
550     &total_inter_frame_delay,
551     &total_squared_inter_frame_delay,
552     &pause_count,
553     &total_pauses_duration,
554     &freeze_count,
555     &total_freezes_duration,
556     &content_type,
557     &estimated_playout_timestamp,
558     &decoder_implementation,
559     &fir_count,
560     &pli_count,
561     &nack_count,
562     &qp_sum,
563     &goog_timing_frame_info,
564     &power_efficient_decoder,
565     &jitter_buffer_flushes,
566     &delayed_packet_outage_samples,
567     &relative_packet_arrival_delay,
568     &interruption_count,
569     &total_interruption_duration,
570     &min_playout_delay)
571 // clang-format on
572 
RTCInboundRTPStreamStats(const std::string & id,int64_t timestamp_us)573 RTCInboundRTPStreamStats::RTCInboundRTPStreamStats(const std::string& id,
574                                                    int64_t timestamp_us)
575     : RTCInboundRTPStreamStats(std::string(id), timestamp_us) {}
576 
RTCInboundRTPStreamStats(std::string && id,int64_t timestamp_us)577 RTCInboundRTPStreamStats::RTCInboundRTPStreamStats(std::string&& id,
578                                                    int64_t timestamp_us)
579     : RTCReceivedRtpStreamStats(std::move(id), timestamp_us),
580       track_identifier("trackIdentifier"),
581       mid("mid"),
582       remote_id("remoteId"),
583       packets_received("packetsReceived"),
584       packets_discarded("packetsDiscarded"),
585       fec_packets_received("fecPacketsReceived"),
586       fec_packets_discarded("fecPacketsDiscarded"),
587       bytes_received("bytesReceived"),
588       header_bytes_received("headerBytesReceived"),
589       last_packet_received_timestamp("lastPacketReceivedTimestamp"),
590       jitter_buffer_delay("jitterBufferDelay"),
591       jitter_buffer_target_delay("jitterBufferTargetDelay"),
592       jitter_buffer_minimum_delay("jitterBufferMinimumDelay"),
593       jitter_buffer_emitted_count("jitterBufferEmittedCount"),
594       total_samples_received("totalSamplesReceived"),
595       concealed_samples("concealedSamples"),
596       silent_concealed_samples("silentConcealedSamples"),
597       concealment_events("concealmentEvents"),
598       inserted_samples_for_deceleration("insertedSamplesForDeceleration"),
599       removed_samples_for_acceleration("removedSamplesForAcceleration"),
600       audio_level("audioLevel"),
601       total_audio_energy("totalAudioEnergy"),
602       total_samples_duration("totalSamplesDuration"),
603       frames_received("framesReceived"),
604       frame_width("frameWidth"),
605       frame_height("frameHeight"),
606       frames_per_second("framesPerSecond"),
607       frames_decoded("framesDecoded"),
608       key_frames_decoded("keyFramesDecoded"),
609       frames_dropped("framesDropped"),
610       total_decode_time("totalDecodeTime"),
611       total_processing_delay("totalProcessingDelay"),
612       total_assembly_time("totalAssemblyTime"),
613       frames_assembled_from_multiple_packets(
614           "framesAssembledFromMultiplePackets"),
615       total_inter_frame_delay("totalInterFrameDelay"),
616       total_squared_inter_frame_delay("totalSquaredInterFrameDelay"),
617       pause_count("pauseCount"),
618       total_pauses_duration("totalPausesDuration"),
619       freeze_count("freezeCount"),
620       total_freezes_duration("totalFreezesDuration"),
621       content_type("contentType"),
622       estimated_playout_timestamp("estimatedPlayoutTimestamp"),
623       decoder_implementation("decoderImplementation"),
624       fir_count("firCount"),
625       pli_count("pliCount"),
626       nack_count("nackCount"),
627       qp_sum("qpSum"),
628       goog_timing_frame_info("googTimingFrameInfo"),
629       power_efficient_decoder("powerEfficientDecoder"),
630       jitter_buffer_flushes(
631           "jitterBufferFlushes",
632           {NonStandardGroupId::kRtcAudioJitterBufferMaxPackets}),
633       delayed_packet_outage_samples(
634           "delayedPacketOutageSamples",
635           {NonStandardGroupId::kRtcAudioJitterBufferMaxPackets,
636            NonStandardGroupId::kRtcStatsRelativePacketArrivalDelay}),
637       relative_packet_arrival_delay(
638           "relativePacketArrivalDelay",
639           {NonStandardGroupId::kRtcStatsRelativePacketArrivalDelay}),
640       interruption_count("interruptionCount"),
641       total_interruption_duration("totalInterruptionDuration"),
642       min_playout_delay("minPlayoutDelay") {}
643 
644 RTCInboundRTPStreamStats::RTCInboundRTPStreamStats(
645     const RTCInboundRTPStreamStats& other) = default;
~RTCInboundRTPStreamStats()646 RTCInboundRTPStreamStats::~RTCInboundRTPStreamStats() {}
647 
648 // clang-format off
649 WEBRTC_RTCSTATS_IMPL(
650     RTCOutboundRTPStreamStats, RTCRTPStreamStats, "outbound-rtp",
651     &media_source_id,
652     &remote_id,
653     &mid,
654     &rid,
655     &packets_sent,
656     &retransmitted_packets_sent,
657     &bytes_sent,
658     &header_bytes_sent,
659     &retransmitted_bytes_sent,
660     &target_bitrate,
661     &frames_encoded,
662     &key_frames_encoded,
663     &total_encode_time,
664     &total_encoded_bytes_target,
665     &frame_width,
666     &frame_height,
667     &frames_per_second,
668     &frames_sent,
669     &huge_frames_sent,
670     &total_packet_send_delay,
671     &quality_limitation_reason,
672     &quality_limitation_durations,
673     &quality_limitation_resolution_changes,
674     &content_type,
675     &encoder_implementation,
676     &fir_count,
677     &pli_count,
678     &nack_count,
679     &qp_sum,
680     &active,
681     &power_efficient_encoder)
682 // clang-format on
683 
RTCOutboundRTPStreamStats(const std::string & id,int64_t timestamp_us)684 RTCOutboundRTPStreamStats::RTCOutboundRTPStreamStats(const std::string& id,
685                                                      int64_t timestamp_us)
686     : RTCOutboundRTPStreamStats(std::string(id), timestamp_us) {}
687 
RTCOutboundRTPStreamStats(std::string && id,int64_t timestamp_us)688 RTCOutboundRTPStreamStats::RTCOutboundRTPStreamStats(std::string&& id,
689                                                      int64_t timestamp_us)
690     : RTCRTPStreamStats(std::move(id), timestamp_us),
691       media_source_id("mediaSourceId"),
692       remote_id("remoteId"),
693       mid("mid"),
694       rid("rid"),
695       packets_sent("packetsSent"),
696       retransmitted_packets_sent("retransmittedPacketsSent"),
697       bytes_sent("bytesSent"),
698       header_bytes_sent("headerBytesSent"),
699       retransmitted_bytes_sent("retransmittedBytesSent"),
700       target_bitrate("targetBitrate"),
701       frames_encoded("framesEncoded"),
702       key_frames_encoded("keyFramesEncoded"),
703       total_encode_time("totalEncodeTime"),
704       total_encoded_bytes_target("totalEncodedBytesTarget"),
705       frame_width("frameWidth"),
706       frame_height("frameHeight"),
707       frames_per_second("framesPerSecond"),
708       frames_sent("framesSent"),
709       huge_frames_sent("hugeFramesSent"),
710       total_packet_send_delay("totalPacketSendDelay"),
711       quality_limitation_reason("qualityLimitationReason"),
712       quality_limitation_durations("qualityLimitationDurations"),
713       quality_limitation_resolution_changes(
714           "qualityLimitationResolutionChanges"),
715       content_type("contentType"),
716       encoder_implementation("encoderImplementation"),
717       fir_count("firCount"),
718       pli_count("pliCount"),
719       nack_count("nackCount"),
720       qp_sum("qpSum"),
721       active("active"),
722       power_efficient_encoder("powerEfficientEncoder") {}
723 
724 RTCOutboundRTPStreamStats::RTCOutboundRTPStreamStats(
725     const RTCOutboundRTPStreamStats& other) = default;
726 
~RTCOutboundRTPStreamStats()727 RTCOutboundRTPStreamStats::~RTCOutboundRTPStreamStats() {}
728 
729 // clang-format off
730 WEBRTC_RTCSTATS_IMPL(
731     RTCRemoteInboundRtpStreamStats, RTCReceivedRtpStreamStats,
732         "remote-inbound-rtp",
733     &local_id,
734     &round_trip_time,
735     &fraction_lost,
736     &total_round_trip_time,
737     &round_trip_time_measurements)
738 // clang-format on
739 
RTCRemoteInboundRtpStreamStats(const std::string & id,int64_t timestamp_us)740 RTCRemoteInboundRtpStreamStats::RTCRemoteInboundRtpStreamStats(
741     const std::string& id,
742     int64_t timestamp_us)
743     : RTCRemoteInboundRtpStreamStats(std::string(id), timestamp_us) {}
744 
RTCRemoteInboundRtpStreamStats(std::string && id,int64_t timestamp_us)745 RTCRemoteInboundRtpStreamStats::RTCRemoteInboundRtpStreamStats(
746     std::string&& id,
747     int64_t timestamp_us)
748     : RTCReceivedRtpStreamStats(std::move(id), timestamp_us),
749       local_id("localId"),
750       round_trip_time("roundTripTime"),
751       fraction_lost("fractionLost"),
752       total_round_trip_time("totalRoundTripTime"),
753       round_trip_time_measurements("roundTripTimeMeasurements") {}
754 
755 RTCRemoteInboundRtpStreamStats::RTCRemoteInboundRtpStreamStats(
756     const RTCRemoteInboundRtpStreamStats& other) = default;
757 
~RTCRemoteInboundRtpStreamStats()758 RTCRemoteInboundRtpStreamStats::~RTCRemoteInboundRtpStreamStats() {}
759 
760 // clang-format off
761 WEBRTC_RTCSTATS_IMPL(
762     RTCRemoteOutboundRtpStreamStats, RTCSentRtpStreamStats,
763     "remote-outbound-rtp",
764     &local_id,
765     &remote_timestamp,
766     &reports_sent,
767     &round_trip_time,
768     &round_trip_time_measurements,
769     &total_round_trip_time)
770 // clang-format on
771 
RTCRemoteOutboundRtpStreamStats(const std::string & id,int64_t timestamp_us)772 RTCRemoteOutboundRtpStreamStats::RTCRemoteOutboundRtpStreamStats(
773     const std::string& id,
774     int64_t timestamp_us)
775     : RTCRemoteOutboundRtpStreamStats(std::string(id), timestamp_us) {}
776 
RTCRemoteOutboundRtpStreamStats(std::string && id,int64_t timestamp_us)777 RTCRemoteOutboundRtpStreamStats::RTCRemoteOutboundRtpStreamStats(
778     std::string&& id,
779     int64_t timestamp_us)
780     : RTCSentRtpStreamStats(std::move(id), timestamp_us),
781       local_id("localId"),
782       remote_timestamp("remoteTimestamp"),
783       reports_sent("reportsSent"),
784       round_trip_time("roundTripTime"),
785       round_trip_time_measurements("roundTripTimeMeasurements"),
786       total_round_trip_time("totalRoundTripTime") {}
787 
788 RTCRemoteOutboundRtpStreamStats::RTCRemoteOutboundRtpStreamStats(
789     const RTCRemoteOutboundRtpStreamStats& other) = default;
790 
~RTCRemoteOutboundRtpStreamStats()791 RTCRemoteOutboundRtpStreamStats::~RTCRemoteOutboundRtpStreamStats() {}
792 
793 // clang-format off
794 WEBRTC_RTCSTATS_IMPL(RTCMediaSourceStats, RTCStats, "parent-media-source",
795     &track_identifier,
796     &kind)
797 // clang-format on
798 
RTCMediaSourceStats(const std::string & id,int64_t timestamp_us)799 RTCMediaSourceStats::RTCMediaSourceStats(const std::string& id,
800                                          int64_t timestamp_us)
801     : RTCMediaSourceStats(std::string(id), timestamp_us) {}
802 
RTCMediaSourceStats(std::string && id,int64_t timestamp_us)803 RTCMediaSourceStats::RTCMediaSourceStats(std::string&& id, int64_t timestamp_us)
804     : RTCStats(std::move(id), timestamp_us),
805       track_identifier("trackIdentifier"),
806       kind("kind") {}
807 
808 RTCMediaSourceStats::RTCMediaSourceStats(const RTCMediaSourceStats& other) =
809     default;
810 
~RTCMediaSourceStats()811 RTCMediaSourceStats::~RTCMediaSourceStats() {}
812 
813 // clang-format off
814 WEBRTC_RTCSTATS_IMPL(RTCAudioSourceStats, RTCMediaSourceStats, "media-source",
815     &audio_level,
816     &total_audio_energy,
817     &total_samples_duration,
818     &echo_return_loss,
819     &echo_return_loss_enhancement)
820 // clang-format on
821 
RTCAudioSourceStats(const std::string & id,int64_t timestamp_us)822 RTCAudioSourceStats::RTCAudioSourceStats(const std::string& id,
823                                          int64_t timestamp_us)
824     : RTCAudioSourceStats(std::string(id), timestamp_us) {}
825 
RTCAudioSourceStats(std::string && id,int64_t timestamp_us)826 RTCAudioSourceStats::RTCAudioSourceStats(std::string&& id, int64_t timestamp_us)
827     : RTCMediaSourceStats(std::move(id), timestamp_us),
828       audio_level("audioLevel"),
829       total_audio_energy("totalAudioEnergy"),
830       total_samples_duration("totalSamplesDuration"),
831       echo_return_loss("echoReturnLoss"),
832       echo_return_loss_enhancement("echoReturnLossEnhancement") {}
833 
834 RTCAudioSourceStats::RTCAudioSourceStats(const RTCAudioSourceStats& other) =
835     default;
836 
~RTCAudioSourceStats()837 RTCAudioSourceStats::~RTCAudioSourceStats() {}
838 
839 // clang-format off
840 WEBRTC_RTCSTATS_IMPL(RTCVideoSourceStats, RTCMediaSourceStats, "media-source",
841     &width,
842     &height,
843     &frames,
844     &frames_per_second)
845 // clang-format on
846 
RTCVideoSourceStats(const std::string & id,int64_t timestamp_us)847 RTCVideoSourceStats::RTCVideoSourceStats(const std::string& id,
848                                          int64_t timestamp_us)
849     : RTCVideoSourceStats(std::string(id), timestamp_us) {}
850 
RTCVideoSourceStats(std::string && id,int64_t timestamp_us)851 RTCVideoSourceStats::RTCVideoSourceStats(std::string&& id, int64_t timestamp_us)
852     : RTCMediaSourceStats(std::move(id), timestamp_us),
853       width("width"),
854       height("height"),
855       frames("frames"),
856       frames_per_second("framesPerSecond") {}
857 
858 RTCVideoSourceStats::RTCVideoSourceStats(const RTCVideoSourceStats& other) =
859     default;
860 
~RTCVideoSourceStats()861 RTCVideoSourceStats::~RTCVideoSourceStats() {}
862 
863 // clang-format off
864 WEBRTC_RTCSTATS_IMPL(RTCTransportStats, RTCStats, "transport",
865     &bytes_sent,
866     &packets_sent,
867     &bytes_received,
868     &packets_received,
869     &rtcp_transport_stats_id,
870     &dtls_state,
871     &selected_candidate_pair_id,
872     &local_certificate_id,
873     &remote_certificate_id,
874     &tls_version,
875     &dtls_cipher,
876     &dtls_role,
877     &srtp_cipher,
878     &selected_candidate_pair_changes,
879     &ice_role,
880     &ice_local_username_fragment,
881     &ice_state)
882 // clang-format on
883 
RTCTransportStats(const std::string & id,int64_t timestamp_us)884 RTCTransportStats::RTCTransportStats(const std::string& id,
885                                      int64_t timestamp_us)
886     : RTCTransportStats(std::string(id), timestamp_us) {}
887 
RTCTransportStats(std::string && id,int64_t timestamp_us)888 RTCTransportStats::RTCTransportStats(std::string&& id, int64_t timestamp_us)
889     : RTCStats(std::move(id), timestamp_us),
890       bytes_sent("bytesSent"),
891       packets_sent("packetsSent"),
892       bytes_received("bytesReceived"),
893       packets_received("packetsReceived"),
894       rtcp_transport_stats_id("rtcpTransportStatsId"),
895       dtls_state("dtlsState"),
896       selected_candidate_pair_id("selectedCandidatePairId"),
897       local_certificate_id("localCertificateId"),
898       remote_certificate_id("remoteCertificateId"),
899       tls_version("tlsVersion"),
900       dtls_cipher("dtlsCipher"),
901       dtls_role("dtlsRole"),
902       srtp_cipher("srtpCipher"),
903       selected_candidate_pair_changes("selectedCandidatePairChanges"),
904       ice_role("iceRole"),
905       ice_local_username_fragment("iceLocalUsernameFragment"),
906       ice_state("iceState") {}
907 
908 RTCTransportStats::RTCTransportStats(const RTCTransportStats& other) = default;
909 
~RTCTransportStats()910 RTCTransportStats::~RTCTransportStats() {}
911 
912 }  // namespace webrtc
913