blob: 197a810d294d174e9f0a47bd65019a6910a0caba [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;
hbos0adb8282016-11-23 02:32:06 -0800121 RTCStatsMember<uint32_t> channels;
hbos13f54b22017-02-28 06:56:04 -0800122 RTCStatsMember<std::string> sdp_fmtp_line;
hbos0adb8282016-11-23 02:32:06 -0800123};
124
hbos2fa7c672016-10-24 04:00:05 -0700125// https://w3c.github.io/webrtc-stats/#dcstats-dict*
Mirko Bonadei276827c2018-10-16 14:13:50 +0200126class RTC_EXPORT RTCDataChannelStats final : public RTCStats {
hbos2fa7c672016-10-24 04:00:05 -0700127 public:
128 WEBRTC_RTCSTATS_DECL();
129
130 RTCDataChannelStats(const std::string& id, int64_t timestamp_us);
131 RTCDataChannelStats(std::string&& id, int64_t timestamp_us);
132 RTCDataChannelStats(const RTCDataChannelStats& other);
133 ~RTCDataChannelStats() override;
134
135 RTCStatsMember<std::string> label;
136 RTCStatsMember<std::string> protocol;
137 RTCStatsMember<int32_t> datachannelid;
138 // TODO(hbos): Support enum types? "RTCStatsMember<RTCDataChannelState>"?
139 RTCStatsMember<std::string> state;
140 RTCStatsMember<uint32_t> messages_sent;
141 RTCStatsMember<uint64_t> bytes_sent;
142 RTCStatsMember<uint32_t> messages_received;
143 RTCStatsMember<uint64_t> bytes_received;
144};
145
146// https://w3c.github.io/webrtc-stats/#candidatepair-dict*
hbos338f78a2017-02-07 06:41:21 -0800147// TODO(hbos): Tracking bug https://bugs.webrtc.org/7062
Mirko Bonadei276827c2018-10-16 14:13:50 +0200148class RTC_EXPORT RTCIceCandidatePairStats final : public RTCStats {
hbosc47a0c32016-10-11 14:54:49 -0700149 public:
150 WEBRTC_RTCSTATS_DECL();
151
152 RTCIceCandidatePairStats(const std::string& id, int64_t timestamp_us);
153 RTCIceCandidatePairStats(std::string&& id, int64_t timestamp_us);
154 RTCIceCandidatePairStats(const RTCIceCandidatePairStats& other);
155 ~RTCIceCandidatePairStats() override;
156
157 RTCStatsMember<std::string> transport_id;
158 RTCStatsMember<std::string> local_candidate_id;
159 RTCStatsMember<std::string> remote_candidate_id;
160 // TODO(hbos): Support enum types?
161 // "RTCStatsMember<RTCStatsIceCandidatePairState>"?
162 RTCStatsMember<std::string> state;
163 RTCStatsMember<uint64_t> priority;
164 RTCStatsMember<bool> nominated;
hbos338f78a2017-02-07 06:41:21 -0800165 // TODO(hbos): Collect this the way the spec describes it. We have a value for
166 // it but it is not spec-compliant. https://bugs.webrtc.org/7062
hbosc47a0c32016-10-11 14:54:49 -0700167 RTCStatsMember<bool> writable;
hbos338f78a2017-02-07 06:41:21 -0800168 // TODO(hbos): Collect and populate this value. https://bugs.webrtc.org/7062
hbosc47a0c32016-10-11 14:54:49 -0700169 RTCStatsMember<bool> readable;
170 RTCStatsMember<uint64_t> bytes_sent;
171 RTCStatsMember<uint64_t> bytes_received;
hbos3168c7a2016-12-15 06:17:08 -0800172 RTCStatsMember<double> total_round_trip_time;
hbos3168c7a2016-12-15 06:17:08 -0800173 RTCStatsMember<double> current_round_trip_time;
hbosc47a0c32016-10-11 14:54:49 -0700174 RTCStatsMember<double> available_outgoing_bitrate;
hbos338f78a2017-02-07 06:41:21 -0800175 // TODO(hbos): Populate this value. It is wired up and collected the same way
hbosbf8d3e52017-02-28 06:34:47 -0800176 // "VideoBwe.googAvailableReceiveBandwidth" is, but that value is always
hbos338f78a2017-02-07 06:41:21 -0800177 // undefined. https://bugs.webrtc.org/7062
hbosc47a0c32016-10-11 14:54:49 -0700178 RTCStatsMember<double> available_incoming_bitrate;
179 RTCStatsMember<uint64_t> requests_received;
180 RTCStatsMember<uint64_t> requests_sent;
181 RTCStatsMember<uint64_t> responses_received;
182 RTCStatsMember<uint64_t> responses_sent;
hbos338f78a2017-02-07 06:41:21 -0800183 // TODO(hbos): Collect and populate this value. https://bugs.webrtc.org/7062
hbosc47a0c32016-10-11 14:54:49 -0700184 RTCStatsMember<uint64_t> retransmissions_received;
hbos338f78a2017-02-07 06:41:21 -0800185 // TODO(hbos): Collect and populate this value. https://bugs.webrtc.org/7062
hbosc47a0c32016-10-11 14:54:49 -0700186 RTCStatsMember<uint64_t> retransmissions_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> consent_requests_received;
189 RTCStatsMember<uint64_t> consent_requests_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_responses_received;
hbos338f78a2017-02-07 06:41:21 -0800192 // TODO(hbos): Collect and populate this value. https://bugs.webrtc.org/7062
hbosc47a0c32016-10-11 14:54:49 -0700193 RTCStatsMember<uint64_t> consent_responses_sent;
194};
195
hbosab9f6e42016-10-07 02:18:47 -0700196// https://w3c.github.io/webrtc-stats/#icecandidate-dict*
hbos5d79a7c2016-10-24 09:27:10 -0700197// TODO(hbos): |RTCStatsCollector| only collects candidates that are part of
198// ice candidate pairs, but there could be candidates not paired with anything.
199// crbug.com/632723
Qingsi Wang72a43a12018-02-20 16:03:18 -0800200// TODO(qingsi): Add the stats of STUN binding requests (keepalives) and collect
201// them in the new PeerConnection::GetStats.
Mirko Bonadei276827c2018-10-16 14:13:50 +0200202class RTC_EXPORT RTCIceCandidateStats : public RTCStats {
hbosab9f6e42016-10-07 02:18:47 -0700203 public:
204 WEBRTC_RTCSTATS_DECL();
205
206 RTCIceCandidateStats(const RTCIceCandidateStats& other);
207 ~RTCIceCandidateStats() override;
208
hbosb4e426e2017-01-02 09:59:31 -0800209 RTCStatsMember<std::string> transport_id;
hbosc3a2b7f2017-01-02 04:46:15 -0800210 RTCStatsMember<bool> is_remote;
Gary Liu37e489c2017-11-21 10:49:36 -0800211 RTCStatsMember<std::string> network_type;
hbosab9f6e42016-10-07 02:18:47 -0700212 RTCStatsMember<std::string> ip;
213 RTCStatsMember<int32_t> port;
214 RTCStatsMember<std::string> protocol;
Philipp Hancke95513752018-09-27 14:40:08 +0200215 RTCStatsMember<std::string> relay_protocol;
hbosab9f6e42016-10-07 02:18:47 -0700216 // TODO(hbos): Support enum types? "RTCStatsMember<RTCIceCandidateType>"?
217 RTCStatsMember<std::string> candidate_type;
218 RTCStatsMember<int32_t> priority;
hbos5d79a7c2016-10-24 09:27:10 -0700219 // TODO(hbos): Not collected by |RTCStatsCollector|. crbug.com/632723
hbosab9f6e42016-10-07 02:18:47 -0700220 RTCStatsMember<std::string> url;
hbosd17a5a72017-01-02 08:09:59 -0800221 // TODO(hbos): |deleted = true| case is not supported by |RTCStatsCollector|.
222 // crbug.com/632723
223 RTCStatsMember<bool> deleted; // = false
hbosab9f6e42016-10-07 02:18:47 -0700224
225 protected:
Yves Gerey665174f2018-06-19 15:03:05 +0200226 RTCIceCandidateStats(const std::string& id,
227 int64_t timestamp_us,
228 bool is_remote);
hbosc3a2b7f2017-01-02 04:46:15 -0800229 RTCIceCandidateStats(std::string&& id, int64_t timestamp_us, bool is_remote);
hbosab9f6e42016-10-07 02:18:47 -0700230};
231
232// In the spec both local and remote varieties are of type RTCIceCandidateStats.
233// But here we define them as subclasses of |RTCIceCandidateStats| because the
234// |kType| need to be different ("RTCStatsType type") in the local/remote case.
235// https://w3c.github.io/webrtc-stats/#rtcstatstype-str*
Henrik Boström1df1bf82018-03-20 13:24:20 +0100236// This forces us to have to override copy() and type().
Mirko Bonadei276827c2018-10-16 14:13:50 +0200237class RTC_EXPORT RTCLocalIceCandidateStats final : public RTCIceCandidateStats {
hbosab9f6e42016-10-07 02:18:47 -0700238 public:
239 static const char kType[];
240 RTCLocalIceCandidateStats(const std::string& id, int64_t timestamp_us);
241 RTCLocalIceCandidateStats(std::string&& id, int64_t timestamp_us);
Henrik Boström1df1bf82018-03-20 13:24:20 +0100242 std::unique_ptr<RTCStats> copy() const override;
hbosab9f6e42016-10-07 02:18:47 -0700243 const char* type() const override;
244};
245
Mirko Bonadei276827c2018-10-16 14:13:50 +0200246class RTC_EXPORT RTCRemoteIceCandidateStats final
247 : public RTCIceCandidateStats {
hbosab9f6e42016-10-07 02:18:47 -0700248 public:
249 static const char kType[];
250 RTCRemoteIceCandidateStats(const std::string& id, int64_t timestamp_us);
251 RTCRemoteIceCandidateStats(std::string&& id, int64_t timestamp_us);
Henrik Boström1df1bf82018-03-20 13:24:20 +0100252 std::unique_ptr<RTCStats> copy() const override;
hbosab9f6e42016-10-07 02:18:47 -0700253 const char* type() const override;
254};
255
hbos09bc1282016-11-08 06:29:22 -0800256// https://w3c.github.io/webrtc-stats/#msstats-dict*
hbos0adb8282016-11-23 02:32:06 -0800257// TODO(hbos): Tracking bug crbug.com/660827
Mirko Bonadei276827c2018-10-16 14:13:50 +0200258class RTC_EXPORT RTCMediaStreamStats final : public RTCStats {
hbos09bc1282016-11-08 06:29:22 -0800259 public:
260 WEBRTC_RTCSTATS_DECL();
261
262 RTCMediaStreamStats(const std::string& id, int64_t timestamp_us);
263 RTCMediaStreamStats(std::string&& id, int64_t timestamp_us);
264 RTCMediaStreamStats(const RTCMediaStreamStats& other);
265 ~RTCMediaStreamStats() override;
266
267 RTCStatsMember<std::string> stream_identifier;
268 RTCStatsMember<std::vector<std::string>> track_ids;
269};
270
271// https://w3c.github.io/webrtc-stats/#mststats-dict*
hbos0adb8282016-11-23 02:32:06 -0800272// TODO(hbos): Tracking bug crbug.com/659137
Mirko Bonadei276827c2018-10-16 14:13:50 +0200273class RTC_EXPORT RTCMediaStreamTrackStats final : public RTCStats {
hbos09bc1282016-11-08 06:29:22 -0800274 public:
275 WEBRTC_RTCSTATS_DECL();
276
Yves Gerey665174f2018-06-19 15:03:05 +0200277 RTCMediaStreamTrackStats(const std::string& id,
278 int64_t timestamp_us,
hbos160e4a72017-01-17 02:53:23 -0800279 const char* kind);
Yves Gerey665174f2018-06-19 15:03:05 +0200280 RTCMediaStreamTrackStats(std::string&& id,
281 int64_t timestamp_us,
hbos160e4a72017-01-17 02:53:23 -0800282 const char* kind);
hbos09bc1282016-11-08 06:29:22 -0800283 RTCMediaStreamTrackStats(const RTCMediaStreamTrackStats& other);
284 ~RTCMediaStreamTrackStats() override;
285
286 RTCStatsMember<std::string> track_identifier;
Henrik Boström646fda02019-05-22 15:49:42 +0200287 RTCStatsMember<std::string> media_source_id;
hbos09bc1282016-11-08 06:29:22 -0800288 RTCStatsMember<bool> remote_source;
289 RTCStatsMember<bool> ended;
290 // TODO(hbos): |RTCStatsCollector| does not return stats for detached tracks.
291 // crbug.com/659137
292 RTCStatsMember<bool> detached;
hbos160e4a72017-01-17 02:53:23 -0800293 // See |RTCMediaStreamTrackKind| for valid values.
294 RTCStatsMember<std::string> kind;
Gustaf Ullbergb0a02072017-10-02 12:00:34 +0200295 RTCStatsMember<double> jitter_buffer_delay;
Chen Xing0acffb52019-01-15 15:46:29 +0100296 RTCStatsMember<uint64_t> jitter_buffer_emitted_count;
hbos09bc1282016-11-08 06:29:22 -0800297 // Video-only members
298 RTCStatsMember<uint32_t> frame_width;
299 RTCStatsMember<uint32_t> frame_height;
300 // TODO(hbos): Not collected by |RTCStatsCollector|. crbug.com/659137
301 RTCStatsMember<double> frames_per_second;
hbos09bc1282016-11-08 06:29:22 -0800302 RTCStatsMember<uint32_t> frames_sent;
Ilya Nikolaevskiy70473fc2018-02-28 16:35:03 +0100303 RTCStatsMember<uint32_t> huge_frames_sent;
hbos09bc1282016-11-08 06:29:22 -0800304 RTCStatsMember<uint32_t> frames_received;
hbos09bc1282016-11-08 06:29:22 -0800305 RTCStatsMember<uint32_t> frames_decoded;
hbos09bc1282016-11-08 06:29:22 -0800306 RTCStatsMember<uint32_t> frames_dropped;
307 // TODO(hbos): Not collected by |RTCStatsCollector|. crbug.com/659137
308 RTCStatsMember<uint32_t> frames_corrupted;
309 // TODO(hbos): Not collected by |RTCStatsCollector|. crbug.com/659137
310 RTCStatsMember<uint32_t> partial_frames_lost;
311 // TODO(hbos): Not collected by |RTCStatsCollector|. crbug.com/659137
312 RTCStatsMember<uint32_t> full_frames_lost;
313 // Audio-only members
Henrik Boströmd2c336f2019-07-03 17:11:10 +0200314 RTCStatsMember<double> audio_level; // Receive-only
315 RTCStatsMember<double> total_audio_energy; // Receive-only
hbos09bc1282016-11-08 06:29:22 -0800316 RTCStatsMember<double> echo_return_loss;
317 RTCStatsMember<double> echo_return_loss_enhancement;
Steve Anton2dbc69f2017-08-24 17:15:13 -0700318 RTCStatsMember<uint64_t> total_samples_received;
Henrik Boströmd2c336f2019-07-03 17:11:10 +0200319 RTCStatsMember<double> total_samples_duration; // Receive-only
Steve Anton2dbc69f2017-08-24 17:15:13 -0700320 RTCStatsMember<uint64_t> concealed_samples;
Ivo Creusen8d8ffdb2019-04-30 09:45:21 +0200321 RTCStatsMember<uint64_t> silent_concealed_samples;
Gustaf Ullberg9a2e9062017-09-18 09:28:20 +0200322 RTCStatsMember<uint64_t> concealment_events;
Ivo Creusen8d8ffdb2019-04-30 09:45:21 +0200323 RTCStatsMember<uint64_t> inserted_samples_for_deceleration;
324 RTCStatsMember<uint64_t> removed_samples_for_acceleration;
Ruslan Burakov8af88962018-11-22 17:21:10 +0100325 // Non-standard audio-only member
Jakob Ivarsson352ce5c2018-11-27 12:52:16 +0100326 // TODO(kuddai): Add description to standard. crbug.com/webrtc/10042
Ruslan Burakov8af88962018-11-22 17:21:10 +0100327 RTCNonStandardStatsMember<uint64_t> jitter_buffer_flushes;
Jakob Ivarsson352ce5c2018-11-27 12:52:16 +0100328 RTCNonStandardStatsMember<uint64_t> delayed_packet_outage_samples;
Jakob Ivarsson232b3fd2019-03-06 09:18:40 +0100329 RTCNonStandardStatsMember<double> relative_packet_arrival_delay;
Henrik Lundin44125fa2019-04-29 17:00:46 +0200330 // TODO(henrik.lundin): Add description of the interruption metrics at
331 // https://github.com/henbos/webrtc-provisional-stats/issues/17
332 RTCNonStandardStatsMember<uint32_t> interruption_count;
333 RTCNonStandardStatsMember<double> total_interruption_duration;
Sergey Silkin02371062019-01-31 16:45:42 +0100334 // Non-standard video-only members.
335 // https://henbos.github.io/webrtc-provisional-stats/#RTCVideoReceiverStats-dict*
336 RTCNonStandardStatsMember<uint32_t> freeze_count;
337 RTCNonStandardStatsMember<uint32_t> pause_count;
338 RTCNonStandardStatsMember<double> total_freezes_duration;
339 RTCNonStandardStatsMember<double> total_pauses_duration;
340 RTCNonStandardStatsMember<double> total_frames_duration;
341 RTCNonStandardStatsMember<double> sum_squared_frame_durations;
hbos09bc1282016-11-08 06:29:22 -0800342};
343
hbos6ab97ce2016-10-03 14:16:56 -0700344// https://w3c.github.io/webrtc-stats/#pcstats-dict*
Mirko Bonadei276827c2018-10-16 14:13:50 +0200345class RTC_EXPORT RTCPeerConnectionStats final : public RTCStats {
hbosd565b732016-08-30 14:04:35 -0700346 public:
hbosfc5e0502016-10-06 02:06:10 -0700347 WEBRTC_RTCSTATS_DECL();
348
hbos0e6758d2016-08-31 07:57:36 -0700349 RTCPeerConnectionStats(const std::string& id, int64_t timestamp_us);
350 RTCPeerConnectionStats(std::string&& id, int64_t timestamp_us);
hbosfc5e0502016-10-06 02:06:10 -0700351 RTCPeerConnectionStats(const RTCPeerConnectionStats& other);
352 ~RTCPeerConnectionStats() override;
hbosd565b732016-08-30 14:04:35 -0700353
354 RTCStatsMember<uint32_t> data_channels_opened;
355 RTCStatsMember<uint32_t> data_channels_closed;
356};
357
hbos6ded1902016-11-01 01:50:46 -0700358// https://w3c.github.io/webrtc-stats/#streamstats-dict*
hbos0adb8282016-11-23 02:32:06 -0800359// TODO(hbos): Tracking bug crbug.com/657854
Mirko Bonadei276827c2018-10-16 14:13:50 +0200360class RTC_EXPORT RTCRTPStreamStats : public RTCStats {
hbos6ded1902016-11-01 01:50:46 -0700361 public:
362 WEBRTC_RTCSTATS_DECL();
363
364 RTCRTPStreamStats(const RTCRTPStreamStats& other);
365 ~RTCRTPStreamStats() override;
366
hbos3443bb72017-02-07 06:28:11 -0800367 RTCStatsMember<uint32_t> ssrc;
hbos6ded1902016-11-01 01:50:46 -0700368 // TODO(hbos): Remote case not supported by |RTCStatsCollector|.
369 // crbug.com/657855, 657856
Jonas Olssona4d87372019-07-05 19:08:33 +0200370 RTCStatsMember<bool> is_remote; // = false
Philipp Hancke3bc01662018-08-28 14:55:03 +0200371 RTCStatsMember<std::string> media_type; // renamed to kind.
372 RTCStatsMember<std::string> kind;
hbosb0ae9202017-01-27 06:35:16 -0800373 RTCStatsMember<std::string> track_id;
hbos6ded1902016-11-01 01:50:46 -0700374 RTCStatsMember<std::string> transport_id;
hbos6ded1902016-11-01 01:50:46 -0700375 RTCStatsMember<std::string> codec_id;
376 // FIR and PLI counts are only defined for |media_type == "video"|.
377 RTCStatsMember<uint32_t> fir_count;
378 RTCStatsMember<uint32_t> pli_count;
379 // TODO(hbos): NACK count should be collected by |RTCStatsCollector| for both
380 // audio and video but is only defined in the "video" case. crbug.com/657856
381 RTCStatsMember<uint32_t> nack_count;
382 // TODO(hbos): Not collected by |RTCStatsCollector|. crbug.com/657854
383 // SLI count is only defined for |media_type == "video"|.
384 RTCStatsMember<uint32_t> sli_count;
hbos6769c492017-01-02 08:35:13 -0800385 RTCStatsMember<uint64_t> qp_sum;
hbos6ded1902016-11-01 01:50:46 -0700386
387 protected:
388 RTCRTPStreamStats(const std::string& id, int64_t timestamp_us);
389 RTCRTPStreamStats(std::string&& id, int64_t timestamp_us);
390};
391
hboseeafe942016-11-01 03:00:17 -0700392// https://w3c.github.io/webrtc-stats/#inboundrtpstats-dict*
hbosa7a9be12017-03-01 01:02:45 -0800393// TODO(hbos): Support the remote case |is_remote = true|.
394// https://bugs.webrtc.org/7065
Mirko Bonadei276827c2018-10-16 14:13:50 +0200395class RTC_EXPORT RTCInboundRTPStreamStats final : public RTCRTPStreamStats {
hboseeafe942016-11-01 03:00:17 -0700396 public:
397 WEBRTC_RTCSTATS_DECL();
398
399 RTCInboundRTPStreamStats(const std::string& id, int64_t timestamp_us);
400 RTCInboundRTPStreamStats(std::string&& id, int64_t timestamp_us);
401 RTCInboundRTPStreamStats(const RTCInboundRTPStreamStats& other);
402 ~RTCInboundRTPStreamStats() override;
403
404 RTCStatsMember<uint32_t> packets_received;
Ivo Creusen8d8ffdb2019-04-30 09:45:21 +0200405 RTCStatsMember<uint64_t> fec_packets_received;
406 RTCStatsMember<uint64_t> fec_packets_discarded;
hboseeafe942016-11-01 03:00:17 -0700407 RTCStatsMember<uint64_t> bytes_received;
Niels Möllerac0a4cb2019-10-09 15:01:33 +0200408 RTCStatsMember<uint64_t> header_bytes_received;
Harald Alvestrand719487e2017-12-13 12:26:04 +0100409 RTCStatsMember<int32_t> packets_lost; // Signed per RFC 3550
Henrik Boström01738c62019-04-15 17:32:00 +0200410 RTCStatsMember<double> last_packet_received_timestamp;
hbosa7a9be12017-03-01 01:02:45 -0800411 // TODO(hbos): Collect and populate this value for both "audio" and "video",
412 // currently not collected for "video". https://bugs.webrtc.org/7065
hboseeafe942016-11-01 03:00:17 -0700413 RTCStatsMember<double> jitter;
hbosa7a9be12017-03-01 01:02:45 -0800414 // TODO(hbos): Collect and populate this value. https://bugs.webrtc.org/7065
415 RTCStatsMember<double> round_trip_time;
416 // TODO(hbos): Collect and populate this value. https://bugs.webrtc.org/7065
hboseeafe942016-11-01 03:00:17 -0700417 RTCStatsMember<uint32_t> packets_discarded;
hbosa7a9be12017-03-01 01:02:45 -0800418 // TODO(hbos): Collect and populate this value. https://bugs.webrtc.org/7065
hboseeafe942016-11-01 03:00:17 -0700419 RTCStatsMember<uint32_t> packets_repaired;
hbosa7a9be12017-03-01 01:02:45 -0800420 // TODO(hbos): Collect and populate this value. https://bugs.webrtc.org/7065
hboseeafe942016-11-01 03:00:17 -0700421 RTCStatsMember<uint32_t> burst_packets_lost;
hbosa7a9be12017-03-01 01:02:45 -0800422 // TODO(hbos): Collect and populate this value. https://bugs.webrtc.org/7065
hboseeafe942016-11-01 03:00:17 -0700423 RTCStatsMember<uint32_t> burst_packets_discarded;
hbosa7a9be12017-03-01 01:02:45 -0800424 // TODO(hbos): Collect and populate this value. https://bugs.webrtc.org/7065
hboseeafe942016-11-01 03:00:17 -0700425 RTCStatsMember<uint32_t> burst_loss_count;
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> burst_discard_count;
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<double> burst_loss_rate;
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<double> burst_discard_rate;
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<double> gap_loss_rate;
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<double> gap_discard_rate;
hbos6769c492017-01-02 08:35:13 -0800436 RTCStatsMember<uint32_t> frames_decoded;
Rasmus Brandt2efae772019-06-27 14:29:34 +0200437 RTCStatsMember<uint32_t> key_frames_decoded;
Johannes Kronbfd343b2019-07-01 10:07:50 +0200438 RTCStatsMember<double> total_decode_time;
Johannes Kron00376e12019-11-25 10:25:42 +0100439 RTCStatsMember<double> total_inter_frame_delay;
440 RTCStatsMember<double> total_squared_inter_frame_delay;
Henrik Boström2e069262019-04-09 13:59:31 +0200441 // https://henbos.github.io/webrtc-provisional-stats/#dom-rtcinboundrtpstreamstats-contenttype
442 RTCStatsMember<std::string> content_type;
Åsa Perssonfcf79cc2019-10-22 15:23:44 +0200443 // TODO(asapersson): Currently only populated if audio/video sync is enabled.
444 RTCStatsMember<double> estimated_playout_timestamp;
Henrik Boström6b430862019-08-16 13:09:51 +0200445 // TODO(hbos): This is only implemented for video; implement it for audio as
446 // well.
447 RTCStatsMember<std::string> decoder_implementation;
hboseeafe942016-11-01 03:00:17 -0700448};
449
hbos6ded1902016-11-01 01:50:46 -0700450// https://w3c.github.io/webrtc-stats/#outboundrtpstats-dict*
hbosa7a9be12017-03-01 01:02:45 -0800451// TODO(hbos): Support the remote case |is_remote = true|.
452// https://bugs.webrtc.org/7066
Mirko Bonadei276827c2018-10-16 14:13:50 +0200453class RTC_EXPORT RTCOutboundRTPStreamStats final : public RTCRTPStreamStats {
hbos6ded1902016-11-01 01:50:46 -0700454 public:
455 WEBRTC_RTCSTATS_DECL();
456
457 RTCOutboundRTPStreamStats(const std::string& id, int64_t timestamp_us);
458 RTCOutboundRTPStreamStats(std::string&& id, int64_t timestamp_us);
459 RTCOutboundRTPStreamStats(const RTCOutboundRTPStreamStats& other);
460 ~RTCOutboundRTPStreamStats() override;
461
Henrik Boström646fda02019-05-22 15:49:42 +0200462 RTCStatsMember<std::string> media_source_id;
Henrik Boström4f40fa52019-12-19 13:27:27 +0100463 RTCStatsMember<std::string> remote_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;
Niels Möllerac0a4cb2019-10-09 15:01:33 +0200467 RTCStatsMember<uint64_t> header_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;
Evan Shrubsolecc62b162019-09-09 11:26:45 +0200483 // https://w3c.github.io/webrtc-stats/#dom-rtcoutboundrtpstreamstats-qualitylimitationresolutionchanges
484 RTCStatsMember<uint32_t> quality_limitation_resolution_changes;
Henrik Boström2e069262019-04-09 13:59:31 +0200485 // https://henbos.github.io/webrtc-provisional-stats/#dom-rtcoutboundrtpstreamstats-contenttype
486 RTCStatsMember<std::string> content_type;
Henrik Boström6b430862019-08-16 13:09:51 +0200487 // TODO(hbos): This is only implemented for video; implement it for audio as
488 // well.
489 RTCStatsMember<std::string> encoder_implementation;
hbos6ded1902016-11-01 01:50:46 -0700490};
491
Henrik Boström883eefc2019-05-27 13:40:25 +0200492// TODO(https://crbug.com/webrtc/10671): Refactor the stats dictionaries to have
493// the same hierarchy as in the spec; implement RTCReceivedRtpStreamStats.
494// Several metrics are shared between "outbound-rtp", "remote-inbound-rtp",
495// "inbound-rtp" and "remote-outbound-rtp". In the spec there is a hierarchy of
496// dictionaries that minimizes defining the same metrics in multiple places.
497// From JavaScript this hierarchy is not observable and the spec's hierarchy is
498// purely editorial. In C++ non-final classes in the hierarchy could be used to
499// refer to different stats objects within the hierarchy.
500// https://w3c.github.io/webrtc-stats/#remoteinboundrtpstats-dict*
501class RTC_EXPORT RTCRemoteInboundRtpStreamStats final : public RTCStats {
502 public:
503 WEBRTC_RTCSTATS_DECL();
504
505 RTCRemoteInboundRtpStreamStats(const std::string& id, int64_t timestamp_us);
506 RTCRemoteInboundRtpStreamStats(std::string&& id, int64_t timestamp_us);
507 RTCRemoteInboundRtpStreamStats(const RTCRemoteInboundRtpStreamStats& other);
508 ~RTCRemoteInboundRtpStreamStats() override;
509
510 // In the spec RTCRemoteInboundRtpStreamStats inherits from RTCRtpStreamStats
511 // and RTCReceivedRtpStreamStats. The members here are listed based on where
512 // they are defined in the spec.
513 // RTCRtpStreamStats
514 RTCStatsMember<uint32_t> ssrc;
515 RTCStatsMember<std::string> kind;
516 RTCStatsMember<std::string> transport_id;
517 RTCStatsMember<std::string> codec_id;
518 // RTCReceivedRtpStreamStats
519 RTCStatsMember<int32_t> packets_lost;
520 RTCStatsMember<double> jitter;
521 // TODO(hbos): The following RTCReceivedRtpStreamStats metrics should also be
522 // implemented: packetsReceived, packetsDiscarded, packetsRepaired,
523 // burstPacketsLost, burstPacketsDiscarded, burstLossCount, burstDiscardCount,
524 // burstLossRate, burstDiscardRate, gapLossRate and gapDiscardRate.
525 // RTCRemoteInboundRtpStreamStats
526 RTCStatsMember<std::string> local_id;
527 RTCStatsMember<double> round_trip_time;
528 // TODO(hbos): The following RTCRemoteInboundRtpStreamStats metric should also
529 // be implemented: fractionLost.
530};
531
Henrik Boström646fda02019-05-22 15:49:42 +0200532// https://w3c.github.io/webrtc-stats/#dom-rtcmediasourcestats
533class RTC_EXPORT RTCMediaSourceStats : public RTCStats {
534 public:
535 WEBRTC_RTCSTATS_DECL();
536
537 RTCMediaSourceStats(const RTCMediaSourceStats& other);
538 ~RTCMediaSourceStats() override;
539
540 RTCStatsMember<std::string> track_identifier;
541 RTCStatsMember<std::string> kind;
542
543 protected:
544 RTCMediaSourceStats(const std::string& id, int64_t timestamp_us);
545 RTCMediaSourceStats(std::string&& id, int64_t timestamp_us);
546};
547
548// https://w3c.github.io/webrtc-stats/#dom-rtcaudiosourcestats
549class RTC_EXPORT RTCAudioSourceStats final : public RTCMediaSourceStats {
550 public:
551 WEBRTC_RTCSTATS_DECL();
552
553 RTCAudioSourceStats(const std::string& id, int64_t timestamp_us);
554 RTCAudioSourceStats(std::string&& id, int64_t timestamp_us);
555 RTCAudioSourceStats(const RTCAudioSourceStats& other);
556 ~RTCAudioSourceStats() override;
Henrik Boströmd2c336f2019-07-03 17:11:10 +0200557
558 RTCStatsMember<double> audio_level;
559 RTCStatsMember<double> total_audio_energy;
560 RTCStatsMember<double> total_samples_duration;
Henrik Boström646fda02019-05-22 15:49:42 +0200561};
562
563// https://w3c.github.io/webrtc-stats/#dom-rtcvideosourcestats
564class RTC_EXPORT RTCVideoSourceStats final : public RTCMediaSourceStats {
565 public:
566 WEBRTC_RTCSTATS_DECL();
567
568 RTCVideoSourceStats(const std::string& id, int64_t timestamp_us);
569 RTCVideoSourceStats(std::string&& id, int64_t timestamp_us);
570 RTCVideoSourceStats(const RTCVideoSourceStats& other);
571 ~RTCVideoSourceStats() override;
572
573 RTCStatsMember<uint32_t> width;
574 RTCStatsMember<uint32_t> height;
575 // TODO(hbos): Implement this metric.
576 RTCStatsMember<uint32_t> frames;
577 RTCStatsMember<uint32_t> frames_per_second;
578};
579
hbos2fa7c672016-10-24 04:00:05 -0700580// https://w3c.github.io/webrtc-stats/#transportstats-dict*
Mirko Bonadei276827c2018-10-16 14:13:50 +0200581class RTC_EXPORT RTCTransportStats final : public RTCStats {
hbos2fa7c672016-10-24 04:00:05 -0700582 public:
583 WEBRTC_RTCSTATS_DECL();
584
585 RTCTransportStats(const std::string& id, int64_t timestamp_us);
586 RTCTransportStats(std::string&& id, int64_t timestamp_us);
587 RTCTransportStats(const RTCTransportStats& other);
588 ~RTCTransportStats() override;
589
590 RTCStatsMember<uint64_t> bytes_sent;
591 RTCStatsMember<uint64_t> bytes_received;
592 RTCStatsMember<std::string> rtcp_transport_stats_id;
hbos7064d592017-01-16 07:38:02 -0800593 // TODO(hbos): Support enum types? "RTCStatsMember<RTCDtlsTransportState>"?
594 RTCStatsMember<std::string> dtls_state;
hbos2fa7c672016-10-24 04:00:05 -0700595 RTCStatsMember<std::string> selected_candidate_pair_id;
596 RTCStatsMember<std::string> local_certificate_id;
597 RTCStatsMember<std::string> remote_certificate_id;
Harald Alvestrand5cb78072019-10-28 09:51:17 +0100598 RTCStatsMember<std::string> tls_version;
599 RTCStatsMember<std::string> dtls_cipher;
600 RTCStatsMember<std::string> srtp_cipher;
Jonas Oreland149dc722019-08-28 08:10:27 +0200601 RTCStatsMember<uint32_t> selected_candidate_pair_changes;
hbos2fa7c672016-10-24 04:00:05 -0700602};
603
hbosd565b732016-08-30 14:04:35 -0700604} // namespace webrtc
605
Mirko Bonadei92ea95e2017-09-15 06:47:31 +0200606#endif // API_STATS_RTCSTATS_OBJECTS_H_