blob: 1f8b973b2ea015b1f4a6960268457df066d300f9 [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>
Henrik Boström1df1bf82018-03-20 13:24:20 +010015#include <memory>
hbosd565b732016-08-30 14:04:35 -070016#include <string>
oprypin803dc292017-02-01 01:55:59 -080017#include <vector>
hbosd565b732016-08-30 14:04:35 -070018
Steve Anton10542f22019-01-11 09:11:00 -080019#include "api/stats/rtc_stats.h"
Mirko Bonadei276827c2018-10-16 14:13:50 +020020#include "rtc_base/system/rtc_export.h"
hbosd565b732016-08-30 14:04:35 -070021
22namespace webrtc {
23
hboscc555c52016-10-18 12:48:31 -070024// https://w3c.github.io/webrtc-pc/#idl-def-rtcdatachannelstate
25struct RTCDataChannelState {
agrieve26622d32017-08-08 10:48:15 -070026 static const char* const kConnecting;
27 static const char* const kOpen;
28 static const char* const kClosing;
29 static const char* const kClosed;
hboscc555c52016-10-18 12:48:31 -070030};
31
hbosc47a0c32016-10-11 14:54:49 -070032// https://w3c.github.io/webrtc-stats/#dom-rtcstatsicecandidatepairstate
33struct RTCStatsIceCandidatePairState {
agrieve26622d32017-08-08 10:48:15 -070034 static const char* const kFrozen;
35 static const char* const kWaiting;
36 static const char* const kInProgress;
37 static const char* const kFailed;
38 static const char* const kSucceeded;
hbosc47a0c32016-10-11 14:54:49 -070039};
40
hboscc555c52016-10-18 12:48:31 -070041// https://w3c.github.io/webrtc-pc/#rtcicecandidatetype-enum
hbosab9f6e42016-10-07 02:18:47 -070042struct RTCIceCandidateType {
agrieve26622d32017-08-08 10:48:15 -070043 static const char* const kHost;
44 static const char* const kSrflx;
45 static const char* const kPrflx;
46 static const char* const kRelay;
hbosab9f6e42016-10-07 02:18:47 -070047};
48
hbos7064d592017-01-16 07:38:02 -080049// https://w3c.github.io/webrtc-pc/#idl-def-rtcdtlstransportstate
50struct RTCDtlsTransportState {
agrieve26622d32017-08-08 10:48:15 -070051 static const char* const kNew;
52 static const char* const kConnecting;
53 static const char* const kConnected;
54 static const char* const kClosed;
55 static const char* const kFailed;
hbos7064d592017-01-16 07:38:02 -080056};
57
hbos160e4a72017-01-17 02:53:23 -080058// |RTCMediaStreamTrackStats::kind| is not an enum in the spec but the only
59// valid values are "audio" and "video".
60// https://w3c.github.io/webrtc-stats/#dom-rtcmediastreamtrackstats-kind
61struct RTCMediaStreamTrackKind {
agrieve26622d32017-08-08 10:48:15 -070062 static const char* const kAudio;
63 static const char* const kVideo;
hbos160e4a72017-01-17 02:53:23 -080064};
65
Gary Liu37e489c2017-11-21 10:49:36 -080066// https://w3c.github.io/webrtc-stats/#dom-rtcnetworktype
67struct RTCNetworkType {
68 static const char* const kBluetooth;
69 static const char* const kCellular;
70 static const char* const kEthernet;
71 static const char* const kWifi;
72 static const char* const kWimax;
73 static const char* const kVpn;
74 static const char* const kUnknown;
75};
76
Henrik Boströmce33b6a2019-05-28 17:42:38 +020077// https://w3c.github.io/webrtc-stats/#dom-rtcqualitylimitationreason
78struct RTCQualityLimitationReason {
79 static const char* const kNone;
80 static const char* const kCpu;
81 static const char* const kBandwidth;
82 static const char* const kOther;
83};
84
Henrik Boström2e069262019-04-09 13:59:31 +020085// https://webrtc.org/experiments/rtp-hdrext/video-content-type/
86struct RTCContentType {
87 static const char* const kUnspecified;
88 static const char* const kScreenshare;
89};
90
hbos2fa7c672016-10-24 04:00:05 -070091// https://w3c.github.io/webrtc-stats/#certificatestats-dict*
Mirko Bonadei276827c2018-10-16 14:13:50 +020092class RTC_EXPORT RTCCertificateStats final : public RTCStats {
hbos2fa7c672016-10-24 04:00:05 -070093 public:
94 WEBRTC_RTCSTATS_DECL();
95
96 RTCCertificateStats(const std::string& id, int64_t timestamp_us);
97 RTCCertificateStats(std::string&& id, int64_t timestamp_us);
98 RTCCertificateStats(const RTCCertificateStats& other);
99 ~RTCCertificateStats() override;
100
101 RTCStatsMember<std::string> fingerprint;
102 RTCStatsMember<std::string> fingerprint_algorithm;
103 RTCStatsMember<std::string> base64_certificate;
104 RTCStatsMember<std::string> issuer_certificate_id;
105};
106
hbos0adb8282016-11-23 02:32:06 -0800107// https://w3c.github.io/webrtc-stats/#codec-dict*
Mirko Bonadei276827c2018-10-16 14:13:50 +0200108class RTC_EXPORT RTCCodecStats final : public RTCStats {
hbos0adb8282016-11-23 02:32:06 -0800109 public:
110 WEBRTC_RTCSTATS_DECL();
111
112 RTCCodecStats(const std::string& id, int64_t timestamp_us);
113 RTCCodecStats(std::string&& id, int64_t timestamp_us);
114 RTCCodecStats(const RTCCodecStats& other);
115 ~RTCCodecStats() override;
116
117 RTCStatsMember<uint32_t> payload_type;
hbos13f54b22017-02-28 06:56:04 -0800118 RTCStatsMember<std::string> mime_type;
hbos0adb8282016-11-23 02:32:06 -0800119 RTCStatsMember<uint32_t> clock_rate;
hbos585a9b12017-02-07 04:59:16 -0800120 // TODO(hbos): Collect and populate this value. https://bugs.webrtc.org/7061
hbos0adb8282016-11-23 02:32:06 -0800121 RTCStatsMember<uint32_t> channels;
hbos585a9b12017-02-07 04:59:16 -0800122 // TODO(hbos): Collect and populate this value. https://bugs.webrtc.org/7061
hbos13f54b22017-02-28 06:56:04 -0800123 RTCStatsMember<std::string> sdp_fmtp_line;
hbos585a9b12017-02-07 04:59:16 -0800124 // TODO(hbos): Collect and populate this value. https://bugs.webrtc.org/7061
hbos0adb8282016-11-23 02:32:06 -0800125 RTCStatsMember<std::string> implementation;
126};
127
hbos2fa7c672016-10-24 04:00:05 -0700128// https://w3c.github.io/webrtc-stats/#dcstats-dict*
Mirko Bonadei276827c2018-10-16 14:13:50 +0200129class RTC_EXPORT RTCDataChannelStats final : public RTCStats {
hbos2fa7c672016-10-24 04:00:05 -0700130 public:
131 WEBRTC_RTCSTATS_DECL();
132
133 RTCDataChannelStats(const std::string& id, int64_t timestamp_us);
134 RTCDataChannelStats(std::string&& id, int64_t timestamp_us);
135 RTCDataChannelStats(const RTCDataChannelStats& other);
136 ~RTCDataChannelStats() override;
137
138 RTCStatsMember<std::string> label;
139 RTCStatsMember<std::string> protocol;
140 RTCStatsMember<int32_t> datachannelid;
141 // TODO(hbos): Support enum types? "RTCStatsMember<RTCDataChannelState>"?
142 RTCStatsMember<std::string> state;
143 RTCStatsMember<uint32_t> messages_sent;
144 RTCStatsMember<uint64_t> bytes_sent;
145 RTCStatsMember<uint32_t> messages_received;
146 RTCStatsMember<uint64_t> bytes_received;
147};
148
149// https://w3c.github.io/webrtc-stats/#candidatepair-dict*
hbos338f78a2017-02-07 06:41:21 -0800150// TODO(hbos): Tracking bug https://bugs.webrtc.org/7062
Mirko Bonadei276827c2018-10-16 14:13:50 +0200151class RTC_EXPORT RTCIceCandidatePairStats final : public RTCStats {
hbosc47a0c32016-10-11 14:54:49 -0700152 public:
153 WEBRTC_RTCSTATS_DECL();
154
155 RTCIceCandidatePairStats(const std::string& id, int64_t timestamp_us);
156 RTCIceCandidatePairStats(std::string&& id, int64_t timestamp_us);
157 RTCIceCandidatePairStats(const RTCIceCandidatePairStats& other);
158 ~RTCIceCandidatePairStats() override;
159
160 RTCStatsMember<std::string> transport_id;
161 RTCStatsMember<std::string> local_candidate_id;
162 RTCStatsMember<std::string> remote_candidate_id;
163 // TODO(hbos): Support enum types?
164 // "RTCStatsMember<RTCStatsIceCandidatePairState>"?
165 RTCStatsMember<std::string> state;
166 RTCStatsMember<uint64_t> priority;
167 RTCStatsMember<bool> nominated;
hbos338f78a2017-02-07 06:41:21 -0800168 // TODO(hbos): Collect this the way the spec describes it. We have a value for
169 // it but it is not spec-compliant. https://bugs.webrtc.org/7062
hbosc47a0c32016-10-11 14:54:49 -0700170 RTCStatsMember<bool> writable;
hbos338f78a2017-02-07 06:41:21 -0800171 // TODO(hbos): Collect and populate this value. https://bugs.webrtc.org/7062
hbosc47a0c32016-10-11 14:54:49 -0700172 RTCStatsMember<bool> readable;
173 RTCStatsMember<uint64_t> bytes_sent;
174 RTCStatsMember<uint64_t> bytes_received;
hbos3168c7a2016-12-15 06:17:08 -0800175 RTCStatsMember<double> total_round_trip_time;
hbos3168c7a2016-12-15 06:17:08 -0800176 RTCStatsMember<double> current_round_trip_time;
hbosc47a0c32016-10-11 14:54:49 -0700177 RTCStatsMember<double> available_outgoing_bitrate;
hbos338f78a2017-02-07 06:41:21 -0800178 // TODO(hbos): Populate this value. It is wired up and collected the same way
hbosbf8d3e52017-02-28 06:34:47 -0800179 // "VideoBwe.googAvailableReceiveBandwidth" is, but that value is always
hbos338f78a2017-02-07 06:41:21 -0800180 // undefined. https://bugs.webrtc.org/7062
hbosc47a0c32016-10-11 14:54:49 -0700181 RTCStatsMember<double> available_incoming_bitrate;
182 RTCStatsMember<uint64_t> requests_received;
183 RTCStatsMember<uint64_t> requests_sent;
184 RTCStatsMember<uint64_t> responses_received;
185 RTCStatsMember<uint64_t> responses_sent;
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_received;
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> retransmissions_sent;
hbos338f78a2017-02-07 06:41:21 -0800190 // TODO(hbos): Collect and populate this value. https://bugs.webrtc.org/7062
hbosc47a0c32016-10-11 14:54:49 -0700191 RTCStatsMember<uint64_t> consent_requests_received;
192 RTCStatsMember<uint64_t> consent_requests_sent;
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_received;
hbos338f78a2017-02-07 06:41:21 -0800195 // TODO(hbos): Collect and populate this value. https://bugs.webrtc.org/7062
hbosc47a0c32016-10-11 14:54:49 -0700196 RTCStatsMember<uint64_t> consent_responses_sent;
197};
198
hbosab9f6e42016-10-07 02:18:47 -0700199// https://w3c.github.io/webrtc-stats/#icecandidate-dict*
hbos5d79a7c2016-10-24 09:27:10 -0700200// TODO(hbos): |RTCStatsCollector| only collects candidates that are part of
201// ice candidate pairs, but there could be candidates not paired with anything.
202// crbug.com/632723
Qingsi Wang72a43a12018-02-20 16:03:18 -0800203// TODO(qingsi): Add the stats of STUN binding requests (keepalives) and collect
204// them in the new PeerConnection::GetStats.
Mirko Bonadei276827c2018-10-16 14:13:50 +0200205class RTC_EXPORT RTCIceCandidateStats : public RTCStats {
hbosab9f6e42016-10-07 02:18:47 -0700206 public:
207 WEBRTC_RTCSTATS_DECL();
208
209 RTCIceCandidateStats(const RTCIceCandidateStats& other);
210 ~RTCIceCandidateStats() override;
211
hbosb4e426e2017-01-02 09:59:31 -0800212 RTCStatsMember<std::string> transport_id;
hbosc3a2b7f2017-01-02 04:46:15 -0800213 RTCStatsMember<bool> is_remote;
Gary Liu37e489c2017-11-21 10:49:36 -0800214 RTCStatsMember<std::string> network_type;
hbosab9f6e42016-10-07 02:18:47 -0700215 RTCStatsMember<std::string> ip;
216 RTCStatsMember<int32_t> port;
217 RTCStatsMember<std::string> protocol;
Philipp Hancke95513752018-09-27 14:40:08 +0200218 RTCStatsMember<std::string> relay_protocol;
hbosab9f6e42016-10-07 02:18:47 -0700219 // TODO(hbos): Support enum types? "RTCStatsMember<RTCIceCandidateType>"?
220 RTCStatsMember<std::string> candidate_type;
221 RTCStatsMember<int32_t> priority;
hbos5d79a7c2016-10-24 09:27:10 -0700222 // TODO(hbos): Not collected by |RTCStatsCollector|. crbug.com/632723
hbosab9f6e42016-10-07 02:18:47 -0700223 RTCStatsMember<std::string> url;
hbosd17a5a72017-01-02 08:09:59 -0800224 // TODO(hbos): |deleted = true| case is not supported by |RTCStatsCollector|.
225 // crbug.com/632723
226 RTCStatsMember<bool> deleted; // = false
hbosab9f6e42016-10-07 02:18:47 -0700227
228 protected:
Yves Gerey665174f2018-06-19 15:03:05 +0200229 RTCIceCandidateStats(const std::string& id,
230 int64_t timestamp_us,
231 bool is_remote);
hbosc3a2b7f2017-01-02 04:46:15 -0800232 RTCIceCandidateStats(std::string&& id, int64_t timestamp_us, bool is_remote);
hbosab9f6e42016-10-07 02:18:47 -0700233};
234
235// In the spec both local and remote varieties are of type RTCIceCandidateStats.
236// But here we define them as subclasses of |RTCIceCandidateStats| because the
237// |kType| need to be different ("RTCStatsType type") in the local/remote case.
238// https://w3c.github.io/webrtc-stats/#rtcstatstype-str*
Henrik Boström1df1bf82018-03-20 13:24:20 +0100239// This forces us to have to override copy() and type().
Mirko Bonadei276827c2018-10-16 14:13:50 +0200240class RTC_EXPORT RTCLocalIceCandidateStats final : public RTCIceCandidateStats {
hbosab9f6e42016-10-07 02:18:47 -0700241 public:
242 static const char kType[];
243 RTCLocalIceCandidateStats(const std::string& id, int64_t timestamp_us);
244 RTCLocalIceCandidateStats(std::string&& id, int64_t timestamp_us);
Henrik Boström1df1bf82018-03-20 13:24:20 +0100245 std::unique_ptr<RTCStats> copy() const override;
hbosab9f6e42016-10-07 02:18:47 -0700246 const char* type() const override;
247};
248
Mirko Bonadei276827c2018-10-16 14:13:50 +0200249class RTC_EXPORT RTCRemoteIceCandidateStats final
250 : public RTCIceCandidateStats {
hbosab9f6e42016-10-07 02:18:47 -0700251 public:
252 static const char kType[];
253 RTCRemoteIceCandidateStats(const std::string& id, int64_t timestamp_us);
254 RTCRemoteIceCandidateStats(std::string&& id, int64_t timestamp_us);
Henrik Boström1df1bf82018-03-20 13:24:20 +0100255 std::unique_ptr<RTCStats> copy() const override;
hbosab9f6e42016-10-07 02:18:47 -0700256 const char* type() const override;
257};
258
hbos09bc1282016-11-08 06:29:22 -0800259// https://w3c.github.io/webrtc-stats/#msstats-dict*
hbos0adb8282016-11-23 02:32:06 -0800260// TODO(hbos): Tracking bug crbug.com/660827
Mirko Bonadei276827c2018-10-16 14:13:50 +0200261class RTC_EXPORT RTCMediaStreamStats final : public RTCStats {
hbos09bc1282016-11-08 06:29:22 -0800262 public:
263 WEBRTC_RTCSTATS_DECL();
264
265 RTCMediaStreamStats(const std::string& id, int64_t timestamp_us);
266 RTCMediaStreamStats(std::string&& id, int64_t timestamp_us);
267 RTCMediaStreamStats(const RTCMediaStreamStats& other);
268 ~RTCMediaStreamStats() override;
269
270 RTCStatsMember<std::string> stream_identifier;
271 RTCStatsMember<std::vector<std::string>> track_ids;
272};
273
274// https://w3c.github.io/webrtc-stats/#mststats-dict*
hbos0adb8282016-11-23 02:32:06 -0800275// TODO(hbos): Tracking bug crbug.com/659137
Mirko Bonadei276827c2018-10-16 14:13:50 +0200276class RTC_EXPORT RTCMediaStreamTrackStats final : public RTCStats {
hbos09bc1282016-11-08 06:29:22 -0800277 public:
278 WEBRTC_RTCSTATS_DECL();
279
Yves Gerey665174f2018-06-19 15:03:05 +0200280 RTCMediaStreamTrackStats(const std::string& id,
281 int64_t timestamp_us,
hbos160e4a72017-01-17 02:53:23 -0800282 const char* kind);
Yves Gerey665174f2018-06-19 15:03:05 +0200283 RTCMediaStreamTrackStats(std::string&& id,
284 int64_t timestamp_us,
hbos160e4a72017-01-17 02:53:23 -0800285 const char* kind);
hbos09bc1282016-11-08 06:29:22 -0800286 RTCMediaStreamTrackStats(const RTCMediaStreamTrackStats& other);
287 ~RTCMediaStreamTrackStats() override;
288
289 RTCStatsMember<std::string> track_identifier;
Henrik Boström646fda02019-05-22 15:49:42 +0200290 RTCStatsMember<std::string> media_source_id;
hbos09bc1282016-11-08 06:29:22 -0800291 RTCStatsMember<bool> remote_source;
292 RTCStatsMember<bool> ended;
293 // TODO(hbos): |RTCStatsCollector| does not return stats for detached tracks.
294 // crbug.com/659137
295 RTCStatsMember<bool> detached;
hbos160e4a72017-01-17 02:53:23 -0800296 // See |RTCMediaStreamTrackKind| for valid values.
297 RTCStatsMember<std::string> kind;
Gustaf Ullbergb0a02072017-10-02 12:00:34 +0200298 // TODO(gustaf): Implement jitter_buffer_delay for video (currently
299 // implemented for audio only).
300 // https://crbug.com/webrtc/8318
301 RTCStatsMember<double> jitter_buffer_delay;
Chen Xing0acffb52019-01-15 15:46:29 +0100302 RTCStatsMember<uint64_t> jitter_buffer_emitted_count;
hbos09bc1282016-11-08 06:29:22 -0800303 // Video-only members
304 RTCStatsMember<uint32_t> frame_width;
305 RTCStatsMember<uint32_t> frame_height;
306 // TODO(hbos): Not collected by |RTCStatsCollector|. crbug.com/659137
307 RTCStatsMember<double> frames_per_second;
hbos09bc1282016-11-08 06:29:22 -0800308 RTCStatsMember<uint32_t> frames_sent;
Ilya Nikolaevskiy70473fc2018-02-28 16:35:03 +0100309 RTCStatsMember<uint32_t> huge_frames_sent;
hbos09bc1282016-11-08 06:29:22 -0800310 RTCStatsMember<uint32_t> frames_received;
hbos09bc1282016-11-08 06:29:22 -0800311 RTCStatsMember<uint32_t> frames_decoded;
hbos09bc1282016-11-08 06:29:22 -0800312 RTCStatsMember<uint32_t> frames_dropped;
313 // TODO(hbos): Not collected by |RTCStatsCollector|. crbug.com/659137
314 RTCStatsMember<uint32_t> frames_corrupted;
315 // TODO(hbos): Not collected by |RTCStatsCollector|. crbug.com/659137
316 RTCStatsMember<uint32_t> partial_frames_lost;
317 // TODO(hbos): Not collected by |RTCStatsCollector|. crbug.com/659137
318 RTCStatsMember<uint32_t> full_frames_lost;
319 // Audio-only members
320 RTCStatsMember<double> audio_level;
zsteine76bd3a2017-07-14 12:17:49 -0700321 RTCStatsMember<double> total_audio_energy;
hbos09bc1282016-11-08 06:29:22 -0800322 RTCStatsMember<double> echo_return_loss;
323 RTCStatsMember<double> echo_return_loss_enhancement;
Steve Anton2dbc69f2017-08-24 17:15:13 -0700324 RTCStatsMember<uint64_t> total_samples_received;
325 RTCStatsMember<double> total_samples_duration;
326 RTCStatsMember<uint64_t> concealed_samples;
Ivo Creusen8d8ffdb2019-04-30 09:45:21 +0200327 RTCStatsMember<uint64_t> silent_concealed_samples;
Gustaf Ullberg9a2e9062017-09-18 09:28:20 +0200328 RTCStatsMember<uint64_t> concealment_events;
Ivo Creusen8d8ffdb2019-04-30 09:45:21 +0200329 RTCStatsMember<uint64_t> inserted_samples_for_deceleration;
330 RTCStatsMember<uint64_t> removed_samples_for_acceleration;
Ruslan Burakov8af88962018-11-22 17:21:10 +0100331 // Non-standard audio-only member
Jakob Ivarsson352ce5c2018-11-27 12:52:16 +0100332 // TODO(kuddai): Add description to standard. crbug.com/webrtc/10042
Ruslan Burakov8af88962018-11-22 17:21:10 +0100333 RTCNonStandardStatsMember<uint64_t> jitter_buffer_flushes;
Jakob Ivarsson352ce5c2018-11-27 12:52:16 +0100334 RTCNonStandardStatsMember<uint64_t> delayed_packet_outage_samples;
Jakob Ivarsson232b3fd2019-03-06 09:18:40 +0100335 RTCNonStandardStatsMember<double> relative_packet_arrival_delay;
Henrik Lundin44125fa2019-04-29 17:00:46 +0200336 // TODO(henrik.lundin): Add description of the interruption metrics at
337 // https://github.com/henbos/webrtc-provisional-stats/issues/17
338 RTCNonStandardStatsMember<uint32_t> interruption_count;
339 RTCNonStandardStatsMember<double> total_interruption_duration;
Sergey Silkin02371062019-01-31 16:45:42 +0100340 // Non-standard video-only members.
341 // https://henbos.github.io/webrtc-provisional-stats/#RTCVideoReceiverStats-dict*
342 RTCNonStandardStatsMember<uint32_t> freeze_count;
343 RTCNonStandardStatsMember<uint32_t> pause_count;
344 RTCNonStandardStatsMember<double> total_freezes_duration;
345 RTCNonStandardStatsMember<double> total_pauses_duration;
346 RTCNonStandardStatsMember<double> total_frames_duration;
347 RTCNonStandardStatsMember<double> sum_squared_frame_durations;
hbos09bc1282016-11-08 06:29:22 -0800348};
349
hbos6ab97ce2016-10-03 14:16:56 -0700350// https://w3c.github.io/webrtc-stats/#pcstats-dict*
Mirko Bonadei276827c2018-10-16 14:13:50 +0200351class RTC_EXPORT RTCPeerConnectionStats final : public RTCStats {
hbosd565b732016-08-30 14:04:35 -0700352 public:
hbosfc5e0502016-10-06 02:06:10 -0700353 WEBRTC_RTCSTATS_DECL();
354
hbos0e6758d2016-08-31 07:57:36 -0700355 RTCPeerConnectionStats(const std::string& id, int64_t timestamp_us);
356 RTCPeerConnectionStats(std::string&& id, int64_t timestamp_us);
hbosfc5e0502016-10-06 02:06:10 -0700357 RTCPeerConnectionStats(const RTCPeerConnectionStats& other);
358 ~RTCPeerConnectionStats() override;
hbosd565b732016-08-30 14:04:35 -0700359
360 RTCStatsMember<uint32_t> data_channels_opened;
361 RTCStatsMember<uint32_t> data_channels_closed;
362};
363
hbos6ded1902016-11-01 01:50:46 -0700364// https://w3c.github.io/webrtc-stats/#streamstats-dict*
hbos0adb8282016-11-23 02:32:06 -0800365// TODO(hbos): Tracking bug crbug.com/657854
Mirko Bonadei276827c2018-10-16 14:13:50 +0200366class RTC_EXPORT RTCRTPStreamStats : public RTCStats {
hbos6ded1902016-11-01 01:50:46 -0700367 public:
368 WEBRTC_RTCSTATS_DECL();
369
370 RTCRTPStreamStats(const RTCRTPStreamStats& other);
371 ~RTCRTPStreamStats() override;
372
hbos3443bb72017-02-07 06:28:11 -0800373 RTCStatsMember<uint32_t> ssrc;
hbos6ded1902016-11-01 01:50:46 -0700374 // TODO(hbos): When the remote case is supported |RTCStatsCollector| needs to
375 // set this. crbug.com/657855, 657856
376 RTCStatsMember<std::string> associate_stats_id;
377 // TODO(hbos): Remote case not supported by |RTCStatsCollector|.
378 // crbug.com/657855, 657856
379 RTCStatsMember<bool> is_remote; // = false
Philipp Hancke3bc01662018-08-28 14:55:03 +0200380 RTCStatsMember<std::string> media_type; // renamed to kind.
381 RTCStatsMember<std::string> kind;
hbosb0ae9202017-01-27 06:35:16 -0800382 RTCStatsMember<std::string> track_id;
hbos6ded1902016-11-01 01:50:46 -0700383 RTCStatsMember<std::string> transport_id;
hbos6ded1902016-11-01 01:50:46 -0700384 RTCStatsMember<std::string> codec_id;
385 // FIR and PLI counts are only defined for |media_type == "video"|.
386 RTCStatsMember<uint32_t> fir_count;
387 RTCStatsMember<uint32_t> pli_count;
388 // TODO(hbos): NACK count should be collected by |RTCStatsCollector| for both
389 // audio and video but is only defined in the "video" case. crbug.com/657856
390 RTCStatsMember<uint32_t> nack_count;
391 // TODO(hbos): Not collected by |RTCStatsCollector|. crbug.com/657854
392 // SLI count is only defined for |media_type == "video"|.
393 RTCStatsMember<uint32_t> sli_count;
hbos6769c492017-01-02 08:35:13 -0800394 RTCStatsMember<uint64_t> qp_sum;
hbos6ded1902016-11-01 01:50:46 -0700395
396 protected:
397 RTCRTPStreamStats(const std::string& id, int64_t timestamp_us);
398 RTCRTPStreamStats(std::string&& id, int64_t timestamp_us);
399};
400
hboseeafe942016-11-01 03:00:17 -0700401// https://w3c.github.io/webrtc-stats/#inboundrtpstats-dict*
hbosa7a9be12017-03-01 01:02:45 -0800402// TODO(hbos): Support the remote case |is_remote = true|.
403// https://bugs.webrtc.org/7065
Mirko Bonadei276827c2018-10-16 14:13:50 +0200404class RTC_EXPORT RTCInboundRTPStreamStats final : public RTCRTPStreamStats {
hboseeafe942016-11-01 03:00:17 -0700405 public:
406 WEBRTC_RTCSTATS_DECL();
407
408 RTCInboundRTPStreamStats(const std::string& id, int64_t timestamp_us);
409 RTCInboundRTPStreamStats(std::string&& id, int64_t timestamp_us);
410 RTCInboundRTPStreamStats(const RTCInboundRTPStreamStats& other);
411 ~RTCInboundRTPStreamStats() override;
412
413 RTCStatsMember<uint32_t> packets_received;
Ivo Creusen8d8ffdb2019-04-30 09:45:21 +0200414 RTCStatsMember<uint64_t> fec_packets_received;
415 RTCStatsMember<uint64_t> fec_packets_discarded;
hboseeafe942016-11-01 03:00:17 -0700416 RTCStatsMember<uint64_t> bytes_received;
Harald Alvestrand719487e2017-12-13 12:26:04 +0100417 RTCStatsMember<int32_t> packets_lost; // Signed per RFC 3550
Henrik Boström01738c62019-04-15 17:32:00 +0200418 RTCStatsMember<double> last_packet_received_timestamp;
hbosa7a9be12017-03-01 01:02:45 -0800419 // TODO(hbos): Collect and populate this value for both "audio" and "video",
420 // currently not collected for "video". https://bugs.webrtc.org/7065
hboseeafe942016-11-01 03:00:17 -0700421 RTCStatsMember<double> jitter;
hbosa7a9be12017-03-01 01:02:45 -0800422 // TODO(hbos): Collect and populate this value. https://bugs.webrtc.org/7065
423 RTCStatsMember<double> round_trip_time;
424 // TODO(hbos): Collect and populate this value. https://bugs.webrtc.org/7065
hboseeafe942016-11-01 03:00:17 -0700425 RTCStatsMember<uint32_t> packets_discarded;
hbosa7a9be12017-03-01 01:02:45 -0800426 // TODO(hbos): Collect and populate this value. https://bugs.webrtc.org/7065
hboseeafe942016-11-01 03:00:17 -0700427 RTCStatsMember<uint32_t> packets_repaired;
hbosa7a9be12017-03-01 01:02:45 -0800428 // TODO(hbos): Collect and populate this value. https://bugs.webrtc.org/7065
hboseeafe942016-11-01 03:00:17 -0700429 RTCStatsMember<uint32_t> burst_packets_lost;
hbosa7a9be12017-03-01 01:02:45 -0800430 // TODO(hbos): Collect and populate this value. https://bugs.webrtc.org/7065
hboseeafe942016-11-01 03:00:17 -0700431 RTCStatsMember<uint32_t> burst_packets_discarded;
hbosa7a9be12017-03-01 01:02:45 -0800432 // TODO(hbos): Collect and populate this value. https://bugs.webrtc.org/7065
hboseeafe942016-11-01 03:00:17 -0700433 RTCStatsMember<uint32_t> burst_loss_count;
hbosa7a9be12017-03-01 01:02:45 -0800434 // TODO(hbos): Collect and populate this value. https://bugs.webrtc.org/7065
hboseeafe942016-11-01 03:00:17 -0700435 RTCStatsMember<uint32_t> burst_discard_count;
hbosa7a9be12017-03-01 01:02:45 -0800436 // TODO(hbos): Collect and populate this value. https://bugs.webrtc.org/7065
hboseeafe942016-11-01 03:00:17 -0700437 RTCStatsMember<double> burst_loss_rate;
hbosa7a9be12017-03-01 01:02:45 -0800438 // TODO(hbos): Collect and populate this value. https://bugs.webrtc.org/7065
hboseeafe942016-11-01 03:00:17 -0700439 RTCStatsMember<double> burst_discard_rate;
hbosa7a9be12017-03-01 01:02:45 -0800440 // TODO(hbos): Collect and populate this value. https://bugs.webrtc.org/7065
hboseeafe942016-11-01 03:00:17 -0700441 RTCStatsMember<double> gap_loss_rate;
hbosa7a9be12017-03-01 01:02:45 -0800442 // TODO(hbos): Collect and populate this value. https://bugs.webrtc.org/7065
hboseeafe942016-11-01 03:00:17 -0700443 RTCStatsMember<double> gap_discard_rate;
hbos6769c492017-01-02 08:35:13 -0800444 RTCStatsMember<uint32_t> frames_decoded;
Rasmus Brandt2efae772019-06-27 14:29:34 +0200445 RTCStatsMember<uint32_t> key_frames_decoded;
Johannes Kronbfd343b2019-07-01 10:07:50 +0200446 RTCStatsMember<double> total_decode_time;
Henrik Boström2e069262019-04-09 13:59:31 +0200447 // https://henbos.github.io/webrtc-provisional-stats/#dom-rtcinboundrtpstreamstats-contenttype
448 RTCStatsMember<std::string> content_type;
hboseeafe942016-11-01 03:00:17 -0700449};
450
hbos6ded1902016-11-01 01:50:46 -0700451// https://w3c.github.io/webrtc-stats/#outboundrtpstats-dict*
hbosa7a9be12017-03-01 01:02:45 -0800452// TODO(hbos): Support the remote case |is_remote = true|.
453// https://bugs.webrtc.org/7066
Mirko Bonadei276827c2018-10-16 14:13:50 +0200454class RTC_EXPORT RTCOutboundRTPStreamStats final : public RTCRTPStreamStats {
hbos6ded1902016-11-01 01:50:46 -0700455 public:
456 WEBRTC_RTCSTATS_DECL();
457
458 RTCOutboundRTPStreamStats(const std::string& id, int64_t timestamp_us);
459 RTCOutboundRTPStreamStats(std::string&& id, int64_t timestamp_us);
460 RTCOutboundRTPStreamStats(const RTCOutboundRTPStreamStats& other);
461 ~RTCOutboundRTPStreamStats() override;
462
Henrik Boström646fda02019-05-22 15:49:42 +0200463 RTCStatsMember<std::string> media_source_id;
hbos6ded1902016-11-01 01:50:46 -0700464 RTCStatsMember<uint32_t> packets_sent;
Henrik Boströmcf96e0f2019-04-17 13:51:53 +0200465 RTCStatsMember<uint64_t> retransmitted_packets_sent;
hbos6ded1902016-11-01 01:50:46 -0700466 RTCStatsMember<uint64_t> bytes_sent;
Henrik Boströmcf96e0f2019-04-17 13:51:53 +0200467 RTCStatsMember<uint64_t> retransmitted_bytes_sent;
hbosa7a9be12017-03-01 01:02:45 -0800468 // TODO(hbos): Collect and populate this value. https://bugs.webrtc.org/7066
hbos6ded1902016-11-01 01:50:46 -0700469 RTCStatsMember<double> target_bitrate;
hbos6769c492017-01-02 08:35:13 -0800470 RTCStatsMember<uint32_t> frames_encoded;
Rasmus Brandt2efae772019-06-27 14:29:34 +0200471 RTCStatsMember<uint32_t> key_frames_encoded;
Henrik Boströmf71362f2019-04-08 16:14:23 +0200472 RTCStatsMember<double> total_encode_time;
Henrik Boström23aff9b2019-05-20 15:15:38 +0200473 RTCStatsMember<uint64_t> total_encoded_bytes_target;
Henrik Boström9fe18342019-05-16 18:38:20 +0200474 // TODO(https://crbug.com/webrtc/10635): This is only implemented for video;
475 // implement it for audio as well.
476 RTCStatsMember<double> total_packet_send_delay;
Henrik Boströmce33b6a2019-05-28 17:42:38 +0200477 // Enum type RTCQualityLimitationReason
478 // TODO(https://crbug.com/webrtc/10686): Also expose
479 // qualityLimitationDurations. Requires RTCStatsMember support for
480 // "record<DOMString, double>", see https://crbug.com/webrtc/10685.
481 RTCStatsMember<std::string> quality_limitation_reason;
Henrik Boström2e069262019-04-09 13:59:31 +0200482 // https://henbos.github.io/webrtc-provisional-stats/#dom-rtcoutboundrtpstreamstats-contenttype
483 RTCStatsMember<std::string> content_type;
hbos6ded1902016-11-01 01:50:46 -0700484};
485
Henrik Boström883eefc2019-05-27 13:40:25 +0200486// TODO(https://crbug.com/webrtc/10671): Refactor the stats dictionaries to have
487// the same hierarchy as in the spec; implement RTCReceivedRtpStreamStats.
488// Several metrics are shared between "outbound-rtp", "remote-inbound-rtp",
489// "inbound-rtp" and "remote-outbound-rtp". In the spec there is a hierarchy of
490// dictionaries that minimizes defining the same metrics in multiple places.
491// From JavaScript this hierarchy is not observable and the spec's hierarchy is
492// purely editorial. In C++ non-final classes in the hierarchy could be used to
493// refer to different stats objects within the hierarchy.
494// https://w3c.github.io/webrtc-stats/#remoteinboundrtpstats-dict*
495class RTC_EXPORT RTCRemoteInboundRtpStreamStats final : public RTCStats {
496 public:
497 WEBRTC_RTCSTATS_DECL();
498
499 RTCRemoteInboundRtpStreamStats(const std::string& id, int64_t timestamp_us);
500 RTCRemoteInboundRtpStreamStats(std::string&& id, int64_t timestamp_us);
501 RTCRemoteInboundRtpStreamStats(const RTCRemoteInboundRtpStreamStats& other);
502 ~RTCRemoteInboundRtpStreamStats() override;
503
504 // In the spec RTCRemoteInboundRtpStreamStats inherits from RTCRtpStreamStats
505 // and RTCReceivedRtpStreamStats. The members here are listed based on where
506 // they are defined in the spec.
507 // RTCRtpStreamStats
508 RTCStatsMember<uint32_t> ssrc;
509 RTCStatsMember<std::string> kind;
510 RTCStatsMember<std::string> transport_id;
511 RTCStatsMember<std::string> codec_id;
512 // RTCReceivedRtpStreamStats
513 RTCStatsMember<int32_t> packets_lost;
514 RTCStatsMember<double> jitter;
515 // TODO(hbos): The following RTCReceivedRtpStreamStats metrics should also be
516 // implemented: packetsReceived, packetsDiscarded, packetsRepaired,
517 // burstPacketsLost, burstPacketsDiscarded, burstLossCount, burstDiscardCount,
518 // burstLossRate, burstDiscardRate, gapLossRate and gapDiscardRate.
519 // RTCRemoteInboundRtpStreamStats
520 RTCStatsMember<std::string> local_id;
521 RTCStatsMember<double> round_trip_time;
522 // TODO(hbos): The following RTCRemoteInboundRtpStreamStats metric should also
523 // be implemented: fractionLost.
524};
525
Henrik Boström646fda02019-05-22 15:49:42 +0200526// https://w3c.github.io/webrtc-stats/#dom-rtcmediasourcestats
527class RTC_EXPORT RTCMediaSourceStats : public RTCStats {
528 public:
529 WEBRTC_RTCSTATS_DECL();
530
531 RTCMediaSourceStats(const RTCMediaSourceStats& other);
532 ~RTCMediaSourceStats() override;
533
534 RTCStatsMember<std::string> track_identifier;
535 RTCStatsMember<std::string> kind;
536
537 protected:
538 RTCMediaSourceStats(const std::string& id, int64_t timestamp_us);
539 RTCMediaSourceStats(std::string&& id, int64_t timestamp_us);
540};
541
542// https://w3c.github.io/webrtc-stats/#dom-rtcaudiosourcestats
543class RTC_EXPORT RTCAudioSourceStats final : public RTCMediaSourceStats {
544 public:
545 WEBRTC_RTCSTATS_DECL();
546
547 RTCAudioSourceStats(const std::string& id, int64_t timestamp_us);
548 RTCAudioSourceStats(std::string&& id, int64_t timestamp_us);
549 RTCAudioSourceStats(const RTCAudioSourceStats& other);
550 ~RTCAudioSourceStats() override;
551};
552
553// https://w3c.github.io/webrtc-stats/#dom-rtcvideosourcestats
554class RTC_EXPORT RTCVideoSourceStats final : public RTCMediaSourceStats {
555 public:
556 WEBRTC_RTCSTATS_DECL();
557
558 RTCVideoSourceStats(const std::string& id, int64_t timestamp_us);
559 RTCVideoSourceStats(std::string&& id, int64_t timestamp_us);
560 RTCVideoSourceStats(const RTCVideoSourceStats& other);
561 ~RTCVideoSourceStats() override;
562
563 RTCStatsMember<uint32_t> width;
564 RTCStatsMember<uint32_t> height;
565 // TODO(hbos): Implement this metric.
566 RTCStatsMember<uint32_t> frames;
567 RTCStatsMember<uint32_t> frames_per_second;
568};
569
hbos2fa7c672016-10-24 04:00:05 -0700570// https://w3c.github.io/webrtc-stats/#transportstats-dict*
Mirko Bonadei276827c2018-10-16 14:13:50 +0200571class RTC_EXPORT RTCTransportStats final : public RTCStats {
hbos2fa7c672016-10-24 04:00:05 -0700572 public:
573 WEBRTC_RTCSTATS_DECL();
574
575 RTCTransportStats(const std::string& id, int64_t timestamp_us);
576 RTCTransportStats(std::string&& id, int64_t timestamp_us);
577 RTCTransportStats(const RTCTransportStats& other);
578 ~RTCTransportStats() override;
579
580 RTCStatsMember<uint64_t> bytes_sent;
581 RTCStatsMember<uint64_t> bytes_received;
582 RTCStatsMember<std::string> rtcp_transport_stats_id;
hbos7064d592017-01-16 07:38:02 -0800583 // TODO(hbos): Support enum types? "RTCStatsMember<RTCDtlsTransportState>"?
584 RTCStatsMember<std::string> dtls_state;
hbos2fa7c672016-10-24 04:00:05 -0700585 RTCStatsMember<std::string> selected_candidate_pair_id;
586 RTCStatsMember<std::string> local_certificate_id;
587 RTCStatsMember<std::string> remote_certificate_id;
588};
589
hbosd565b732016-08-30 14:04:35 -0700590} // namespace webrtc
591
Mirko Bonadei92ea95e2017-09-15 06:47:31 +0200592#endif // API_STATS_RTCSTATS_OBJECTS_H_