• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 // clang-format off
66 WEBRTC_RTCSTATS_IMPL(RTCCertificateStats, RTCStats, "certificate",
67     &fingerprint,
68     &fingerprint_algorithm,
69     &base64_certificate,
70     &issuer_certificate_id)
71 // clang-format on
72 
RTCCertificateStats(const std::string & id,int64_t timestamp_us)73 RTCCertificateStats::RTCCertificateStats(const std::string& id,
74                                          int64_t timestamp_us)
75     : RTCCertificateStats(std::string(id), timestamp_us) {}
76 
RTCCertificateStats(std::string && id,int64_t timestamp_us)77 RTCCertificateStats::RTCCertificateStats(std::string&& id, int64_t timestamp_us)
78     : RTCStats(std::move(id), timestamp_us),
79       fingerprint("fingerprint"),
80       fingerprint_algorithm("fingerprintAlgorithm"),
81       base64_certificate("base64Certificate"),
82       issuer_certificate_id("issuerCertificateId") {}
83 
RTCCertificateStats(const RTCCertificateStats & other)84 RTCCertificateStats::RTCCertificateStats(const RTCCertificateStats& other)
85     : RTCStats(other.id(), other.timestamp_us()),
86       fingerprint(other.fingerprint),
87       fingerprint_algorithm(other.fingerprint_algorithm),
88       base64_certificate(other.base64_certificate),
89       issuer_certificate_id(other.issuer_certificate_id) {}
90 
~RTCCertificateStats()91 RTCCertificateStats::~RTCCertificateStats() {}
92 
93 // clang-format off
94 WEBRTC_RTCSTATS_IMPL(RTCCodecStats, RTCStats, "codec",
95     &payload_type,
96     &mime_type,
97     &clock_rate,
98     &channels,
99     &sdp_fmtp_line)
100 // clang-format on
101 
RTCCodecStats(const std::string & id,int64_t timestamp_us)102 RTCCodecStats::RTCCodecStats(const std::string& id, int64_t timestamp_us)
103     : RTCCodecStats(std::string(id), timestamp_us) {}
104 
RTCCodecStats(std::string && id,int64_t timestamp_us)105 RTCCodecStats::RTCCodecStats(std::string&& id, int64_t timestamp_us)
106     : RTCStats(std::move(id), timestamp_us),
107       payload_type("payloadType"),
108       mime_type("mimeType"),
109       clock_rate("clockRate"),
110       channels("channels"),
111       sdp_fmtp_line("sdpFmtpLine") {}
112 
RTCCodecStats(const RTCCodecStats & other)113 RTCCodecStats::RTCCodecStats(const RTCCodecStats& other)
114     : RTCStats(other.id(), other.timestamp_us()),
115       payload_type(other.payload_type),
116       mime_type(other.mime_type),
117       clock_rate(other.clock_rate),
118       channels(other.channels),
119       sdp_fmtp_line(other.sdp_fmtp_line) {}
120 
~RTCCodecStats()121 RTCCodecStats::~RTCCodecStats() {}
122 
123 // clang-format off
124 WEBRTC_RTCSTATS_IMPL(RTCDataChannelStats, RTCStats, "data-channel",
125     &label,
126     &protocol,
127     &data_channel_identifier,
128     &state,
129     &messages_sent,
130     &bytes_sent,
131     &messages_received,
132     &bytes_received)
133 // clang-format on
134 
RTCDataChannelStats(const std::string & id,int64_t timestamp_us)135 RTCDataChannelStats::RTCDataChannelStats(const std::string& id,
136                                          int64_t timestamp_us)
137     : RTCDataChannelStats(std::string(id), timestamp_us) {}
138 
RTCDataChannelStats(std::string && id,int64_t timestamp_us)139 RTCDataChannelStats::RTCDataChannelStats(std::string&& id, int64_t timestamp_us)
140     : RTCStats(std::move(id), timestamp_us),
141       label("label"),
142       protocol("protocol"),
143       data_channel_identifier("dataChannelIdentifier"),
144       state("state"),
145       messages_sent("messagesSent"),
146       bytes_sent("bytesSent"),
147       messages_received("messagesReceived"),
148       bytes_received("bytesReceived") {}
149 
RTCDataChannelStats(const RTCDataChannelStats & other)150 RTCDataChannelStats::RTCDataChannelStats(const RTCDataChannelStats& other)
151     : RTCStats(other.id(), other.timestamp_us()),
152       label(other.label),
153       protocol(other.protocol),
154       data_channel_identifier(other.data_channel_identifier),
155       state(other.state),
156       messages_sent(other.messages_sent),
157       bytes_sent(other.bytes_sent),
158       messages_received(other.messages_received),
159       bytes_received(other.bytes_received) {}
160 
~RTCDataChannelStats()161 RTCDataChannelStats::~RTCDataChannelStats() {}
162 
163 // clang-format off
164 WEBRTC_RTCSTATS_IMPL(RTCIceCandidatePairStats, RTCStats, "candidate-pair",
165     &transport_id,
166     &local_candidate_id,
167     &remote_candidate_id,
168     &state,
169     &priority,
170     &nominated,
171     &writable,
172     &readable,
173     &bytes_sent,
174     &bytes_received,
175     &total_round_trip_time,
176     &current_round_trip_time,
177     &available_outgoing_bitrate,
178     &available_incoming_bitrate,
179     &requests_received,
180     &requests_sent,
181     &responses_received,
182     &responses_sent,
183     &retransmissions_received,
184     &retransmissions_sent,
185     &consent_requests_received,
186     &consent_requests_sent,
187     &consent_responses_received,
188     &consent_responses_sent)
189 // clang-format on
190 
RTCIceCandidatePairStats(const std::string & id,int64_t timestamp_us)191 RTCIceCandidatePairStats::RTCIceCandidatePairStats(const std::string& id,
192                                                    int64_t timestamp_us)
193     : RTCIceCandidatePairStats(std::string(id), timestamp_us) {}
194 
RTCIceCandidatePairStats(std::string && id,int64_t timestamp_us)195 RTCIceCandidatePairStats::RTCIceCandidatePairStats(std::string&& id,
196                                                    int64_t timestamp_us)
197     : RTCStats(std::move(id), timestamp_us),
198       transport_id("transportId"),
199       local_candidate_id("localCandidateId"),
200       remote_candidate_id("remoteCandidateId"),
201       state("state"),
202       priority("priority"),
203       nominated("nominated"),
204       writable("writable"),
205       readable("readable"),
206       bytes_sent("bytesSent"),
207       bytes_received("bytesReceived"),
208       total_round_trip_time("totalRoundTripTime"),
209       current_round_trip_time("currentRoundTripTime"),
210       available_outgoing_bitrate("availableOutgoingBitrate"),
211       available_incoming_bitrate("availableIncomingBitrate"),
212       requests_received("requestsReceived"),
213       requests_sent("requestsSent"),
214       responses_received("responsesReceived"),
215       responses_sent("responsesSent"),
216       retransmissions_received("retransmissionsReceived"),
217       retransmissions_sent("retransmissionsSent"),
218       consent_requests_received("consentRequestsReceived"),
219       consent_requests_sent("consentRequestsSent"),
220       consent_responses_received("consentResponsesReceived"),
221       consent_responses_sent("consentResponsesSent") {}
222 
RTCIceCandidatePairStats(const RTCIceCandidatePairStats & other)223 RTCIceCandidatePairStats::RTCIceCandidatePairStats(
224     const RTCIceCandidatePairStats& other)
225     : RTCStats(other.id(), other.timestamp_us()),
226       transport_id(other.transport_id),
227       local_candidate_id(other.local_candidate_id),
228       remote_candidate_id(other.remote_candidate_id),
229       state(other.state),
230       priority(other.priority),
231       nominated(other.nominated),
232       writable(other.writable),
233       readable(other.readable),
234       bytes_sent(other.bytes_sent),
235       bytes_received(other.bytes_received),
236       total_round_trip_time(other.total_round_trip_time),
237       current_round_trip_time(other.current_round_trip_time),
238       available_outgoing_bitrate(other.available_outgoing_bitrate),
239       available_incoming_bitrate(other.available_incoming_bitrate),
240       requests_received(other.requests_received),
241       requests_sent(other.requests_sent),
242       responses_received(other.responses_received),
243       responses_sent(other.responses_sent),
244       retransmissions_received(other.retransmissions_received),
245       retransmissions_sent(other.retransmissions_sent),
246       consent_requests_received(other.consent_requests_received),
247       consent_requests_sent(other.consent_requests_sent),
248       consent_responses_received(other.consent_responses_received),
249       consent_responses_sent(other.consent_responses_sent) {}
250 
~RTCIceCandidatePairStats()251 RTCIceCandidatePairStats::~RTCIceCandidatePairStats() {}
252 
253 // clang-format off
254 WEBRTC_RTCSTATS_IMPL(RTCIceCandidateStats, RTCStats, "abstract-ice-candidate",
255     &transport_id,
256     &is_remote,
257     &network_type,
258     &ip,
259     &port,
260     &protocol,
261     &relay_protocol,
262     &candidate_type,
263     &priority,
264     &url,
265     &deleted)
266 // clang-format on
267 
RTCIceCandidateStats(const std::string & id,int64_t timestamp_us,bool is_remote)268 RTCIceCandidateStats::RTCIceCandidateStats(const std::string& id,
269                                            int64_t timestamp_us,
270                                            bool is_remote)
271     : RTCIceCandidateStats(std::string(id), timestamp_us, is_remote) {}
272 
RTCIceCandidateStats(std::string && id,int64_t timestamp_us,bool is_remote)273 RTCIceCandidateStats::RTCIceCandidateStats(std::string&& id,
274                                            int64_t timestamp_us,
275                                            bool is_remote)
276     : RTCStats(std::move(id), timestamp_us),
277       transport_id("transportId"),
278       is_remote("isRemote", is_remote),
279       network_type("networkType"),
280       ip("ip"),
281       port("port"),
282       protocol("protocol"),
283       relay_protocol("relayProtocol"),
284       candidate_type("candidateType"),
285       priority("priority"),
286       url("url"),
287       deleted("deleted", false) {}
288 
RTCIceCandidateStats(const RTCIceCandidateStats & other)289 RTCIceCandidateStats::RTCIceCandidateStats(const RTCIceCandidateStats& other)
290     : RTCStats(other.id(), other.timestamp_us()),
291       transport_id(other.transport_id),
292       is_remote(other.is_remote),
293       network_type(other.network_type),
294       ip(other.ip),
295       port(other.port),
296       protocol(other.protocol),
297       relay_protocol(other.relay_protocol),
298       candidate_type(other.candidate_type),
299       priority(other.priority),
300       url(other.url),
301       deleted(other.deleted) {}
302 
~RTCIceCandidateStats()303 RTCIceCandidateStats::~RTCIceCandidateStats() {}
304 
305 const char RTCLocalIceCandidateStats::kType[] = "local-candidate";
306 
RTCLocalIceCandidateStats(const std::string & id,int64_t timestamp_us)307 RTCLocalIceCandidateStats::RTCLocalIceCandidateStats(const std::string& id,
308                                                      int64_t timestamp_us)
309     : RTCIceCandidateStats(id, timestamp_us, false) {}
310 
RTCLocalIceCandidateStats(std::string && id,int64_t timestamp_us)311 RTCLocalIceCandidateStats::RTCLocalIceCandidateStats(std::string&& id,
312                                                      int64_t timestamp_us)
313     : RTCIceCandidateStats(std::move(id), timestamp_us, false) {}
314 
copy() const315 std::unique_ptr<RTCStats> RTCLocalIceCandidateStats::copy() const {
316   return std::unique_ptr<RTCStats>(new RTCLocalIceCandidateStats(*this));
317 }
318 
type() const319 const char* RTCLocalIceCandidateStats::type() const {
320   return kType;
321 }
322 
323 const char RTCRemoteIceCandidateStats::kType[] = "remote-candidate";
324 
RTCRemoteIceCandidateStats(const std::string & id,int64_t timestamp_us)325 RTCRemoteIceCandidateStats::RTCRemoteIceCandidateStats(const std::string& id,
326                                                        int64_t timestamp_us)
327     : RTCIceCandidateStats(id, timestamp_us, true) {}
328 
RTCRemoteIceCandidateStats(std::string && id,int64_t timestamp_us)329 RTCRemoteIceCandidateStats::RTCRemoteIceCandidateStats(std::string&& id,
330                                                        int64_t timestamp_us)
331     : RTCIceCandidateStats(std::move(id), timestamp_us, true) {}
332 
copy() const333 std::unique_ptr<RTCStats> RTCRemoteIceCandidateStats::copy() const {
334   return std::unique_ptr<RTCStats>(new RTCRemoteIceCandidateStats(*this));
335 }
336 
type() const337 const char* RTCRemoteIceCandidateStats::type() const {
338   return kType;
339 }
340 
341 // clang-format off
342 WEBRTC_RTCSTATS_IMPL(RTCMediaStreamStats, RTCStats, "stream",
343     &stream_identifier,
344     &track_ids)
345 // clang-format on
346 
RTCMediaStreamStats(const std::string & id,int64_t timestamp_us)347 RTCMediaStreamStats::RTCMediaStreamStats(const std::string& id,
348                                          int64_t timestamp_us)
349     : RTCMediaStreamStats(std::string(id), timestamp_us) {}
350 
RTCMediaStreamStats(std::string && id,int64_t timestamp_us)351 RTCMediaStreamStats::RTCMediaStreamStats(std::string&& id, int64_t timestamp_us)
352     : RTCStats(std::move(id), timestamp_us),
353       stream_identifier("streamIdentifier"),
354       track_ids("trackIds") {}
355 
RTCMediaStreamStats(const RTCMediaStreamStats & other)356 RTCMediaStreamStats::RTCMediaStreamStats(const RTCMediaStreamStats& other)
357     : RTCStats(other.id(), other.timestamp_us()),
358       stream_identifier(other.stream_identifier),
359       track_ids(other.track_ids) {}
360 
~RTCMediaStreamStats()361 RTCMediaStreamStats::~RTCMediaStreamStats() {}
362 
363 // clang-format off
364 WEBRTC_RTCSTATS_IMPL(RTCMediaStreamTrackStats, RTCStats, "track",
365                      &track_identifier,
366                      &media_source_id,
367                      &remote_source,
368                      &ended,
369                      &detached,
370                      &kind,
371                      &jitter_buffer_delay,
372                      &jitter_buffer_emitted_count,
373                      &frame_width,
374                      &frame_height,
375                      &frames_per_second,
376                      &frames_sent,
377                      &huge_frames_sent,
378                      &frames_received,
379                      &frames_decoded,
380                      &frames_dropped,
381                      &frames_corrupted,
382                      &partial_frames_lost,
383                      &full_frames_lost,
384                      &audio_level,
385                      &total_audio_energy,
386                      &echo_return_loss,
387                      &echo_return_loss_enhancement,
388                      &total_samples_received,
389                      &total_samples_duration,
390                      &concealed_samples,
391                      &silent_concealed_samples,
392                      &concealment_events,
393                      &inserted_samples_for_deceleration,
394                      &removed_samples_for_acceleration,
395                      &jitter_buffer_flushes,
396                      &delayed_packet_outage_samples,
397                      &relative_packet_arrival_delay,
398                      &jitter_buffer_target_delay,
399                      &interruption_count,
400                      &total_interruption_duration,
401                      &freeze_count,
402                      &pause_count,
403                      &total_freezes_duration,
404                      &total_pauses_duration,
405                      &total_frames_duration,
406                      &sum_squared_frame_durations)
407 // clang-format on
408 
RTCMediaStreamTrackStats(const std::string & id,int64_t timestamp_us,const char * kind)409 RTCMediaStreamTrackStats::RTCMediaStreamTrackStats(const std::string& id,
410                                                    int64_t timestamp_us,
411                                                    const char* kind)
412     : RTCMediaStreamTrackStats(std::string(id), timestamp_us, kind) {}
413 
RTCMediaStreamTrackStats(std::string && id,int64_t timestamp_us,const char * kind)414 RTCMediaStreamTrackStats::RTCMediaStreamTrackStats(std::string&& id,
415                                                    int64_t timestamp_us,
416                                                    const char* kind)
417     : RTCStats(std::move(id), timestamp_us),
418       track_identifier("trackIdentifier"),
419       media_source_id("mediaSourceId"),
420       remote_source("remoteSource"),
421       ended("ended"),
422       detached("detached"),
423       kind("kind", kind),
424       jitter_buffer_delay("jitterBufferDelay"),
425       jitter_buffer_emitted_count("jitterBufferEmittedCount"),
426       frame_width("frameWidth"),
427       frame_height("frameHeight"),
428       frames_per_second("framesPerSecond"),
429       frames_sent("framesSent"),
430       huge_frames_sent("hugeFramesSent"),
431       frames_received("framesReceived"),
432       frames_decoded("framesDecoded"),
433       frames_dropped("framesDropped"),
434       frames_corrupted("framesCorrupted"),
435       partial_frames_lost("partialFramesLost"),
436       full_frames_lost("fullFramesLost"),
437       audio_level("audioLevel"),
438       total_audio_energy("totalAudioEnergy"),
439       echo_return_loss("echoReturnLoss"),
440       echo_return_loss_enhancement("echoReturnLossEnhancement"),
441       total_samples_received("totalSamplesReceived"),
442       total_samples_duration("totalSamplesDuration"),
443       concealed_samples("concealedSamples"),
444       silent_concealed_samples("silentConcealedSamples"),
445       concealment_events("concealmentEvents"),
446       inserted_samples_for_deceleration("insertedSamplesForDeceleration"),
447       removed_samples_for_acceleration("removedSamplesForAcceleration"),
448       jitter_buffer_flushes(
449           "jitterBufferFlushes",
450           {NonStandardGroupId::kRtcAudioJitterBufferMaxPackets}),
451       delayed_packet_outage_samples(
452           "delayedPacketOutageSamples",
453           {NonStandardGroupId::kRtcAudioJitterBufferMaxPackets,
454            NonStandardGroupId::kRtcStatsRelativePacketArrivalDelay}),
455       relative_packet_arrival_delay(
456           "relativePacketArrivalDelay",
457           {NonStandardGroupId::kRtcStatsRelativePacketArrivalDelay}),
458       jitter_buffer_target_delay("jitterBufferTargetDelay"),
459       interruption_count("interruptionCount"),
460       total_interruption_duration("totalInterruptionDuration"),
461       freeze_count("freezeCount"),
462       pause_count("pauseCount"),
463       total_freezes_duration("totalFreezesDuration"),
464       total_pauses_duration("totalPausesDuration"),
465       total_frames_duration("totalFramesDuration"),
466       sum_squared_frame_durations("sumOfSquaredFramesDuration") {
467   RTC_DCHECK(kind == RTCMediaStreamTrackKind::kAudio ||
468              kind == RTCMediaStreamTrackKind::kVideo);
469 }
470 
RTCMediaStreamTrackStats(const RTCMediaStreamTrackStats & other)471 RTCMediaStreamTrackStats::RTCMediaStreamTrackStats(
472     const RTCMediaStreamTrackStats& other)
473     : RTCStats(other.id(), other.timestamp_us()),
474       track_identifier(other.track_identifier),
475       media_source_id(other.media_source_id),
476       remote_source(other.remote_source),
477       ended(other.ended),
478       detached(other.detached),
479       kind(other.kind),
480       jitter_buffer_delay(other.jitter_buffer_delay),
481       jitter_buffer_emitted_count(other.jitter_buffer_emitted_count),
482       frame_width(other.frame_width),
483       frame_height(other.frame_height),
484       frames_per_second(other.frames_per_second),
485       frames_sent(other.frames_sent),
486       huge_frames_sent(other.huge_frames_sent),
487       frames_received(other.frames_received),
488       frames_decoded(other.frames_decoded),
489       frames_dropped(other.frames_dropped),
490       frames_corrupted(other.frames_corrupted),
491       partial_frames_lost(other.partial_frames_lost),
492       full_frames_lost(other.full_frames_lost),
493       audio_level(other.audio_level),
494       total_audio_energy(other.total_audio_energy),
495       echo_return_loss(other.echo_return_loss),
496       echo_return_loss_enhancement(other.echo_return_loss_enhancement),
497       total_samples_received(other.total_samples_received),
498       total_samples_duration(other.total_samples_duration),
499       concealed_samples(other.concealed_samples),
500       silent_concealed_samples(other.silent_concealed_samples),
501       concealment_events(other.concealment_events),
502       inserted_samples_for_deceleration(
503           other.inserted_samples_for_deceleration),
504       removed_samples_for_acceleration(other.removed_samples_for_acceleration),
505       jitter_buffer_flushes(other.jitter_buffer_flushes),
506       delayed_packet_outage_samples(other.delayed_packet_outage_samples),
507       relative_packet_arrival_delay(other.relative_packet_arrival_delay),
508       jitter_buffer_target_delay(other.jitter_buffer_target_delay),
509       interruption_count(other.interruption_count),
510       total_interruption_duration(other.total_interruption_duration),
511       freeze_count(other.freeze_count),
512       pause_count(other.pause_count),
513       total_freezes_duration(other.total_freezes_duration),
514       total_pauses_duration(other.total_pauses_duration),
515       total_frames_duration(other.total_frames_duration),
516       sum_squared_frame_durations(other.sum_squared_frame_durations) {}
517 
~RTCMediaStreamTrackStats()518 RTCMediaStreamTrackStats::~RTCMediaStreamTrackStats() {}
519 
520 // clang-format off
521 WEBRTC_RTCSTATS_IMPL(RTCPeerConnectionStats, RTCStats, "peer-connection",
522     &data_channels_opened,
523     &data_channels_closed)
524 // clang-format on
525 
RTCPeerConnectionStats(const std::string & id,int64_t timestamp_us)526 RTCPeerConnectionStats::RTCPeerConnectionStats(const std::string& id,
527                                                int64_t timestamp_us)
528     : RTCPeerConnectionStats(std::string(id), timestamp_us) {}
529 
RTCPeerConnectionStats(std::string && id,int64_t timestamp_us)530 RTCPeerConnectionStats::RTCPeerConnectionStats(std::string&& id,
531                                                int64_t timestamp_us)
532     : RTCStats(std::move(id), timestamp_us),
533       data_channels_opened("dataChannelsOpened"),
534       data_channels_closed("dataChannelsClosed") {}
535 
RTCPeerConnectionStats(const RTCPeerConnectionStats & other)536 RTCPeerConnectionStats::RTCPeerConnectionStats(
537     const RTCPeerConnectionStats& other)
538     : RTCStats(other.id(), other.timestamp_us()),
539       data_channels_opened(other.data_channels_opened),
540       data_channels_closed(other.data_channels_closed) {}
541 
~RTCPeerConnectionStats()542 RTCPeerConnectionStats::~RTCPeerConnectionStats() {}
543 
544 // clang-format off
545 WEBRTC_RTCSTATS_IMPL(RTCRTPStreamStats, RTCStats, "rtp",
546     &ssrc,
547     &is_remote,
548     &media_type,
549     &kind,
550     &track_id,
551     &transport_id,
552     &codec_id,
553     &fir_count,
554     &pli_count,
555     &nack_count,
556     &sli_count,
557     &qp_sum)
558 // clang-format on
559 
RTCRTPStreamStats(const std::string & id,int64_t timestamp_us)560 RTCRTPStreamStats::RTCRTPStreamStats(const std::string& id,
561                                      int64_t timestamp_us)
562     : RTCRTPStreamStats(std::string(id), timestamp_us) {}
563 
RTCRTPStreamStats(std::string && id,int64_t timestamp_us)564 RTCRTPStreamStats::RTCRTPStreamStats(std::string&& id, int64_t timestamp_us)
565     : RTCStats(std::move(id), timestamp_us),
566       ssrc("ssrc"),
567       is_remote("isRemote", false),
568       media_type("mediaType"),
569       kind("kind"),
570       track_id("trackId"),
571       transport_id("transportId"),
572       codec_id("codecId"),
573       fir_count("firCount"),
574       pli_count("pliCount"),
575       nack_count("nackCount"),
576       sli_count("sliCount"),
577       qp_sum("qpSum") {}
578 
RTCRTPStreamStats(const RTCRTPStreamStats & other)579 RTCRTPStreamStats::RTCRTPStreamStats(const RTCRTPStreamStats& other)
580     : RTCStats(other.id(), other.timestamp_us()),
581       ssrc(other.ssrc),
582       is_remote(other.is_remote),
583       media_type(other.media_type),
584       kind(other.kind),
585       track_id(other.track_id),
586       transport_id(other.transport_id),
587       codec_id(other.codec_id),
588       fir_count(other.fir_count),
589       pli_count(other.pli_count),
590       nack_count(other.nack_count),
591       sli_count(other.sli_count),
592       qp_sum(other.qp_sum) {}
593 
~RTCRTPStreamStats()594 RTCRTPStreamStats::~RTCRTPStreamStats() {}
595 
596 // clang-format off
597 WEBRTC_RTCSTATS_IMPL(
598     RTCInboundRTPStreamStats, RTCRTPStreamStats, "inbound-rtp",
599     &packets_received,
600     &fec_packets_received,
601     &fec_packets_discarded,
602     &bytes_received,
603     &header_bytes_received,
604     &packets_lost,
605     &last_packet_received_timestamp,
606     &jitter,
607     &jitter_buffer_delay,
608     &jitter_buffer_emitted_count,
609     &total_samples_received,
610     &concealed_samples,
611     &silent_concealed_samples,
612     &concealment_events,
613     &inserted_samples_for_deceleration,
614     &removed_samples_for_acceleration,
615     &audio_level,
616     &total_audio_energy,
617     &total_samples_duration,
618     &frames_received,
619     &round_trip_time,
620     &packets_discarded,
621     &packets_repaired,
622     &burst_packets_lost,
623     &burst_packets_discarded,
624     &burst_loss_count,
625     &burst_discard_count,
626     &burst_loss_rate,
627     &burst_discard_rate,
628     &gap_loss_rate,
629     &gap_discard_rate,
630     &frame_width,
631     &frame_height,
632     &frame_bit_depth,
633     &frames_per_second,
634     &frames_decoded,
635     &key_frames_decoded,
636     &frames_dropped,
637     &total_decode_time,
638     &total_inter_frame_delay,
639     &total_squared_inter_frame_delay,
640     &content_type,
641     &estimated_playout_timestamp,
642     &decoder_implementation)
643 // clang-format on
644 
RTCInboundRTPStreamStats(const std::string & id,int64_t timestamp_us)645 RTCInboundRTPStreamStats::RTCInboundRTPStreamStats(const std::string& id,
646                                                    int64_t timestamp_us)
647     : RTCInboundRTPStreamStats(std::string(id), timestamp_us) {}
648 
RTCInboundRTPStreamStats(std::string && id,int64_t timestamp_us)649 RTCInboundRTPStreamStats::RTCInboundRTPStreamStats(std::string&& id,
650                                                    int64_t timestamp_us)
651     : RTCRTPStreamStats(std::move(id), timestamp_us),
652       packets_received("packetsReceived"),
653       fec_packets_received("fecPacketsReceived"),
654       fec_packets_discarded("fecPacketsDiscarded"),
655       bytes_received("bytesReceived"),
656       header_bytes_received("headerBytesReceived"),
657       packets_lost("packetsLost"),
658       last_packet_received_timestamp("lastPacketReceivedTimestamp"),
659       jitter("jitter"),
660       jitter_buffer_delay("jitterBufferDelay"),
661       jitter_buffer_emitted_count("jitterBufferEmittedCount"),
662       total_samples_received("totalSamplesReceived"),
663       concealed_samples("concealedSamples"),
664       silent_concealed_samples("silentConcealedSamples"),
665       concealment_events("concealmentEvents"),
666       inserted_samples_for_deceleration("insertedSamplesForDeceleration"),
667       removed_samples_for_acceleration("removedSamplesForAcceleration"),
668       audio_level("audioLevel"),
669       total_audio_energy("totalAudioEnergy"),
670       total_samples_duration("totalSamplesDuration"),
671       frames_received("framesReceived"),
672       round_trip_time("roundTripTime"),
673       packets_discarded("packetsDiscarded"),
674       packets_repaired("packetsRepaired"),
675       burst_packets_lost("burstPacketsLost"),
676       burst_packets_discarded("burstPacketsDiscarded"),
677       burst_loss_count("burstLossCount"),
678       burst_discard_count("burstDiscardCount"),
679       burst_loss_rate("burstLossRate"),
680       burst_discard_rate("burstDiscardRate"),
681       gap_loss_rate("gapLossRate"),
682       gap_discard_rate("gapDiscardRate"),
683       frame_width("frameWidth"),
684       frame_height("frameHeight"),
685       frame_bit_depth("frameBitDepth"),
686       frames_per_second("framesPerSecond"),
687       frames_decoded("framesDecoded"),
688       key_frames_decoded("keyFramesDecoded"),
689       frames_dropped("framesDropped"),
690       total_decode_time("totalDecodeTime"),
691       total_inter_frame_delay("totalInterFrameDelay"),
692       total_squared_inter_frame_delay("totalSquaredInterFrameDelay"),
693       content_type("contentType"),
694       estimated_playout_timestamp("estimatedPlayoutTimestamp"),
695       decoder_implementation("decoderImplementation") {}
696 
RTCInboundRTPStreamStats(const RTCInboundRTPStreamStats & other)697 RTCInboundRTPStreamStats::RTCInboundRTPStreamStats(
698     const RTCInboundRTPStreamStats& other)
699     : RTCRTPStreamStats(other),
700       packets_received(other.packets_received),
701       fec_packets_received(other.fec_packets_received),
702       fec_packets_discarded(other.fec_packets_discarded),
703       bytes_received(other.bytes_received),
704       header_bytes_received(other.header_bytes_received),
705       packets_lost(other.packets_lost),
706       last_packet_received_timestamp(other.last_packet_received_timestamp),
707       jitter(other.jitter),
708       jitter_buffer_delay(other.jitter_buffer_delay),
709       jitter_buffer_emitted_count(other.jitter_buffer_emitted_count),
710       total_samples_received(other.total_samples_received),
711       concealed_samples(other.concealed_samples),
712       silent_concealed_samples(other.silent_concealed_samples),
713       concealment_events(other.concealment_events),
714       inserted_samples_for_deceleration(
715           other.inserted_samples_for_deceleration),
716       removed_samples_for_acceleration(other.removed_samples_for_acceleration),
717       audio_level(other.audio_level),
718       total_audio_energy(other.total_audio_energy),
719       total_samples_duration(other.total_samples_duration),
720       frames_received(other.frames_received),
721       round_trip_time(other.round_trip_time),
722       packets_discarded(other.packets_discarded),
723       packets_repaired(other.packets_repaired),
724       burst_packets_lost(other.burst_packets_lost),
725       burst_packets_discarded(other.burst_packets_discarded),
726       burst_loss_count(other.burst_loss_count),
727       burst_discard_count(other.burst_discard_count),
728       burst_loss_rate(other.burst_loss_rate),
729       burst_discard_rate(other.burst_discard_rate),
730       gap_loss_rate(other.gap_loss_rate),
731       gap_discard_rate(other.gap_discard_rate),
732       frame_width(other.frame_width),
733       frame_height(other.frame_height),
734       frame_bit_depth(other.frame_bit_depth),
735       frames_per_second(other.frames_per_second),
736       frames_decoded(other.frames_decoded),
737       key_frames_decoded(other.key_frames_decoded),
738       frames_dropped(other.frames_dropped),
739       total_decode_time(other.total_decode_time),
740       total_inter_frame_delay(other.total_inter_frame_delay),
741       total_squared_inter_frame_delay(other.total_squared_inter_frame_delay),
742       content_type(other.content_type),
743       estimated_playout_timestamp(other.estimated_playout_timestamp),
744       decoder_implementation(other.decoder_implementation) {}
745 
~RTCInboundRTPStreamStats()746 RTCInboundRTPStreamStats::~RTCInboundRTPStreamStats() {}
747 
748 // clang-format off
749 WEBRTC_RTCSTATS_IMPL(
750     RTCOutboundRTPStreamStats, RTCRTPStreamStats, "outbound-rtp",
751     &media_source_id,
752     &remote_id,
753     &rid,
754     &packets_sent,
755     &retransmitted_packets_sent,
756     &bytes_sent,
757     &header_bytes_sent,
758     &retransmitted_bytes_sent,
759     &target_bitrate,
760     &frames_encoded,
761     &key_frames_encoded,
762     &total_encode_time,
763     &total_encoded_bytes_target,
764     &frame_width,
765     &frame_height,
766     &frames_per_second,
767     &frames_sent,
768     &huge_frames_sent,
769     &total_packet_send_delay,
770     &quality_limitation_reason,
771     &quality_limitation_resolution_changes,
772     &content_type,
773     &encoder_implementation)
774 // clang-format on
775 
RTCOutboundRTPStreamStats(const std::string & id,int64_t timestamp_us)776 RTCOutboundRTPStreamStats::RTCOutboundRTPStreamStats(const std::string& id,
777                                                      int64_t timestamp_us)
778     : RTCOutboundRTPStreamStats(std::string(id), timestamp_us) {}
779 
RTCOutboundRTPStreamStats(std::string && id,int64_t timestamp_us)780 RTCOutboundRTPStreamStats::RTCOutboundRTPStreamStats(std::string&& id,
781                                                      int64_t timestamp_us)
782     : RTCRTPStreamStats(std::move(id), timestamp_us),
783       media_source_id("mediaSourceId"),
784       remote_id("remoteId"),
785       rid("rid"),
786       packets_sent("packetsSent"),
787       retransmitted_packets_sent("retransmittedPacketsSent"),
788       bytes_sent("bytesSent"),
789       header_bytes_sent("headerBytesSent"),
790       retransmitted_bytes_sent("retransmittedBytesSent"),
791       target_bitrate("targetBitrate"),
792       frames_encoded("framesEncoded"),
793       key_frames_encoded("keyFramesEncoded"),
794       total_encode_time("totalEncodeTime"),
795       total_encoded_bytes_target("totalEncodedBytesTarget"),
796       frame_width("frameWidth"),
797       frame_height("frameHeight"),
798       frames_per_second("framesPerSecond"),
799       frames_sent("framesSent"),
800       huge_frames_sent("hugeFramesSent"),
801       total_packet_send_delay("totalPacketSendDelay"),
802       quality_limitation_reason("qualityLimitationReason"),
803       quality_limitation_resolution_changes(
804           "qualityLimitationResolutionChanges"),
805       content_type("contentType"),
806       encoder_implementation("encoderImplementation") {}
807 
RTCOutboundRTPStreamStats(const RTCOutboundRTPStreamStats & other)808 RTCOutboundRTPStreamStats::RTCOutboundRTPStreamStats(
809     const RTCOutboundRTPStreamStats& other)
810     : RTCRTPStreamStats(other),
811       media_source_id(other.media_source_id),
812       remote_id(other.remote_id),
813       rid(other.rid),
814       packets_sent(other.packets_sent),
815       retransmitted_packets_sent(other.retransmitted_packets_sent),
816       bytes_sent(other.bytes_sent),
817       header_bytes_sent(other.header_bytes_sent),
818       retransmitted_bytes_sent(other.retransmitted_bytes_sent),
819       target_bitrate(other.target_bitrate),
820       frames_encoded(other.frames_encoded),
821       key_frames_encoded(other.key_frames_encoded),
822       total_encode_time(other.total_encode_time),
823       total_encoded_bytes_target(other.total_encoded_bytes_target),
824       frame_width(other.frame_width),
825       frame_height(other.frame_height),
826       frames_per_second(other.frames_per_second),
827       frames_sent(other.frames_sent),
828       huge_frames_sent(other.huge_frames_sent),
829       total_packet_send_delay(other.total_packet_send_delay),
830       quality_limitation_reason(other.quality_limitation_reason),
831       quality_limitation_resolution_changes(
832           other.quality_limitation_resolution_changes),
833       content_type(other.content_type),
834       encoder_implementation(other.encoder_implementation) {}
835 
~RTCOutboundRTPStreamStats()836 RTCOutboundRTPStreamStats::~RTCOutboundRTPStreamStats() {}
837 
838 // clang-format off
839 WEBRTC_RTCSTATS_IMPL(
840     RTCRemoteInboundRtpStreamStats, RTCStats, "remote-inbound-rtp",
841     &ssrc,
842     &kind,
843     &transport_id,
844     &codec_id,
845     &packets_lost,
846     &jitter,
847     &local_id,
848     &round_trip_time)
849 // clang-format on
850 
RTCRemoteInboundRtpStreamStats(const std::string & id,int64_t timestamp_us)851 RTCRemoteInboundRtpStreamStats::RTCRemoteInboundRtpStreamStats(
852     const std::string& id,
853     int64_t timestamp_us)
854     : RTCRemoteInboundRtpStreamStats(std::string(id), timestamp_us) {}
855 
RTCRemoteInboundRtpStreamStats(std::string && id,int64_t timestamp_us)856 RTCRemoteInboundRtpStreamStats::RTCRemoteInboundRtpStreamStats(
857     std::string&& id,
858     int64_t timestamp_us)
859     : RTCStats(std::move(id), timestamp_us),
860       ssrc("ssrc"),
861       kind("kind"),
862       transport_id("transportId"),
863       codec_id("codecId"),
864       packets_lost("packetsLost"),
865       jitter("jitter"),
866       local_id("localId"),
867       round_trip_time("roundTripTime") {}
868 
RTCRemoteInboundRtpStreamStats(const RTCRemoteInboundRtpStreamStats & other)869 RTCRemoteInboundRtpStreamStats::RTCRemoteInboundRtpStreamStats(
870     const RTCRemoteInboundRtpStreamStats& other)
871     : RTCStats(other),
872       ssrc(other.ssrc),
873       kind(other.kind),
874       transport_id(other.transport_id),
875       codec_id(other.codec_id),
876       packets_lost(other.packets_lost),
877       jitter(other.jitter),
878       local_id(other.local_id),
879       round_trip_time(other.round_trip_time) {}
880 
~RTCRemoteInboundRtpStreamStats()881 RTCRemoteInboundRtpStreamStats::~RTCRemoteInboundRtpStreamStats() {}
882 
883 // clang-format off
884 WEBRTC_RTCSTATS_IMPL(RTCMediaSourceStats, RTCStats, "parent-media-source",
885     &track_identifier,
886     &kind)
887 // clang-format on
888 
RTCMediaSourceStats(const std::string & id,int64_t timestamp_us)889 RTCMediaSourceStats::RTCMediaSourceStats(const std::string& id,
890                                          int64_t timestamp_us)
891     : RTCMediaSourceStats(std::string(id), timestamp_us) {}
892 
RTCMediaSourceStats(std::string && id,int64_t timestamp_us)893 RTCMediaSourceStats::RTCMediaSourceStats(std::string&& id, int64_t timestamp_us)
894     : RTCStats(std::move(id), timestamp_us),
895       track_identifier("trackIdentifier"),
896       kind("kind") {}
897 
RTCMediaSourceStats(const RTCMediaSourceStats & other)898 RTCMediaSourceStats::RTCMediaSourceStats(const RTCMediaSourceStats& other)
899     : RTCStats(other.id(), other.timestamp_us()),
900       track_identifier(other.track_identifier),
901       kind(other.kind) {}
902 
~RTCMediaSourceStats()903 RTCMediaSourceStats::~RTCMediaSourceStats() {}
904 
905 // clang-format off
906 WEBRTC_RTCSTATS_IMPL(RTCAudioSourceStats, RTCMediaSourceStats, "media-source",
907     &audio_level,
908     &total_audio_energy,
909     &total_samples_duration)
910 // clang-format on
911 
RTCAudioSourceStats(const std::string & id,int64_t timestamp_us)912 RTCAudioSourceStats::RTCAudioSourceStats(const std::string& id,
913                                          int64_t timestamp_us)
914     : RTCAudioSourceStats(std::string(id), timestamp_us) {}
915 
RTCAudioSourceStats(std::string && id,int64_t timestamp_us)916 RTCAudioSourceStats::RTCAudioSourceStats(std::string&& id, int64_t timestamp_us)
917     : RTCMediaSourceStats(std::move(id), timestamp_us),
918       audio_level("audioLevel"),
919       total_audio_energy("totalAudioEnergy"),
920       total_samples_duration("totalSamplesDuration") {}
921 
RTCAudioSourceStats(const RTCAudioSourceStats & other)922 RTCAudioSourceStats::RTCAudioSourceStats(const RTCAudioSourceStats& other)
923     : RTCMediaSourceStats(other),
924       audio_level(other.audio_level),
925       total_audio_energy(other.total_audio_energy),
926       total_samples_duration(other.total_samples_duration) {}
927 
~RTCAudioSourceStats()928 RTCAudioSourceStats::~RTCAudioSourceStats() {}
929 
930 // clang-format off
931 WEBRTC_RTCSTATS_IMPL(RTCVideoSourceStats, RTCMediaSourceStats, "media-source",
932     &width,
933     &height,
934     &frames,
935     &frames_per_second)
936 // clang-format on
937 
RTCVideoSourceStats(const std::string & id,int64_t timestamp_us)938 RTCVideoSourceStats::RTCVideoSourceStats(const std::string& id,
939                                          int64_t timestamp_us)
940     : RTCVideoSourceStats(std::string(id), timestamp_us) {}
941 
RTCVideoSourceStats(std::string && id,int64_t timestamp_us)942 RTCVideoSourceStats::RTCVideoSourceStats(std::string&& id, int64_t timestamp_us)
943     : RTCMediaSourceStats(std::move(id), timestamp_us),
944       width("width"),
945       height("height"),
946       frames("frames"),
947       frames_per_second("framesPerSecond") {}
948 
RTCVideoSourceStats(const RTCVideoSourceStats & other)949 RTCVideoSourceStats::RTCVideoSourceStats(const RTCVideoSourceStats& other)
950     : RTCMediaSourceStats(other),
951       width(other.width),
952       height(other.height),
953       frames(other.frames),
954       frames_per_second(other.frames_per_second) {}
955 
~RTCVideoSourceStats()956 RTCVideoSourceStats::~RTCVideoSourceStats() {}
957 
958 // clang-format off
959 WEBRTC_RTCSTATS_IMPL(RTCTransportStats, RTCStats, "transport",
960     &bytes_sent,
961     &packets_sent,
962     &bytes_received,
963     &packets_received,
964     &rtcp_transport_stats_id,
965     &dtls_state,
966     &selected_candidate_pair_id,
967     &local_certificate_id,
968     &remote_certificate_id,
969     &tls_version,
970     &dtls_cipher,
971     &srtp_cipher,
972     &selected_candidate_pair_changes)
973 // clang-format on
974 
RTCTransportStats(const std::string & id,int64_t timestamp_us)975 RTCTransportStats::RTCTransportStats(const std::string& id,
976                                      int64_t timestamp_us)
977     : RTCTransportStats(std::string(id), timestamp_us) {}
978 
RTCTransportStats(std::string && id,int64_t timestamp_us)979 RTCTransportStats::RTCTransportStats(std::string&& id, int64_t timestamp_us)
980     : RTCStats(std::move(id), timestamp_us),
981       bytes_sent("bytesSent"),
982       packets_sent("packetsSent"),
983       bytes_received("bytesReceived"),
984       packets_received("packetsReceived"),
985       rtcp_transport_stats_id("rtcpTransportStatsId"),
986       dtls_state("dtlsState"),
987       selected_candidate_pair_id("selectedCandidatePairId"),
988       local_certificate_id("localCertificateId"),
989       remote_certificate_id("remoteCertificateId"),
990       tls_version("tlsVersion"),
991       dtls_cipher("dtlsCipher"),
992       srtp_cipher("srtpCipher"),
993       selected_candidate_pair_changes("selectedCandidatePairChanges") {}
994 
RTCTransportStats(const RTCTransportStats & other)995 RTCTransportStats::RTCTransportStats(const RTCTransportStats& other)
996     : RTCStats(other.id(), other.timestamp_us()),
997       bytes_sent(other.bytes_sent),
998       packets_sent(other.packets_sent),
999       bytes_received(other.bytes_received),
1000       packets_received(other.packets_received),
1001       rtcp_transport_stats_id(other.rtcp_transport_stats_id),
1002       dtls_state(other.dtls_state),
1003       selected_candidate_pair_id(other.selected_candidate_pair_id),
1004       local_certificate_id(other.local_certificate_id),
1005       remote_certificate_id(other.remote_certificate_id),
1006       tls_version(other.tls_version),
1007       dtls_cipher(other.dtls_cipher),
1008       srtp_cipher(other.srtp_cipher),
1009       selected_candidate_pair_changes(other.selected_candidate_pair_changes) {}
1010 
~RTCTransportStats()1011 RTCTransportStats::~RTCTransportStats() {}
1012 
1013 }  // namespace webrtc
1014