blob: 8955c4eb3e329fbb05c08e99fd8b855f550e2e19 [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
118 RTCStatsMember<uint32_t> payload_type;
hbos13f54b22017-02-28 06:56:04 -0800119 RTCStatsMember<std::string> mime_type;
hbos0adb8282016-11-23 02:32:06 -0800120 RTCStatsMember<uint32_t> clock_rate;
hbos585a9b12017-02-07 04:59:16 -0800121 // TODO(hbos): Collect and populate this value. https://bugs.webrtc.org/7061
hbos0adb8282016-11-23 02:32:06 -0800122 RTCStatsMember<uint32_t> channels;
hbos585a9b12017-02-07 04:59:16 -0800123 // TODO(hbos): Collect and populate this value. https://bugs.webrtc.org/7061
hbos13f54b22017-02-28 06:56:04 -0800124 RTCStatsMember<std::string> sdp_fmtp_line;
hbos585a9b12017-02-07 04:59:16 -0800125 // TODO(hbos): Collect and populate this value. https://bugs.webrtc.org/7061
hbos0adb8282016-11-23 02:32:06 -0800126 RTCStatsMember<std::string> implementation;
127};
128
hbos2fa7c672016-10-24 04:00:05 -0700129// https://w3c.github.io/webrtc-stats/#dcstats-dict*
Mirko Bonadei276827c2018-10-16 14:13:50 +0200130class RTC_EXPORT RTCDataChannelStats final : public RTCStats {
hbos2fa7c672016-10-24 04:00:05 -0700131 public:
132 WEBRTC_RTCSTATS_DECL();
133
134 RTCDataChannelStats(const std::string& id, int64_t timestamp_us);
135 RTCDataChannelStats(std::string&& id, int64_t timestamp_us);
136 RTCDataChannelStats(const RTCDataChannelStats& other);
137 ~RTCDataChannelStats() override;
138
139 RTCStatsMember<std::string> label;
140 RTCStatsMember<std::string> protocol;
141 RTCStatsMember<int32_t> datachannelid;
142 // TODO(hbos): Support enum types? "RTCStatsMember<RTCDataChannelState>"?
143 RTCStatsMember<std::string> state;
144 RTCStatsMember<uint32_t> messages_sent;
145 RTCStatsMember<uint64_t> bytes_sent;
146 RTCStatsMember<uint32_t> messages_received;
147 RTCStatsMember<uint64_t> bytes_received;
148};
149
150// https://w3c.github.io/webrtc-stats/#candidatepair-dict*
hbos338f78a2017-02-07 06:41:21 -0800151// TODO(hbos): Tracking bug https://bugs.webrtc.org/7062
Mirko Bonadei276827c2018-10-16 14:13:50 +0200152class RTC_EXPORT RTCIceCandidatePairStats final : public RTCStats {
hbosc47a0c32016-10-11 14:54:49 -0700153 public:
154 WEBRTC_RTCSTATS_DECL();
155
156 RTCIceCandidatePairStats(const std::string& id, int64_t timestamp_us);
157 RTCIceCandidatePairStats(std::string&& id, int64_t timestamp_us);
158 RTCIceCandidatePairStats(const RTCIceCandidatePairStats& other);
159 ~RTCIceCandidatePairStats() override;
160
161 RTCStatsMember<std::string> transport_id;
162 RTCStatsMember<std::string> local_candidate_id;
163 RTCStatsMember<std::string> remote_candidate_id;
164 // TODO(hbos): Support enum types?
165 // "RTCStatsMember<RTCStatsIceCandidatePairState>"?
166 RTCStatsMember<std::string> state;
167 RTCStatsMember<uint64_t> priority;
168 RTCStatsMember<bool> nominated;
hbos338f78a2017-02-07 06:41:21 -0800169 // TODO(hbos): Collect this the way the spec describes it. We have a value for
170 // it but it is not spec-compliant. https://bugs.webrtc.org/7062
hbosc47a0c32016-10-11 14:54:49 -0700171 RTCStatsMember<bool> writable;
hbos338f78a2017-02-07 06:41:21 -0800172 // TODO(hbos): Collect and populate this value. https://bugs.webrtc.org/7062
hbosc47a0c32016-10-11 14:54:49 -0700173 RTCStatsMember<bool> readable;
174 RTCStatsMember<uint64_t> bytes_sent;
175 RTCStatsMember<uint64_t> bytes_received;
hbos3168c7a2016-12-15 06:17:08 -0800176 RTCStatsMember<double> total_round_trip_time;
hbos3168c7a2016-12-15 06:17:08 -0800177 RTCStatsMember<double> current_round_trip_time;
hbosc47a0c32016-10-11 14:54:49 -0700178 RTCStatsMember<double> available_outgoing_bitrate;
hbos338f78a2017-02-07 06:41:21 -0800179 // TODO(hbos): Populate this value. It is wired up and collected the same way
hbosbf8d3e52017-02-28 06:34:47 -0800180 // "VideoBwe.googAvailableReceiveBandwidth" is, but that value is always
hbos338f78a2017-02-07 06:41:21 -0800181 // undefined. https://bugs.webrtc.org/7062
hbosc47a0c32016-10-11 14:54:49 -0700182 RTCStatsMember<double> available_incoming_bitrate;
183 RTCStatsMember<uint64_t> requests_received;
184 RTCStatsMember<uint64_t> requests_sent;
185 RTCStatsMember<uint64_t> responses_received;
186 RTCStatsMember<uint64_t> responses_sent;
hbos338f78a2017-02-07 06:41:21 -0800187 // TODO(hbos): Collect and populate this value. https://bugs.webrtc.org/7062
hbosc47a0c32016-10-11 14:54:49 -0700188 RTCStatsMember<uint64_t> retransmissions_received;
hbos338f78a2017-02-07 06:41:21 -0800189 // TODO(hbos): Collect and populate this value. https://bugs.webrtc.org/7062
hbosc47a0c32016-10-11 14:54:49 -0700190 RTCStatsMember<uint64_t> retransmissions_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_requests_received;
193 RTCStatsMember<uint64_t> consent_requests_sent;
hbos338f78a2017-02-07 06:41:21 -0800194 // TODO(hbos): Collect and populate this value. https://bugs.webrtc.org/7062
hbosc47a0c32016-10-11 14:54:49 -0700195 RTCStatsMember<uint64_t> consent_responses_received;
hbos338f78a2017-02-07 06:41:21 -0800196 // TODO(hbos): Collect and populate this value. https://bugs.webrtc.org/7062
hbosc47a0c32016-10-11 14:54:49 -0700197 RTCStatsMember<uint64_t> consent_responses_sent;
198};
199
hbosab9f6e42016-10-07 02:18:47 -0700200// https://w3c.github.io/webrtc-stats/#icecandidate-dict*
hbos5d79a7c2016-10-24 09:27:10 -0700201// TODO(hbos): |RTCStatsCollector| only collects candidates that are part of
202// ice candidate pairs, but there could be candidates not paired with anything.
203// crbug.com/632723
Qingsi Wang72a43a12018-02-20 16:03:18 -0800204// TODO(qingsi): Add the stats of STUN binding requests (keepalives) and collect
205// them in the new PeerConnection::GetStats.
Mirko Bonadei276827c2018-10-16 14:13:50 +0200206class RTC_EXPORT RTCIceCandidateStats : public RTCStats {
hbosab9f6e42016-10-07 02:18:47 -0700207 public:
208 WEBRTC_RTCSTATS_DECL();
209
210 RTCIceCandidateStats(const RTCIceCandidateStats& other);
211 ~RTCIceCandidateStats() override;
212
hbosb4e426e2017-01-02 09:59:31 -0800213 RTCStatsMember<std::string> transport_id;
hbosc3a2b7f2017-01-02 04:46:15 -0800214 RTCStatsMember<bool> is_remote;
Gary Liu37e489c2017-11-21 10:49:36 -0800215 RTCStatsMember<std::string> network_type;
hbosab9f6e42016-10-07 02:18:47 -0700216 RTCStatsMember<std::string> ip;
217 RTCStatsMember<int32_t> port;
218 RTCStatsMember<std::string> protocol;
Philipp Hancke95513752018-09-27 14:40:08 +0200219 RTCStatsMember<std::string> relay_protocol;
hbosab9f6e42016-10-07 02:18:47 -0700220 // TODO(hbos): Support enum types? "RTCStatsMember<RTCIceCandidateType>"?
221 RTCStatsMember<std::string> candidate_type;
222 RTCStatsMember<int32_t> priority;
hbos5d79a7c2016-10-24 09:27:10 -0700223 // TODO(hbos): Not collected by |RTCStatsCollector|. crbug.com/632723
hbosab9f6e42016-10-07 02:18:47 -0700224 RTCStatsMember<std::string> url;
hbosd17a5a72017-01-02 08:09:59 -0800225 // TODO(hbos): |deleted = true| case is not supported by |RTCStatsCollector|.
226 // crbug.com/632723
227 RTCStatsMember<bool> deleted; // = false
hbosab9f6e42016-10-07 02:18:47 -0700228
229 protected:
Yves Gerey665174f2018-06-19 15:03:05 +0200230 RTCIceCandidateStats(const std::string& id,
231 int64_t timestamp_us,
232 bool is_remote);
hbosc3a2b7f2017-01-02 04:46:15 -0800233 RTCIceCandidateStats(std::string&& id, int64_t timestamp_us, bool is_remote);
hbosab9f6e42016-10-07 02:18:47 -0700234};
235
236// In the spec both local and remote varieties are of type RTCIceCandidateStats.
237// But here we define them as subclasses of |RTCIceCandidateStats| because the
238// |kType| need to be different ("RTCStatsType type") in the local/remote case.
239// https://w3c.github.io/webrtc-stats/#rtcstatstype-str*
Henrik Boström1df1bf82018-03-20 13:24:20 +0100240// This forces us to have to override copy() and type().
Mirko Bonadei276827c2018-10-16 14:13:50 +0200241class RTC_EXPORT RTCLocalIceCandidateStats final : public RTCIceCandidateStats {
hbosab9f6e42016-10-07 02:18:47 -0700242 public:
243 static const char kType[];
244 RTCLocalIceCandidateStats(const std::string& id, int64_t timestamp_us);
245 RTCLocalIceCandidateStats(std::string&& id, int64_t timestamp_us);
Henrik Boström1df1bf82018-03-20 13:24:20 +0100246 std::unique_ptr<RTCStats> copy() const override;
hbosab9f6e42016-10-07 02:18:47 -0700247 const char* type() const override;
248};
249
Mirko Bonadei276827c2018-10-16 14:13:50 +0200250class RTC_EXPORT RTCRemoteIceCandidateStats final
251 : public RTCIceCandidateStats {
hbosab9f6e42016-10-07 02:18:47 -0700252 public:
253 static const char kType[];
254 RTCRemoteIceCandidateStats(const std::string& id, int64_t timestamp_us);
255 RTCRemoteIceCandidateStats(std::string&& id, int64_t timestamp_us);
Henrik Boström1df1bf82018-03-20 13:24:20 +0100256 std::unique_ptr<RTCStats> copy() const override;
hbosab9f6e42016-10-07 02:18:47 -0700257 const char* type() const override;
258};
259
hbos09bc1282016-11-08 06:29:22 -0800260// https://w3c.github.io/webrtc-stats/#msstats-dict*
hbos0adb8282016-11-23 02:32:06 -0800261// TODO(hbos): Tracking bug crbug.com/660827
Mirko Bonadei276827c2018-10-16 14:13:50 +0200262class RTC_EXPORT RTCMediaStreamStats final : public RTCStats {
hbos09bc1282016-11-08 06:29:22 -0800263 public:
264 WEBRTC_RTCSTATS_DECL();
265
266 RTCMediaStreamStats(const std::string& id, int64_t timestamp_us);
267 RTCMediaStreamStats(std::string&& id, int64_t timestamp_us);
268 RTCMediaStreamStats(const RTCMediaStreamStats& other);
269 ~RTCMediaStreamStats() override;
270
271 RTCStatsMember<std::string> stream_identifier;
272 RTCStatsMember<std::vector<std::string>> track_ids;
273};
274
275// https://w3c.github.io/webrtc-stats/#mststats-dict*
hbos0adb8282016-11-23 02:32:06 -0800276// TODO(hbos): Tracking bug crbug.com/659137
Mirko Bonadei276827c2018-10-16 14:13:50 +0200277class RTC_EXPORT RTCMediaStreamTrackStats final : public RTCStats {
hbos09bc1282016-11-08 06:29:22 -0800278 public:
279 WEBRTC_RTCSTATS_DECL();
280
Yves Gerey665174f2018-06-19 15:03:05 +0200281 RTCMediaStreamTrackStats(const std::string& id,
282 int64_t timestamp_us,
hbos160e4a72017-01-17 02:53:23 -0800283 const char* kind);
Yves Gerey665174f2018-06-19 15:03:05 +0200284 RTCMediaStreamTrackStats(std::string&& id,
285 int64_t timestamp_us,
hbos160e4a72017-01-17 02:53:23 -0800286 const char* kind);
hbos09bc1282016-11-08 06:29:22 -0800287 RTCMediaStreamTrackStats(const RTCMediaStreamTrackStats& other);
288 ~RTCMediaStreamTrackStats() override;
289
290 RTCStatsMember<std::string> track_identifier;
Henrik Boström646fda02019-05-22 15:49:42 +0200291 RTCStatsMember<std::string> media_source_id;
hbos09bc1282016-11-08 06:29:22 -0800292 RTCStatsMember<bool> remote_source;
293 RTCStatsMember<bool> ended;
294 // TODO(hbos): |RTCStatsCollector| does not return stats for detached tracks.
295 // crbug.com/659137
296 RTCStatsMember<bool> detached;
hbos160e4a72017-01-17 02:53:23 -0800297 // See |RTCMediaStreamTrackKind| for valid values.
298 RTCStatsMember<std::string> kind;
Gustaf Ullbergb0a02072017-10-02 12:00:34 +0200299 // TODO(gustaf): Implement jitter_buffer_delay for video (currently
300 // implemented for audio only).
301 // https://crbug.com/webrtc/8318
302 RTCStatsMember<double> jitter_buffer_delay;
Chen Xing0acffb52019-01-15 15:46:29 +0100303 RTCStatsMember<uint64_t> jitter_buffer_emitted_count;
hbos09bc1282016-11-08 06:29:22 -0800304 // Video-only members
305 RTCStatsMember<uint32_t> frame_width;
306 RTCStatsMember<uint32_t> frame_height;
307 // TODO(hbos): Not collected by |RTCStatsCollector|. crbug.com/659137
308 RTCStatsMember<double> frames_per_second;
hbos09bc1282016-11-08 06:29:22 -0800309 RTCStatsMember<uint32_t> frames_sent;
Ilya Nikolaevskiy70473fc2018-02-28 16:35:03 +0100310 RTCStatsMember<uint32_t> huge_frames_sent;
hbos09bc1282016-11-08 06:29:22 -0800311 RTCStatsMember<uint32_t> frames_received;
hbos09bc1282016-11-08 06:29:22 -0800312 RTCStatsMember<uint32_t> frames_decoded;
hbos09bc1282016-11-08 06:29:22 -0800313 RTCStatsMember<uint32_t> frames_dropped;
314 // TODO(hbos): Not collected by |RTCStatsCollector|. crbug.com/659137
315 RTCStatsMember<uint32_t> frames_corrupted;
316 // TODO(hbos): Not collected by |RTCStatsCollector|. crbug.com/659137
317 RTCStatsMember<uint32_t> partial_frames_lost;
318 // TODO(hbos): Not collected by |RTCStatsCollector|. crbug.com/659137
319 RTCStatsMember<uint32_t> full_frames_lost;
320 // Audio-only members
Henrik Boströmd2c336f2019-07-03 17:11:10 +0200321 RTCStatsMember<double> audio_level; // Receive-only
322 RTCStatsMember<double> total_audio_energy; // Receive-only
hbos09bc1282016-11-08 06:29:22 -0800323 RTCStatsMember<double> echo_return_loss;
324 RTCStatsMember<double> echo_return_loss_enhancement;
Steve Anton2dbc69f2017-08-24 17:15:13 -0700325 RTCStatsMember<uint64_t> total_samples_received;
Henrik Boströmd2c336f2019-07-03 17:11:10 +0200326 RTCStatsMember<double> total_samples_duration; // Receive-only
Steve Anton2dbc69f2017-08-24 17:15:13 -0700327 RTCStatsMember<uint64_t> concealed_samples;
Ivo Creusen8d8ffdb2019-04-30 09:45:21 +0200328 RTCStatsMember<uint64_t> silent_concealed_samples;
Gustaf Ullberg9a2e9062017-09-18 09:28:20 +0200329 RTCStatsMember<uint64_t> concealment_events;
Ivo Creusen8d8ffdb2019-04-30 09:45:21 +0200330 RTCStatsMember<uint64_t> inserted_samples_for_deceleration;
331 RTCStatsMember<uint64_t> removed_samples_for_acceleration;
Ruslan Burakov8af88962018-11-22 17:21:10 +0100332 // Non-standard audio-only member
Jakob Ivarsson352ce5c2018-11-27 12:52:16 +0100333 // TODO(kuddai): Add description to standard. crbug.com/webrtc/10042
Ruslan Burakov8af88962018-11-22 17:21:10 +0100334 RTCNonStandardStatsMember<uint64_t> jitter_buffer_flushes;
Jakob Ivarsson352ce5c2018-11-27 12:52:16 +0100335 RTCNonStandardStatsMember<uint64_t> delayed_packet_outage_samples;
Jakob Ivarsson232b3fd2019-03-06 09:18:40 +0100336 RTCNonStandardStatsMember<double> relative_packet_arrival_delay;
Henrik Lundin44125fa2019-04-29 17:00:46 +0200337 // TODO(henrik.lundin): Add description of the interruption metrics at
338 // https://github.com/henbos/webrtc-provisional-stats/issues/17
339 RTCNonStandardStatsMember<uint32_t> interruption_count;
340 RTCNonStandardStatsMember<double> total_interruption_duration;
Sergey Silkin02371062019-01-31 16:45:42 +0100341 // Non-standard video-only members.
342 // https://henbos.github.io/webrtc-provisional-stats/#RTCVideoReceiverStats-dict*
343 RTCNonStandardStatsMember<uint32_t> freeze_count;
344 RTCNonStandardStatsMember<uint32_t> pause_count;
345 RTCNonStandardStatsMember<double> total_freezes_duration;
346 RTCNonStandardStatsMember<double> total_pauses_duration;
347 RTCNonStandardStatsMember<double> total_frames_duration;
348 RTCNonStandardStatsMember<double> sum_squared_frame_durations;
hbos09bc1282016-11-08 06:29:22 -0800349};
350
hbos6ab97ce2016-10-03 14:16:56 -0700351// https://w3c.github.io/webrtc-stats/#pcstats-dict*
Mirko Bonadei276827c2018-10-16 14:13:50 +0200352class RTC_EXPORT RTCPeerConnectionStats final : public RTCStats {
hbosd565b732016-08-30 14:04:35 -0700353 public:
hbosfc5e0502016-10-06 02:06:10 -0700354 WEBRTC_RTCSTATS_DECL();
355
hbos0e6758d2016-08-31 07:57:36 -0700356 RTCPeerConnectionStats(const std::string& id, int64_t timestamp_us);
357 RTCPeerConnectionStats(std::string&& id, int64_t timestamp_us);
hbosfc5e0502016-10-06 02:06:10 -0700358 RTCPeerConnectionStats(const RTCPeerConnectionStats& other);
359 ~RTCPeerConnectionStats() override;
hbosd565b732016-08-30 14:04:35 -0700360
361 RTCStatsMember<uint32_t> data_channels_opened;
362 RTCStatsMember<uint32_t> data_channels_closed;
363};
364
hbos6ded1902016-11-01 01:50:46 -0700365// https://w3c.github.io/webrtc-stats/#streamstats-dict*
hbos0adb8282016-11-23 02:32:06 -0800366// TODO(hbos): Tracking bug crbug.com/657854
Mirko Bonadei276827c2018-10-16 14:13:50 +0200367class RTC_EXPORT RTCRTPStreamStats : public RTCStats {
hbos6ded1902016-11-01 01:50:46 -0700368 public:
369 WEBRTC_RTCSTATS_DECL();
370
371 RTCRTPStreamStats(const RTCRTPStreamStats& other);
372 ~RTCRTPStreamStats() override;
373
hbos3443bb72017-02-07 06:28:11 -0800374 RTCStatsMember<uint32_t> ssrc;
hbos6ded1902016-11-01 01:50:46 -0700375 // TODO(hbos): When the remote case is supported |RTCStatsCollector| needs to
376 // set this. crbug.com/657855, 657856
377 RTCStatsMember<std::string> associate_stats_id;
378 // TODO(hbos): Remote case not supported by |RTCStatsCollector|.
379 // crbug.com/657855, 657856
Jonas Olssona4d87372019-07-05 19:08:33 +0200380 RTCStatsMember<bool> is_remote; // = false
Philipp Hancke3bc01662018-08-28 14:55:03 +0200381 RTCStatsMember<std::string> media_type; // renamed to kind.
382 RTCStatsMember<std::string> kind;
hbosb0ae9202017-01-27 06:35:16 -0800383 RTCStatsMember<std::string> track_id;
hbos6ded1902016-11-01 01:50:46 -0700384 RTCStatsMember<std::string> transport_id;
hbos6ded1902016-11-01 01:50:46 -0700385 RTCStatsMember<std::string> codec_id;
386 // FIR and PLI counts are only defined for |media_type == "video"|.
387 RTCStatsMember<uint32_t> fir_count;
388 RTCStatsMember<uint32_t> pli_count;
389 // TODO(hbos): NACK count should be collected by |RTCStatsCollector| for both
390 // audio and video but is only defined in the "video" case. crbug.com/657856
391 RTCStatsMember<uint32_t> nack_count;
392 // TODO(hbos): Not collected by |RTCStatsCollector|. crbug.com/657854
393 // SLI count is only defined for |media_type == "video"|.
394 RTCStatsMember<uint32_t> sli_count;
hbos6769c492017-01-02 08:35:13 -0800395 RTCStatsMember<uint64_t> qp_sum;
hbos6ded1902016-11-01 01:50:46 -0700396
397 protected:
398 RTCRTPStreamStats(const std::string& id, int64_t timestamp_us);
399 RTCRTPStreamStats(std::string&& id, int64_t timestamp_us);
400};
401
hboseeafe942016-11-01 03:00:17 -0700402// https://w3c.github.io/webrtc-stats/#inboundrtpstats-dict*
hbosa7a9be12017-03-01 01:02:45 -0800403// TODO(hbos): Support the remote case |is_remote = true|.
404// https://bugs.webrtc.org/7065
Mirko Bonadei276827c2018-10-16 14:13:50 +0200405class RTC_EXPORT RTCInboundRTPStreamStats final : public RTCRTPStreamStats {
hboseeafe942016-11-01 03:00:17 -0700406 public:
407 WEBRTC_RTCSTATS_DECL();
408
409 RTCInboundRTPStreamStats(const std::string& id, int64_t timestamp_us);
410 RTCInboundRTPStreamStats(std::string&& id, int64_t timestamp_us);
411 RTCInboundRTPStreamStats(const RTCInboundRTPStreamStats& other);
412 ~RTCInboundRTPStreamStats() override;
413
414 RTCStatsMember<uint32_t> packets_received;
Ivo Creusen8d8ffdb2019-04-30 09:45:21 +0200415 RTCStatsMember<uint64_t> fec_packets_received;
416 RTCStatsMember<uint64_t> fec_packets_discarded;
hboseeafe942016-11-01 03:00:17 -0700417 RTCStatsMember<uint64_t> bytes_received;
Harald Alvestrand719487e2017-12-13 12:26:04 +0100418 RTCStatsMember<int32_t> packets_lost; // Signed per RFC 3550
Henrik Boström01738c62019-04-15 17:32:00 +0200419 RTCStatsMember<double> last_packet_received_timestamp;
hbosa7a9be12017-03-01 01:02:45 -0800420 // TODO(hbos): Collect and populate this value for both "audio" and "video",
421 // currently not collected for "video". https://bugs.webrtc.org/7065
hboseeafe942016-11-01 03:00:17 -0700422 RTCStatsMember<double> jitter;
hbosa7a9be12017-03-01 01:02:45 -0800423 // TODO(hbos): Collect and populate this value. https://bugs.webrtc.org/7065
424 RTCStatsMember<double> round_trip_time;
425 // TODO(hbos): Collect and populate this value. https://bugs.webrtc.org/7065
hboseeafe942016-11-01 03:00:17 -0700426 RTCStatsMember<uint32_t> packets_discarded;
hbosa7a9be12017-03-01 01:02:45 -0800427 // TODO(hbos): Collect and populate this value. https://bugs.webrtc.org/7065
hboseeafe942016-11-01 03:00:17 -0700428 RTCStatsMember<uint32_t> packets_repaired;
hbosa7a9be12017-03-01 01:02:45 -0800429 // TODO(hbos): Collect and populate this value. https://bugs.webrtc.org/7065
hboseeafe942016-11-01 03:00:17 -0700430 RTCStatsMember<uint32_t> burst_packets_lost;
hbosa7a9be12017-03-01 01:02:45 -0800431 // TODO(hbos): Collect and populate this value. https://bugs.webrtc.org/7065
hboseeafe942016-11-01 03:00:17 -0700432 RTCStatsMember<uint32_t> burst_packets_discarded;
hbosa7a9be12017-03-01 01:02:45 -0800433 // TODO(hbos): Collect and populate this value. https://bugs.webrtc.org/7065
hboseeafe942016-11-01 03:00:17 -0700434 RTCStatsMember<uint32_t> burst_loss_count;
hbosa7a9be12017-03-01 01:02:45 -0800435 // TODO(hbos): Collect and populate this value. https://bugs.webrtc.org/7065
hboseeafe942016-11-01 03:00:17 -0700436 RTCStatsMember<uint32_t> burst_discard_count;
hbosa7a9be12017-03-01 01:02:45 -0800437 // TODO(hbos): Collect and populate this value. https://bugs.webrtc.org/7065
hboseeafe942016-11-01 03:00:17 -0700438 RTCStatsMember<double> burst_loss_rate;
hbosa7a9be12017-03-01 01:02:45 -0800439 // TODO(hbos): Collect and populate this value. https://bugs.webrtc.org/7065
hboseeafe942016-11-01 03:00:17 -0700440 RTCStatsMember<double> burst_discard_rate;
hbosa7a9be12017-03-01 01:02:45 -0800441 // TODO(hbos): Collect and populate this value. https://bugs.webrtc.org/7065
hboseeafe942016-11-01 03:00:17 -0700442 RTCStatsMember<double> gap_loss_rate;
hbosa7a9be12017-03-01 01:02:45 -0800443 // TODO(hbos): Collect and populate this value. https://bugs.webrtc.org/7065
hboseeafe942016-11-01 03:00:17 -0700444 RTCStatsMember<double> gap_discard_rate;
hbos6769c492017-01-02 08:35:13 -0800445 RTCStatsMember<uint32_t> frames_decoded;
Rasmus Brandt2efae772019-06-27 14:29:34 +0200446 RTCStatsMember<uint32_t> key_frames_decoded;
Johannes Kronbfd343b2019-07-01 10:07:50 +0200447 RTCStatsMember<double> total_decode_time;
Henrik Boström2e069262019-04-09 13:59:31 +0200448 // https://henbos.github.io/webrtc-provisional-stats/#dom-rtcinboundrtpstreamstats-contenttype
449 RTCStatsMember<std::string> content_type;
hboseeafe942016-11-01 03:00:17 -0700450};
451
hbos6ded1902016-11-01 01:50:46 -0700452// https://w3c.github.io/webrtc-stats/#outboundrtpstats-dict*
hbosa7a9be12017-03-01 01:02:45 -0800453// TODO(hbos): Support the remote case |is_remote = true|.
454// https://bugs.webrtc.org/7066
Mirko Bonadei276827c2018-10-16 14:13:50 +0200455class RTC_EXPORT RTCOutboundRTPStreamStats final : public RTCRTPStreamStats {
hbos6ded1902016-11-01 01:50:46 -0700456 public:
457 WEBRTC_RTCSTATS_DECL();
458
459 RTCOutboundRTPStreamStats(const std::string& id, int64_t timestamp_us);
460 RTCOutboundRTPStreamStats(std::string&& id, int64_t timestamp_us);
461 RTCOutboundRTPStreamStats(const RTCOutboundRTPStreamStats& other);
462 ~RTCOutboundRTPStreamStats() override;
463
Henrik Boström646fda02019-05-22 15:49:42 +0200464 RTCStatsMember<std::string> media_source_id;
hbos6ded1902016-11-01 01:50:46 -0700465 RTCStatsMember<uint32_t> packets_sent;
Henrik Boströmcf96e0f2019-04-17 13:51:53 +0200466 RTCStatsMember<uint64_t> retransmitted_packets_sent;
hbos6ded1902016-11-01 01:50:46 -0700467 RTCStatsMember<uint64_t> bytes_sent;
Henrik Boströmcf96e0f2019-04-17 13:51:53 +0200468 RTCStatsMember<uint64_t> retransmitted_bytes_sent;
hbosa7a9be12017-03-01 01:02:45 -0800469 // TODO(hbos): Collect and populate this value. https://bugs.webrtc.org/7066
hbos6ded1902016-11-01 01:50:46 -0700470 RTCStatsMember<double> target_bitrate;
hbos6769c492017-01-02 08:35:13 -0800471 RTCStatsMember<uint32_t> frames_encoded;
Rasmus Brandt2efae772019-06-27 14:29:34 +0200472 RTCStatsMember<uint32_t> key_frames_encoded;
Henrik Boströmf71362f2019-04-08 16:14:23 +0200473 RTCStatsMember<double> total_encode_time;
Henrik Boström23aff9b2019-05-20 15:15:38 +0200474 RTCStatsMember<uint64_t> total_encoded_bytes_target;
Henrik Boström9fe18342019-05-16 18:38:20 +0200475 // TODO(https://crbug.com/webrtc/10635): This is only implemented for video;
476 // implement it for audio as well.
477 RTCStatsMember<double> total_packet_send_delay;
Henrik Boströmce33b6a2019-05-28 17:42:38 +0200478 // Enum type RTCQualityLimitationReason
479 // TODO(https://crbug.com/webrtc/10686): Also expose
480 // qualityLimitationDurations. Requires RTCStatsMember support for
481 // "record<DOMString, double>", see https://crbug.com/webrtc/10685.
482 RTCStatsMember<std::string> quality_limitation_reason;
Henrik Boström2e069262019-04-09 13:59:31 +0200483 // https://henbos.github.io/webrtc-provisional-stats/#dom-rtcoutboundrtpstreamstats-contenttype
484 RTCStatsMember<std::string> content_type;
hbos6ded1902016-11-01 01:50:46 -0700485};
486
Henrik Boström883eefc2019-05-27 13:40:25 +0200487// TODO(https://crbug.com/webrtc/10671): Refactor the stats dictionaries to have
488// the same hierarchy as in the spec; implement RTCReceivedRtpStreamStats.
489// Several metrics are shared between "outbound-rtp", "remote-inbound-rtp",
490// "inbound-rtp" and "remote-outbound-rtp". In the spec there is a hierarchy of
491// dictionaries that minimizes defining the same metrics in multiple places.
492// From JavaScript this hierarchy is not observable and the spec's hierarchy is
493// purely editorial. In C++ non-final classes in the hierarchy could be used to
494// refer to different stats objects within the hierarchy.
495// https://w3c.github.io/webrtc-stats/#remoteinboundrtpstats-dict*
496class RTC_EXPORT RTCRemoteInboundRtpStreamStats final : public RTCStats {
497 public:
498 WEBRTC_RTCSTATS_DECL();
499
500 RTCRemoteInboundRtpStreamStats(const std::string& id, int64_t timestamp_us);
501 RTCRemoteInboundRtpStreamStats(std::string&& id, int64_t timestamp_us);
502 RTCRemoteInboundRtpStreamStats(const RTCRemoteInboundRtpStreamStats& other);
503 ~RTCRemoteInboundRtpStreamStats() override;
504
505 // In the spec RTCRemoteInboundRtpStreamStats inherits from RTCRtpStreamStats
506 // and RTCReceivedRtpStreamStats. The members here are listed based on where
507 // they are defined in the spec.
508 // RTCRtpStreamStats
509 RTCStatsMember<uint32_t> ssrc;
510 RTCStatsMember<std::string> kind;
511 RTCStatsMember<std::string> transport_id;
512 RTCStatsMember<std::string> codec_id;
513 // RTCReceivedRtpStreamStats
514 RTCStatsMember<int32_t> packets_lost;
515 RTCStatsMember<double> jitter;
516 // TODO(hbos): The following RTCReceivedRtpStreamStats metrics should also be
517 // implemented: packetsReceived, packetsDiscarded, packetsRepaired,
518 // burstPacketsLost, burstPacketsDiscarded, burstLossCount, burstDiscardCount,
519 // burstLossRate, burstDiscardRate, gapLossRate and gapDiscardRate.
520 // RTCRemoteInboundRtpStreamStats
521 RTCStatsMember<std::string> local_id;
522 RTCStatsMember<double> round_trip_time;
523 // TODO(hbos): The following RTCRemoteInboundRtpStreamStats metric should also
524 // be implemented: fractionLost.
525};
526
Henrik Boström646fda02019-05-22 15:49:42 +0200527// https://w3c.github.io/webrtc-stats/#dom-rtcmediasourcestats
528class RTC_EXPORT RTCMediaSourceStats : public RTCStats {
529 public:
530 WEBRTC_RTCSTATS_DECL();
531
532 RTCMediaSourceStats(const RTCMediaSourceStats& other);
533 ~RTCMediaSourceStats() override;
534
535 RTCStatsMember<std::string> track_identifier;
536 RTCStatsMember<std::string> kind;
537
538 protected:
539 RTCMediaSourceStats(const std::string& id, int64_t timestamp_us);
540 RTCMediaSourceStats(std::string&& id, int64_t timestamp_us);
541};
542
543// https://w3c.github.io/webrtc-stats/#dom-rtcaudiosourcestats
544class RTC_EXPORT RTCAudioSourceStats final : public RTCMediaSourceStats {
545 public:
546 WEBRTC_RTCSTATS_DECL();
547
548 RTCAudioSourceStats(const std::string& id, int64_t timestamp_us);
549 RTCAudioSourceStats(std::string&& id, int64_t timestamp_us);
550 RTCAudioSourceStats(const RTCAudioSourceStats& other);
551 ~RTCAudioSourceStats() override;
Henrik Boströmd2c336f2019-07-03 17:11:10 +0200552
553 RTCStatsMember<double> audio_level;
554 RTCStatsMember<double> total_audio_energy;
555 RTCStatsMember<double> total_samples_duration;
Henrik Boström646fda02019-05-22 15:49:42 +0200556};
557
558// https://w3c.github.io/webrtc-stats/#dom-rtcvideosourcestats
559class RTC_EXPORT RTCVideoSourceStats final : public RTCMediaSourceStats {
560 public:
561 WEBRTC_RTCSTATS_DECL();
562
563 RTCVideoSourceStats(const std::string& id, int64_t timestamp_us);
564 RTCVideoSourceStats(std::string&& id, int64_t timestamp_us);
565 RTCVideoSourceStats(const RTCVideoSourceStats& other);
566 ~RTCVideoSourceStats() override;
567
568 RTCStatsMember<uint32_t> width;
569 RTCStatsMember<uint32_t> height;
570 // TODO(hbos): Implement this metric.
571 RTCStatsMember<uint32_t> frames;
572 RTCStatsMember<uint32_t> frames_per_second;
573};
574
hbos2fa7c672016-10-24 04:00:05 -0700575// https://w3c.github.io/webrtc-stats/#transportstats-dict*
Mirko Bonadei276827c2018-10-16 14:13:50 +0200576class RTC_EXPORT RTCTransportStats final : public RTCStats {
hbos2fa7c672016-10-24 04:00:05 -0700577 public:
578 WEBRTC_RTCSTATS_DECL();
579
580 RTCTransportStats(const std::string& id, int64_t timestamp_us);
581 RTCTransportStats(std::string&& id, int64_t timestamp_us);
582 RTCTransportStats(const RTCTransportStats& other);
583 ~RTCTransportStats() override;
584
585 RTCStatsMember<uint64_t> bytes_sent;
586 RTCStatsMember<uint64_t> bytes_received;
587 RTCStatsMember<std::string> rtcp_transport_stats_id;
hbos7064d592017-01-16 07:38:02 -0800588 // TODO(hbos): Support enum types? "RTCStatsMember<RTCDtlsTransportState>"?
589 RTCStatsMember<std::string> dtls_state;
hbos2fa7c672016-10-24 04:00:05 -0700590 RTCStatsMember<std::string> selected_candidate_pair_id;
591 RTCStatsMember<std::string> local_certificate_id;
592 RTCStatsMember<std::string> remote_certificate_id;
593};
594
hbosd565b732016-08-30 14:04:35 -0700595} // namespace webrtc
596
Mirko Bonadei92ea95e2017-09-15 06:47:31 +0200597#endif // API_STATS_RTCSTATS_OBJECTS_H_