blob: 81ec084f16fdbeed241b8be75804103a9c48d9bc [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;
Gustaf Ullberg9a2e9062017-09-18 09:28:20 +0200318 RTCStatsMember<uint64_t> concealment_events;
Ruslan Burakov8af88962018-11-22 17:21:10 +0100319 // Non-standard audio-only member
Jakob Ivarsson352ce5c2018-11-27 12:52:16 +0100320 // TODO(kuddai): Add description to standard. crbug.com/webrtc/10042
Ruslan Burakov8af88962018-11-22 17:21:10 +0100321 RTCNonStandardStatsMember<uint64_t> jitter_buffer_flushes;
Jakob Ivarsson352ce5c2018-11-27 12:52:16 +0100322 RTCNonStandardStatsMember<uint64_t> delayed_packet_outage_samples;
Jakob Ivarsson232b3fd2019-03-06 09:18:40 +0100323 RTCNonStandardStatsMember<double> relative_packet_arrival_delay;
Sergey Silkin02371062019-01-31 16:45:42 +0100324 // Non-standard video-only members.
325 // https://henbos.github.io/webrtc-provisional-stats/#RTCVideoReceiverStats-dict*
326 RTCNonStandardStatsMember<uint32_t> freeze_count;
327 RTCNonStandardStatsMember<uint32_t> pause_count;
328 RTCNonStandardStatsMember<double> total_freezes_duration;
329 RTCNonStandardStatsMember<double> total_pauses_duration;
330 RTCNonStandardStatsMember<double> total_frames_duration;
331 RTCNonStandardStatsMember<double> sum_squared_frame_durations;
hbos09bc1282016-11-08 06:29:22 -0800332};
333
hbos6ab97ce2016-10-03 14:16:56 -0700334// https://w3c.github.io/webrtc-stats/#pcstats-dict*
Mirko Bonadei276827c2018-10-16 14:13:50 +0200335class RTC_EXPORT RTCPeerConnectionStats final : public RTCStats {
hbosd565b732016-08-30 14:04:35 -0700336 public:
hbosfc5e0502016-10-06 02:06:10 -0700337 WEBRTC_RTCSTATS_DECL();
338
hbos0e6758d2016-08-31 07:57:36 -0700339 RTCPeerConnectionStats(const std::string& id, int64_t timestamp_us);
340 RTCPeerConnectionStats(std::string&& id, int64_t timestamp_us);
hbosfc5e0502016-10-06 02:06:10 -0700341 RTCPeerConnectionStats(const RTCPeerConnectionStats& other);
342 ~RTCPeerConnectionStats() override;
hbosd565b732016-08-30 14:04:35 -0700343
344 RTCStatsMember<uint32_t> data_channels_opened;
345 RTCStatsMember<uint32_t> data_channels_closed;
346};
347
hbos6ded1902016-11-01 01:50:46 -0700348// https://w3c.github.io/webrtc-stats/#streamstats-dict*
hbos0adb8282016-11-23 02:32:06 -0800349// TODO(hbos): Tracking bug crbug.com/657854
Mirko Bonadei276827c2018-10-16 14:13:50 +0200350class RTC_EXPORT RTCRTPStreamStats : public RTCStats {
hbos6ded1902016-11-01 01:50:46 -0700351 public:
352 WEBRTC_RTCSTATS_DECL();
353
354 RTCRTPStreamStats(const RTCRTPStreamStats& other);
355 ~RTCRTPStreamStats() override;
356
hbos3443bb72017-02-07 06:28:11 -0800357 RTCStatsMember<uint32_t> ssrc;
hbos6ded1902016-11-01 01:50:46 -0700358 // TODO(hbos): When the remote case is supported |RTCStatsCollector| needs to
359 // set this. crbug.com/657855, 657856
360 RTCStatsMember<std::string> associate_stats_id;
361 // TODO(hbos): Remote case not supported by |RTCStatsCollector|.
362 // crbug.com/657855, 657856
363 RTCStatsMember<bool> is_remote; // = false
Philipp Hancke3bc01662018-08-28 14:55:03 +0200364 RTCStatsMember<std::string> media_type; // renamed to kind.
365 RTCStatsMember<std::string> kind;
hbosb0ae9202017-01-27 06:35:16 -0800366 RTCStatsMember<std::string> track_id;
hbos6ded1902016-11-01 01:50:46 -0700367 RTCStatsMember<std::string> transport_id;
hbos6ded1902016-11-01 01:50:46 -0700368 RTCStatsMember<std::string> codec_id;
369 // FIR and PLI counts are only defined for |media_type == "video"|.
370 RTCStatsMember<uint32_t> fir_count;
371 RTCStatsMember<uint32_t> pli_count;
372 // TODO(hbos): NACK count should be collected by |RTCStatsCollector| for both
373 // audio and video but is only defined in the "video" case. crbug.com/657856
374 RTCStatsMember<uint32_t> nack_count;
375 // TODO(hbos): Not collected by |RTCStatsCollector|. crbug.com/657854
376 // SLI count is only defined for |media_type == "video"|.
377 RTCStatsMember<uint32_t> sli_count;
hbos6769c492017-01-02 08:35:13 -0800378 RTCStatsMember<uint64_t> qp_sum;
hbos6ded1902016-11-01 01:50:46 -0700379
380 protected:
381 RTCRTPStreamStats(const std::string& id, int64_t timestamp_us);
382 RTCRTPStreamStats(std::string&& id, int64_t timestamp_us);
383};
384
hboseeafe942016-11-01 03:00:17 -0700385// https://w3c.github.io/webrtc-stats/#inboundrtpstats-dict*
hbosa7a9be12017-03-01 01:02:45 -0800386// TODO(hbos): Support the remote case |is_remote = true|.
387// https://bugs.webrtc.org/7065
Mirko Bonadei276827c2018-10-16 14:13:50 +0200388class RTC_EXPORT RTCInboundRTPStreamStats final : public RTCRTPStreamStats {
hboseeafe942016-11-01 03:00:17 -0700389 public:
390 WEBRTC_RTCSTATS_DECL();
391
392 RTCInboundRTPStreamStats(const std::string& id, int64_t timestamp_us);
393 RTCInboundRTPStreamStats(std::string&& id, int64_t timestamp_us);
394 RTCInboundRTPStreamStats(const RTCInboundRTPStreamStats& other);
395 ~RTCInboundRTPStreamStats() override;
396
397 RTCStatsMember<uint32_t> packets_received;
398 RTCStatsMember<uint64_t> bytes_received;
Harald Alvestrand719487e2017-12-13 12:26:04 +0100399 RTCStatsMember<int32_t> packets_lost; // Signed per RFC 3550
Henrik Boström01738c62019-04-15 17:32:00 +0200400 RTCStatsMember<double> last_packet_received_timestamp;
hbosa7a9be12017-03-01 01:02:45 -0800401 // TODO(hbos): Collect and populate this value for both "audio" and "video",
402 // currently not collected for "video". https://bugs.webrtc.org/7065
hboseeafe942016-11-01 03:00:17 -0700403 RTCStatsMember<double> jitter;
404 RTCStatsMember<double> fraction_lost;
hbosa7a9be12017-03-01 01:02:45 -0800405 // TODO(hbos): Collect and populate this value. https://bugs.webrtc.org/7065
406 RTCStatsMember<double> round_trip_time;
407 // TODO(hbos): Collect and populate this value. https://bugs.webrtc.org/7065
hboseeafe942016-11-01 03:00:17 -0700408 RTCStatsMember<uint32_t> packets_discarded;
hbosa7a9be12017-03-01 01:02:45 -0800409 // TODO(hbos): Collect and populate this value. https://bugs.webrtc.org/7065
hboseeafe942016-11-01 03:00:17 -0700410 RTCStatsMember<uint32_t> packets_repaired;
hbosa7a9be12017-03-01 01:02:45 -0800411 // TODO(hbos): Collect and populate this value. https://bugs.webrtc.org/7065
hboseeafe942016-11-01 03:00:17 -0700412 RTCStatsMember<uint32_t> burst_packets_lost;
hbosa7a9be12017-03-01 01:02:45 -0800413 // TODO(hbos): Collect and populate this value. https://bugs.webrtc.org/7065
hboseeafe942016-11-01 03:00:17 -0700414 RTCStatsMember<uint32_t> burst_packets_discarded;
hbosa7a9be12017-03-01 01:02:45 -0800415 // TODO(hbos): Collect and populate this value. https://bugs.webrtc.org/7065
hboseeafe942016-11-01 03:00:17 -0700416 RTCStatsMember<uint32_t> burst_loss_count;
hbosa7a9be12017-03-01 01:02:45 -0800417 // TODO(hbos): Collect and populate this value. https://bugs.webrtc.org/7065
hboseeafe942016-11-01 03:00:17 -0700418 RTCStatsMember<uint32_t> burst_discard_count;
hbosa7a9be12017-03-01 01:02:45 -0800419 // TODO(hbos): Collect and populate this value. https://bugs.webrtc.org/7065
hboseeafe942016-11-01 03:00:17 -0700420 RTCStatsMember<double> burst_loss_rate;
hbosa7a9be12017-03-01 01:02:45 -0800421 // TODO(hbos): Collect and populate this value. https://bugs.webrtc.org/7065
hboseeafe942016-11-01 03:00:17 -0700422 RTCStatsMember<double> burst_discard_rate;
hbosa7a9be12017-03-01 01:02:45 -0800423 // TODO(hbos): Collect and populate this value. https://bugs.webrtc.org/7065
hboseeafe942016-11-01 03:00:17 -0700424 RTCStatsMember<double> gap_loss_rate;
hbosa7a9be12017-03-01 01:02:45 -0800425 // TODO(hbos): Collect and populate this value. https://bugs.webrtc.org/7065
hboseeafe942016-11-01 03:00:17 -0700426 RTCStatsMember<double> gap_discard_rate;
hbos6769c492017-01-02 08:35:13 -0800427 RTCStatsMember<uint32_t> frames_decoded;
Henrik Boström2e069262019-04-09 13:59:31 +0200428 // https://henbos.github.io/webrtc-provisional-stats/#dom-rtcinboundrtpstreamstats-contenttype
429 RTCStatsMember<std::string> content_type;
hboseeafe942016-11-01 03:00:17 -0700430};
431
hbos6ded1902016-11-01 01:50:46 -0700432// https://w3c.github.io/webrtc-stats/#outboundrtpstats-dict*
hbosa7a9be12017-03-01 01:02:45 -0800433// TODO(hbos): Support the remote case |is_remote = true|.
434// https://bugs.webrtc.org/7066
Mirko Bonadei276827c2018-10-16 14:13:50 +0200435class RTC_EXPORT RTCOutboundRTPStreamStats final : public RTCRTPStreamStats {
hbos6ded1902016-11-01 01:50:46 -0700436 public:
437 WEBRTC_RTCSTATS_DECL();
438
439 RTCOutboundRTPStreamStats(const std::string& id, int64_t timestamp_us);
440 RTCOutboundRTPStreamStats(std::string&& id, int64_t timestamp_us);
441 RTCOutboundRTPStreamStats(const RTCOutboundRTPStreamStats& other);
442 ~RTCOutboundRTPStreamStats() override;
443
444 RTCStatsMember<uint32_t> packets_sent;
445 RTCStatsMember<uint64_t> bytes_sent;
hbosa7a9be12017-03-01 01:02:45 -0800446 // TODO(hbos): Collect and populate this value. https://bugs.webrtc.org/7066
hbos6ded1902016-11-01 01:50:46 -0700447 RTCStatsMember<double> target_bitrate;
hbos6769c492017-01-02 08:35:13 -0800448 RTCStatsMember<uint32_t> frames_encoded;
Henrik Boströmf71362f2019-04-08 16:14:23 +0200449 RTCStatsMember<double> total_encode_time;
Henrik Boström2e069262019-04-09 13:59:31 +0200450 // https://henbos.github.io/webrtc-provisional-stats/#dom-rtcoutboundrtpstreamstats-contenttype
451 RTCStatsMember<std::string> content_type;
hbos6ded1902016-11-01 01:50:46 -0700452};
453
hbos2fa7c672016-10-24 04:00:05 -0700454// https://w3c.github.io/webrtc-stats/#transportstats-dict*
Mirko Bonadei276827c2018-10-16 14:13:50 +0200455class RTC_EXPORT RTCTransportStats final : public RTCStats {
hbos2fa7c672016-10-24 04:00:05 -0700456 public:
457 WEBRTC_RTCSTATS_DECL();
458
459 RTCTransportStats(const std::string& id, int64_t timestamp_us);
460 RTCTransportStats(std::string&& id, int64_t timestamp_us);
461 RTCTransportStats(const RTCTransportStats& other);
462 ~RTCTransportStats() override;
463
464 RTCStatsMember<uint64_t> bytes_sent;
465 RTCStatsMember<uint64_t> bytes_received;
466 RTCStatsMember<std::string> rtcp_transport_stats_id;
hbos7064d592017-01-16 07:38:02 -0800467 // TODO(hbos): Support enum types? "RTCStatsMember<RTCDtlsTransportState>"?
468 RTCStatsMember<std::string> dtls_state;
hbos2fa7c672016-10-24 04:00:05 -0700469 RTCStatsMember<std::string> selected_candidate_pair_id;
470 RTCStatsMember<std::string> local_certificate_id;
471 RTCStatsMember<std::string> remote_certificate_id;
472};
473
hbosd565b732016-08-30 14:04:35 -0700474} // namespace webrtc
475
Mirko Bonadei92ea95e2017-09-15 06:47:31 +0200476#endif // API_STATS_RTCSTATS_OBJECTS_H_