blob: d614a869f2417d515a2f3736500a8a7c9e396d3a [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öm2e069262019-04-09 13:59:31 +020077// https://webrtc.org/experiments/rtp-hdrext/video-content-type/
78struct RTCContentType {
79 static const char* const kUnspecified;
80 static const char* const kScreenshare;
81};
82
hbos2fa7c672016-10-24 04:00:05 -070083// https://w3c.github.io/webrtc-stats/#certificatestats-dict*
Mirko Bonadei276827c2018-10-16 14:13:50 +020084class RTC_EXPORT RTCCertificateStats final : public RTCStats {
hbos2fa7c672016-10-24 04:00:05 -070085 public:
86 WEBRTC_RTCSTATS_DECL();
87
88 RTCCertificateStats(const std::string& id, int64_t timestamp_us);
89 RTCCertificateStats(std::string&& id, int64_t timestamp_us);
90 RTCCertificateStats(const RTCCertificateStats& other);
91 ~RTCCertificateStats() override;
92
93 RTCStatsMember<std::string> fingerprint;
94 RTCStatsMember<std::string> fingerprint_algorithm;
95 RTCStatsMember<std::string> base64_certificate;
96 RTCStatsMember<std::string> issuer_certificate_id;
97};
98
hbos0adb8282016-11-23 02:32:06 -080099// https://w3c.github.io/webrtc-stats/#codec-dict*
Mirko Bonadei276827c2018-10-16 14:13:50 +0200100class RTC_EXPORT RTCCodecStats final : public RTCStats {
hbos0adb8282016-11-23 02:32:06 -0800101 public:
102 WEBRTC_RTCSTATS_DECL();
103
104 RTCCodecStats(const std::string& id, int64_t timestamp_us);
105 RTCCodecStats(std::string&& id, int64_t timestamp_us);
106 RTCCodecStats(const RTCCodecStats& other);
107 ~RTCCodecStats() override;
108
109 RTCStatsMember<uint32_t> payload_type;
hbos13f54b22017-02-28 06:56:04 -0800110 RTCStatsMember<std::string> mime_type;
hbos0adb8282016-11-23 02:32:06 -0800111 RTCStatsMember<uint32_t> clock_rate;
hbos585a9b12017-02-07 04:59:16 -0800112 // TODO(hbos): Collect and populate this value. https://bugs.webrtc.org/7061
hbos0adb8282016-11-23 02:32:06 -0800113 RTCStatsMember<uint32_t> channels;
hbos585a9b12017-02-07 04:59:16 -0800114 // TODO(hbos): Collect and populate this value. https://bugs.webrtc.org/7061
hbos13f54b22017-02-28 06:56:04 -0800115 RTCStatsMember<std::string> sdp_fmtp_line;
hbos585a9b12017-02-07 04:59:16 -0800116 // TODO(hbos): Collect and populate this value. https://bugs.webrtc.org/7061
hbos0adb8282016-11-23 02:32:06 -0800117 RTCStatsMember<std::string> implementation;
118};
119
hbos2fa7c672016-10-24 04:00:05 -0700120// https://w3c.github.io/webrtc-stats/#dcstats-dict*
Mirko Bonadei276827c2018-10-16 14:13:50 +0200121class RTC_EXPORT RTCDataChannelStats final : public RTCStats {
hbos2fa7c672016-10-24 04:00:05 -0700122 public:
123 WEBRTC_RTCSTATS_DECL();
124
125 RTCDataChannelStats(const std::string& id, int64_t timestamp_us);
126 RTCDataChannelStats(std::string&& id, int64_t timestamp_us);
127 RTCDataChannelStats(const RTCDataChannelStats& other);
128 ~RTCDataChannelStats() override;
129
130 RTCStatsMember<std::string> label;
131 RTCStatsMember<std::string> protocol;
132 RTCStatsMember<int32_t> datachannelid;
133 // TODO(hbos): Support enum types? "RTCStatsMember<RTCDataChannelState>"?
134 RTCStatsMember<std::string> state;
135 RTCStatsMember<uint32_t> messages_sent;
136 RTCStatsMember<uint64_t> bytes_sent;
137 RTCStatsMember<uint32_t> messages_received;
138 RTCStatsMember<uint64_t> bytes_received;
139};
140
141// https://w3c.github.io/webrtc-stats/#candidatepair-dict*
hbos338f78a2017-02-07 06:41:21 -0800142// TODO(hbos): Tracking bug https://bugs.webrtc.org/7062
Mirko Bonadei276827c2018-10-16 14:13:50 +0200143class RTC_EXPORT RTCIceCandidatePairStats final : public RTCStats {
hbosc47a0c32016-10-11 14:54:49 -0700144 public:
145 WEBRTC_RTCSTATS_DECL();
146
147 RTCIceCandidatePairStats(const std::string& id, int64_t timestamp_us);
148 RTCIceCandidatePairStats(std::string&& id, int64_t timestamp_us);
149 RTCIceCandidatePairStats(const RTCIceCandidatePairStats& other);
150 ~RTCIceCandidatePairStats() override;
151
152 RTCStatsMember<std::string> transport_id;
153 RTCStatsMember<std::string> local_candidate_id;
154 RTCStatsMember<std::string> remote_candidate_id;
155 // TODO(hbos): Support enum types?
156 // "RTCStatsMember<RTCStatsIceCandidatePairState>"?
157 RTCStatsMember<std::string> state;
158 RTCStatsMember<uint64_t> priority;
159 RTCStatsMember<bool> nominated;
hbos338f78a2017-02-07 06:41:21 -0800160 // TODO(hbos): Collect this the way the spec describes it. We have a value for
161 // it but it is not spec-compliant. https://bugs.webrtc.org/7062
hbosc47a0c32016-10-11 14:54:49 -0700162 RTCStatsMember<bool> writable;
hbos338f78a2017-02-07 06:41:21 -0800163 // TODO(hbos): Collect and populate this value. https://bugs.webrtc.org/7062
hbosc47a0c32016-10-11 14:54:49 -0700164 RTCStatsMember<bool> readable;
165 RTCStatsMember<uint64_t> bytes_sent;
166 RTCStatsMember<uint64_t> bytes_received;
hbos3168c7a2016-12-15 06:17:08 -0800167 RTCStatsMember<double> total_round_trip_time;
hbos3168c7a2016-12-15 06:17:08 -0800168 RTCStatsMember<double> current_round_trip_time;
hbosc47a0c32016-10-11 14:54:49 -0700169 RTCStatsMember<double> available_outgoing_bitrate;
hbos338f78a2017-02-07 06:41:21 -0800170 // TODO(hbos): Populate this value. It is wired up and collected the same way
hbosbf8d3e52017-02-28 06:34:47 -0800171 // "VideoBwe.googAvailableReceiveBandwidth" is, but that value is always
hbos338f78a2017-02-07 06:41:21 -0800172 // undefined. https://bugs.webrtc.org/7062
hbosc47a0c32016-10-11 14:54:49 -0700173 RTCStatsMember<double> available_incoming_bitrate;
174 RTCStatsMember<uint64_t> requests_received;
175 RTCStatsMember<uint64_t> requests_sent;
176 RTCStatsMember<uint64_t> responses_received;
177 RTCStatsMember<uint64_t> responses_sent;
hbos338f78a2017-02-07 06:41:21 -0800178 // TODO(hbos): Collect and populate this value. https://bugs.webrtc.org/7062
hbosc47a0c32016-10-11 14:54:49 -0700179 RTCStatsMember<uint64_t> retransmissions_received;
hbos338f78a2017-02-07 06:41:21 -0800180 // TODO(hbos): Collect and populate this value. https://bugs.webrtc.org/7062
hbosc47a0c32016-10-11 14:54:49 -0700181 RTCStatsMember<uint64_t> retransmissions_sent;
hbos338f78a2017-02-07 06:41:21 -0800182 // TODO(hbos): Collect and populate this value. https://bugs.webrtc.org/7062
hbosc47a0c32016-10-11 14:54:49 -0700183 RTCStatsMember<uint64_t> consent_requests_received;
184 RTCStatsMember<uint64_t> consent_requests_sent;
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> consent_responses_received;
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_responses_sent;
189};
190
hbosab9f6e42016-10-07 02:18:47 -0700191// https://w3c.github.io/webrtc-stats/#icecandidate-dict*
hbos5d79a7c2016-10-24 09:27:10 -0700192// TODO(hbos): |RTCStatsCollector| only collects candidates that are part of
193// ice candidate pairs, but there could be candidates not paired with anything.
194// crbug.com/632723
Qingsi Wang72a43a12018-02-20 16:03:18 -0800195// TODO(qingsi): Add the stats of STUN binding requests (keepalives) and collect
196// them in the new PeerConnection::GetStats.
Mirko Bonadei276827c2018-10-16 14:13:50 +0200197class RTC_EXPORT RTCIceCandidateStats : public RTCStats {
hbosab9f6e42016-10-07 02:18:47 -0700198 public:
199 WEBRTC_RTCSTATS_DECL();
200
201 RTCIceCandidateStats(const RTCIceCandidateStats& other);
202 ~RTCIceCandidateStats() override;
203
hbosb4e426e2017-01-02 09:59:31 -0800204 RTCStatsMember<std::string> transport_id;
hbosc3a2b7f2017-01-02 04:46:15 -0800205 RTCStatsMember<bool> is_remote;
Gary Liu37e489c2017-11-21 10:49:36 -0800206 RTCStatsMember<std::string> network_type;
hbosab9f6e42016-10-07 02:18:47 -0700207 RTCStatsMember<std::string> ip;
208 RTCStatsMember<int32_t> port;
209 RTCStatsMember<std::string> protocol;
Philipp Hancke95513752018-09-27 14:40:08 +0200210 RTCStatsMember<std::string> relay_protocol;
hbosab9f6e42016-10-07 02:18:47 -0700211 // TODO(hbos): Support enum types? "RTCStatsMember<RTCIceCandidateType>"?
212 RTCStatsMember<std::string> candidate_type;
213 RTCStatsMember<int32_t> priority;
hbos5d79a7c2016-10-24 09:27:10 -0700214 // TODO(hbos): Not collected by |RTCStatsCollector|. crbug.com/632723
hbosab9f6e42016-10-07 02:18:47 -0700215 RTCStatsMember<std::string> url;
hbosd17a5a72017-01-02 08:09:59 -0800216 // TODO(hbos): |deleted = true| case is not supported by |RTCStatsCollector|.
217 // crbug.com/632723
218 RTCStatsMember<bool> deleted; // = false
hbosab9f6e42016-10-07 02:18:47 -0700219
220 protected:
Yves Gerey665174f2018-06-19 15:03:05 +0200221 RTCIceCandidateStats(const std::string& id,
222 int64_t timestamp_us,
223 bool is_remote);
hbosc3a2b7f2017-01-02 04:46:15 -0800224 RTCIceCandidateStats(std::string&& id, int64_t timestamp_us, bool is_remote);
hbosab9f6e42016-10-07 02:18:47 -0700225};
226
227// In the spec both local and remote varieties are of type RTCIceCandidateStats.
228// But here we define them as subclasses of |RTCIceCandidateStats| because the
229// |kType| need to be different ("RTCStatsType type") in the local/remote case.
230// https://w3c.github.io/webrtc-stats/#rtcstatstype-str*
Henrik Boström1df1bf82018-03-20 13:24:20 +0100231// This forces us to have to override copy() and type().
Mirko Bonadei276827c2018-10-16 14:13:50 +0200232class RTC_EXPORT RTCLocalIceCandidateStats final : public RTCIceCandidateStats {
hbosab9f6e42016-10-07 02:18:47 -0700233 public:
234 static const char kType[];
235 RTCLocalIceCandidateStats(const std::string& id, int64_t timestamp_us);
236 RTCLocalIceCandidateStats(std::string&& id, int64_t timestamp_us);
Henrik Boström1df1bf82018-03-20 13:24:20 +0100237 std::unique_ptr<RTCStats> copy() const override;
hbosab9f6e42016-10-07 02:18:47 -0700238 const char* type() const override;
239};
240
Mirko Bonadei276827c2018-10-16 14:13:50 +0200241class RTC_EXPORT RTCRemoteIceCandidateStats final
242 : public RTCIceCandidateStats {
hbosab9f6e42016-10-07 02:18:47 -0700243 public:
244 static const char kType[];
245 RTCRemoteIceCandidateStats(const std::string& id, int64_t timestamp_us);
246 RTCRemoteIceCandidateStats(std::string&& id, int64_t timestamp_us);
Henrik Boström1df1bf82018-03-20 13:24:20 +0100247 std::unique_ptr<RTCStats> copy() const override;
hbosab9f6e42016-10-07 02:18:47 -0700248 const char* type() const override;
249};
250
hbos09bc1282016-11-08 06:29:22 -0800251// https://w3c.github.io/webrtc-stats/#msstats-dict*
hbos0adb8282016-11-23 02:32:06 -0800252// TODO(hbos): Tracking bug crbug.com/660827
Mirko Bonadei276827c2018-10-16 14:13:50 +0200253class RTC_EXPORT RTCMediaStreamStats final : public RTCStats {
hbos09bc1282016-11-08 06:29:22 -0800254 public:
255 WEBRTC_RTCSTATS_DECL();
256
257 RTCMediaStreamStats(const std::string& id, int64_t timestamp_us);
258 RTCMediaStreamStats(std::string&& id, int64_t timestamp_us);
259 RTCMediaStreamStats(const RTCMediaStreamStats& other);
260 ~RTCMediaStreamStats() override;
261
262 RTCStatsMember<std::string> stream_identifier;
263 RTCStatsMember<std::vector<std::string>> track_ids;
264};
265
266// https://w3c.github.io/webrtc-stats/#mststats-dict*
hbos0adb8282016-11-23 02:32:06 -0800267// TODO(hbos): Tracking bug crbug.com/659137
Mirko Bonadei276827c2018-10-16 14:13:50 +0200268class RTC_EXPORT RTCMediaStreamTrackStats final : public RTCStats {
hbos09bc1282016-11-08 06:29:22 -0800269 public:
270 WEBRTC_RTCSTATS_DECL();
271
Yves Gerey665174f2018-06-19 15:03:05 +0200272 RTCMediaStreamTrackStats(const std::string& id,
273 int64_t timestamp_us,
hbos160e4a72017-01-17 02:53:23 -0800274 const char* kind);
Yves Gerey665174f2018-06-19 15:03:05 +0200275 RTCMediaStreamTrackStats(std::string&& id,
276 int64_t timestamp_us,
hbos160e4a72017-01-17 02:53:23 -0800277 const char* kind);
hbos09bc1282016-11-08 06:29:22 -0800278 RTCMediaStreamTrackStats(const RTCMediaStreamTrackStats& other);
279 ~RTCMediaStreamTrackStats() override;
280
281 RTCStatsMember<std::string> track_identifier;
282 RTCStatsMember<bool> remote_source;
283 RTCStatsMember<bool> ended;
284 // TODO(hbos): |RTCStatsCollector| does not return stats for detached tracks.
285 // crbug.com/659137
286 RTCStatsMember<bool> detached;
hbos160e4a72017-01-17 02:53:23 -0800287 // See |RTCMediaStreamTrackKind| for valid values.
288 RTCStatsMember<std::string> kind;
Gustaf Ullbergb0a02072017-10-02 12:00:34 +0200289 // TODO(gustaf): Implement jitter_buffer_delay for video (currently
290 // implemented for audio only).
291 // https://crbug.com/webrtc/8318
292 RTCStatsMember<double> jitter_buffer_delay;
Chen Xing0acffb52019-01-15 15:46:29 +0100293 RTCStatsMember<uint64_t> jitter_buffer_emitted_count;
hbos09bc1282016-11-08 06:29:22 -0800294 // Video-only members
295 RTCStatsMember<uint32_t> frame_width;
296 RTCStatsMember<uint32_t> frame_height;
297 // TODO(hbos): Not collected by |RTCStatsCollector|. crbug.com/659137
298 RTCStatsMember<double> frames_per_second;
hbos09bc1282016-11-08 06:29:22 -0800299 RTCStatsMember<uint32_t> frames_sent;
Ilya Nikolaevskiy70473fc2018-02-28 16:35:03 +0100300 RTCStatsMember<uint32_t> huge_frames_sent;
hbos09bc1282016-11-08 06:29:22 -0800301 RTCStatsMember<uint32_t> frames_received;
hbos09bc1282016-11-08 06:29:22 -0800302 RTCStatsMember<uint32_t> frames_decoded;
hbos09bc1282016-11-08 06:29:22 -0800303 RTCStatsMember<uint32_t> frames_dropped;
304 // TODO(hbos): Not collected by |RTCStatsCollector|. crbug.com/659137
305 RTCStatsMember<uint32_t> frames_corrupted;
306 // TODO(hbos): Not collected by |RTCStatsCollector|. crbug.com/659137
307 RTCStatsMember<uint32_t> partial_frames_lost;
308 // TODO(hbos): Not collected by |RTCStatsCollector|. crbug.com/659137
309 RTCStatsMember<uint32_t> full_frames_lost;
310 // Audio-only members
311 RTCStatsMember<double> audio_level;
zsteine76bd3a2017-07-14 12:17:49 -0700312 RTCStatsMember<double> total_audio_energy;
hbos09bc1282016-11-08 06:29:22 -0800313 RTCStatsMember<double> echo_return_loss;
314 RTCStatsMember<double> echo_return_loss_enhancement;
Steve Anton2dbc69f2017-08-24 17:15:13 -0700315 RTCStatsMember<uint64_t> total_samples_received;
316 RTCStatsMember<double> total_samples_duration;
317 RTCStatsMember<uint64_t> concealed_samples;
Ivo Creusen8d8ffdb2019-04-30 09:45:21 +0200318 RTCStatsMember<uint64_t> silent_concealed_samples;
Gustaf Ullberg9a2e9062017-09-18 09:28:20 +0200319 RTCStatsMember<uint64_t> concealment_events;
Ivo Creusen8d8ffdb2019-04-30 09:45:21 +0200320 RTCStatsMember<uint64_t> inserted_samples_for_deceleration;
321 RTCStatsMember<uint64_t> removed_samples_for_acceleration;
Ruslan Burakov8af88962018-11-22 17:21:10 +0100322 // Non-standard audio-only member
Jakob Ivarsson352ce5c2018-11-27 12:52:16 +0100323 // TODO(kuddai): Add description to standard. crbug.com/webrtc/10042
Ruslan Burakov8af88962018-11-22 17:21:10 +0100324 RTCNonStandardStatsMember<uint64_t> jitter_buffer_flushes;
Jakob Ivarsson352ce5c2018-11-27 12:52:16 +0100325 RTCNonStandardStatsMember<uint64_t> delayed_packet_outage_samples;
Jakob Ivarsson232b3fd2019-03-06 09:18:40 +0100326 RTCNonStandardStatsMember<double> relative_packet_arrival_delay;
Henrik Lundin44125fa2019-04-29 17:00:46 +0200327 // TODO(henrik.lundin): Add description of the interruption metrics at
328 // https://github.com/henbos/webrtc-provisional-stats/issues/17
329 RTCNonStandardStatsMember<uint32_t> interruption_count;
330 RTCNonStandardStatsMember<double> total_interruption_duration;
Sergey Silkin02371062019-01-31 16:45:42 +0100331 // Non-standard video-only members.
332 // https://henbos.github.io/webrtc-provisional-stats/#RTCVideoReceiverStats-dict*
333 RTCNonStandardStatsMember<uint32_t> freeze_count;
334 RTCNonStandardStatsMember<uint32_t> pause_count;
335 RTCNonStandardStatsMember<double> total_freezes_duration;
336 RTCNonStandardStatsMember<double> total_pauses_duration;
337 RTCNonStandardStatsMember<double> total_frames_duration;
338 RTCNonStandardStatsMember<double> sum_squared_frame_durations;
hbos09bc1282016-11-08 06:29:22 -0800339};
340
hbos6ab97ce2016-10-03 14:16:56 -0700341// https://w3c.github.io/webrtc-stats/#pcstats-dict*
Mirko Bonadei276827c2018-10-16 14:13:50 +0200342class RTC_EXPORT RTCPeerConnectionStats final : public RTCStats {
hbosd565b732016-08-30 14:04:35 -0700343 public:
hbosfc5e0502016-10-06 02:06:10 -0700344 WEBRTC_RTCSTATS_DECL();
345
hbos0e6758d2016-08-31 07:57:36 -0700346 RTCPeerConnectionStats(const std::string& id, int64_t timestamp_us);
347 RTCPeerConnectionStats(std::string&& id, int64_t timestamp_us);
hbosfc5e0502016-10-06 02:06:10 -0700348 RTCPeerConnectionStats(const RTCPeerConnectionStats& other);
349 ~RTCPeerConnectionStats() override;
hbosd565b732016-08-30 14:04:35 -0700350
351 RTCStatsMember<uint32_t> data_channels_opened;
352 RTCStatsMember<uint32_t> data_channels_closed;
353};
354
hbos6ded1902016-11-01 01:50:46 -0700355// https://w3c.github.io/webrtc-stats/#streamstats-dict*
hbos0adb8282016-11-23 02:32:06 -0800356// TODO(hbos): Tracking bug crbug.com/657854
Mirko Bonadei276827c2018-10-16 14:13:50 +0200357class RTC_EXPORT RTCRTPStreamStats : public RTCStats {
hbos6ded1902016-11-01 01:50:46 -0700358 public:
359 WEBRTC_RTCSTATS_DECL();
360
361 RTCRTPStreamStats(const RTCRTPStreamStats& other);
362 ~RTCRTPStreamStats() override;
363
hbos3443bb72017-02-07 06:28:11 -0800364 RTCStatsMember<uint32_t> ssrc;
hbos6ded1902016-11-01 01:50:46 -0700365 // TODO(hbos): When the remote case is supported |RTCStatsCollector| needs to
366 // set this. crbug.com/657855, 657856
367 RTCStatsMember<std::string> associate_stats_id;
368 // TODO(hbos): Remote case not supported by |RTCStatsCollector|.
369 // crbug.com/657855, 657856
370 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;
Harald Alvestrand719487e2017-12-13 12:26:04 +0100408 RTCStatsMember<int32_t> packets_lost; // Signed per RFC 3550
Henrik Boström01738c62019-04-15 17:32:00 +0200409 RTCStatsMember<double> last_packet_received_timestamp;
hbosa7a9be12017-03-01 01:02:45 -0800410 // TODO(hbos): Collect and populate this value for both "audio" and "video",
411 // currently not collected for "video". https://bugs.webrtc.org/7065
hboseeafe942016-11-01 03:00:17 -0700412 RTCStatsMember<double> jitter;
413 RTCStatsMember<double> fraction_lost;
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;
Henrik Boström2e069262019-04-09 13:59:31 +0200437 // https://henbos.github.io/webrtc-provisional-stats/#dom-rtcinboundrtpstreamstats-contenttype
438 RTCStatsMember<std::string> content_type;
hboseeafe942016-11-01 03:00:17 -0700439};
440
hbos6ded1902016-11-01 01:50:46 -0700441// https://w3c.github.io/webrtc-stats/#outboundrtpstats-dict*
hbosa7a9be12017-03-01 01:02:45 -0800442// TODO(hbos): Support the remote case |is_remote = true|.
443// https://bugs.webrtc.org/7066
Mirko Bonadei276827c2018-10-16 14:13:50 +0200444class RTC_EXPORT RTCOutboundRTPStreamStats final : public RTCRTPStreamStats {
hbos6ded1902016-11-01 01:50:46 -0700445 public:
446 WEBRTC_RTCSTATS_DECL();
447
448 RTCOutboundRTPStreamStats(const std::string& id, int64_t timestamp_us);
449 RTCOutboundRTPStreamStats(std::string&& id, int64_t timestamp_us);
450 RTCOutboundRTPStreamStats(const RTCOutboundRTPStreamStats& other);
451 ~RTCOutboundRTPStreamStats() override;
452
453 RTCStatsMember<uint32_t> packets_sent;
Henrik Boströmcf96e0f2019-04-17 13:51:53 +0200454 RTCStatsMember<uint64_t> retransmitted_packets_sent;
hbos6ded1902016-11-01 01:50:46 -0700455 RTCStatsMember<uint64_t> bytes_sent;
Henrik Boströmcf96e0f2019-04-17 13:51:53 +0200456 RTCStatsMember<uint64_t> retransmitted_bytes_sent;
hbosa7a9be12017-03-01 01:02:45 -0800457 // TODO(hbos): Collect and populate this value. https://bugs.webrtc.org/7066
hbos6ded1902016-11-01 01:50:46 -0700458 RTCStatsMember<double> target_bitrate;
hbos6769c492017-01-02 08:35:13 -0800459 RTCStatsMember<uint32_t> frames_encoded;
Henrik Boströmf71362f2019-04-08 16:14:23 +0200460 RTCStatsMember<double> total_encode_time;
Henrik Boström2e069262019-04-09 13:59:31 +0200461 // https://henbos.github.io/webrtc-provisional-stats/#dom-rtcoutboundrtpstreamstats-contenttype
462 RTCStatsMember<std::string> content_type;
hbos6ded1902016-11-01 01:50:46 -0700463};
464
hbos2fa7c672016-10-24 04:00:05 -0700465// https://w3c.github.io/webrtc-stats/#transportstats-dict*
Mirko Bonadei276827c2018-10-16 14:13:50 +0200466class RTC_EXPORT RTCTransportStats final : public RTCStats {
hbos2fa7c672016-10-24 04:00:05 -0700467 public:
468 WEBRTC_RTCSTATS_DECL();
469
470 RTCTransportStats(const std::string& id, int64_t timestamp_us);
471 RTCTransportStats(std::string&& id, int64_t timestamp_us);
472 RTCTransportStats(const RTCTransportStats& other);
473 ~RTCTransportStats() override;
474
475 RTCStatsMember<uint64_t> bytes_sent;
476 RTCStatsMember<uint64_t> bytes_received;
477 RTCStatsMember<std::string> rtcp_transport_stats_id;
hbos7064d592017-01-16 07:38:02 -0800478 // TODO(hbos): Support enum types? "RTCStatsMember<RTCDtlsTransportState>"?
479 RTCStatsMember<std::string> dtls_state;
hbos2fa7c672016-10-24 04:00:05 -0700480 RTCStatsMember<std::string> selected_candidate_pair_id;
481 RTCStatsMember<std::string> local_certificate_id;
482 RTCStatsMember<std::string> remote_certificate_id;
483};
484
hbosd565b732016-08-30 14:04:35 -0700485} // namespace webrtc
486
Mirko Bonadei92ea95e2017-09-15 06:47:31 +0200487#endif // API_STATS_RTCSTATS_OBJECTS_H_