blob: 96114dfa72c895528a02086d217eebf97fe17812 [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#ifndef API_STATS_RTCSTATS_OBJECTS_H_
12#define API_STATS_RTCSTATS_OBJECTS_H_
hbosd565b732016-08-30 14:04:35 -070013
Yves Gerey3e707812018-11-28 16:47:49 +010014#include <stdint.h>
Jonas Olssona4d87372019-07-05 19:08:33 +020015
Byoungchan Lee7d235352021-05-28 21:32:04 +090016#include <map>
Henrik Boström1df1bf82018-03-20 13:24:20 +010017#include <memory>
hbosd565b732016-08-30 14:04:35 -070018#include <string>
oprypin803dc292017-02-01 01:55:59 -080019#include <vector>
hbosd565b732016-08-30 14:04:35 -070020
Steve Anton10542f22019-01-11 09:11:00 -080021#include "api/stats/rtc_stats.h"
Mirko Bonadei276827c2018-10-16 14:13:50 +020022#include "rtc_base/system/rtc_export.h"
hbosd565b732016-08-30 14:04:35 -070023
24namespace webrtc {
25
hboscc555c52016-10-18 12:48:31 -070026// https://w3c.github.io/webrtc-pc/#idl-def-rtcdatachannelstate
27struct RTCDataChannelState {
agrieve26622d32017-08-08 10:48:15 -070028 static const char* const kConnecting;
29 static const char* const kOpen;
30 static const char* const kClosing;
31 static const char* const kClosed;
hboscc555c52016-10-18 12:48:31 -070032};
33
hbosc47a0c32016-10-11 14:54:49 -070034// https://w3c.github.io/webrtc-stats/#dom-rtcstatsicecandidatepairstate
35struct RTCStatsIceCandidatePairState {
agrieve26622d32017-08-08 10:48:15 -070036 static const char* const kFrozen;
37 static const char* const kWaiting;
38 static const char* const kInProgress;
39 static const char* const kFailed;
40 static const char* const kSucceeded;
hbosc47a0c32016-10-11 14:54:49 -070041};
42
hboscc555c52016-10-18 12:48:31 -070043// https://w3c.github.io/webrtc-pc/#rtcicecandidatetype-enum
hbosab9f6e42016-10-07 02:18:47 -070044struct RTCIceCandidateType {
agrieve26622d32017-08-08 10:48:15 -070045 static const char* const kHost;
46 static const char* const kSrflx;
47 static const char* const kPrflx;
48 static const char* const kRelay;
hbosab9f6e42016-10-07 02:18:47 -070049};
50
hbos7064d592017-01-16 07:38:02 -080051// https://w3c.github.io/webrtc-pc/#idl-def-rtcdtlstransportstate
52struct RTCDtlsTransportState {
agrieve26622d32017-08-08 10:48:15 -070053 static const char* const kNew;
54 static const char* const kConnecting;
55 static const char* const kConnected;
56 static const char* const kClosed;
57 static const char* const kFailed;
hbos7064d592017-01-16 07:38:02 -080058};
59
Artem Titovcfea2182021-08-10 01:22:31 +020060// `RTCMediaStreamTrackStats::kind` is not an enum in the spec but the only
hbos160e4a72017-01-17 02:53:23 -080061// valid values are "audio" and "video".
62// https://w3c.github.io/webrtc-stats/#dom-rtcmediastreamtrackstats-kind
63struct RTCMediaStreamTrackKind {
agrieve26622d32017-08-08 10:48:15 -070064 static const char* const kAudio;
65 static const char* const kVideo;
hbos160e4a72017-01-17 02:53:23 -080066};
67
Gary Liu37e489c2017-11-21 10:49:36 -080068// https://w3c.github.io/webrtc-stats/#dom-rtcnetworktype
69struct RTCNetworkType {
70 static const char* const kBluetooth;
71 static const char* const kCellular;
72 static const char* const kEthernet;
73 static const char* const kWifi;
74 static const char* const kWimax;
75 static const char* const kVpn;
76 static const char* const kUnknown;
77};
78
Henrik Boströmce33b6a2019-05-28 17:42:38 +020079// https://w3c.github.io/webrtc-stats/#dom-rtcqualitylimitationreason
80struct RTCQualityLimitationReason {
81 static const char* const kNone;
82 static const char* const kCpu;
83 static const char* const kBandwidth;
84 static const char* const kOther;
85};
86
Henrik Boström2e069262019-04-09 13:59:31 +020087// https://webrtc.org/experiments/rtp-hdrext/video-content-type/
88struct RTCContentType {
89 static const char* const kUnspecified;
90 static const char* const kScreenshare;
91};
92
Philipp Hancke69c1df22022-04-22 15:46:24 +020093// https://w3c.github.io/webrtc-stats/#dom-rtcdtlsrole
94struct RTCDtlsRole {
95 static const char* const kUnknown;
96 static const char* const kClient;
97 static const char* const kServer;
98};
99
Philipp Hanckecc1b9b02022-05-04 18:58:26 +0200100// https://www.w3.org/TR/webrtc/#rtcicerole
101struct RTCIceRole {
102 static const char* const kUnknown;
103 static const char* const kControlled;
104 static const char* const kControlling;
105};
106
Philipp Hancke1f491572022-05-09 17:43:31 +0200107// https://www.w3.org/TR/webrtc/#dom-rtcicetransportstate
108struct RTCIceTransportState {
109 static const char* const kNew;
110 static const char* const kChecking;
111 static const char* const kConnected;
112 static const char* const kCompleted;
113 static const char* const kDisconnected;
114 static const char* const kFailed;
115 static const char* const kClosed;
116};
117
hbos2fa7c672016-10-24 04:00:05 -0700118// https://w3c.github.io/webrtc-stats/#certificatestats-dict*
Mirko Bonadei276827c2018-10-16 14:13:50 +0200119class RTC_EXPORT RTCCertificateStats final : public RTCStats {
hbos2fa7c672016-10-24 04:00:05 -0700120 public:
121 WEBRTC_RTCSTATS_DECL();
122
Philipp Hanckeb81823a2023-01-04 15:17:42 +0100123 RTCCertificateStats(std::string id, Timestamp timestamp);
Philipp Hanckee137c452023-01-10 13:06:02 +0100124 ABSL_DEPRECATED("Use constructor with Timestamp instead")
Philipp Hancke7a5de442023-01-02 13:20:45 +0100125 RTCCertificateStats(std::string id, int64_t timestamp_us);
hbos2fa7c672016-10-24 04:00:05 -0700126 RTCCertificateStats(const RTCCertificateStats& other);
127 ~RTCCertificateStats() override;
128
129 RTCStatsMember<std::string> fingerprint;
130 RTCStatsMember<std::string> fingerprint_algorithm;
131 RTCStatsMember<std::string> base64_certificate;
132 RTCStatsMember<std::string> issuer_certificate_id;
133};
134
Jonas Oreland0d13bbd2022-03-02 11:17:36 +0100135// Non standard extension mapping to rtc::AdapterType
136struct RTCNetworkAdapterType {
137 static constexpr char kUnknown[] = "unknown";
138 static constexpr char kEthernet[] = "ethernet";
139 static constexpr char kWifi[] = "wifi";
140 static constexpr char kCellular[] = "cellular";
141 static constexpr char kLoopback[] = "loopback";
142 static constexpr char kAny[] = "any";
143 static constexpr char kCellular2g[] = "cellular2g";
144 static constexpr char kCellular3g[] = "cellular3g";
145 static constexpr char kCellular4g[] = "cellular4g";
146 static constexpr char kCellular5g[] = "cellular5g";
147};
148
hbos0adb8282016-11-23 02:32:06 -0800149// https://w3c.github.io/webrtc-stats/#codec-dict*
Mirko Bonadei276827c2018-10-16 14:13:50 +0200150class RTC_EXPORT RTCCodecStats final : public RTCStats {
hbos0adb8282016-11-23 02:32:06 -0800151 public:
152 WEBRTC_RTCSTATS_DECL();
153
Philipp Hanckeb81823a2023-01-04 15:17:42 +0100154 RTCCodecStats(std::string id, Timestamp timestamp);
Philipp Hanckee137c452023-01-10 13:06:02 +0100155 ABSL_DEPRECATED("Use constructor with Timestamp instead")
Philipp Hancke7a5de442023-01-02 13:20:45 +0100156 RTCCodecStats(std::string id, int64_t timestamp_us);
hbos0adb8282016-11-23 02:32:06 -0800157 RTCCodecStats(const RTCCodecStats& other);
158 ~RTCCodecStats() override;
159
Philipp Hancke95157a02020-11-16 20:08:27 +0100160 RTCStatsMember<std::string> transport_id;
hbos0adb8282016-11-23 02:32:06 -0800161 RTCStatsMember<uint32_t> payload_type;
hbos13f54b22017-02-28 06:56:04 -0800162 RTCStatsMember<std::string> mime_type;
hbos0adb8282016-11-23 02:32:06 -0800163 RTCStatsMember<uint32_t> clock_rate;
hbos0adb8282016-11-23 02:32:06 -0800164 RTCStatsMember<uint32_t> channels;
hbos13f54b22017-02-28 06:56:04 -0800165 RTCStatsMember<std::string> sdp_fmtp_line;
hbos0adb8282016-11-23 02:32:06 -0800166};
167
hbos2fa7c672016-10-24 04:00:05 -0700168// https://w3c.github.io/webrtc-stats/#dcstats-dict*
Mirko Bonadei276827c2018-10-16 14:13:50 +0200169class RTC_EXPORT RTCDataChannelStats final : public RTCStats {
hbos2fa7c672016-10-24 04:00:05 -0700170 public:
171 WEBRTC_RTCSTATS_DECL();
172
Philipp Hanckeb81823a2023-01-04 15:17:42 +0100173 RTCDataChannelStats(std::string id, Timestamp timestamp);
Philipp Hanckee137c452023-01-10 13:06:02 +0100174 ABSL_DEPRECATED("Use constructor with Timestamp instead")
Philipp Hancke7a5de442023-01-02 13:20:45 +0100175 RTCDataChannelStats(std::string id, int64_t timestamp_us);
hbos2fa7c672016-10-24 04:00:05 -0700176 RTCDataChannelStats(const RTCDataChannelStats& other);
177 ~RTCDataChannelStats() override;
178
179 RTCStatsMember<std::string> label;
180 RTCStatsMember<std::string> protocol;
Harald Alvestrand10ef8472020-06-05 15:38:51 +0200181 RTCStatsMember<int32_t> data_channel_identifier;
Henrik Boström5abfc922022-06-13 10:23:28 +0200182 // Enum type RTCDataChannelState.
hbos2fa7c672016-10-24 04:00:05 -0700183 RTCStatsMember<std::string> state;
184 RTCStatsMember<uint32_t> messages_sent;
185 RTCStatsMember<uint64_t> bytes_sent;
186 RTCStatsMember<uint32_t> messages_received;
187 RTCStatsMember<uint64_t> bytes_received;
188};
189
190// https://w3c.github.io/webrtc-stats/#candidatepair-dict*
Mirko Bonadei276827c2018-10-16 14:13:50 +0200191class RTC_EXPORT RTCIceCandidatePairStats final : public RTCStats {
hbosc47a0c32016-10-11 14:54:49 -0700192 public:
193 WEBRTC_RTCSTATS_DECL();
194
Philipp Hanckeb81823a2023-01-04 15:17:42 +0100195 RTCIceCandidatePairStats(std::string id, Timestamp timestamp);
Philipp Hanckee137c452023-01-10 13:06:02 +0100196 ABSL_DEPRECATED("Use constructor with Timestamp instead")
Philipp Hancke7a5de442023-01-02 13:20:45 +0100197 RTCIceCandidatePairStats(std::string id, int64_t timestamp_us);
hbosc47a0c32016-10-11 14:54:49 -0700198 RTCIceCandidatePairStats(const RTCIceCandidatePairStats& other);
199 ~RTCIceCandidatePairStats() override;
200
201 RTCStatsMember<std::string> transport_id;
202 RTCStatsMember<std::string> local_candidate_id;
203 RTCStatsMember<std::string> remote_candidate_id;
Henrik Boström5abfc922022-06-13 10:23:28 +0200204 // Enum type RTCStatsIceCandidatePairState.
hbosc47a0c32016-10-11 14:54:49 -0700205 RTCStatsMember<std::string> state;
Di Wuef036cd2021-03-19 08:24:41 -0700206 // Obsolete: priority
hbosc47a0c32016-10-11 14:54:49 -0700207 RTCStatsMember<uint64_t> priority;
208 RTCStatsMember<bool> nominated;
Henrik Boström5abfc922022-06-13 10:23:28 +0200209 // `writable` does not exist in the spec and old comments suggest it used to
210 // exist but was incorrectly implemented.
211 // TODO(https://crbug.com/webrtc/14171): Standardize and/or modify
212 // implementation.
hbosc47a0c32016-10-11 14:54:49 -0700213 RTCStatsMember<bool> writable;
Taylor Brandstetter79326ea2021-09-28 15:09:53 -0700214 RTCStatsMember<uint64_t> packets_sent;
215 RTCStatsMember<uint64_t> packets_received;
hbosc47a0c32016-10-11 14:54:49 -0700216 RTCStatsMember<uint64_t> bytes_sent;
217 RTCStatsMember<uint64_t> bytes_received;
hbos3168c7a2016-12-15 06:17:08 -0800218 RTCStatsMember<double> total_round_trip_time;
hbos3168c7a2016-12-15 06:17:08 -0800219 RTCStatsMember<double> current_round_trip_time;
hbosc47a0c32016-10-11 14:54:49 -0700220 RTCStatsMember<double> available_outgoing_bitrate;
221 RTCStatsMember<double> available_incoming_bitrate;
222 RTCStatsMember<uint64_t> requests_received;
223 RTCStatsMember<uint64_t> requests_sent;
224 RTCStatsMember<uint64_t> responses_received;
225 RTCStatsMember<uint64_t> responses_sent;
hbosc47a0c32016-10-11 14:54:49 -0700226 RTCStatsMember<uint64_t> consent_requests_sent;
Taylor Brandstetter79326ea2021-09-28 15:09:53 -0700227 RTCStatsMember<uint64_t> packets_discarded_on_send;
228 RTCStatsMember<uint64_t> bytes_discarded_on_send;
Philipp Hancke0487c572022-11-01 17:03:01 +0100229 RTCStatsMember<double> last_packet_received_timestamp;
230 RTCStatsMember<double> last_packet_sent_timestamp;
hbosc47a0c32016-10-11 14:54:49 -0700231};
232
hbosab9f6e42016-10-07 02:18:47 -0700233// https://w3c.github.io/webrtc-stats/#icecandidate-dict*
Mirko Bonadei276827c2018-10-16 14:13:50 +0200234class RTC_EXPORT RTCIceCandidateStats : public RTCStats {
hbosab9f6e42016-10-07 02:18:47 -0700235 public:
236 WEBRTC_RTCSTATS_DECL();
237
238 RTCIceCandidateStats(const RTCIceCandidateStats& other);
239 ~RTCIceCandidateStats() override;
240
hbosb4e426e2017-01-02 09:59:31 -0800241 RTCStatsMember<std::string> transport_id;
Di Wuef036cd2021-03-19 08:24:41 -0700242 // Obsolete: is_remote
hbosc3a2b7f2017-01-02 04:46:15 -0800243 RTCStatsMember<bool> is_remote;
Gary Liu37e489c2017-11-21 10:49:36 -0800244 RTCStatsMember<std::string> network_type;
hbosab9f6e42016-10-07 02:18:47 -0700245 RTCStatsMember<std::string> ip;
Philipp Hanckea9ba4502021-03-22 13:22:54 +0100246 RTCStatsMember<std::string> address;
hbosab9f6e42016-10-07 02:18:47 -0700247 RTCStatsMember<int32_t> port;
248 RTCStatsMember<std::string> protocol;
Philipp Hancke95513752018-09-27 14:40:08 +0200249 RTCStatsMember<std::string> relay_protocol;
Henrik Boström5abfc922022-06-13 10:23:28 +0200250 // Enum type RTCIceCandidateType.
hbosab9f6e42016-10-07 02:18:47 -0700251 RTCStatsMember<std::string> candidate_type;
252 RTCStatsMember<int32_t> priority;
253 RTCStatsMember<std::string> url;
Philipp Hancke0e3cd632022-09-27 10:23:09 +0200254 RTCStatsMember<std::string> foundation;
255 RTCStatsMember<std::string> related_address;
256 RTCStatsMember<int32_t> related_port;
257 RTCStatsMember<std::string> username_fragment;
258 // Enum type RTCIceTcpCandidateType.
259 RTCStatsMember<std::string> tcp_type;
hbosab9f6e42016-10-07 02:18:47 -0700260
Jonas Oreland0d13bbd2022-03-02 11:17:36 +0100261 RTCNonStandardStatsMember<bool> vpn;
262 RTCNonStandardStatsMember<std::string> network_adapter_type;
263
hbosab9f6e42016-10-07 02:18:47 -0700264 protected:
Philipp Hanckeb81823a2023-01-04 15:17:42 +0100265 RTCIceCandidateStats(std::string id, Timestamp timestamp, bool is_remote);
Philipp Hanckee137c452023-01-10 13:06:02 +0100266 ABSL_DEPRECATED("Use constructor with Timestamp instead")
Philipp Hancke7a5de442023-01-02 13:20:45 +0100267 RTCIceCandidateStats(std::string id, int64_t timestamp_us, bool is_remote);
hbosab9f6e42016-10-07 02:18:47 -0700268};
269
270// In the spec both local and remote varieties are of type RTCIceCandidateStats.
Artem Titov0e61fdd2021-07-25 21:50:14 +0200271// But here we define them as subclasses of `RTCIceCandidateStats` because the
272// `kType` need to be different ("RTCStatsType type") in the local/remote case.
hbosab9f6e42016-10-07 02:18:47 -0700273// https://w3c.github.io/webrtc-stats/#rtcstatstype-str*
Henrik Boström1df1bf82018-03-20 13:24:20 +0100274// This forces us to have to override copy() and type().
Mirko Bonadei276827c2018-10-16 14:13:50 +0200275class RTC_EXPORT RTCLocalIceCandidateStats final : public RTCIceCandidateStats {
hbosab9f6e42016-10-07 02:18:47 -0700276 public:
277 static const char kType[];
Philipp Hanckeb81823a2023-01-04 15:17:42 +0100278 RTCLocalIceCandidateStats(std::string id, Timestamp timestamp);
Philipp Hanckee137c452023-01-10 13:06:02 +0100279 ABSL_DEPRECATED("Use constructor with Timestamp instead")
Philipp Hancke7a5de442023-01-02 13:20:45 +0100280 RTCLocalIceCandidateStats(std::string id, int64_t timestamp_us);
Henrik Boström1df1bf82018-03-20 13:24:20 +0100281 std::unique_ptr<RTCStats> copy() const override;
hbosab9f6e42016-10-07 02:18:47 -0700282 const char* type() const override;
283};
284
Mirko Bonadei276827c2018-10-16 14:13:50 +0200285class RTC_EXPORT RTCRemoteIceCandidateStats final
286 : public RTCIceCandidateStats {
hbosab9f6e42016-10-07 02:18:47 -0700287 public:
288 static const char kType[];
Philipp Hanckeb81823a2023-01-04 15:17:42 +0100289 RTCRemoteIceCandidateStats(std::string id, Timestamp timestamp);
Philipp Hanckee137c452023-01-10 13:06:02 +0100290 ABSL_DEPRECATED("Use constructor with Timestamp instead")
Philipp Hancke7a5de442023-01-02 13:20:45 +0100291 RTCRemoteIceCandidateStats(std::string id, int64_t timestamp_us);
Henrik Boström1df1bf82018-03-20 13:24:20 +0100292 std::unique_ptr<RTCStats> copy() const override;
hbosab9f6e42016-10-07 02:18:47 -0700293 const char* type() const override;
294};
295
Henrik Boström15166b22022-10-19 11:06:58 +0200296// TODO(https://crbug.com/webrtc/14419): Delete this class, it's deprecated.
297class RTC_EXPORT DEPRECATED_RTCMediaStreamStats final : public RTCStats {
hbos09bc1282016-11-08 06:29:22 -0800298 public:
299 WEBRTC_RTCSTATS_DECL();
300
Philipp Hanckeb81823a2023-01-04 15:17:42 +0100301 DEPRECATED_RTCMediaStreamStats(std::string id, Timestamp timestamp);
Philipp Hanckee137c452023-01-10 13:06:02 +0100302 ABSL_DEPRECATED("Use constructor with Timestamp instead")
Philipp Hancke7a5de442023-01-02 13:20:45 +0100303 DEPRECATED_RTCMediaStreamStats(std::string id, int64_t timestamp_us);
Henrik Boström15166b22022-10-19 11:06:58 +0200304 DEPRECATED_RTCMediaStreamStats(const DEPRECATED_RTCMediaStreamStats& other);
305 ~DEPRECATED_RTCMediaStreamStats() override;
hbos09bc1282016-11-08 06:29:22 -0800306
307 RTCStatsMember<std::string> stream_identifier;
308 RTCStatsMember<std::vector<std::string>> track_ids;
309};
Henrik Boström15166b22022-10-19 11:06:58 +0200310using RTCMediaStreamStats [[deprecated("bugs.webrtc.org/14419")]] =
311 DEPRECATED_RTCMediaStreamStats;
hbos09bc1282016-11-08 06:29:22 -0800312
Henrik Boström15166b22022-10-19 11:06:58 +0200313// TODO(https://crbug.com/webrtc/14175): Delete this class, it's deprecated.
314class RTC_EXPORT DEPRECATED_RTCMediaStreamTrackStats final : public RTCStats {
hbos09bc1282016-11-08 06:29:22 -0800315 public:
316 WEBRTC_RTCSTATS_DECL();
317
Philipp Hancke7a5de442023-01-02 13:20:45 +0100318 DEPRECATED_RTCMediaStreamTrackStats(std::string id,
Philipp Hanckeb81823a2023-01-04 15:17:42 +0100319 Timestamp timestamp,
320 const char* kind);
Philipp Hanckee137c452023-01-10 13:06:02 +0100321 ABSL_DEPRECATED("Use constructor with Timestamp instead")
Philipp Hanckeb81823a2023-01-04 15:17:42 +0100322 DEPRECATED_RTCMediaStreamTrackStats(std::string id,
Henrik Boström15166b22022-10-19 11:06:58 +0200323 int64_t timestamp_us,
324 const char* kind);
325 DEPRECATED_RTCMediaStreamTrackStats(
326 const DEPRECATED_RTCMediaStreamTrackStats& other);
327 ~DEPRECATED_RTCMediaStreamTrackStats() override;
hbos09bc1282016-11-08 06:29:22 -0800328
329 RTCStatsMember<std::string> track_identifier;
Henrik Boström646fda02019-05-22 15:49:42 +0200330 RTCStatsMember<std::string> media_source_id;
hbos09bc1282016-11-08 06:29:22 -0800331 RTCStatsMember<bool> remote_source;
332 RTCStatsMember<bool> ended;
Henrik Boström5abfc922022-06-13 10:23:28 +0200333 // TODO(https://crbug.com/webrtc/14173): Remove this obsolete metric.
hbos09bc1282016-11-08 06:29:22 -0800334 RTCStatsMember<bool> detached;
Henrik Boström5abfc922022-06-13 10:23:28 +0200335 // Enum type RTCMediaStreamTrackKind.
hbos160e4a72017-01-17 02:53:23 -0800336 RTCStatsMember<std::string> kind;
Gustaf Ullbergb0a02072017-10-02 12:00:34 +0200337 RTCStatsMember<double> jitter_buffer_delay;
Chen Xing0acffb52019-01-15 15:46:29 +0100338 RTCStatsMember<uint64_t> jitter_buffer_emitted_count;
hbos09bc1282016-11-08 06:29:22 -0800339 // Video-only members
340 RTCStatsMember<uint32_t> frame_width;
341 RTCStatsMember<uint32_t> frame_height;
hbos09bc1282016-11-08 06:29:22 -0800342 RTCStatsMember<uint32_t> frames_sent;
Ilya Nikolaevskiy70473fc2018-02-28 16:35:03 +0100343 RTCStatsMember<uint32_t> huge_frames_sent;
hbos09bc1282016-11-08 06:29:22 -0800344 RTCStatsMember<uint32_t> frames_received;
hbos09bc1282016-11-08 06:29:22 -0800345 RTCStatsMember<uint32_t> frames_decoded;
hbos09bc1282016-11-08 06:29:22 -0800346 RTCStatsMember<uint32_t> frames_dropped;
hbos09bc1282016-11-08 06:29:22 -0800347 // Audio-only members
Henrik Boströmd2c336f2019-07-03 17:11:10 +0200348 RTCStatsMember<double> audio_level; // Receive-only
349 RTCStatsMember<double> total_audio_energy; // Receive-only
hbos09bc1282016-11-08 06:29:22 -0800350 RTCStatsMember<double> echo_return_loss;
351 RTCStatsMember<double> echo_return_loss_enhancement;
Steve Anton2dbc69f2017-08-24 17:15:13 -0700352 RTCStatsMember<uint64_t> total_samples_received;
Henrik Boströmd2c336f2019-07-03 17:11:10 +0200353 RTCStatsMember<double> total_samples_duration; // Receive-only
Steve Anton2dbc69f2017-08-24 17:15:13 -0700354 RTCStatsMember<uint64_t> concealed_samples;
Ivo Creusen8d8ffdb2019-04-30 09:45:21 +0200355 RTCStatsMember<uint64_t> silent_concealed_samples;
Gustaf Ullberg9a2e9062017-09-18 09:28:20 +0200356 RTCStatsMember<uint64_t> concealment_events;
Ivo Creusen8d8ffdb2019-04-30 09:45:21 +0200357 RTCStatsMember<uint64_t> inserted_samples_for_deceleration;
358 RTCStatsMember<uint64_t> removed_samples_for_acceleration;
hbos09bc1282016-11-08 06:29:22 -0800359};
Henrik Boström15166b22022-10-19 11:06:58 +0200360using RTCMediaStreamTrackStats [[deprecated("bugs.webrtc.org/14175")]] =
361 DEPRECATED_RTCMediaStreamTrackStats;
hbos09bc1282016-11-08 06:29:22 -0800362
hbos6ab97ce2016-10-03 14:16:56 -0700363// https://w3c.github.io/webrtc-stats/#pcstats-dict*
Mirko Bonadei276827c2018-10-16 14:13:50 +0200364class RTC_EXPORT RTCPeerConnectionStats final : public RTCStats {
hbosd565b732016-08-30 14:04:35 -0700365 public:
hbosfc5e0502016-10-06 02:06:10 -0700366 WEBRTC_RTCSTATS_DECL();
367
Philipp Hanckeb81823a2023-01-04 15:17:42 +0100368 RTCPeerConnectionStats(std::string id, Timestamp timestamp);
Philipp Hanckee137c452023-01-10 13:06:02 +0100369 ABSL_DEPRECATED("Use constructor with Timestamp instead")
Philipp Hancke7a5de442023-01-02 13:20:45 +0100370 RTCPeerConnectionStats(std::string id, int64_t timestamp_us);
hbosfc5e0502016-10-06 02:06:10 -0700371 RTCPeerConnectionStats(const RTCPeerConnectionStats& other);
372 ~RTCPeerConnectionStats() override;
hbosd565b732016-08-30 14:04:35 -0700373
374 RTCStatsMember<uint32_t> data_channels_opened;
375 RTCStatsMember<uint32_t> data_channels_closed;
376};
377
hbos6ded1902016-11-01 01:50:46 -0700378// https://w3c.github.io/webrtc-stats/#streamstats-dict*
Mirko Bonadei276827c2018-10-16 14:13:50 +0200379class RTC_EXPORT RTCRTPStreamStats : public RTCStats {
hbos6ded1902016-11-01 01:50:46 -0700380 public:
381 WEBRTC_RTCSTATS_DECL();
382
383 RTCRTPStreamStats(const RTCRTPStreamStats& other);
384 ~RTCRTPStreamStats() override;
385
hbos3443bb72017-02-07 06:28:11 -0800386 RTCStatsMember<uint32_t> ssrc;
Philipp Hancke3bc01662018-08-28 14:55:03 +0200387 RTCStatsMember<std::string> kind;
Di Wuef036cd2021-03-19 08:24:41 -0700388 // Obsolete: track_id
hbosb0ae9202017-01-27 06:35:16 -0800389 RTCStatsMember<std::string> track_id;
hbos6ded1902016-11-01 01:50:46 -0700390 RTCStatsMember<std::string> transport_id;
hbos6ded1902016-11-01 01:50:46 -0700391 RTCStatsMember<std::string> codec_id;
Di Wufd1e9d12021-03-09 09:25:28 -0800392
393 // Obsolete
394 RTCStatsMember<std::string> media_type; // renamed to kind.
hbos6ded1902016-11-01 01:50:46 -0700395
396 protected:
Philipp Hanckeb81823a2023-01-04 15:17:42 +0100397 RTCRTPStreamStats(std::string id, Timestamp timestamp);
Philipp Hanckee137c452023-01-10 13:06:02 +0100398 ABSL_DEPRECATED("Use constructor with Timestamp instead")
Philipp Hancke7a5de442023-01-02 13:20:45 +0100399 RTCRTPStreamStats(std::string id, int64_t timestamp_us);
hbos6ded1902016-11-01 01:50:46 -0700400};
401
Alessio Bazzicaf7b1b952021-03-23 17:23:04 +0100402// https://www.w3.org/TR/webrtc-stats/#receivedrtpstats-dict*
Di Wufd1e9d12021-03-09 09:25:28 -0800403class RTC_EXPORT RTCReceivedRtpStreamStats : public RTCRTPStreamStats {
404 public:
405 WEBRTC_RTCSTATS_DECL();
406
407 RTCReceivedRtpStreamStats(const RTCReceivedRtpStreamStats& other);
408 ~RTCReceivedRtpStreamStats() override;
409
Di Wufd1e9d12021-03-09 09:25:28 -0800410 RTCStatsMember<double> jitter;
411 RTCStatsMember<int32_t> packets_lost; // Signed per RFC 3550
412
413 protected:
Philipp Hanckeb81823a2023-01-04 15:17:42 +0100414 RTCReceivedRtpStreamStats(std::string id, Timestamp timestamp);
Philipp Hanckee137c452023-01-10 13:06:02 +0100415 ABSL_DEPRECATED("Use constructor with Timestamp instead")
Philipp Hancke7a5de442023-01-02 13:20:45 +0100416 RTCReceivedRtpStreamStats(std::string id, int64_t timestamp_us);
Di Wufd1e9d12021-03-09 09:25:28 -0800417};
418
Alessio Bazzicaf7b1b952021-03-23 17:23:04 +0100419// https://www.w3.org/TR/webrtc-stats/#sentrtpstats-dict*
420class RTC_EXPORT RTCSentRtpStreamStats : public RTCRTPStreamStats {
421 public:
422 WEBRTC_RTCSTATS_DECL();
423
424 RTCSentRtpStreamStats(const RTCSentRtpStreamStats& other);
425 ~RTCSentRtpStreamStats() override;
426
427 RTCStatsMember<uint32_t> packets_sent;
428 RTCStatsMember<uint64_t> bytes_sent;
429
430 protected:
Philipp Hanckeb81823a2023-01-04 15:17:42 +0100431 RTCSentRtpStreamStats(std::string id, Timestamp timestamp);
Philipp Hanckee137c452023-01-10 13:06:02 +0100432 ABSL_DEPRECATED("Use constructor with Timestamp instead")
Philipp Hancke7a5de442023-01-02 13:20:45 +0100433 RTCSentRtpStreamStats(std::string id, int64_t timestamp_us);
Alessio Bazzicaf7b1b952021-03-23 17:23:04 +0100434};
435
hboseeafe942016-11-01 03:00:17 -0700436// https://w3c.github.io/webrtc-stats/#inboundrtpstats-dict*
Di Wufd1e9d12021-03-09 09:25:28 -0800437class RTC_EXPORT RTCInboundRTPStreamStats final
438 : public RTCReceivedRtpStreamStats {
hboseeafe942016-11-01 03:00:17 -0700439 public:
440 WEBRTC_RTCSTATS_DECL();
441
Philipp Hanckeb81823a2023-01-04 15:17:42 +0100442 RTCInboundRTPStreamStats(std::string id, Timestamp timestamp);
Philipp Hanckee137c452023-01-10 13:06:02 +0100443 ABSL_DEPRECATED("Use constructor with Timestamp instead")
Philipp Hancke7a5de442023-01-02 13:20:45 +0100444 RTCInboundRTPStreamStats(std::string id, int64_t timestamp_us);
hboseeafe942016-11-01 03:00:17 -0700445 RTCInboundRTPStreamStats(const RTCInboundRTPStreamStats& other);
446 ~RTCInboundRTPStreamStats() override;
447
Henrik Boström5abfc922022-06-13 10:23:28 +0200448 // TODO(https://crbug.com/webrtc/14174): Implement trackIdentifier and kind.
449
Henrik Boströma6c7d5c2022-06-16 16:55:31 +0200450 RTCStatsMember<std::string> track_identifier;
Henrik Boström1ab61882022-06-16 17:07:33 +0200451 RTCStatsMember<std::string> mid;
Alessio Bazzicaf7b1b952021-03-23 17:23:04 +0100452 RTCStatsMember<std::string> remote_id;
hboseeafe942016-11-01 03:00:17 -0700453 RTCStatsMember<uint32_t> packets_received;
Henrik Boströma494e4b2022-10-03 17:26:41 +0200454 RTCStatsMember<uint64_t> packets_discarded;
Ivo Creusen8d8ffdb2019-04-30 09:45:21 +0200455 RTCStatsMember<uint64_t> fec_packets_received;
456 RTCStatsMember<uint64_t> fec_packets_discarded;
hboseeafe942016-11-01 03:00:17 -0700457 RTCStatsMember<uint64_t> bytes_received;
Niels Möllerac0a4cb2019-10-09 15:01:33 +0200458 RTCStatsMember<uint64_t> header_bytes_received;
Henrik Boström01738c62019-04-15 17:32:00 +0200459 RTCStatsMember<double> last_packet_received_timestamp;
Eldar Rello4e5bc9f2020-07-06 14:18:07 +0300460 RTCStatsMember<double> jitter_buffer_delay;
Ivo Creusen11fdb082022-07-04 14:16:39 +0200461 RTCStatsMember<double> jitter_buffer_target_delay;
Ivo Creusen1a84b562022-07-19 16:33:10 +0200462 RTCStatsMember<double> jitter_buffer_minimum_delay;
Eldar Rello4e5bc9f2020-07-06 14:18:07 +0300463 RTCStatsMember<uint64_t> jitter_buffer_emitted_count;
464 RTCStatsMember<uint64_t> total_samples_received;
465 RTCStatsMember<uint64_t> concealed_samples;
466 RTCStatsMember<uint64_t> silent_concealed_samples;
467 RTCStatsMember<uint64_t> concealment_events;
468 RTCStatsMember<uint64_t> inserted_samples_for_deceleration;
469 RTCStatsMember<uint64_t> removed_samples_for_acceleration;
470 RTCStatsMember<double> audio_level;
471 RTCStatsMember<double> total_audio_energy;
472 RTCStatsMember<double> total_samples_duration;
Philipp Hanckea16a6a62022-04-25 12:21:30 +0200473 // Stats below are only implemented or defined for video.
474 RTCStatsMember<int32_t> frames_received;
Eldar Rello4e5bc9f2020-07-06 14:18:07 +0300475 RTCStatsMember<uint32_t> frame_width;
476 RTCStatsMember<uint32_t> frame_height;
Eldar Rello4e5bc9f2020-07-06 14:18:07 +0300477 RTCStatsMember<double> frames_per_second;
hbos6769c492017-01-02 08:35:13 -0800478 RTCStatsMember<uint32_t> frames_decoded;
Rasmus Brandt2efae772019-06-27 14:29:34 +0200479 RTCStatsMember<uint32_t> key_frames_decoded;
Eldar Rello4e5bc9f2020-07-06 14:18:07 +0300480 RTCStatsMember<uint32_t> frames_dropped;
Johannes Kronbfd343b2019-07-01 10:07:50 +0200481 RTCStatsMember<double> total_decode_time;
Philipp Hanckea16a6a62022-04-25 12:21:30 +0200482 RTCStatsMember<double> total_processing_delay;
Philipp Hancke95d88022022-10-11 17:12:24 +0200483 RTCStatsMember<double> total_assembly_time;
484 RTCStatsMember<uint32_t> frames_assembled_from_multiple_packets;
Johannes Kron00376e12019-11-25 10:25:42 +0100485 RTCStatsMember<double> total_inter_frame_delay;
486 RTCStatsMember<double> total_squared_inter_frame_delay;
Henrik Boströmc57a28c2022-10-06 11:59:05 +0200487 RTCStatsMember<uint32_t> pause_count;
488 RTCStatsMember<double> total_pauses_duration;
489 RTCStatsMember<uint32_t> freeze_count;
490 RTCStatsMember<double> total_freezes_duration;
Henrik Boström5abfc922022-06-13 10:23:28 +0200491 // https://w3c.github.io/webrtc-provisional-stats/#dom-rtcinboundrtpstreamstats-contenttype
Henrik Boström2e069262019-04-09 13:59:31 +0200492 RTCStatsMember<std::string> content_type;
Henrik Boström5abfc922022-06-13 10:23:28 +0200493 // Only populated if audio/video sync is enabled.
494 // TODO(https://crbug.com/webrtc/14177): Expose even if A/V sync is off?
Åsa Perssonfcf79cc2019-10-22 15:23:44 +0200495 RTCStatsMember<double> estimated_playout_timestamp;
Henrik Boström5abfc922022-06-13 10:23:28 +0200496 // Only implemented for video.
497 // TODO(https://crbug.com/webrtc/14178): Also implement for audio.
Evan Shrubsolef4abcc02022-10-31 11:04:22 +0000498 RTCRestrictedStatsMember<std::string,
499 StatExposureCriteria::kHardwareCapability>
500 decoder_implementation;
Philipp Hanckea3b5c4e2022-04-22 15:09:54 +0200501 // FIR and PLI counts are only defined for |kind == "video"|.
Di Wufd1e9d12021-03-09 09:25:28 -0800502 RTCStatsMember<uint32_t> fir_count;
503 RTCStatsMember<uint32_t> pli_count;
Di Wufd1e9d12021-03-09 09:25:28 -0800504 RTCStatsMember<uint32_t> nack_count;
505 RTCStatsMember<uint64_t> qp_sum;
Henrik Boströmc5f8f802022-10-19 17:50:09 +0200506 // This is a remnant of the legacy getStats() API. When the "video-timing"
507 // header extension is used,
508 // https://webrtc.github.io/webrtc-org/experiments/rtp-hdrext/video-timing/,
509 // `googTimingFrameInfo` is exposed with the value of
510 // TimingFrameInfo::ToString().
511 // TODO(https://crbug.com/webrtc/14586): Unship or standardize this metric.
512 RTCStatsMember<std::string> goog_timing_frame_info;
Evan Shrubsole13c0be42022-10-31 11:03:10 +0000513 RTCRestrictedStatsMember<bool, StatExposureCriteria::kHardwareCapability>
514 power_efficient_decoder;
Henrik Boström2fb83072022-10-06 13:37:11 +0200515 // Non-standard audio metrics.
516 RTCNonStandardStatsMember<uint64_t> jitter_buffer_flushes;
517 RTCNonStandardStatsMember<uint64_t> delayed_packet_outage_samples;
518 RTCNonStandardStatsMember<double> relative_packet_arrival_delay;
519 RTCNonStandardStatsMember<uint32_t> interruption_count;
520 RTCNonStandardStatsMember<double> total_interruption_duration;
Philipp Hancke6fb8d1a2022-05-30 12:37:04 +0200521
522 // The former googMinPlayoutDelayMs (in seconds).
523 RTCNonStandardStatsMember<double> min_playout_delay;
hboseeafe942016-11-01 03:00:17 -0700524};
525
hbos6ded1902016-11-01 01:50:46 -0700526// https://w3c.github.io/webrtc-stats/#outboundrtpstats-dict*
Mirko Bonadei276827c2018-10-16 14:13:50 +0200527class RTC_EXPORT RTCOutboundRTPStreamStats final : public RTCRTPStreamStats {
hbos6ded1902016-11-01 01:50:46 -0700528 public:
529 WEBRTC_RTCSTATS_DECL();
530
Philipp Hanckeb81823a2023-01-04 15:17:42 +0100531 RTCOutboundRTPStreamStats(std::string id, Timestamp timestamp);
Philipp Hanckee137c452023-01-10 13:06:02 +0100532 ABSL_DEPRECATED("Use constructor with Timestamp instead")
Philipp Hancke7a5de442023-01-02 13:20:45 +0100533 RTCOutboundRTPStreamStats(std::string id, int64_t timestamp_us);
hbos6ded1902016-11-01 01:50:46 -0700534 RTCOutboundRTPStreamStats(const RTCOutboundRTPStreamStats& other);
535 ~RTCOutboundRTPStreamStats() override;
536
Henrik Boström646fda02019-05-22 15:49:42 +0200537 RTCStatsMember<std::string> media_source_id;
Henrik Boström4f40fa52019-12-19 13:27:27 +0100538 RTCStatsMember<std::string> remote_id;
Henrik Boström1ab61882022-06-16 17:07:33 +0200539 RTCStatsMember<std::string> mid;
Henrik Boströma0ff50c2020-05-05 15:54:46 +0200540 RTCStatsMember<std::string> rid;
hbos6ded1902016-11-01 01:50:46 -0700541 RTCStatsMember<uint32_t> packets_sent;
Henrik Boströmcf96e0f2019-04-17 13:51:53 +0200542 RTCStatsMember<uint64_t> retransmitted_packets_sent;
hbos6ded1902016-11-01 01:50:46 -0700543 RTCStatsMember<uint64_t> bytes_sent;
Niels Möllerac0a4cb2019-10-09 15:01:33 +0200544 RTCStatsMember<uint64_t> header_bytes_sent;
Henrik Boströmcf96e0f2019-04-17 13:51:53 +0200545 RTCStatsMember<uint64_t> retransmitted_bytes_sent;
hbos6ded1902016-11-01 01:50:46 -0700546 RTCStatsMember<double> target_bitrate;
hbos6769c492017-01-02 08:35:13 -0800547 RTCStatsMember<uint32_t> frames_encoded;
Rasmus Brandt2efae772019-06-27 14:29:34 +0200548 RTCStatsMember<uint32_t> key_frames_encoded;
Henrik Boströmf71362f2019-04-08 16:14:23 +0200549 RTCStatsMember<double> total_encode_time;
Henrik Boström23aff9b2019-05-20 15:15:38 +0200550 RTCStatsMember<uint64_t> total_encoded_bytes_target;
Henrik Boströma0ff50c2020-05-05 15:54:46 +0200551 RTCStatsMember<uint32_t> frame_width;
552 RTCStatsMember<uint32_t> frame_height;
553 RTCStatsMember<double> frames_per_second;
554 RTCStatsMember<uint32_t> frames_sent;
555 RTCStatsMember<uint32_t> huge_frames_sent;
Henrik Boström9fe18342019-05-16 18:38:20 +0200556 RTCStatsMember<double> total_packet_send_delay;
Henrik Boströmce33b6a2019-05-28 17:42:38 +0200557 // Enum type RTCQualityLimitationReason
Henrik Boströmce33b6a2019-05-28 17:42:38 +0200558 RTCStatsMember<std::string> quality_limitation_reason;
Byoungchan Lee7d235352021-05-28 21:32:04 +0900559 RTCStatsMember<std::map<std::string, double>> quality_limitation_durations;
Evan Shrubsolecc62b162019-09-09 11:26:45 +0200560 // https://w3c.github.io/webrtc-stats/#dom-rtcoutboundrtpstreamstats-qualitylimitationresolutionchanges
561 RTCStatsMember<uint32_t> quality_limitation_resolution_changes;
Henrik Boström5abfc922022-06-13 10:23:28 +0200562 // https://w3c.github.io/webrtc-provisional-stats/#dom-rtcoutboundrtpstreamstats-contenttype
Henrik Boström2e069262019-04-09 13:59:31 +0200563 RTCStatsMember<std::string> content_type;
Henrik Boström5abfc922022-06-13 10:23:28 +0200564 // Only implemented for video.
565 // TODO(https://crbug.com/webrtc/14178): Implement for audio as well.
Evan Shrubsolef4abcc02022-10-31 11:04:22 +0000566 RTCRestrictedStatsMember<std::string,
567 StatExposureCriteria::kHardwareCapability>
568 encoder_implementation;
Philipp Hanckea3b5c4e2022-04-22 15:09:54 +0200569 // FIR and PLI counts are only defined for |kind == "video"|.
Di Wufd1e9d12021-03-09 09:25:28 -0800570 RTCStatsMember<uint32_t> fir_count;
571 RTCStatsMember<uint32_t> pli_count;
Di Wufd1e9d12021-03-09 09:25:28 -0800572 RTCStatsMember<uint32_t> nack_count;
573 RTCStatsMember<uint64_t> qp_sum;
Philipp Hancke684e2412022-07-28 12:41:00 +0200574 RTCStatsMember<bool> active;
Evan Shrubsole13c0be42022-10-31 11:03:10 +0000575 RTCRestrictedStatsMember<bool, StatExposureCriteria::kHardwareCapability>
576 power_efficient_encoder;
Evan Shrubsole9b235cd2022-12-06 10:09:10 +0000577 RTCStatsMember<std::string> scalability_mode;
hbos6ded1902016-11-01 01:50:46 -0700578};
579
Henrik Boström883eefc2019-05-27 13:40:25 +0200580// https://w3c.github.io/webrtc-stats/#remoteinboundrtpstats-dict*
Di Wufd1e9d12021-03-09 09:25:28 -0800581class RTC_EXPORT RTCRemoteInboundRtpStreamStats final
582 : public RTCReceivedRtpStreamStats {
Henrik Boström883eefc2019-05-27 13:40:25 +0200583 public:
584 WEBRTC_RTCSTATS_DECL();
585
Philipp Hanckeb81823a2023-01-04 15:17:42 +0100586 RTCRemoteInboundRtpStreamStats(std::string id, Timestamp timestamp);
Philipp Hanckee137c452023-01-10 13:06:02 +0100587 ABSL_DEPRECATED("Use constructor with Timestamp instead")
Philipp Hancke7a5de442023-01-02 13:20:45 +0100588 RTCRemoteInboundRtpStreamStats(std::string id, int64_t timestamp_us);
Henrik Boström883eefc2019-05-27 13:40:25 +0200589 RTCRemoteInboundRtpStreamStats(const RTCRemoteInboundRtpStreamStats& other);
590 ~RTCRemoteInboundRtpStreamStats() override;
591
Henrik Boström883eefc2019-05-27 13:40:25 +0200592 RTCStatsMember<std::string> local_id;
593 RTCStatsMember<double> round_trip_time;
Di Wu86f04ad2021-02-28 23:36:03 -0800594 RTCStatsMember<double> fraction_lost;
Di Wu88a51b22021-03-01 11:22:06 -0800595 RTCStatsMember<double> total_round_trip_time;
596 RTCStatsMember<int32_t> round_trip_time_measurements;
Henrik Boström883eefc2019-05-27 13:40:25 +0200597};
598
Alessio Bazzicaf7b1b952021-03-23 17:23:04 +0100599// https://w3c.github.io/webrtc-stats/#remoteoutboundrtpstats-dict*
600class RTC_EXPORT RTCRemoteOutboundRtpStreamStats final
601 : public RTCSentRtpStreamStats {
602 public:
603 WEBRTC_RTCSTATS_DECL();
604
Philipp Hanckeb81823a2023-01-04 15:17:42 +0100605 RTCRemoteOutboundRtpStreamStats(std::string id, Timestamp timestamp);
Philipp Hanckee137c452023-01-10 13:06:02 +0100606 ABSL_DEPRECATED("Use constructor with Timestamp instead")
Philipp Hancke7a5de442023-01-02 13:20:45 +0100607 RTCRemoteOutboundRtpStreamStats(std::string id, int64_t timestamp_us);
Alessio Bazzicaf7b1b952021-03-23 17:23:04 +0100608 RTCRemoteOutboundRtpStreamStats(const RTCRemoteOutboundRtpStreamStats& other);
609 ~RTCRemoteOutboundRtpStreamStats() override;
610
611 RTCStatsMember<std::string> local_id;
612 RTCStatsMember<double> remote_timestamp;
613 RTCStatsMember<uint64_t> reports_sent;
Ivo Creusen2562cf02021-09-03 14:51:22 +0000614 RTCStatsMember<double> round_trip_time;
615 RTCStatsMember<uint64_t> round_trip_time_measurements;
616 RTCStatsMember<double> total_round_trip_time;
Alessio Bazzicaf7b1b952021-03-23 17:23:04 +0100617};
618
Henrik Boström646fda02019-05-22 15:49:42 +0200619// https://w3c.github.io/webrtc-stats/#dom-rtcmediasourcestats
620class RTC_EXPORT RTCMediaSourceStats : public RTCStats {
621 public:
622 WEBRTC_RTCSTATS_DECL();
623
624 RTCMediaSourceStats(const RTCMediaSourceStats& other);
625 ~RTCMediaSourceStats() override;
626
627 RTCStatsMember<std::string> track_identifier;
628 RTCStatsMember<std::string> kind;
629
630 protected:
Philipp Hanckeb81823a2023-01-04 15:17:42 +0100631 RTCMediaSourceStats(std::string id, Timestamp timestamp);
Philipp Hanckee137c452023-01-10 13:06:02 +0100632 ABSL_DEPRECATED("Use constructor with Timestamp instead")
Philipp Hancke7a5de442023-01-02 13:20:45 +0100633 RTCMediaSourceStats(std::string id, int64_t timestamp_us);
Henrik Boström646fda02019-05-22 15:49:42 +0200634};
635
636// https://w3c.github.io/webrtc-stats/#dom-rtcaudiosourcestats
637class RTC_EXPORT RTCAudioSourceStats final : public RTCMediaSourceStats {
638 public:
639 WEBRTC_RTCSTATS_DECL();
640
Philipp Hanckeb81823a2023-01-04 15:17:42 +0100641 RTCAudioSourceStats(std::string id, Timestamp timestamp);
Philipp Hanckee137c452023-01-10 13:06:02 +0100642 ABSL_DEPRECATED("Use constructor with Timestamp instead")
Philipp Hancke7a5de442023-01-02 13:20:45 +0100643 RTCAudioSourceStats(std::string id, int64_t timestamp_us);
Henrik Boström646fda02019-05-22 15:49:42 +0200644 RTCAudioSourceStats(const RTCAudioSourceStats& other);
645 ~RTCAudioSourceStats() override;
Henrik Boströmd2c336f2019-07-03 17:11:10 +0200646
647 RTCStatsMember<double> audio_level;
648 RTCStatsMember<double> total_audio_energy;
649 RTCStatsMember<double> total_samples_duration;
Taylor Brandstetter64851c02021-06-24 13:32:50 -0700650 RTCStatsMember<double> echo_return_loss;
651 RTCStatsMember<double> echo_return_loss_enhancement;
Henrik Boström646fda02019-05-22 15:49:42 +0200652};
653
654// https://w3c.github.io/webrtc-stats/#dom-rtcvideosourcestats
655class RTC_EXPORT RTCVideoSourceStats final : public RTCMediaSourceStats {
656 public:
657 WEBRTC_RTCSTATS_DECL();
658
Philipp Hanckeb81823a2023-01-04 15:17:42 +0100659 RTCVideoSourceStats(std::string id, Timestamp timestamp);
Philipp Hanckee137c452023-01-10 13:06:02 +0100660 ABSL_DEPRECATED("Use constructor with Timestamp instead")
Philipp Hancke7a5de442023-01-02 13:20:45 +0100661 RTCVideoSourceStats(std::string id, int64_t timestamp_us);
Henrik Boström646fda02019-05-22 15:49:42 +0200662 RTCVideoSourceStats(const RTCVideoSourceStats& other);
663 ~RTCVideoSourceStats() override;
664
665 RTCStatsMember<uint32_t> width;
666 RTCStatsMember<uint32_t> height;
Henrik Boström646fda02019-05-22 15:49:42 +0200667 RTCStatsMember<uint32_t> frames;
Byoungchan Leeefe46b62021-11-10 11:23:56 +0900668 RTCStatsMember<double> frames_per_second;
Henrik Boström646fda02019-05-22 15:49:42 +0200669};
670
hbos2fa7c672016-10-24 04:00:05 -0700671// https://w3c.github.io/webrtc-stats/#transportstats-dict*
Mirko Bonadei276827c2018-10-16 14:13:50 +0200672class RTC_EXPORT RTCTransportStats final : public RTCStats {
hbos2fa7c672016-10-24 04:00:05 -0700673 public:
674 WEBRTC_RTCSTATS_DECL();
675
Philipp Hanckeb81823a2023-01-04 15:17:42 +0100676 RTCTransportStats(std::string id, Timestamp timestamp);
Philipp Hanckee137c452023-01-10 13:06:02 +0100677 ABSL_DEPRECATED("Use constructor with Timestamp instead")
Philipp Hancke7a5de442023-01-02 13:20:45 +0100678 RTCTransportStats(std::string id, int64_t timestamp_us);
hbos2fa7c672016-10-24 04:00:05 -0700679 RTCTransportStats(const RTCTransportStats& other);
680 ~RTCTransportStats() override;
681
682 RTCStatsMember<uint64_t> bytes_sent;
Artem Titovedacbd52020-07-06 16:06:37 +0200683 RTCStatsMember<uint64_t> packets_sent;
hbos2fa7c672016-10-24 04:00:05 -0700684 RTCStatsMember<uint64_t> bytes_received;
Artem Titovedacbd52020-07-06 16:06:37 +0200685 RTCStatsMember<uint64_t> packets_received;
hbos2fa7c672016-10-24 04:00:05 -0700686 RTCStatsMember<std::string> rtcp_transport_stats_id;
Henrik Boström5abfc922022-06-13 10:23:28 +0200687 // Enum type RTCDtlsTransportState.
hbos7064d592017-01-16 07:38:02 -0800688 RTCStatsMember<std::string> dtls_state;
hbos2fa7c672016-10-24 04:00:05 -0700689 RTCStatsMember<std::string> selected_candidate_pair_id;
690 RTCStatsMember<std::string> local_certificate_id;
691 RTCStatsMember<std::string> remote_certificate_id;
Harald Alvestrand5cb78072019-10-28 09:51:17 +0100692 RTCStatsMember<std::string> tls_version;
693 RTCStatsMember<std::string> dtls_cipher;
Philipp Hancke69c1df22022-04-22 15:46:24 +0200694 RTCStatsMember<std::string> dtls_role;
Harald Alvestrand5cb78072019-10-28 09:51:17 +0100695 RTCStatsMember<std::string> srtp_cipher;
Jonas Oreland149dc722019-08-28 08:10:27 +0200696 RTCStatsMember<uint32_t> selected_candidate_pair_changes;
Philipp Hanckecc1b9b02022-05-04 18:58:26 +0200697 RTCStatsMember<std::string> ice_role;
Philipp Hancke95b1a342022-05-05 07:53:54 +0200698 RTCStatsMember<std::string> ice_local_username_fragment;
Philipp Hancke1f491572022-05-09 17:43:31 +0200699 RTCStatsMember<std::string> ice_state;
hbos2fa7c672016-10-24 04:00:05 -0700700};
701
Fredrik Hernqvistefbe7532023-01-13 16:42:36 +0100702// https://w3c.github.io/webrtc-stats/#playoutstats-dict*
703class RTC_EXPORT RTCAudioPlayoutStats final : public RTCStats {
704 public:
705 WEBRTC_RTCSTATS_DECL();
706
707 RTCAudioPlayoutStats(const std::string& id, Timestamp timestamp);
708 RTCAudioPlayoutStats(const RTCAudioPlayoutStats& other);
709 ~RTCAudioPlayoutStats() override;
710
711 RTCStatsMember<double> synthesized_samples_duration;
712 RTCStatsMember<uint64_t> synthesized_samples_events;
713 RTCStatsMember<double> total_samples_duration;
714 RTCStatsMember<double> total_playout_delay;
715 RTCStatsMember<uint64_t> total_samples_count;
716};
717
hbosd565b732016-08-30 14:04:35 -0700718} // namespace webrtc
719
Mirko Bonadei92ea95e2017-09-15 06:47:31 +0200720#endif // API_STATS_RTCSTATS_OBJECTS_H_