blob: a4e8ead6b7f7b5390aa722229dd9d00a1c664751 [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
Henrik Boström1df1bf82018-03-20 13:24:20 +010016#include <memory>
hbosd565b732016-08-30 14:04:35 -070017#include <string>
oprypin803dc292017-02-01 01:55:59 -080018#include <vector>
hbosd565b732016-08-30 14:04:35 -070019
Steve Anton10542f22019-01-11 09:11:00 -080020#include "api/stats/rtc_stats.h"
Mirko Bonadei276827c2018-10-16 14:13:50 +020021#include "rtc_base/system/rtc_export.h"
hbosd565b732016-08-30 14:04:35 -070022
23namespace webrtc {
24
hboscc555c52016-10-18 12:48:31 -070025// https://w3c.github.io/webrtc-pc/#idl-def-rtcdatachannelstate
26struct RTCDataChannelState {
agrieve26622d32017-08-08 10:48:15 -070027 static const char* const kConnecting;
28 static const char* const kOpen;
29 static const char* const kClosing;
30 static const char* const kClosed;
hboscc555c52016-10-18 12:48:31 -070031};
32
hbosc47a0c32016-10-11 14:54:49 -070033// https://w3c.github.io/webrtc-stats/#dom-rtcstatsicecandidatepairstate
34struct RTCStatsIceCandidatePairState {
agrieve26622d32017-08-08 10:48:15 -070035 static const char* const kFrozen;
36 static const char* const kWaiting;
37 static const char* const kInProgress;
38 static const char* const kFailed;
39 static const char* const kSucceeded;
hbosc47a0c32016-10-11 14:54:49 -070040};
41
hboscc555c52016-10-18 12:48:31 -070042// https://w3c.github.io/webrtc-pc/#rtcicecandidatetype-enum
hbosab9f6e42016-10-07 02:18:47 -070043struct RTCIceCandidateType {
agrieve26622d32017-08-08 10:48:15 -070044 static const char* const kHost;
45 static const char* const kSrflx;
46 static const char* const kPrflx;
47 static const char* const kRelay;
hbosab9f6e42016-10-07 02:18:47 -070048};
49
hbos7064d592017-01-16 07:38:02 -080050// https://w3c.github.io/webrtc-pc/#idl-def-rtcdtlstransportstate
51struct RTCDtlsTransportState {
agrieve26622d32017-08-08 10:48:15 -070052 static const char* const kNew;
53 static const char* const kConnecting;
54 static const char* const kConnected;
55 static const char* const kClosed;
56 static const char* const kFailed;
hbos7064d592017-01-16 07:38:02 -080057};
58
hbos160e4a72017-01-17 02:53:23 -080059// |RTCMediaStreamTrackStats::kind| is not an enum in the spec but the only
60// valid values are "audio" and "video".
61// https://w3c.github.io/webrtc-stats/#dom-rtcmediastreamtrackstats-kind
62struct RTCMediaStreamTrackKind {
agrieve26622d32017-08-08 10:48:15 -070063 static const char* const kAudio;
64 static const char* const kVideo;
hbos160e4a72017-01-17 02:53:23 -080065};
66
Gary Liu37e489c2017-11-21 10:49:36 -080067// https://w3c.github.io/webrtc-stats/#dom-rtcnetworktype
68struct RTCNetworkType {
69 static const char* const kBluetooth;
70 static const char* const kCellular;
71 static const char* const kEthernet;
72 static const char* const kWifi;
73 static const char* const kWimax;
74 static const char* const kVpn;
75 static const char* const kUnknown;
76};
77
Henrik Boströmce33b6a2019-05-28 17:42:38 +020078// https://w3c.github.io/webrtc-stats/#dom-rtcqualitylimitationreason
79struct RTCQualityLimitationReason {
80 static const char* const kNone;
81 static const char* const kCpu;
82 static const char* const kBandwidth;
83 static const char* const kOther;
84};
85
Henrik Boström2e069262019-04-09 13:59:31 +020086// https://webrtc.org/experiments/rtp-hdrext/video-content-type/
87struct RTCContentType {
88 static const char* const kUnspecified;
89 static const char* const kScreenshare;
90};
91
hbos2fa7c672016-10-24 04:00:05 -070092// https://w3c.github.io/webrtc-stats/#certificatestats-dict*
Mirko Bonadei276827c2018-10-16 14:13:50 +020093class RTC_EXPORT RTCCertificateStats final : public RTCStats {
hbos2fa7c672016-10-24 04:00:05 -070094 public:
95 WEBRTC_RTCSTATS_DECL();
96
97 RTCCertificateStats(const std::string& id, int64_t timestamp_us);
98 RTCCertificateStats(std::string&& id, int64_t timestamp_us);
99 RTCCertificateStats(const RTCCertificateStats& other);
100 ~RTCCertificateStats() override;
101
102 RTCStatsMember<std::string> fingerprint;
103 RTCStatsMember<std::string> fingerprint_algorithm;
104 RTCStatsMember<std::string> base64_certificate;
105 RTCStatsMember<std::string> issuer_certificate_id;
106};
107
hbos0adb8282016-11-23 02:32:06 -0800108// https://w3c.github.io/webrtc-stats/#codec-dict*
Mirko Bonadei276827c2018-10-16 14:13:50 +0200109class RTC_EXPORT RTCCodecStats final : public RTCStats {
hbos0adb8282016-11-23 02:32:06 -0800110 public:
111 WEBRTC_RTCSTATS_DECL();
112
113 RTCCodecStats(const std::string& id, int64_t timestamp_us);
114 RTCCodecStats(std::string&& id, int64_t timestamp_us);
115 RTCCodecStats(const RTCCodecStats& other);
116 ~RTCCodecStats() override;
117
Philipp Hancke95157a02020-11-16 20:08:27 +0100118 RTCStatsMember<std::string> transport_id;
hbos0adb8282016-11-23 02:32:06 -0800119 RTCStatsMember<uint32_t> payload_type;
hbos13f54b22017-02-28 06:56:04 -0800120 RTCStatsMember<std::string> mime_type;
hbos0adb8282016-11-23 02:32:06 -0800121 RTCStatsMember<uint32_t> clock_rate;
hbos0adb8282016-11-23 02:32:06 -0800122 RTCStatsMember<uint32_t> channels;
hbos13f54b22017-02-28 06:56:04 -0800123 RTCStatsMember<std::string> sdp_fmtp_line;
hbos0adb8282016-11-23 02:32:06 -0800124};
125
hbos2fa7c672016-10-24 04:00:05 -0700126// https://w3c.github.io/webrtc-stats/#dcstats-dict*
Mirko Bonadei276827c2018-10-16 14:13:50 +0200127class RTC_EXPORT RTCDataChannelStats final : public RTCStats {
hbos2fa7c672016-10-24 04:00:05 -0700128 public:
129 WEBRTC_RTCSTATS_DECL();
130
131 RTCDataChannelStats(const std::string& id, int64_t timestamp_us);
132 RTCDataChannelStats(std::string&& id, int64_t timestamp_us);
133 RTCDataChannelStats(const RTCDataChannelStats& other);
134 ~RTCDataChannelStats() override;
135
136 RTCStatsMember<std::string> label;
137 RTCStatsMember<std::string> protocol;
Harald Alvestrand10ef8472020-06-05 15:38:51 +0200138 RTCStatsMember<int32_t> data_channel_identifier;
hbos2fa7c672016-10-24 04:00:05 -0700139 // TODO(hbos): Support enum types? "RTCStatsMember<RTCDataChannelState>"?
140 RTCStatsMember<std::string> state;
141 RTCStatsMember<uint32_t> messages_sent;
142 RTCStatsMember<uint64_t> bytes_sent;
143 RTCStatsMember<uint32_t> messages_received;
144 RTCStatsMember<uint64_t> bytes_received;
145};
146
147// https://w3c.github.io/webrtc-stats/#candidatepair-dict*
hbos338f78a2017-02-07 06:41:21 -0800148// TODO(hbos): Tracking bug https://bugs.webrtc.org/7062
Mirko Bonadei276827c2018-10-16 14:13:50 +0200149class RTC_EXPORT RTCIceCandidatePairStats final : public RTCStats {
hbosc47a0c32016-10-11 14:54:49 -0700150 public:
151 WEBRTC_RTCSTATS_DECL();
152
153 RTCIceCandidatePairStats(const std::string& id, int64_t timestamp_us);
154 RTCIceCandidatePairStats(std::string&& id, int64_t timestamp_us);
155 RTCIceCandidatePairStats(const RTCIceCandidatePairStats& other);
156 ~RTCIceCandidatePairStats() override;
157
158 RTCStatsMember<std::string> transport_id;
159 RTCStatsMember<std::string> local_candidate_id;
160 RTCStatsMember<std::string> remote_candidate_id;
161 // TODO(hbos): Support enum types?
162 // "RTCStatsMember<RTCStatsIceCandidatePairState>"?
163 RTCStatsMember<std::string> state;
164 RTCStatsMember<uint64_t> priority;
165 RTCStatsMember<bool> nominated;
hbos338f78a2017-02-07 06:41:21 -0800166 // TODO(hbos): Collect this the way the spec describes it. We have a value for
167 // it but it is not spec-compliant. https://bugs.webrtc.org/7062
hbosc47a0c32016-10-11 14:54:49 -0700168 RTCStatsMember<bool> writable;
hbos338f78a2017-02-07 06:41:21 -0800169 // TODO(hbos): Collect and populate this value. https://bugs.webrtc.org/7062
hbosc47a0c32016-10-11 14:54:49 -0700170 RTCStatsMember<bool> readable;
171 RTCStatsMember<uint64_t> bytes_sent;
172 RTCStatsMember<uint64_t> bytes_received;
hbos3168c7a2016-12-15 06:17:08 -0800173 RTCStatsMember<double> total_round_trip_time;
hbos3168c7a2016-12-15 06:17:08 -0800174 RTCStatsMember<double> current_round_trip_time;
hbosc47a0c32016-10-11 14:54:49 -0700175 RTCStatsMember<double> available_outgoing_bitrate;
hbos338f78a2017-02-07 06:41:21 -0800176 // TODO(hbos): Populate this value. It is wired up and collected the same way
hbosbf8d3e52017-02-28 06:34:47 -0800177 // "VideoBwe.googAvailableReceiveBandwidth" is, but that value is always
hbos338f78a2017-02-07 06:41:21 -0800178 // undefined. https://bugs.webrtc.org/7062
hbosc47a0c32016-10-11 14:54:49 -0700179 RTCStatsMember<double> available_incoming_bitrate;
180 RTCStatsMember<uint64_t> requests_received;
181 RTCStatsMember<uint64_t> requests_sent;
182 RTCStatsMember<uint64_t> responses_received;
183 RTCStatsMember<uint64_t> responses_sent;
hbos338f78a2017-02-07 06:41:21 -0800184 // TODO(hbos): Collect and populate this value. https://bugs.webrtc.org/7062
hbosc47a0c32016-10-11 14:54:49 -0700185 RTCStatsMember<uint64_t> retransmissions_received;
hbos338f78a2017-02-07 06:41:21 -0800186 // TODO(hbos): Collect and populate this value. https://bugs.webrtc.org/7062
hbosc47a0c32016-10-11 14:54:49 -0700187 RTCStatsMember<uint64_t> retransmissions_sent;
hbos338f78a2017-02-07 06:41:21 -0800188 // TODO(hbos): Collect and populate this value. https://bugs.webrtc.org/7062
hbosc47a0c32016-10-11 14:54:49 -0700189 RTCStatsMember<uint64_t> consent_requests_received;
190 RTCStatsMember<uint64_t> consent_requests_sent;
hbos338f78a2017-02-07 06:41:21 -0800191 // TODO(hbos): Collect and populate this value. https://bugs.webrtc.org/7062
hbosc47a0c32016-10-11 14:54:49 -0700192 RTCStatsMember<uint64_t> consent_responses_received;
hbos338f78a2017-02-07 06:41:21 -0800193 // TODO(hbos): Collect and populate this value. https://bugs.webrtc.org/7062
hbosc47a0c32016-10-11 14:54:49 -0700194 RTCStatsMember<uint64_t> consent_responses_sent;
195};
196
hbosab9f6e42016-10-07 02:18:47 -0700197// https://w3c.github.io/webrtc-stats/#icecandidate-dict*
hbos5d79a7c2016-10-24 09:27:10 -0700198// TODO(hbos): |RTCStatsCollector| only collects candidates that are part of
199// ice candidate pairs, but there could be candidates not paired with anything.
200// crbug.com/632723
Qingsi Wang72a43a12018-02-20 16:03:18 -0800201// TODO(qingsi): Add the stats of STUN binding requests (keepalives) and collect
202// them in the new PeerConnection::GetStats.
Mirko Bonadei276827c2018-10-16 14:13:50 +0200203class RTC_EXPORT RTCIceCandidateStats : public RTCStats {
hbosab9f6e42016-10-07 02:18:47 -0700204 public:
205 WEBRTC_RTCSTATS_DECL();
206
207 RTCIceCandidateStats(const RTCIceCandidateStats& other);
208 ~RTCIceCandidateStats() override;
209
hbosb4e426e2017-01-02 09:59:31 -0800210 RTCStatsMember<std::string> transport_id;
hbosc3a2b7f2017-01-02 04:46:15 -0800211 RTCStatsMember<bool> is_remote;
Gary Liu37e489c2017-11-21 10:49:36 -0800212 RTCStatsMember<std::string> network_type;
hbosab9f6e42016-10-07 02:18:47 -0700213 RTCStatsMember<std::string> ip;
214 RTCStatsMember<int32_t> port;
215 RTCStatsMember<std::string> protocol;
Philipp Hancke95513752018-09-27 14:40:08 +0200216 RTCStatsMember<std::string> relay_protocol;
hbosab9f6e42016-10-07 02:18:47 -0700217 // TODO(hbos): Support enum types? "RTCStatsMember<RTCIceCandidateType>"?
218 RTCStatsMember<std::string> candidate_type;
219 RTCStatsMember<int32_t> priority;
hbos5d79a7c2016-10-24 09:27:10 -0700220 // TODO(hbos): Not collected by |RTCStatsCollector|. crbug.com/632723
hbosab9f6e42016-10-07 02:18:47 -0700221 RTCStatsMember<std::string> url;
hbosd17a5a72017-01-02 08:09:59 -0800222 // TODO(hbos): |deleted = true| case is not supported by |RTCStatsCollector|.
223 // crbug.com/632723
224 RTCStatsMember<bool> deleted; // = false
hbosab9f6e42016-10-07 02:18:47 -0700225
226 protected:
Yves Gerey665174f2018-06-19 15:03:05 +0200227 RTCIceCandidateStats(const std::string& id,
228 int64_t timestamp_us,
229 bool is_remote);
hbosc3a2b7f2017-01-02 04:46:15 -0800230 RTCIceCandidateStats(std::string&& id, int64_t timestamp_us, bool is_remote);
hbosab9f6e42016-10-07 02:18:47 -0700231};
232
233// In the spec both local and remote varieties are of type RTCIceCandidateStats.
234// But here we define them as subclasses of |RTCIceCandidateStats| because the
235// |kType| need to be different ("RTCStatsType type") in the local/remote case.
236// https://w3c.github.io/webrtc-stats/#rtcstatstype-str*
Henrik Boström1df1bf82018-03-20 13:24:20 +0100237// This forces us to have to override copy() and type().
Mirko Bonadei276827c2018-10-16 14:13:50 +0200238class RTC_EXPORT RTCLocalIceCandidateStats final : public RTCIceCandidateStats {
hbosab9f6e42016-10-07 02:18:47 -0700239 public:
240 static const char kType[];
241 RTCLocalIceCandidateStats(const std::string& id, int64_t timestamp_us);
242 RTCLocalIceCandidateStats(std::string&& id, int64_t timestamp_us);
Henrik Boström1df1bf82018-03-20 13:24:20 +0100243 std::unique_ptr<RTCStats> copy() const override;
hbosab9f6e42016-10-07 02:18:47 -0700244 const char* type() const override;
245};
246
Mirko Bonadei276827c2018-10-16 14:13:50 +0200247class RTC_EXPORT RTCRemoteIceCandidateStats final
248 : public RTCIceCandidateStats {
hbosab9f6e42016-10-07 02:18:47 -0700249 public:
250 static const char kType[];
251 RTCRemoteIceCandidateStats(const std::string& id, int64_t timestamp_us);
252 RTCRemoteIceCandidateStats(std::string&& id, int64_t timestamp_us);
Henrik Boström1df1bf82018-03-20 13:24:20 +0100253 std::unique_ptr<RTCStats> copy() const override;
hbosab9f6e42016-10-07 02:18:47 -0700254 const char* type() const override;
255};
256
hbos09bc1282016-11-08 06:29:22 -0800257// https://w3c.github.io/webrtc-stats/#msstats-dict*
hbos0adb8282016-11-23 02:32:06 -0800258// TODO(hbos): Tracking bug crbug.com/660827
Mirko Bonadei276827c2018-10-16 14:13:50 +0200259class RTC_EXPORT RTCMediaStreamStats final : public RTCStats {
hbos09bc1282016-11-08 06:29:22 -0800260 public:
261 WEBRTC_RTCSTATS_DECL();
262
263 RTCMediaStreamStats(const std::string& id, int64_t timestamp_us);
264 RTCMediaStreamStats(std::string&& id, int64_t timestamp_us);
265 RTCMediaStreamStats(const RTCMediaStreamStats& other);
266 ~RTCMediaStreamStats() override;
267
268 RTCStatsMember<std::string> stream_identifier;
269 RTCStatsMember<std::vector<std::string>> track_ids;
270};
271
272// https://w3c.github.io/webrtc-stats/#mststats-dict*
hbos0adb8282016-11-23 02:32:06 -0800273// TODO(hbos): Tracking bug crbug.com/659137
Mirko Bonadei276827c2018-10-16 14:13:50 +0200274class RTC_EXPORT RTCMediaStreamTrackStats final : public RTCStats {
hbos09bc1282016-11-08 06:29:22 -0800275 public:
276 WEBRTC_RTCSTATS_DECL();
277
Yves Gerey665174f2018-06-19 15:03:05 +0200278 RTCMediaStreamTrackStats(const std::string& id,
279 int64_t timestamp_us,
hbos160e4a72017-01-17 02:53:23 -0800280 const char* kind);
Yves Gerey665174f2018-06-19 15:03:05 +0200281 RTCMediaStreamTrackStats(std::string&& id,
282 int64_t timestamp_us,
hbos160e4a72017-01-17 02:53:23 -0800283 const char* kind);
hbos09bc1282016-11-08 06:29:22 -0800284 RTCMediaStreamTrackStats(const RTCMediaStreamTrackStats& other);
285 ~RTCMediaStreamTrackStats() override;
286
287 RTCStatsMember<std::string> track_identifier;
Henrik Boström646fda02019-05-22 15:49:42 +0200288 RTCStatsMember<std::string> media_source_id;
hbos09bc1282016-11-08 06:29:22 -0800289 RTCStatsMember<bool> remote_source;
290 RTCStatsMember<bool> ended;
291 // TODO(hbos): |RTCStatsCollector| does not return stats for detached tracks.
292 // crbug.com/659137
293 RTCStatsMember<bool> detached;
hbos160e4a72017-01-17 02:53:23 -0800294 // See |RTCMediaStreamTrackKind| for valid values.
295 RTCStatsMember<std::string> kind;
Gustaf Ullbergb0a02072017-10-02 12:00:34 +0200296 RTCStatsMember<double> jitter_buffer_delay;
Chen Xing0acffb52019-01-15 15:46:29 +0100297 RTCStatsMember<uint64_t> jitter_buffer_emitted_count;
hbos09bc1282016-11-08 06:29:22 -0800298 // Video-only members
299 RTCStatsMember<uint32_t> frame_width;
300 RTCStatsMember<uint32_t> frame_height;
301 // TODO(hbos): Not collected by |RTCStatsCollector|. crbug.com/659137
302 RTCStatsMember<double> frames_per_second;
hbos09bc1282016-11-08 06:29:22 -0800303 RTCStatsMember<uint32_t> frames_sent;
Ilya Nikolaevskiy70473fc2018-02-28 16:35:03 +0100304 RTCStatsMember<uint32_t> huge_frames_sent;
hbos09bc1282016-11-08 06:29:22 -0800305 RTCStatsMember<uint32_t> frames_received;
hbos09bc1282016-11-08 06:29:22 -0800306 RTCStatsMember<uint32_t> frames_decoded;
hbos09bc1282016-11-08 06:29:22 -0800307 RTCStatsMember<uint32_t> frames_dropped;
308 // TODO(hbos): Not collected by |RTCStatsCollector|. crbug.com/659137
309 RTCStatsMember<uint32_t> frames_corrupted;
310 // TODO(hbos): Not collected by |RTCStatsCollector|. crbug.com/659137
311 RTCStatsMember<uint32_t> partial_frames_lost;
312 // TODO(hbos): Not collected by |RTCStatsCollector|. crbug.com/659137
313 RTCStatsMember<uint32_t> full_frames_lost;
314 // Audio-only members
Henrik Boströmd2c336f2019-07-03 17:11:10 +0200315 RTCStatsMember<double> audio_level; // Receive-only
316 RTCStatsMember<double> total_audio_energy; // Receive-only
hbos09bc1282016-11-08 06:29:22 -0800317 RTCStatsMember<double> echo_return_loss;
318 RTCStatsMember<double> echo_return_loss_enhancement;
Steve Anton2dbc69f2017-08-24 17:15:13 -0700319 RTCStatsMember<uint64_t> total_samples_received;
Henrik Boströmd2c336f2019-07-03 17:11:10 +0200320 RTCStatsMember<double> total_samples_duration; // Receive-only
Steve Anton2dbc69f2017-08-24 17:15:13 -0700321 RTCStatsMember<uint64_t> concealed_samples;
Ivo Creusen8d8ffdb2019-04-30 09:45:21 +0200322 RTCStatsMember<uint64_t> silent_concealed_samples;
Gustaf Ullberg9a2e9062017-09-18 09:28:20 +0200323 RTCStatsMember<uint64_t> concealment_events;
Ivo Creusen8d8ffdb2019-04-30 09:45:21 +0200324 RTCStatsMember<uint64_t> inserted_samples_for_deceleration;
325 RTCStatsMember<uint64_t> removed_samples_for_acceleration;
Ruslan Burakov8af88962018-11-22 17:21:10 +0100326 // Non-standard audio-only member
Jakob Ivarsson352ce5c2018-11-27 12:52:16 +0100327 // TODO(kuddai): Add description to standard. crbug.com/webrtc/10042
Ruslan Burakov8af88962018-11-22 17:21:10 +0100328 RTCNonStandardStatsMember<uint64_t> jitter_buffer_flushes;
Jakob Ivarsson352ce5c2018-11-27 12:52:16 +0100329 RTCNonStandardStatsMember<uint64_t> delayed_packet_outage_samples;
Jakob Ivarsson232b3fd2019-03-06 09:18:40 +0100330 RTCNonStandardStatsMember<double> relative_packet_arrival_delay;
Artem Titove618cc92020-03-11 11:18:54 +0100331 // Non-standard metric showing target delay of jitter buffer.
332 // This value is increased by the target jitter buffer delay every time a
333 // sample is emitted by the jitter buffer. The added target is the target
334 // delay, in seconds, at the time that the sample was emitted from the jitter
335 // buffer. (https://github.com/w3c/webrtc-provisional-stats/pull/20)
336 // Currently it is implemented only for audio.
337 // TODO(titovartem) implement for video streams when will be requested.
338 RTCNonStandardStatsMember<double> jitter_buffer_target_delay;
Henrik Lundin44125fa2019-04-29 17:00:46 +0200339 // TODO(henrik.lundin): Add description of the interruption metrics at
340 // https://github.com/henbos/webrtc-provisional-stats/issues/17
341 RTCNonStandardStatsMember<uint32_t> interruption_count;
342 RTCNonStandardStatsMember<double> total_interruption_duration;
Sergey Silkin02371062019-01-31 16:45:42 +0100343 // Non-standard video-only members.
344 // https://henbos.github.io/webrtc-provisional-stats/#RTCVideoReceiverStats-dict*
345 RTCNonStandardStatsMember<uint32_t> freeze_count;
346 RTCNonStandardStatsMember<uint32_t> pause_count;
347 RTCNonStandardStatsMember<double> total_freezes_duration;
348 RTCNonStandardStatsMember<double> total_pauses_duration;
349 RTCNonStandardStatsMember<double> total_frames_duration;
350 RTCNonStandardStatsMember<double> sum_squared_frame_durations;
hbos09bc1282016-11-08 06:29:22 -0800351};
352
hbos6ab97ce2016-10-03 14:16:56 -0700353// https://w3c.github.io/webrtc-stats/#pcstats-dict*
Mirko Bonadei276827c2018-10-16 14:13:50 +0200354class RTC_EXPORT RTCPeerConnectionStats final : public RTCStats {
hbosd565b732016-08-30 14:04:35 -0700355 public:
hbosfc5e0502016-10-06 02:06:10 -0700356 WEBRTC_RTCSTATS_DECL();
357
hbos0e6758d2016-08-31 07:57:36 -0700358 RTCPeerConnectionStats(const std::string& id, int64_t timestamp_us);
359 RTCPeerConnectionStats(std::string&& id, int64_t timestamp_us);
hbosfc5e0502016-10-06 02:06:10 -0700360 RTCPeerConnectionStats(const RTCPeerConnectionStats& other);
361 ~RTCPeerConnectionStats() override;
hbosd565b732016-08-30 14:04:35 -0700362
363 RTCStatsMember<uint32_t> data_channels_opened;
364 RTCStatsMember<uint32_t> data_channels_closed;
365};
366
hbos6ded1902016-11-01 01:50:46 -0700367// https://w3c.github.io/webrtc-stats/#streamstats-dict*
hbos0adb8282016-11-23 02:32:06 -0800368// TODO(hbos): Tracking bug crbug.com/657854
Mirko Bonadei276827c2018-10-16 14:13:50 +0200369class RTC_EXPORT RTCRTPStreamStats : public RTCStats {
hbos6ded1902016-11-01 01:50:46 -0700370 public:
371 WEBRTC_RTCSTATS_DECL();
372
373 RTCRTPStreamStats(const RTCRTPStreamStats& other);
374 ~RTCRTPStreamStats() override;
375
hbos3443bb72017-02-07 06:28:11 -0800376 RTCStatsMember<uint32_t> ssrc;
Philipp Hancke3bc01662018-08-28 14:55:03 +0200377 RTCStatsMember<std::string> kind;
hbosb0ae9202017-01-27 06:35:16 -0800378 RTCStatsMember<std::string> track_id;
hbos6ded1902016-11-01 01:50:46 -0700379 RTCStatsMember<std::string> transport_id;
hbos6ded1902016-11-01 01:50:46 -0700380 RTCStatsMember<std::string> codec_id;
Di Wufd1e9d12021-03-09 09:25:28 -0800381
382 // Obsolete
383 RTCStatsMember<std::string> media_type; // renamed to kind.
hbos6ded1902016-11-01 01:50:46 -0700384
385 protected:
386 RTCRTPStreamStats(const std::string& id, int64_t timestamp_us);
387 RTCRTPStreamStats(std::string&& id, int64_t timestamp_us);
388};
389
Di Wufd1e9d12021-03-09 09:25:28 -0800390class RTC_EXPORT RTCReceivedRtpStreamStats : public RTCRTPStreamStats {
391 public:
392 WEBRTC_RTCSTATS_DECL();
393
394 RTCReceivedRtpStreamStats(const RTCReceivedRtpStreamStats& other);
395 ~RTCReceivedRtpStreamStats() override;
396
397 // TODO(hbos) The following fields need to be added and migrated
398 // both from RTCInboundRtpStreamStats and RTCRemoteInboundRtpStreamStats:
399 // packetsReceived, packetsDiscarded, packetsRepaired, burstPacketsLost,
400 // burstPacketDiscarded, burstLossCount, burstDiscardCount, burstLossRate,
401 // burstDiscardRate, gapLossRate, gapDiscardRate, framesDropped,
402 // partialFramesLost, fullFramesLost
403 // crbug.com/webrtc/12532
404 RTCStatsMember<double> jitter;
405 RTCStatsMember<int32_t> packets_lost; // Signed per RFC 3550
406
407 protected:
408 RTCReceivedRtpStreamStats(const std::string&& id, int64_t timestamp_us);
409 RTCReceivedRtpStreamStats(std::string&& id, int64_t timestamp_us);
410};
411
hboseeafe942016-11-01 03:00:17 -0700412// https://w3c.github.io/webrtc-stats/#inboundrtpstats-dict*
hbosa7a9be12017-03-01 01:02:45 -0800413// TODO(hbos): Support the remote case |is_remote = true|.
414// https://bugs.webrtc.org/7065
Di Wufd1e9d12021-03-09 09:25:28 -0800415class RTC_EXPORT RTCInboundRTPStreamStats final
416 : public RTCReceivedRtpStreamStats {
hboseeafe942016-11-01 03:00:17 -0700417 public:
418 WEBRTC_RTCSTATS_DECL();
419
420 RTCInboundRTPStreamStats(const std::string& id, int64_t timestamp_us);
421 RTCInboundRTPStreamStats(std::string&& id, int64_t timestamp_us);
422 RTCInboundRTPStreamStats(const RTCInboundRTPStreamStats& other);
423 ~RTCInboundRTPStreamStats() override;
424
425 RTCStatsMember<uint32_t> packets_received;
Ivo Creusen8d8ffdb2019-04-30 09:45:21 +0200426 RTCStatsMember<uint64_t> fec_packets_received;
427 RTCStatsMember<uint64_t> fec_packets_discarded;
hboseeafe942016-11-01 03:00:17 -0700428 RTCStatsMember<uint64_t> bytes_received;
Niels Möllerac0a4cb2019-10-09 15:01:33 +0200429 RTCStatsMember<uint64_t> header_bytes_received;
Henrik Boström01738c62019-04-15 17:32:00 +0200430 RTCStatsMember<double> last_packet_received_timestamp;
Eldar Rello4e5bc9f2020-07-06 14:18:07 +0300431 RTCStatsMember<double> jitter_buffer_delay;
432 RTCStatsMember<uint64_t> jitter_buffer_emitted_count;
433 RTCStatsMember<uint64_t> total_samples_received;
434 RTCStatsMember<uint64_t> concealed_samples;
435 RTCStatsMember<uint64_t> silent_concealed_samples;
436 RTCStatsMember<uint64_t> concealment_events;
437 RTCStatsMember<uint64_t> inserted_samples_for_deceleration;
438 RTCStatsMember<uint64_t> removed_samples_for_acceleration;
439 RTCStatsMember<double> audio_level;
440 RTCStatsMember<double> total_audio_energy;
441 RTCStatsMember<double> total_samples_duration;
442 RTCStatsMember<int32_t> frames_received;
hbosa7a9be12017-03-01 01:02:45 -0800443 // TODO(hbos): Collect and populate this value. https://bugs.webrtc.org/7065
444 RTCStatsMember<double> round_trip_time;
445 // TODO(hbos): Collect and populate this value. https://bugs.webrtc.org/7065
hboseeafe942016-11-01 03:00:17 -0700446 RTCStatsMember<uint32_t> packets_discarded;
hbosa7a9be12017-03-01 01:02:45 -0800447 // TODO(hbos): Collect and populate this value. https://bugs.webrtc.org/7065
hboseeafe942016-11-01 03:00:17 -0700448 RTCStatsMember<uint32_t> packets_repaired;
hbosa7a9be12017-03-01 01:02:45 -0800449 // TODO(hbos): Collect and populate this value. https://bugs.webrtc.org/7065
hboseeafe942016-11-01 03:00:17 -0700450 RTCStatsMember<uint32_t> burst_packets_lost;
hbosa7a9be12017-03-01 01:02:45 -0800451 // TODO(hbos): Collect and populate this value. https://bugs.webrtc.org/7065
hboseeafe942016-11-01 03:00:17 -0700452 RTCStatsMember<uint32_t> burst_packets_discarded;
hbosa7a9be12017-03-01 01:02:45 -0800453 // TODO(hbos): Collect and populate this value. https://bugs.webrtc.org/7065
hboseeafe942016-11-01 03:00:17 -0700454 RTCStatsMember<uint32_t> burst_loss_count;
hbosa7a9be12017-03-01 01:02:45 -0800455 // TODO(hbos): Collect and populate this value. https://bugs.webrtc.org/7065
hboseeafe942016-11-01 03:00:17 -0700456 RTCStatsMember<uint32_t> burst_discard_count;
hbosa7a9be12017-03-01 01:02:45 -0800457 // TODO(hbos): Collect and populate this value. https://bugs.webrtc.org/7065
hboseeafe942016-11-01 03:00:17 -0700458 RTCStatsMember<double> burst_loss_rate;
hbosa7a9be12017-03-01 01:02:45 -0800459 // TODO(hbos): Collect and populate this value. https://bugs.webrtc.org/7065
hboseeafe942016-11-01 03:00:17 -0700460 RTCStatsMember<double> burst_discard_rate;
hbosa7a9be12017-03-01 01:02:45 -0800461 // TODO(hbos): Collect and populate this value. https://bugs.webrtc.org/7065
hboseeafe942016-11-01 03:00:17 -0700462 RTCStatsMember<double> gap_loss_rate;
hbosa7a9be12017-03-01 01:02:45 -0800463 // TODO(hbos): Collect and populate this value. https://bugs.webrtc.org/7065
hboseeafe942016-11-01 03:00:17 -0700464 RTCStatsMember<double> gap_discard_rate;
Eldar Rello4e5bc9f2020-07-06 14:18:07 +0300465 RTCStatsMember<uint32_t> frame_width;
466 RTCStatsMember<uint32_t> frame_height;
467 RTCStatsMember<uint32_t> frame_bit_depth;
468 RTCStatsMember<double> frames_per_second;
hbos6769c492017-01-02 08:35:13 -0800469 RTCStatsMember<uint32_t> frames_decoded;
Rasmus Brandt2efae772019-06-27 14:29:34 +0200470 RTCStatsMember<uint32_t> key_frames_decoded;
Eldar Rello4e5bc9f2020-07-06 14:18:07 +0300471 RTCStatsMember<uint32_t> frames_dropped;
Johannes Kronbfd343b2019-07-01 10:07:50 +0200472 RTCStatsMember<double> total_decode_time;
Johannes Kron00376e12019-11-25 10:25:42 +0100473 RTCStatsMember<double> total_inter_frame_delay;
474 RTCStatsMember<double> total_squared_inter_frame_delay;
Henrik Boström2e069262019-04-09 13:59:31 +0200475 // https://henbos.github.io/webrtc-provisional-stats/#dom-rtcinboundrtpstreamstats-contenttype
476 RTCStatsMember<std::string> content_type;
Åsa Perssonfcf79cc2019-10-22 15:23:44 +0200477 // TODO(asapersson): Currently only populated if audio/video sync is enabled.
478 RTCStatsMember<double> estimated_playout_timestamp;
Henrik Boström6b430862019-08-16 13:09:51 +0200479 // TODO(hbos): This is only implemented for video; implement it for audio as
480 // well.
481 RTCStatsMember<std::string> decoder_implementation;
Di Wufd1e9d12021-03-09 09:25:28 -0800482 // FIR and PLI counts are only defined for |media_type == "video"|.
483 RTCStatsMember<uint32_t> fir_count;
484 RTCStatsMember<uint32_t> pli_count;
485 // TODO(hbos): NACK count should be collected by |RTCStatsCollector| for both
486 // audio and video but is only defined in the "video" case. crbug.com/657856
487 RTCStatsMember<uint32_t> nack_count;
488 RTCStatsMember<uint64_t> qp_sum;
489
490 // Obsolete
491 RTCStatsMember<bool> is_remote; // = false
hboseeafe942016-11-01 03:00:17 -0700492};
493
hbos6ded1902016-11-01 01:50:46 -0700494// https://w3c.github.io/webrtc-stats/#outboundrtpstats-dict*
hbosa7a9be12017-03-01 01:02:45 -0800495// TODO(hbos): Support the remote case |is_remote = true|.
496// https://bugs.webrtc.org/7066
Mirko Bonadei276827c2018-10-16 14:13:50 +0200497class RTC_EXPORT RTCOutboundRTPStreamStats final : public RTCRTPStreamStats {
hbos6ded1902016-11-01 01:50:46 -0700498 public:
499 WEBRTC_RTCSTATS_DECL();
500
501 RTCOutboundRTPStreamStats(const std::string& id, int64_t timestamp_us);
502 RTCOutboundRTPStreamStats(std::string&& id, int64_t timestamp_us);
503 RTCOutboundRTPStreamStats(const RTCOutboundRTPStreamStats& other);
504 ~RTCOutboundRTPStreamStats() override;
505
Henrik Boström646fda02019-05-22 15:49:42 +0200506 RTCStatsMember<std::string> media_source_id;
Henrik Boström4f40fa52019-12-19 13:27:27 +0100507 RTCStatsMember<std::string> remote_id;
Henrik Boströma0ff50c2020-05-05 15:54:46 +0200508 RTCStatsMember<std::string> rid;
hbos6ded1902016-11-01 01:50:46 -0700509 RTCStatsMember<uint32_t> packets_sent;
Henrik Boströmcf96e0f2019-04-17 13:51:53 +0200510 RTCStatsMember<uint64_t> retransmitted_packets_sent;
hbos6ded1902016-11-01 01:50:46 -0700511 RTCStatsMember<uint64_t> bytes_sent;
Niels Möllerac0a4cb2019-10-09 15:01:33 +0200512 RTCStatsMember<uint64_t> header_bytes_sent;
Henrik Boströmcf96e0f2019-04-17 13:51:53 +0200513 RTCStatsMember<uint64_t> retransmitted_bytes_sent;
hbosa7a9be12017-03-01 01:02:45 -0800514 // TODO(hbos): Collect and populate this value. https://bugs.webrtc.org/7066
hbos6ded1902016-11-01 01:50:46 -0700515 RTCStatsMember<double> target_bitrate;
hbos6769c492017-01-02 08:35:13 -0800516 RTCStatsMember<uint32_t> frames_encoded;
Rasmus Brandt2efae772019-06-27 14:29:34 +0200517 RTCStatsMember<uint32_t> key_frames_encoded;
Henrik Boströmf71362f2019-04-08 16:14:23 +0200518 RTCStatsMember<double> total_encode_time;
Henrik Boström23aff9b2019-05-20 15:15:38 +0200519 RTCStatsMember<uint64_t> total_encoded_bytes_target;
Henrik Boströma0ff50c2020-05-05 15:54:46 +0200520 RTCStatsMember<uint32_t> frame_width;
521 RTCStatsMember<uint32_t> frame_height;
522 RTCStatsMember<double> frames_per_second;
523 RTCStatsMember<uint32_t> frames_sent;
524 RTCStatsMember<uint32_t> huge_frames_sent;
Henrik Boström9fe18342019-05-16 18:38:20 +0200525 // TODO(https://crbug.com/webrtc/10635): This is only implemented for video;
526 // implement it for audio as well.
527 RTCStatsMember<double> total_packet_send_delay;
Henrik Boströmce33b6a2019-05-28 17:42:38 +0200528 // Enum type RTCQualityLimitationReason
529 // TODO(https://crbug.com/webrtc/10686): Also expose
530 // qualityLimitationDurations. Requires RTCStatsMember support for
531 // "record<DOMString, double>", see https://crbug.com/webrtc/10685.
532 RTCStatsMember<std::string> quality_limitation_reason;
Evan Shrubsolecc62b162019-09-09 11:26:45 +0200533 // https://w3c.github.io/webrtc-stats/#dom-rtcoutboundrtpstreamstats-qualitylimitationresolutionchanges
534 RTCStatsMember<uint32_t> quality_limitation_resolution_changes;
Henrik Boström2e069262019-04-09 13:59:31 +0200535 // https://henbos.github.io/webrtc-provisional-stats/#dom-rtcoutboundrtpstreamstats-contenttype
536 RTCStatsMember<std::string> content_type;
Henrik Boström6b430862019-08-16 13:09:51 +0200537 // TODO(hbos): This is only implemented for video; implement it for audio as
538 // well.
539 RTCStatsMember<std::string> encoder_implementation;
Di Wufd1e9d12021-03-09 09:25:28 -0800540 // FIR and PLI counts are only defined for |media_type == "video"|.
541 RTCStatsMember<uint32_t> fir_count;
542 RTCStatsMember<uint32_t> pli_count;
543 // TODO(hbos): NACK count should be collected by |RTCStatsCollector| for both
544 // audio and video but is only defined in the "video" case. crbug.com/657856
545 RTCStatsMember<uint32_t> nack_count;
546 RTCStatsMember<uint64_t> qp_sum;
547
548 // Obsolete
549 RTCStatsMember<bool> is_remote; // = false
hbos6ded1902016-11-01 01:50:46 -0700550};
551
Henrik Boström883eefc2019-05-27 13:40:25 +0200552// https://w3c.github.io/webrtc-stats/#remoteinboundrtpstats-dict*
Di Wufd1e9d12021-03-09 09:25:28 -0800553class RTC_EXPORT RTCRemoteInboundRtpStreamStats final
554 : public RTCReceivedRtpStreamStats {
Henrik Boström883eefc2019-05-27 13:40:25 +0200555 public:
556 WEBRTC_RTCSTATS_DECL();
557
558 RTCRemoteInboundRtpStreamStats(const std::string& id, int64_t timestamp_us);
559 RTCRemoteInboundRtpStreamStats(std::string&& id, int64_t timestamp_us);
560 RTCRemoteInboundRtpStreamStats(const RTCRemoteInboundRtpStreamStats& other);
561 ~RTCRemoteInboundRtpStreamStats() override;
562
Henrik Boström883eefc2019-05-27 13:40:25 +0200563 // TODO(hbos): The following RTCReceivedRtpStreamStats metrics should also be
564 // implemented: packetsReceived, packetsDiscarded, packetsRepaired,
565 // burstPacketsLost, burstPacketsDiscarded, burstLossCount, burstDiscardCount,
566 // burstLossRate, burstDiscardRate, gapLossRate and gapDiscardRate.
567 // RTCRemoteInboundRtpStreamStats
568 RTCStatsMember<std::string> local_id;
569 RTCStatsMember<double> round_trip_time;
Di Wu86f04ad2021-02-28 23:36:03 -0800570 RTCStatsMember<double> fraction_lost;
Di Wu88a51b22021-03-01 11:22:06 -0800571 RTCStatsMember<double> total_round_trip_time;
572 RTCStatsMember<int32_t> round_trip_time_measurements;
Henrik Boström883eefc2019-05-27 13:40:25 +0200573};
574
Henrik Boström646fda02019-05-22 15:49:42 +0200575// https://w3c.github.io/webrtc-stats/#dom-rtcmediasourcestats
576class RTC_EXPORT RTCMediaSourceStats : public RTCStats {
577 public:
578 WEBRTC_RTCSTATS_DECL();
579
580 RTCMediaSourceStats(const RTCMediaSourceStats& other);
581 ~RTCMediaSourceStats() override;
582
583 RTCStatsMember<std::string> track_identifier;
584 RTCStatsMember<std::string> kind;
585
586 protected:
587 RTCMediaSourceStats(const std::string& id, int64_t timestamp_us);
588 RTCMediaSourceStats(std::string&& id, int64_t timestamp_us);
589};
590
591// https://w3c.github.io/webrtc-stats/#dom-rtcaudiosourcestats
592class RTC_EXPORT RTCAudioSourceStats final : public RTCMediaSourceStats {
593 public:
594 WEBRTC_RTCSTATS_DECL();
595
596 RTCAudioSourceStats(const std::string& id, int64_t timestamp_us);
597 RTCAudioSourceStats(std::string&& id, int64_t timestamp_us);
598 RTCAudioSourceStats(const RTCAudioSourceStats& other);
599 ~RTCAudioSourceStats() override;
Henrik Boströmd2c336f2019-07-03 17:11:10 +0200600
601 RTCStatsMember<double> audio_level;
602 RTCStatsMember<double> total_audio_energy;
603 RTCStatsMember<double> total_samples_duration;
Henrik Boström646fda02019-05-22 15:49:42 +0200604};
605
606// https://w3c.github.io/webrtc-stats/#dom-rtcvideosourcestats
607class RTC_EXPORT RTCVideoSourceStats final : public RTCMediaSourceStats {
608 public:
609 WEBRTC_RTCSTATS_DECL();
610
611 RTCVideoSourceStats(const std::string& id, int64_t timestamp_us);
612 RTCVideoSourceStats(std::string&& id, int64_t timestamp_us);
613 RTCVideoSourceStats(const RTCVideoSourceStats& other);
614 ~RTCVideoSourceStats() override;
615
616 RTCStatsMember<uint32_t> width;
617 RTCStatsMember<uint32_t> height;
Henrik Boström646fda02019-05-22 15:49:42 +0200618 RTCStatsMember<uint32_t> frames;
619 RTCStatsMember<uint32_t> frames_per_second;
620};
621
hbos2fa7c672016-10-24 04:00:05 -0700622// https://w3c.github.io/webrtc-stats/#transportstats-dict*
Mirko Bonadei276827c2018-10-16 14:13:50 +0200623class RTC_EXPORT RTCTransportStats final : public RTCStats {
hbos2fa7c672016-10-24 04:00:05 -0700624 public:
625 WEBRTC_RTCSTATS_DECL();
626
627 RTCTransportStats(const std::string& id, int64_t timestamp_us);
628 RTCTransportStats(std::string&& id, int64_t timestamp_us);
629 RTCTransportStats(const RTCTransportStats& other);
630 ~RTCTransportStats() override;
631
632 RTCStatsMember<uint64_t> bytes_sent;
Artem Titovedacbd52020-07-06 16:06:37 +0200633 RTCStatsMember<uint64_t> packets_sent;
hbos2fa7c672016-10-24 04:00:05 -0700634 RTCStatsMember<uint64_t> bytes_received;
Artem Titovedacbd52020-07-06 16:06:37 +0200635 RTCStatsMember<uint64_t> packets_received;
hbos2fa7c672016-10-24 04:00:05 -0700636 RTCStatsMember<std::string> rtcp_transport_stats_id;
hbos7064d592017-01-16 07:38:02 -0800637 // TODO(hbos): Support enum types? "RTCStatsMember<RTCDtlsTransportState>"?
638 RTCStatsMember<std::string> dtls_state;
hbos2fa7c672016-10-24 04:00:05 -0700639 RTCStatsMember<std::string> selected_candidate_pair_id;
640 RTCStatsMember<std::string> local_certificate_id;
641 RTCStatsMember<std::string> remote_certificate_id;
Harald Alvestrand5cb78072019-10-28 09:51:17 +0100642 RTCStatsMember<std::string> tls_version;
643 RTCStatsMember<std::string> dtls_cipher;
644 RTCStatsMember<std::string> srtp_cipher;
Jonas Oreland149dc722019-08-28 08:10:27 +0200645 RTCStatsMember<uint32_t> selected_candidate_pair_changes;
hbos2fa7c672016-10-24 04:00:05 -0700646};
647
hbosd565b732016-08-30 14:04:35 -0700648} // namespace webrtc
649
Mirko Bonadei92ea95e2017-09-15 06:47:31 +0200650#endif // API_STATS_RTCSTATS_OBJECTS_H_