blob: 473a3f3334e79a23d7eb32617d812d4d8de55efa [file] [log] [blame]
hbosd565b732016-08-30 14:04:35 -07001/*
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
Mirko Bonadei92ea95e2017-09-15 06:47:31 +020011#include "api/stats/rtcstats_objects.h"
hbosd565b732016-08-30 14:04:35 -070012
Yves Gerey3e707812018-11-28 16:47:49 +010013#include <utility>
14
15#include "rtc_base/checks.h"
16
hbosd565b732016-08-30 14:04:35 -070017namespace webrtc {
18
agrieve26622d32017-08-08 10:48:15 -070019const char* const RTCDataChannelState::kConnecting = "connecting";
20const char* const RTCDataChannelState::kOpen = "open";
21const char* const RTCDataChannelState::kClosing = "closing";
22const char* const RTCDataChannelState::kClosed = "closed";
hboscc555c52016-10-18 12:48:31 -070023
agrieve26622d32017-08-08 10:48:15 -070024const char* const RTCStatsIceCandidatePairState::kFrozen = "frozen";
25const char* const RTCStatsIceCandidatePairState::kWaiting = "waiting";
26const char* const RTCStatsIceCandidatePairState::kInProgress = "in-progress";
27const char* const RTCStatsIceCandidatePairState::kFailed = "failed";
28const char* const RTCStatsIceCandidatePairState::kSucceeded = "succeeded";
hbosc47a0c32016-10-11 14:54:49 -070029
30// Strings defined in https://tools.ietf.org/html/rfc5245.
agrieve26622d32017-08-08 10:48:15 -070031const char* const RTCIceCandidateType::kHost = "host";
32const char* const RTCIceCandidateType::kSrflx = "srflx";
33const char* const RTCIceCandidateType::kPrflx = "prflx";
34const char* const RTCIceCandidateType::kRelay = "relay";
hbosab9f6e42016-10-07 02:18:47 -070035
agrieve26622d32017-08-08 10:48:15 -070036const char* const RTCDtlsTransportState::kNew = "new";
37const char* const RTCDtlsTransportState::kConnecting = "connecting";
38const char* const RTCDtlsTransportState::kConnected = "connected";
39const char* const RTCDtlsTransportState::kClosed = "closed";
40const char* const RTCDtlsTransportState::kFailed = "failed";
hbos7064d592017-01-16 07:38:02 -080041
agrieve26622d32017-08-08 10:48:15 -070042const char* const RTCMediaStreamTrackKind::kAudio = "audio";
43const char* const RTCMediaStreamTrackKind::kVideo = "video";
hbos160e4a72017-01-17 02:53:23 -080044
Gary Liu37e489c2017-11-21 10:49:36 -080045// https://w3c.github.io/webrtc-stats/#dom-rtcnetworktype
46const char* const RTCNetworkType::kBluetooth = "bluetooth";
47const char* const RTCNetworkType::kCellular = "cellular";
48const char* const RTCNetworkType::kEthernet = "ethernet";
49const char* const RTCNetworkType::kWifi = "wifi";
50const char* const RTCNetworkType::kWimax = "wimax";
51const char* const RTCNetworkType::kVpn = "vpn";
52const char* const RTCNetworkType::kUnknown = "unknown";
53
Steve Antond6a5cbd2017-08-18 09:40:25 -070054// clang-format off
hbos2fa7c672016-10-24 04:00:05 -070055WEBRTC_RTCSTATS_IMPL(RTCCertificateStats, RTCStats, "certificate",
56 &fingerprint,
57 &fingerprint_algorithm,
58 &base64_certificate,
59 &issuer_certificate_id);
Steve Antond6a5cbd2017-08-18 09:40:25 -070060// clang-format on
hbos2fa7c672016-10-24 04:00:05 -070061
Yves Gerey665174f2018-06-19 15:03:05 +020062RTCCertificateStats::RTCCertificateStats(const std::string& id,
63 int64_t timestamp_us)
64 : RTCCertificateStats(std::string(id), timestamp_us) {}
hbos2fa7c672016-10-24 04:00:05 -070065
Yves Gerey665174f2018-06-19 15:03:05 +020066RTCCertificateStats::RTCCertificateStats(std::string&& id, int64_t timestamp_us)
hbos2fa7c672016-10-24 04:00:05 -070067 : RTCStats(std::move(id), timestamp_us),
68 fingerprint("fingerprint"),
69 fingerprint_algorithm("fingerprintAlgorithm"),
70 base64_certificate("base64Certificate"),
Yves Gerey665174f2018-06-19 15:03:05 +020071 issuer_certificate_id("issuerCertificateId") {}
hbos2fa7c672016-10-24 04:00:05 -070072
Yves Gerey665174f2018-06-19 15:03:05 +020073RTCCertificateStats::RTCCertificateStats(const RTCCertificateStats& other)
hbos2fa7c672016-10-24 04:00:05 -070074 : RTCStats(other.id(), other.timestamp_us()),
75 fingerprint(other.fingerprint),
76 fingerprint_algorithm(other.fingerprint_algorithm),
77 base64_certificate(other.base64_certificate),
Yves Gerey665174f2018-06-19 15:03:05 +020078 issuer_certificate_id(other.issuer_certificate_id) {}
hbos2fa7c672016-10-24 04:00:05 -070079
Yves Gerey665174f2018-06-19 15:03:05 +020080RTCCertificateStats::~RTCCertificateStats() {}
hbos2fa7c672016-10-24 04:00:05 -070081
Steve Antond6a5cbd2017-08-18 09:40:25 -070082// clang-format off
hbos0adb8282016-11-23 02:32:06 -080083WEBRTC_RTCSTATS_IMPL(RTCCodecStats, RTCStats, "codec",
84 &payload_type,
hbos13f54b22017-02-28 06:56:04 -080085 &mime_type,
hbos0adb8282016-11-23 02:32:06 -080086 &clock_rate,
87 &channels,
hbos13f54b22017-02-28 06:56:04 -080088 &sdp_fmtp_line,
hbos0adb8282016-11-23 02:32:06 -080089 &implementation);
Steve Antond6a5cbd2017-08-18 09:40:25 -070090// clang-format on
hbos0adb8282016-11-23 02:32:06 -080091
Yves Gerey665174f2018-06-19 15:03:05 +020092RTCCodecStats::RTCCodecStats(const std::string& id, int64_t timestamp_us)
93 : RTCCodecStats(std::string(id), timestamp_us) {}
hbos0adb8282016-11-23 02:32:06 -080094
Yves Gerey665174f2018-06-19 15:03:05 +020095RTCCodecStats::RTCCodecStats(std::string&& id, int64_t timestamp_us)
hbos0adb8282016-11-23 02:32:06 -080096 : RTCStats(std::move(id), timestamp_us),
97 payload_type("payloadType"),
hbos13f54b22017-02-28 06:56:04 -080098 mime_type("mimeType"),
hbos0adb8282016-11-23 02:32:06 -080099 clock_rate("clockRate"),
100 channels("channels"),
hbos13f54b22017-02-28 06:56:04 -0800101 sdp_fmtp_line("sdpFmtpLine"),
Yves Gerey665174f2018-06-19 15:03:05 +0200102 implementation("implementation") {}
hbos0adb8282016-11-23 02:32:06 -0800103
Yves Gerey665174f2018-06-19 15:03:05 +0200104RTCCodecStats::RTCCodecStats(const RTCCodecStats& other)
hbos0adb8282016-11-23 02:32:06 -0800105 : RTCStats(other.id(), other.timestamp_us()),
106 payload_type(other.payload_type),
hbos13f54b22017-02-28 06:56:04 -0800107 mime_type(other.mime_type),
hbos0adb8282016-11-23 02:32:06 -0800108 clock_rate(other.clock_rate),
109 channels(other.channels),
hbos13f54b22017-02-28 06:56:04 -0800110 sdp_fmtp_line(other.sdp_fmtp_line),
Yves Gerey665174f2018-06-19 15:03:05 +0200111 implementation(other.implementation) {}
hbos0adb8282016-11-23 02:32:06 -0800112
Yves Gerey665174f2018-06-19 15:03:05 +0200113RTCCodecStats::~RTCCodecStats() {}
hbos0adb8282016-11-23 02:32:06 -0800114
Steve Antond6a5cbd2017-08-18 09:40:25 -0700115// clang-format off
hbos2fa7c672016-10-24 04:00:05 -0700116WEBRTC_RTCSTATS_IMPL(RTCDataChannelStats, RTCStats, "data-channel",
117 &label,
118 &protocol,
119 &datachannelid,
120 &state,
121 &messages_sent,
122 &bytes_sent,
123 &messages_received,
124 &bytes_received);
Steve Antond6a5cbd2017-08-18 09:40:25 -0700125// clang-format on
hbos2fa7c672016-10-24 04:00:05 -0700126
Yves Gerey665174f2018-06-19 15:03:05 +0200127RTCDataChannelStats::RTCDataChannelStats(const std::string& id,
128 int64_t timestamp_us)
129 : RTCDataChannelStats(std::string(id), timestamp_us) {}
hbos2fa7c672016-10-24 04:00:05 -0700130
Yves Gerey665174f2018-06-19 15:03:05 +0200131RTCDataChannelStats::RTCDataChannelStats(std::string&& id, int64_t timestamp_us)
hbos2fa7c672016-10-24 04:00:05 -0700132 : RTCStats(std::move(id), timestamp_us),
133 label("label"),
134 protocol("protocol"),
135 datachannelid("datachannelid"),
136 state("state"),
137 messages_sent("messagesSent"),
138 bytes_sent("bytesSent"),
139 messages_received("messagesReceived"),
Yves Gerey665174f2018-06-19 15:03:05 +0200140 bytes_received("bytesReceived") {}
hbos2fa7c672016-10-24 04:00:05 -0700141
Yves Gerey665174f2018-06-19 15:03:05 +0200142RTCDataChannelStats::RTCDataChannelStats(const RTCDataChannelStats& other)
hbos2fa7c672016-10-24 04:00:05 -0700143 : RTCStats(other.id(), other.timestamp_us()),
144 label(other.label),
145 protocol(other.protocol),
146 datachannelid(other.datachannelid),
147 state(other.state),
148 messages_sent(other.messages_sent),
149 bytes_sent(other.bytes_sent),
150 messages_received(other.messages_received),
Yves Gerey665174f2018-06-19 15:03:05 +0200151 bytes_received(other.bytes_received) {}
hbos2fa7c672016-10-24 04:00:05 -0700152
Yves Gerey665174f2018-06-19 15:03:05 +0200153RTCDataChannelStats::~RTCDataChannelStats() {}
hbos2fa7c672016-10-24 04:00:05 -0700154
Steve Antond6a5cbd2017-08-18 09:40:25 -0700155// clang-format off
hbosc47a0c32016-10-11 14:54:49 -0700156WEBRTC_RTCSTATS_IMPL(RTCIceCandidatePairStats, RTCStats, "candidate-pair",
157 &transport_id,
158 &local_candidate_id,
159 &remote_candidate_id,
160 &state,
161 &priority,
162 &nominated,
163 &writable,
164 &readable,
165 &bytes_sent,
166 &bytes_received,
hbos3168c7a2016-12-15 06:17:08 -0800167 &total_round_trip_time,
168 &current_round_trip_time,
hbosc47a0c32016-10-11 14:54:49 -0700169 &available_outgoing_bitrate,
170 &available_incoming_bitrate,
171 &requests_received,
172 &requests_sent,
173 &responses_received,
174 &responses_sent,
175 &retransmissions_received,
176 &retransmissions_sent,
177 &consent_requests_received,
178 &consent_requests_sent,
179 &consent_responses_received,
180 &consent_responses_sent);
Steve Antond6a5cbd2017-08-18 09:40:25 -0700181// clang-format on
hbosc47a0c32016-10-11 14:54:49 -0700182
Yves Gerey665174f2018-06-19 15:03:05 +0200183RTCIceCandidatePairStats::RTCIceCandidatePairStats(const std::string& id,
184 int64_t timestamp_us)
185 : RTCIceCandidatePairStats(std::string(id), timestamp_us) {}
hbosc47a0c32016-10-11 14:54:49 -0700186
Yves Gerey665174f2018-06-19 15:03:05 +0200187RTCIceCandidatePairStats::RTCIceCandidatePairStats(std::string&& id,
188 int64_t timestamp_us)
hbosc47a0c32016-10-11 14:54:49 -0700189 : RTCStats(std::move(id), timestamp_us),
190 transport_id("transportId"),
191 local_candidate_id("localCandidateId"),
192 remote_candidate_id("remoteCandidateId"),
193 state("state"),
194 priority("priority"),
195 nominated("nominated"),
196 writable("writable"),
197 readable("readable"),
198 bytes_sent("bytesSent"),
199 bytes_received("bytesReceived"),
hbos3168c7a2016-12-15 06:17:08 -0800200 total_round_trip_time("totalRoundTripTime"),
201 current_round_trip_time("currentRoundTripTime"),
hbosc47a0c32016-10-11 14:54:49 -0700202 available_outgoing_bitrate("availableOutgoingBitrate"),
203 available_incoming_bitrate("availableIncomingBitrate"),
204 requests_received("requestsReceived"),
205 requests_sent("requestsSent"),
206 responses_received("responsesReceived"),
207 responses_sent("responsesSent"),
208 retransmissions_received("retransmissionsReceived"),
209 retransmissions_sent("retransmissionsSent"),
210 consent_requests_received("consentRequestsReceived"),
211 consent_requests_sent("consentRequestsSent"),
212 consent_responses_received("consentResponsesReceived"),
Yves Gerey665174f2018-06-19 15:03:05 +0200213 consent_responses_sent("consentResponsesSent") {}
hbosc47a0c32016-10-11 14:54:49 -0700214
215RTCIceCandidatePairStats::RTCIceCandidatePairStats(
216 const RTCIceCandidatePairStats& other)
217 : RTCStats(other.id(), other.timestamp_us()),
218 transport_id(other.transport_id),
219 local_candidate_id(other.local_candidate_id),
220 remote_candidate_id(other.remote_candidate_id),
221 state(other.state),
222 priority(other.priority),
223 nominated(other.nominated),
224 writable(other.writable),
225 readable(other.readable),
226 bytes_sent(other.bytes_sent),
227 bytes_received(other.bytes_received),
hbos3168c7a2016-12-15 06:17:08 -0800228 total_round_trip_time(other.total_round_trip_time),
229 current_round_trip_time(other.current_round_trip_time),
hbosc47a0c32016-10-11 14:54:49 -0700230 available_outgoing_bitrate(other.available_outgoing_bitrate),
231 available_incoming_bitrate(other.available_incoming_bitrate),
232 requests_received(other.requests_received),
233 requests_sent(other.requests_sent),
234 responses_received(other.responses_received),
235 responses_sent(other.responses_sent),
236 retransmissions_received(other.retransmissions_received),
237 retransmissions_sent(other.retransmissions_sent),
238 consent_requests_received(other.consent_requests_received),
239 consent_requests_sent(other.consent_requests_sent),
240 consent_responses_received(other.consent_responses_received),
Yves Gerey665174f2018-06-19 15:03:05 +0200241 consent_responses_sent(other.consent_responses_sent) {}
hbosc47a0c32016-10-11 14:54:49 -0700242
Yves Gerey665174f2018-06-19 15:03:05 +0200243RTCIceCandidatePairStats::~RTCIceCandidatePairStats() {}
hbosc47a0c32016-10-11 14:54:49 -0700244
Steve Antond6a5cbd2017-08-18 09:40:25 -0700245// clang-format off
Henrik Boström1df1bf82018-03-20 13:24:20 +0100246WEBRTC_RTCSTATS_IMPL(RTCIceCandidateStats, RTCStats, "abstract-ice-candidate",
hbosb4e426e2017-01-02 09:59:31 -0800247 &transport_id,
hbosc3a2b7f2017-01-02 04:46:15 -0800248 &is_remote,
Gary Liu37e489c2017-11-21 10:49:36 -0800249 &network_type,
hbosab9f6e42016-10-07 02:18:47 -0700250 &ip,
251 &port,
252 &protocol,
Philipp Hancke95513752018-09-27 14:40:08 +0200253 &relay_protocol,
hbosab9f6e42016-10-07 02:18:47 -0700254 &candidate_type,
255 &priority,
hbosd17a5a72017-01-02 08:09:59 -0800256 &url,
257 &deleted);
Steve Antond6a5cbd2017-08-18 09:40:25 -0700258// clang-format on
hbosab9f6e42016-10-07 02:18:47 -0700259
Yves Gerey665174f2018-06-19 15:03:05 +0200260RTCIceCandidateStats::RTCIceCandidateStats(const std::string& id,
261 int64_t timestamp_us,
262 bool is_remote)
263 : RTCIceCandidateStats(std::string(id), timestamp_us, is_remote) {}
hbosab9f6e42016-10-07 02:18:47 -0700264
Gary Liu37e489c2017-11-21 10:49:36 -0800265RTCIceCandidateStats::RTCIceCandidateStats(std::string&& id,
266 int64_t timestamp_us,
267 bool is_remote)
hbosab9f6e42016-10-07 02:18:47 -0700268 : RTCStats(std::move(id), timestamp_us),
hbosb4e426e2017-01-02 09:59:31 -0800269 transport_id("transportId"),
hbosc3a2b7f2017-01-02 04:46:15 -0800270 is_remote("isRemote", is_remote),
Gary Liu37e489c2017-11-21 10:49:36 -0800271 network_type("networkType"),
hbosab9f6e42016-10-07 02:18:47 -0700272 ip("ip"),
273 port("port"),
274 protocol("protocol"),
Philipp Hancke95513752018-09-27 14:40:08 +0200275 relay_protocol("relayProtocol"),
hbosab9f6e42016-10-07 02:18:47 -0700276 candidate_type("candidateType"),
277 priority("priority"),
hbosd17a5a72017-01-02 08:09:59 -0800278 url("url"),
Gary Liu37e489c2017-11-21 10:49:36 -0800279 deleted("deleted", false) {}
hbosab9f6e42016-10-07 02:18:47 -0700280
281RTCIceCandidateStats::RTCIceCandidateStats(const RTCIceCandidateStats& other)
282 : RTCStats(other.id(), other.timestamp_us()),
hbosb4e426e2017-01-02 09:59:31 -0800283 transport_id(other.transport_id),
hbosc3a2b7f2017-01-02 04:46:15 -0800284 is_remote(other.is_remote),
Gary Liu37e489c2017-11-21 10:49:36 -0800285 network_type(other.network_type),
hbosab9f6e42016-10-07 02:18:47 -0700286 ip(other.ip),
287 port(other.port),
288 protocol(other.protocol),
Philipp Hancke95513752018-09-27 14:40:08 +0200289 relay_protocol(other.relay_protocol),
hbosab9f6e42016-10-07 02:18:47 -0700290 candidate_type(other.candidate_type),
291 priority(other.priority),
hbosd17a5a72017-01-02 08:09:59 -0800292 url(other.url),
Gary Liu37e489c2017-11-21 10:49:36 -0800293 deleted(other.deleted) {}
hbosab9f6e42016-10-07 02:18:47 -0700294
Yves Gerey665174f2018-06-19 15:03:05 +0200295RTCIceCandidateStats::~RTCIceCandidateStats() {}
hbosab9f6e42016-10-07 02:18:47 -0700296
297const char RTCLocalIceCandidateStats::kType[] = "local-candidate";
298
Yves Gerey665174f2018-06-19 15:03:05 +0200299RTCLocalIceCandidateStats::RTCLocalIceCandidateStats(const std::string& id,
300 int64_t timestamp_us)
301 : RTCIceCandidateStats(id, timestamp_us, false) {}
hbosab9f6e42016-10-07 02:18:47 -0700302
Yves Gerey665174f2018-06-19 15:03:05 +0200303RTCLocalIceCandidateStats::RTCLocalIceCandidateStats(std::string&& id,
304 int64_t timestamp_us)
305 : RTCIceCandidateStats(std::move(id), timestamp_us, false) {}
hbosab9f6e42016-10-07 02:18:47 -0700306
Henrik Boström1df1bf82018-03-20 13:24:20 +0100307std::unique_ptr<RTCStats> RTCLocalIceCandidateStats::copy() const {
308 return std::unique_ptr<RTCStats>(new RTCLocalIceCandidateStats(*this));
309}
310
hbosab9f6e42016-10-07 02:18:47 -0700311const char* RTCLocalIceCandidateStats::type() const {
312 return kType;
313}
314
315const char RTCRemoteIceCandidateStats::kType[] = "remote-candidate";
316
Yves Gerey665174f2018-06-19 15:03:05 +0200317RTCRemoteIceCandidateStats::RTCRemoteIceCandidateStats(const std::string& id,
318 int64_t timestamp_us)
319 : RTCIceCandidateStats(id, timestamp_us, true) {}
hbosab9f6e42016-10-07 02:18:47 -0700320
Yves Gerey665174f2018-06-19 15:03:05 +0200321RTCRemoteIceCandidateStats::RTCRemoteIceCandidateStats(std::string&& id,
322 int64_t timestamp_us)
323 : RTCIceCandidateStats(std::move(id), timestamp_us, true) {}
hbosab9f6e42016-10-07 02:18:47 -0700324
Henrik Boström1df1bf82018-03-20 13:24:20 +0100325std::unique_ptr<RTCStats> RTCRemoteIceCandidateStats::copy() const {
326 return std::unique_ptr<RTCStats>(new RTCRemoteIceCandidateStats(*this));
327}
328
hbosab9f6e42016-10-07 02:18:47 -0700329const char* RTCRemoteIceCandidateStats::type() const {
330 return kType;
331}
332
Steve Antond6a5cbd2017-08-18 09:40:25 -0700333// clang-format off
hbos09bc1282016-11-08 06:29:22 -0800334WEBRTC_RTCSTATS_IMPL(RTCMediaStreamStats, RTCStats, "stream",
335 &stream_identifier,
336 &track_ids);
Steve Antond6a5cbd2017-08-18 09:40:25 -0700337// clang-format on
hbos09bc1282016-11-08 06:29:22 -0800338
Yves Gerey665174f2018-06-19 15:03:05 +0200339RTCMediaStreamStats::RTCMediaStreamStats(const std::string& id,
340 int64_t timestamp_us)
341 : RTCMediaStreamStats(std::string(id), timestamp_us) {}
hbos09bc1282016-11-08 06:29:22 -0800342
Yves Gerey665174f2018-06-19 15:03:05 +0200343RTCMediaStreamStats::RTCMediaStreamStats(std::string&& id, int64_t timestamp_us)
hbos09bc1282016-11-08 06:29:22 -0800344 : RTCStats(std::move(id), timestamp_us),
345 stream_identifier("streamIdentifier"),
Yves Gerey665174f2018-06-19 15:03:05 +0200346 track_ids("trackIds") {}
hbos09bc1282016-11-08 06:29:22 -0800347
Yves Gerey665174f2018-06-19 15:03:05 +0200348RTCMediaStreamStats::RTCMediaStreamStats(const RTCMediaStreamStats& other)
hbos09bc1282016-11-08 06:29:22 -0800349 : RTCStats(other.id(), other.timestamp_us()),
350 stream_identifier(other.stream_identifier),
Yves Gerey665174f2018-06-19 15:03:05 +0200351 track_ids(other.track_ids) {}
hbos09bc1282016-11-08 06:29:22 -0800352
Yves Gerey665174f2018-06-19 15:03:05 +0200353RTCMediaStreamStats::~RTCMediaStreamStats() {}
hbos09bc1282016-11-08 06:29:22 -0800354
Steve Antond6a5cbd2017-08-18 09:40:25 -0700355// clang-format off
hbos09bc1282016-11-08 06:29:22 -0800356WEBRTC_RTCSTATS_IMPL(RTCMediaStreamTrackStats, RTCStats, "track",
zsteine76bd3a2017-07-14 12:17:49 -0700357 &track_identifier,
358 &remote_source,
359 &ended,
360 &detached,
361 &kind,
Gustaf Ullbergb0a02072017-10-02 12:00:34 +0200362 &jitter_buffer_delay,
Chen Xing0acffb52019-01-15 15:46:29 +0100363 &jitter_buffer_emitted_count,
zsteine76bd3a2017-07-14 12:17:49 -0700364 &frame_width,
365 &frame_height,
366 &frames_per_second,
367 &frames_sent,
Ilya Nikolaevskiy70473fc2018-02-28 16:35:03 +0100368 &huge_frames_sent,
zsteine76bd3a2017-07-14 12:17:49 -0700369 &frames_received,
370 &frames_decoded,
371 &frames_dropped,
372 &frames_corrupted,
373 &partial_frames_lost,
374 &full_frames_lost,
375 &audio_level,
376 &total_audio_energy,
zsteine76bd3a2017-07-14 12:17:49 -0700377 &echo_return_loss,
Steve Anton2dbc69f2017-08-24 17:15:13 -0700378 &echo_return_loss_enhancement,
379 &total_samples_received,
380 &total_samples_duration,
Gustaf Ullberg9a2e9062017-09-18 09:28:20 +0200381 &concealed_samples,
Ruslan Burakov8af88962018-11-22 17:21:10 +0100382 &concealment_events,
Jakob Ivarsson352ce5c2018-11-27 12:52:16 +0100383 &jitter_buffer_flushes,
Sergey Silkin02371062019-01-31 16:45:42 +0100384 &delayed_packet_outage_samples,
385 &freeze_count,
386 &pause_count,
387 &total_freezes_duration,
388 &total_pauses_duration,
389 &total_frames_duration,
390 &sum_squared_frame_durations);
Steve Antond6a5cbd2017-08-18 09:40:25 -0700391// clang-format on
hbos09bc1282016-11-08 06:29:22 -0800392
Yves Gerey665174f2018-06-19 15:03:05 +0200393RTCMediaStreamTrackStats::RTCMediaStreamTrackStats(const std::string& id,
394 int64_t timestamp_us,
395 const char* kind)
396 : RTCMediaStreamTrackStats(std::string(id), timestamp_us, kind) {}
hbos09bc1282016-11-08 06:29:22 -0800397
zsteine76bd3a2017-07-14 12:17:49 -0700398RTCMediaStreamTrackStats::RTCMediaStreamTrackStats(std::string&& id,
399 int64_t timestamp_us,
400 const char* kind)
hbos09bc1282016-11-08 06:29:22 -0800401 : RTCStats(std::move(id), timestamp_us),
402 track_identifier("trackIdentifier"),
403 remote_source("remoteSource"),
404 ended("ended"),
405 detached("detached"),
hbos160e4a72017-01-17 02:53:23 -0800406 kind("kind", kind),
Gustaf Ullbergb0a02072017-10-02 12:00:34 +0200407 jitter_buffer_delay("jitterBufferDelay"),
Chen Xing0acffb52019-01-15 15:46:29 +0100408 jitter_buffer_emitted_count("jitterBufferEmittedCount"),
hbos09bc1282016-11-08 06:29:22 -0800409 frame_width("frameWidth"),
410 frame_height("frameHeight"),
411 frames_per_second("framesPerSecond"),
412 frames_sent("framesSent"),
Ilya Nikolaevskiy70473fc2018-02-28 16:35:03 +0100413 huge_frames_sent("hugeFramesSent"),
hbos09bc1282016-11-08 06:29:22 -0800414 frames_received("framesReceived"),
415 frames_decoded("framesDecoded"),
416 frames_dropped("framesDropped"),
417 frames_corrupted("framesCorrupted"),
418 partial_frames_lost("partialFramesLost"),
419 full_frames_lost("fullFramesLost"),
420 audio_level("audioLevel"),
zsteine76bd3a2017-07-14 12:17:49 -0700421 total_audio_energy("totalAudioEnergy"),
hbos09bc1282016-11-08 06:29:22 -0800422 echo_return_loss("echoReturnLoss"),
Steve Anton2dbc69f2017-08-24 17:15:13 -0700423 echo_return_loss_enhancement("echoReturnLossEnhancement"),
424 total_samples_received("totalSamplesReceived"),
425 total_samples_duration("totalSamplesDuration"),
Gustaf Ullberg9a2e9062017-09-18 09:28:20 +0200426 concealed_samples("concealedSamples"),
Ruslan Burakov8af88962018-11-22 17:21:10 +0100427 concealment_events("concealmentEvents"),
Jakob Ivarsson352ce5c2018-11-27 12:52:16 +0100428 jitter_buffer_flushes("jitterBufferFlushes"),
Sergey Silkin02371062019-01-31 16:45:42 +0100429 delayed_packet_outage_samples("delayedPacketOutageSamples"),
430 freeze_count("freezeCount"),
431 pause_count("pauseCount"),
432 total_freezes_duration("totalFreezesDuration"),
433 total_pauses_duration("totalPausesDuration"),
434 total_frames_duration("totalFramesDuration"),
435 sum_squared_frame_durations("sumOfSquaredFramesDuration") {
hbos160e4a72017-01-17 02:53:23 -0800436 RTC_DCHECK(kind == RTCMediaStreamTrackKind::kAudio ||
437 kind == RTCMediaStreamTrackKind::kVideo);
hbos09bc1282016-11-08 06:29:22 -0800438}
439
440RTCMediaStreamTrackStats::RTCMediaStreamTrackStats(
441 const RTCMediaStreamTrackStats& other)
442 : RTCStats(other.id(), other.timestamp_us()),
443 track_identifier(other.track_identifier),
444 remote_source(other.remote_source),
445 ended(other.ended),
446 detached(other.detached),
hbos160e4a72017-01-17 02:53:23 -0800447 kind(other.kind),
Gustaf Ullbergb0a02072017-10-02 12:00:34 +0200448 jitter_buffer_delay(other.jitter_buffer_delay),
Chen Xing0acffb52019-01-15 15:46:29 +0100449 jitter_buffer_emitted_count(other.jitter_buffer_emitted_count),
hbos09bc1282016-11-08 06:29:22 -0800450 frame_width(other.frame_width),
451 frame_height(other.frame_height),
452 frames_per_second(other.frames_per_second),
453 frames_sent(other.frames_sent),
Ilya Nikolaevskiy70473fc2018-02-28 16:35:03 +0100454 huge_frames_sent(other.huge_frames_sent),
hbos09bc1282016-11-08 06:29:22 -0800455 frames_received(other.frames_received),
456 frames_decoded(other.frames_decoded),
457 frames_dropped(other.frames_dropped),
458 frames_corrupted(other.frames_corrupted),
459 partial_frames_lost(other.partial_frames_lost),
460 full_frames_lost(other.full_frames_lost),
461 audio_level(other.audio_level),
zsteine76bd3a2017-07-14 12:17:49 -0700462 total_audio_energy(other.total_audio_energy),
hbos09bc1282016-11-08 06:29:22 -0800463 echo_return_loss(other.echo_return_loss),
Steve Anton2dbc69f2017-08-24 17:15:13 -0700464 echo_return_loss_enhancement(other.echo_return_loss_enhancement),
465 total_samples_received(other.total_samples_received),
466 total_samples_duration(other.total_samples_duration),
Gustaf Ullberg9a2e9062017-09-18 09:28:20 +0200467 concealed_samples(other.concealed_samples),
Ruslan Burakov8af88962018-11-22 17:21:10 +0100468 concealment_events(other.concealment_events),
Jakob Ivarsson352ce5c2018-11-27 12:52:16 +0100469 jitter_buffer_flushes(other.jitter_buffer_flushes),
Sergey Silkin02371062019-01-31 16:45:42 +0100470 delayed_packet_outage_samples(other.delayed_packet_outage_samples),
471 freeze_count(other.freeze_count),
472 pause_count(other.pause_count),
473 total_freezes_duration(other.total_freezes_duration),
474 total_pauses_duration(other.total_pauses_duration),
475 total_frames_duration(other.total_frames_duration),
476 sum_squared_frame_durations(other.sum_squared_frame_durations) {}
hbos09bc1282016-11-08 06:29:22 -0800477
Yves Gerey665174f2018-06-19 15:03:05 +0200478RTCMediaStreamTrackStats::~RTCMediaStreamTrackStats() {}
hbos09bc1282016-11-08 06:29:22 -0800479
Steve Antond6a5cbd2017-08-18 09:40:25 -0700480// clang-format off
hbosfc5e0502016-10-06 02:06:10 -0700481WEBRTC_RTCSTATS_IMPL(RTCPeerConnectionStats, RTCStats, "peer-connection",
482 &data_channels_opened,
483 &data_channels_closed);
Steve Antond6a5cbd2017-08-18 09:40:25 -0700484// clang-format on
hbosd565b732016-08-30 14:04:35 -0700485
Yves Gerey665174f2018-06-19 15:03:05 +0200486RTCPeerConnectionStats::RTCPeerConnectionStats(const std::string& id,
487 int64_t timestamp_us)
488 : RTCPeerConnectionStats(std::string(id), timestamp_us) {}
hbosd565b732016-08-30 14:04:35 -0700489
Yves Gerey665174f2018-06-19 15:03:05 +0200490RTCPeerConnectionStats::RTCPeerConnectionStats(std::string&& id,
491 int64_t timestamp_us)
hbos0e6758d2016-08-31 07:57:36 -0700492 : RTCStats(std::move(id), timestamp_us),
hbosd565b732016-08-30 14:04:35 -0700493 data_channels_opened("dataChannelsOpened"),
Yves Gerey665174f2018-06-19 15:03:05 +0200494 data_channels_closed("dataChannelsClosed") {}
hbosd565b732016-08-30 14:04:35 -0700495
hbosfc5e0502016-10-06 02:06:10 -0700496RTCPeerConnectionStats::RTCPeerConnectionStats(
497 const RTCPeerConnectionStats& other)
498 : RTCStats(other.id(), other.timestamp_us()),
499 data_channels_opened(other.data_channels_opened),
Yves Gerey665174f2018-06-19 15:03:05 +0200500 data_channels_closed(other.data_channels_closed) {}
hbosfc5e0502016-10-06 02:06:10 -0700501
Yves Gerey665174f2018-06-19 15:03:05 +0200502RTCPeerConnectionStats::~RTCPeerConnectionStats() {}
hbosfc5e0502016-10-06 02:06:10 -0700503
Steve Antond6a5cbd2017-08-18 09:40:25 -0700504// clang-format off
hbos6ded1902016-11-01 01:50:46 -0700505WEBRTC_RTCSTATS_IMPL(RTCRTPStreamStats, RTCStats, "rtp",
506 &ssrc,
507 &associate_stats_id,
508 &is_remote,
509 &media_type,
Philipp Hancke3bc01662018-08-28 14:55:03 +0200510 &kind,
hbosb0ae9202017-01-27 06:35:16 -0800511 &track_id,
hbos6ded1902016-11-01 01:50:46 -0700512 &transport_id,
513 &codec_id,
514 &fir_count,
515 &pli_count,
516 &nack_count,
hbos6769c492017-01-02 08:35:13 -0800517 &sli_count,
518 &qp_sum);
Steve Antond6a5cbd2017-08-18 09:40:25 -0700519// clang-format on
hbos6ded1902016-11-01 01:50:46 -0700520
Yves Gerey665174f2018-06-19 15:03:05 +0200521RTCRTPStreamStats::RTCRTPStreamStats(const std::string& id,
522 int64_t timestamp_us)
523 : RTCRTPStreamStats(std::string(id), timestamp_us) {}
hbos6ded1902016-11-01 01:50:46 -0700524
Yves Gerey665174f2018-06-19 15:03:05 +0200525RTCRTPStreamStats::RTCRTPStreamStats(std::string&& id, int64_t timestamp_us)
hbos6ded1902016-11-01 01:50:46 -0700526 : RTCStats(std::move(id), timestamp_us),
527 ssrc("ssrc"),
528 associate_stats_id("associateStatsId"),
529 is_remote("isRemote", false),
530 media_type("mediaType"),
Philipp Hancke3bc01662018-08-28 14:55:03 +0200531 kind("kind"),
hbosb0ae9202017-01-27 06:35:16 -0800532 track_id("trackId"),
hbos6ded1902016-11-01 01:50:46 -0700533 transport_id("transportId"),
534 codec_id("codecId"),
535 fir_count("firCount"),
536 pli_count("pliCount"),
537 nack_count("nackCount"),
hbos6769c492017-01-02 08:35:13 -0800538 sli_count("sliCount"),
Yves Gerey665174f2018-06-19 15:03:05 +0200539 qp_sum("qpSum") {}
hbos6ded1902016-11-01 01:50:46 -0700540
Yves Gerey665174f2018-06-19 15:03:05 +0200541RTCRTPStreamStats::RTCRTPStreamStats(const RTCRTPStreamStats& other)
hbos6ded1902016-11-01 01:50:46 -0700542 : RTCStats(other.id(), other.timestamp_us()),
543 ssrc(other.ssrc),
544 associate_stats_id(other.associate_stats_id),
545 is_remote(other.is_remote),
546 media_type(other.media_type),
Philipp Hancke3bc01662018-08-28 14:55:03 +0200547 kind(other.kind),
hbosb0ae9202017-01-27 06:35:16 -0800548 track_id(other.track_id),
hbos6ded1902016-11-01 01:50:46 -0700549 transport_id(other.transport_id),
550 codec_id(other.codec_id),
551 fir_count(other.fir_count),
552 pli_count(other.pli_count),
553 nack_count(other.nack_count),
hbos6769c492017-01-02 08:35:13 -0800554 sli_count(other.sli_count),
Yves Gerey665174f2018-06-19 15:03:05 +0200555 qp_sum(other.qp_sum) {}
hbos6ded1902016-11-01 01:50:46 -0700556
Yves Gerey665174f2018-06-19 15:03:05 +0200557RTCRTPStreamStats::~RTCRTPStreamStats() {}
hbos6ded1902016-11-01 01:50:46 -0700558
Steve Antond6a5cbd2017-08-18 09:40:25 -0700559// clang-format off
hbos6ded1902016-11-01 01:50:46 -0700560WEBRTC_RTCSTATS_IMPL(
hboseeafe942016-11-01 03:00:17 -0700561 RTCInboundRTPStreamStats, RTCRTPStreamStats, "inbound-rtp",
562 &packets_received,
563 &bytes_received,
564 &packets_lost,
565 &jitter,
566 &fraction_lost,
hbosa7a9be12017-03-01 01:02:45 -0800567 &round_trip_time,
hboseeafe942016-11-01 03:00:17 -0700568 &packets_discarded,
569 &packets_repaired,
570 &burst_packets_lost,
571 &burst_packets_discarded,
572 &burst_loss_count,
573 &burst_discard_count,
574 &burst_loss_rate,
575 &burst_discard_rate,
576 &gap_loss_rate,
hbos6769c492017-01-02 08:35:13 -0800577 &gap_discard_rate,
578 &frames_decoded);
Steve Antond6a5cbd2017-08-18 09:40:25 -0700579// clang-format on
hboseeafe942016-11-01 03:00:17 -0700580
Yves Gerey665174f2018-06-19 15:03:05 +0200581RTCInboundRTPStreamStats::RTCInboundRTPStreamStats(const std::string& id,
582 int64_t timestamp_us)
583 : RTCInboundRTPStreamStats(std::string(id), timestamp_us) {}
hboseeafe942016-11-01 03:00:17 -0700584
Yves Gerey665174f2018-06-19 15:03:05 +0200585RTCInboundRTPStreamStats::RTCInboundRTPStreamStats(std::string&& id,
586 int64_t timestamp_us)
hboseeafe942016-11-01 03:00:17 -0700587 : RTCRTPStreamStats(std::move(id), timestamp_us),
588 packets_received("packetsReceived"),
589 bytes_received("bytesReceived"),
590 packets_lost("packetsLost"),
591 jitter("jitter"),
592 fraction_lost("fractionLost"),
hbosa7a9be12017-03-01 01:02:45 -0800593 round_trip_time("roundTripTime"),
hboseeafe942016-11-01 03:00:17 -0700594 packets_discarded("packetsDiscarded"),
595 packets_repaired("packetsRepaired"),
596 burst_packets_lost("burstPacketsLost"),
597 burst_packets_discarded("burstPacketsDiscarded"),
598 burst_loss_count("burstLossCount"),
599 burst_discard_count("burstDiscardCount"),
600 burst_loss_rate("burstLossRate"),
601 burst_discard_rate("burstDiscardRate"),
602 gap_loss_rate("gapLossRate"),
hbos6769c492017-01-02 08:35:13 -0800603 gap_discard_rate("gapDiscardRate"),
Yves Gerey665174f2018-06-19 15:03:05 +0200604 frames_decoded("framesDecoded") {}
hboseeafe942016-11-01 03:00:17 -0700605
606RTCInboundRTPStreamStats::RTCInboundRTPStreamStats(
607 const RTCInboundRTPStreamStats& other)
608 : RTCRTPStreamStats(other),
609 packets_received(other.packets_received),
610 bytes_received(other.bytes_received),
611 packets_lost(other.packets_lost),
612 jitter(other.jitter),
613 fraction_lost(other.fraction_lost),
hbosa7a9be12017-03-01 01:02:45 -0800614 round_trip_time(other.round_trip_time),
hboseeafe942016-11-01 03:00:17 -0700615 packets_discarded(other.packets_discarded),
616 packets_repaired(other.packets_repaired),
617 burst_packets_lost(other.burst_packets_lost),
618 burst_packets_discarded(other.burst_packets_discarded),
619 burst_loss_count(other.burst_loss_count),
620 burst_discard_count(other.burst_discard_count),
621 burst_loss_rate(other.burst_loss_rate),
622 burst_discard_rate(other.burst_discard_rate),
623 gap_loss_rate(other.gap_loss_rate),
hbos6769c492017-01-02 08:35:13 -0800624 gap_discard_rate(other.gap_discard_rate),
Yves Gerey665174f2018-06-19 15:03:05 +0200625 frames_decoded(other.frames_decoded) {}
hboseeafe942016-11-01 03:00:17 -0700626
Yves Gerey665174f2018-06-19 15:03:05 +0200627RTCInboundRTPStreamStats::~RTCInboundRTPStreamStats() {}
hboseeafe942016-11-01 03:00:17 -0700628
Steve Antond6a5cbd2017-08-18 09:40:25 -0700629// clang-format off
hboseeafe942016-11-01 03:00:17 -0700630WEBRTC_RTCSTATS_IMPL(
hbos6ded1902016-11-01 01:50:46 -0700631 RTCOutboundRTPStreamStats, RTCRTPStreamStats, "outbound-rtp",
632 &packets_sent,
633 &bytes_sent,
634 &target_bitrate,
hbos6769c492017-01-02 08:35:13 -0800635 &frames_encoded);
Steve Antond6a5cbd2017-08-18 09:40:25 -0700636// clang-format on
hbos6ded1902016-11-01 01:50:46 -0700637
Yves Gerey665174f2018-06-19 15:03:05 +0200638RTCOutboundRTPStreamStats::RTCOutboundRTPStreamStats(const std::string& id,
639 int64_t timestamp_us)
640 : RTCOutboundRTPStreamStats(std::string(id), timestamp_us) {}
hbos6ded1902016-11-01 01:50:46 -0700641
Yves Gerey665174f2018-06-19 15:03:05 +0200642RTCOutboundRTPStreamStats::RTCOutboundRTPStreamStats(std::string&& id,
643 int64_t timestamp_us)
hbos6ded1902016-11-01 01:50:46 -0700644 : RTCRTPStreamStats(std::move(id), timestamp_us),
645 packets_sent("packetsSent"),
646 bytes_sent("bytesSent"),
647 target_bitrate("targetBitrate"),
Yves Gerey665174f2018-06-19 15:03:05 +0200648 frames_encoded("framesEncoded") {}
hbos6ded1902016-11-01 01:50:46 -0700649
650RTCOutboundRTPStreamStats::RTCOutboundRTPStreamStats(
651 const RTCOutboundRTPStreamStats& other)
652 : RTCRTPStreamStats(other),
653 packets_sent(other.packets_sent),
654 bytes_sent(other.bytes_sent),
655 target_bitrate(other.target_bitrate),
Yves Gerey665174f2018-06-19 15:03:05 +0200656 frames_encoded(other.frames_encoded) {}
hbos6ded1902016-11-01 01:50:46 -0700657
Yves Gerey665174f2018-06-19 15:03:05 +0200658RTCOutboundRTPStreamStats::~RTCOutboundRTPStreamStats() {}
hbos6ded1902016-11-01 01:50:46 -0700659
Steve Antond6a5cbd2017-08-18 09:40:25 -0700660// clang-format off
hbos2fa7c672016-10-24 04:00:05 -0700661WEBRTC_RTCSTATS_IMPL(RTCTransportStats, RTCStats, "transport",
662 &bytes_sent,
663 &bytes_received,
664 &rtcp_transport_stats_id,
hbos7064d592017-01-16 07:38:02 -0800665 &dtls_state,
hbos2fa7c672016-10-24 04:00:05 -0700666 &selected_candidate_pair_id,
667 &local_certificate_id,
668 &remote_certificate_id);
Steve Antond6a5cbd2017-08-18 09:40:25 -0700669// clang-format on
hbos2fa7c672016-10-24 04:00:05 -0700670
Yves Gerey665174f2018-06-19 15:03:05 +0200671RTCTransportStats::RTCTransportStats(const std::string& id,
672 int64_t timestamp_us)
673 : RTCTransportStats(std::string(id), timestamp_us) {}
hbos2fa7c672016-10-24 04:00:05 -0700674
Yves Gerey665174f2018-06-19 15:03:05 +0200675RTCTransportStats::RTCTransportStats(std::string&& id, int64_t timestamp_us)
hbos2fa7c672016-10-24 04:00:05 -0700676 : RTCStats(std::move(id), timestamp_us),
677 bytes_sent("bytesSent"),
678 bytes_received("bytesReceived"),
679 rtcp_transport_stats_id("rtcpTransportStatsId"),
hbos7064d592017-01-16 07:38:02 -0800680 dtls_state("dtlsState"),
hbos2fa7c672016-10-24 04:00:05 -0700681 selected_candidate_pair_id("selectedCandidatePairId"),
682 local_certificate_id("localCertificateId"),
Yves Gerey665174f2018-06-19 15:03:05 +0200683 remote_certificate_id("remoteCertificateId") {}
hbos2fa7c672016-10-24 04:00:05 -0700684
Yves Gerey665174f2018-06-19 15:03:05 +0200685RTCTransportStats::RTCTransportStats(const RTCTransportStats& other)
hbos2fa7c672016-10-24 04:00:05 -0700686 : RTCStats(other.id(), other.timestamp_us()),
687 bytes_sent(other.bytes_sent),
688 bytes_received(other.bytes_received),
689 rtcp_transport_stats_id(other.rtcp_transport_stats_id),
hbos7064d592017-01-16 07:38:02 -0800690 dtls_state(other.dtls_state),
hbos2fa7c672016-10-24 04:00:05 -0700691 selected_candidate_pair_id(other.selected_candidate_pair_id),
692 local_certificate_id(other.local_certificate_id),
Yves Gerey665174f2018-06-19 15:03:05 +0200693 remote_certificate_id(other.remote_certificate_id) {}
hbos2fa7c672016-10-24 04:00:05 -0700694
Yves Gerey665174f2018-06-19 15:03:05 +0200695RTCTransportStats::~RTCTransportStats() {}
hbos2fa7c672016-10-24 04:00:05 -0700696
hbosd565b732016-08-30 14:04:35 -0700697} // namespace webrtc