blob: 158ea92f88395ad80b93c90d0ce1884ece20c504 [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
hbos2fa7c672016-10-24 04:00:05 -070077// https://w3c.github.io/webrtc-stats/#certificatestats-dict*
Mirko Bonadei276827c2018-10-16 14:13:50 +020078class RTC_EXPORT RTCCertificateStats final : public RTCStats {
hbos2fa7c672016-10-24 04:00:05 -070079 public:
80 WEBRTC_RTCSTATS_DECL();
81
82 RTCCertificateStats(const std::string& id, int64_t timestamp_us);
83 RTCCertificateStats(std::string&& id, int64_t timestamp_us);
84 RTCCertificateStats(const RTCCertificateStats& other);
85 ~RTCCertificateStats() override;
86
87 RTCStatsMember<std::string> fingerprint;
88 RTCStatsMember<std::string> fingerprint_algorithm;
89 RTCStatsMember<std::string> base64_certificate;
90 RTCStatsMember<std::string> issuer_certificate_id;
91};
92
hbos0adb8282016-11-23 02:32:06 -080093// https://w3c.github.io/webrtc-stats/#codec-dict*
Mirko Bonadei276827c2018-10-16 14:13:50 +020094class RTC_EXPORT RTCCodecStats final : public RTCStats {
hbos0adb8282016-11-23 02:32:06 -080095 public:
96 WEBRTC_RTCSTATS_DECL();
97
98 RTCCodecStats(const std::string& id, int64_t timestamp_us);
99 RTCCodecStats(std::string&& id, int64_t timestamp_us);
100 RTCCodecStats(const RTCCodecStats& other);
101 ~RTCCodecStats() override;
102
103 RTCStatsMember<uint32_t> payload_type;
hbos13f54b22017-02-28 06:56:04 -0800104 RTCStatsMember<std::string> mime_type;
hbos0adb8282016-11-23 02:32:06 -0800105 RTCStatsMember<uint32_t> clock_rate;
hbos585a9b12017-02-07 04:59:16 -0800106 // TODO(hbos): Collect and populate this value. https://bugs.webrtc.org/7061
hbos0adb8282016-11-23 02:32:06 -0800107 RTCStatsMember<uint32_t> channels;
hbos585a9b12017-02-07 04:59:16 -0800108 // TODO(hbos): Collect and populate this value. https://bugs.webrtc.org/7061
hbos13f54b22017-02-28 06:56:04 -0800109 RTCStatsMember<std::string> sdp_fmtp_line;
hbos585a9b12017-02-07 04:59:16 -0800110 // TODO(hbos): Collect and populate this value. https://bugs.webrtc.org/7061
hbos0adb8282016-11-23 02:32:06 -0800111 RTCStatsMember<std::string> implementation;
112};
113
hbos2fa7c672016-10-24 04:00:05 -0700114// https://w3c.github.io/webrtc-stats/#dcstats-dict*
Mirko Bonadei276827c2018-10-16 14:13:50 +0200115class RTC_EXPORT RTCDataChannelStats final : public RTCStats {
hbos2fa7c672016-10-24 04:00:05 -0700116 public:
117 WEBRTC_RTCSTATS_DECL();
118
119 RTCDataChannelStats(const std::string& id, int64_t timestamp_us);
120 RTCDataChannelStats(std::string&& id, int64_t timestamp_us);
121 RTCDataChannelStats(const RTCDataChannelStats& other);
122 ~RTCDataChannelStats() override;
123
124 RTCStatsMember<std::string> label;
125 RTCStatsMember<std::string> protocol;
126 RTCStatsMember<int32_t> datachannelid;
127 // TODO(hbos): Support enum types? "RTCStatsMember<RTCDataChannelState>"?
128 RTCStatsMember<std::string> state;
129 RTCStatsMember<uint32_t> messages_sent;
130 RTCStatsMember<uint64_t> bytes_sent;
131 RTCStatsMember<uint32_t> messages_received;
132 RTCStatsMember<uint64_t> bytes_received;
133};
134
135// https://w3c.github.io/webrtc-stats/#candidatepair-dict*
hbos338f78a2017-02-07 06:41:21 -0800136// TODO(hbos): Tracking bug https://bugs.webrtc.org/7062
Mirko Bonadei276827c2018-10-16 14:13:50 +0200137class RTC_EXPORT RTCIceCandidatePairStats final : public RTCStats {
hbosc47a0c32016-10-11 14:54:49 -0700138 public:
139 WEBRTC_RTCSTATS_DECL();
140
141 RTCIceCandidatePairStats(const std::string& id, int64_t timestamp_us);
142 RTCIceCandidatePairStats(std::string&& id, int64_t timestamp_us);
143 RTCIceCandidatePairStats(const RTCIceCandidatePairStats& other);
144 ~RTCIceCandidatePairStats() override;
145
146 RTCStatsMember<std::string> transport_id;
147 RTCStatsMember<std::string> local_candidate_id;
148 RTCStatsMember<std::string> remote_candidate_id;
149 // TODO(hbos): Support enum types?
150 // "RTCStatsMember<RTCStatsIceCandidatePairState>"?
151 RTCStatsMember<std::string> state;
152 RTCStatsMember<uint64_t> priority;
153 RTCStatsMember<bool> nominated;
hbos338f78a2017-02-07 06:41:21 -0800154 // TODO(hbos): Collect this the way the spec describes it. We have a value for
155 // it but it is not spec-compliant. https://bugs.webrtc.org/7062
hbosc47a0c32016-10-11 14:54:49 -0700156 RTCStatsMember<bool> writable;
hbos338f78a2017-02-07 06:41:21 -0800157 // TODO(hbos): Collect and populate this value. https://bugs.webrtc.org/7062
hbosc47a0c32016-10-11 14:54:49 -0700158 RTCStatsMember<bool> readable;
159 RTCStatsMember<uint64_t> bytes_sent;
160 RTCStatsMember<uint64_t> bytes_received;
hbos3168c7a2016-12-15 06:17:08 -0800161 RTCStatsMember<double> total_round_trip_time;
hbos3168c7a2016-12-15 06:17:08 -0800162 RTCStatsMember<double> current_round_trip_time;
hbosc47a0c32016-10-11 14:54:49 -0700163 RTCStatsMember<double> available_outgoing_bitrate;
hbos338f78a2017-02-07 06:41:21 -0800164 // TODO(hbos): Populate this value. It is wired up and collected the same way
hbosbf8d3e52017-02-28 06:34:47 -0800165 // "VideoBwe.googAvailableReceiveBandwidth" is, but that value is always
hbos338f78a2017-02-07 06:41:21 -0800166 // undefined. https://bugs.webrtc.org/7062
hbosc47a0c32016-10-11 14:54:49 -0700167 RTCStatsMember<double> available_incoming_bitrate;
168 RTCStatsMember<uint64_t> requests_received;
169 RTCStatsMember<uint64_t> requests_sent;
170 RTCStatsMember<uint64_t> responses_received;
171 RTCStatsMember<uint64_t> responses_sent;
hbos338f78a2017-02-07 06:41:21 -0800172 // TODO(hbos): Collect and populate this value. https://bugs.webrtc.org/7062
hbosc47a0c32016-10-11 14:54:49 -0700173 RTCStatsMember<uint64_t> retransmissions_received;
hbos338f78a2017-02-07 06:41:21 -0800174 // TODO(hbos): Collect and populate this value. https://bugs.webrtc.org/7062
hbosc47a0c32016-10-11 14:54:49 -0700175 RTCStatsMember<uint64_t> retransmissions_sent;
hbos338f78a2017-02-07 06:41:21 -0800176 // TODO(hbos): Collect and populate this value. https://bugs.webrtc.org/7062
hbosc47a0c32016-10-11 14:54:49 -0700177 RTCStatsMember<uint64_t> consent_requests_received;
178 RTCStatsMember<uint64_t> consent_requests_sent;
hbos338f78a2017-02-07 06:41:21 -0800179 // TODO(hbos): Collect and populate this value. https://bugs.webrtc.org/7062
hbosc47a0c32016-10-11 14:54:49 -0700180 RTCStatsMember<uint64_t> consent_responses_received;
hbos338f78a2017-02-07 06:41:21 -0800181 // TODO(hbos): Collect and populate this value. https://bugs.webrtc.org/7062
hbosc47a0c32016-10-11 14:54:49 -0700182 RTCStatsMember<uint64_t> consent_responses_sent;
183};
184
hbosab9f6e42016-10-07 02:18:47 -0700185// https://w3c.github.io/webrtc-stats/#icecandidate-dict*
hbos5d79a7c2016-10-24 09:27:10 -0700186// TODO(hbos): |RTCStatsCollector| only collects candidates that are part of
187// ice candidate pairs, but there could be candidates not paired with anything.
188// crbug.com/632723
Qingsi Wang72a43a12018-02-20 16:03:18 -0800189// TODO(qingsi): Add the stats of STUN binding requests (keepalives) and collect
190// them in the new PeerConnection::GetStats.
Mirko Bonadei276827c2018-10-16 14:13:50 +0200191class RTC_EXPORT RTCIceCandidateStats : public RTCStats {
hbosab9f6e42016-10-07 02:18:47 -0700192 public:
193 WEBRTC_RTCSTATS_DECL();
194
195 RTCIceCandidateStats(const RTCIceCandidateStats& other);
196 ~RTCIceCandidateStats() override;
197
hbosb4e426e2017-01-02 09:59:31 -0800198 RTCStatsMember<std::string> transport_id;
hbosc3a2b7f2017-01-02 04:46:15 -0800199 RTCStatsMember<bool> is_remote;
Gary Liu37e489c2017-11-21 10:49:36 -0800200 RTCStatsMember<std::string> network_type;
hbosab9f6e42016-10-07 02:18:47 -0700201 RTCStatsMember<std::string> ip;
202 RTCStatsMember<int32_t> port;
203 RTCStatsMember<std::string> protocol;
Philipp Hancke95513752018-09-27 14:40:08 +0200204 RTCStatsMember<std::string> relay_protocol;
hbosab9f6e42016-10-07 02:18:47 -0700205 // TODO(hbos): Support enum types? "RTCStatsMember<RTCIceCandidateType>"?
206 RTCStatsMember<std::string> candidate_type;
207 RTCStatsMember<int32_t> priority;
hbos5d79a7c2016-10-24 09:27:10 -0700208 // TODO(hbos): Not collected by |RTCStatsCollector|. crbug.com/632723
hbosab9f6e42016-10-07 02:18:47 -0700209 RTCStatsMember<std::string> url;
hbosd17a5a72017-01-02 08:09:59 -0800210 // TODO(hbos): |deleted = true| case is not supported by |RTCStatsCollector|.
211 // crbug.com/632723
212 RTCStatsMember<bool> deleted; // = false
hbosab9f6e42016-10-07 02:18:47 -0700213
214 protected:
Yves Gerey665174f2018-06-19 15:03:05 +0200215 RTCIceCandidateStats(const std::string& id,
216 int64_t timestamp_us,
217 bool is_remote);
hbosc3a2b7f2017-01-02 04:46:15 -0800218 RTCIceCandidateStats(std::string&& id, int64_t timestamp_us, bool is_remote);
hbosab9f6e42016-10-07 02:18:47 -0700219};
220
221// In the spec both local and remote varieties are of type RTCIceCandidateStats.
222// But here we define them as subclasses of |RTCIceCandidateStats| because the
223// |kType| need to be different ("RTCStatsType type") in the local/remote case.
224// https://w3c.github.io/webrtc-stats/#rtcstatstype-str*
Henrik Boström1df1bf82018-03-20 13:24:20 +0100225// This forces us to have to override copy() and type().
Mirko Bonadei276827c2018-10-16 14:13:50 +0200226class RTC_EXPORT RTCLocalIceCandidateStats final : public RTCIceCandidateStats {
hbosab9f6e42016-10-07 02:18:47 -0700227 public:
228 static const char kType[];
229 RTCLocalIceCandidateStats(const std::string& id, int64_t timestamp_us);
230 RTCLocalIceCandidateStats(std::string&& id, int64_t timestamp_us);
Henrik Boström1df1bf82018-03-20 13:24:20 +0100231 std::unique_ptr<RTCStats> copy() const override;
hbosab9f6e42016-10-07 02:18:47 -0700232 const char* type() const override;
233};
234
Mirko Bonadei276827c2018-10-16 14:13:50 +0200235class RTC_EXPORT RTCRemoteIceCandidateStats final
236 : public RTCIceCandidateStats {
hbosab9f6e42016-10-07 02:18:47 -0700237 public:
238 static const char kType[];
239 RTCRemoteIceCandidateStats(const std::string& id, int64_t timestamp_us);
240 RTCRemoteIceCandidateStats(std::string&& id, int64_t timestamp_us);
Henrik Boström1df1bf82018-03-20 13:24:20 +0100241 std::unique_ptr<RTCStats> copy() const override;
hbosab9f6e42016-10-07 02:18:47 -0700242 const char* type() const override;
243};
244
hbos09bc1282016-11-08 06:29:22 -0800245// https://w3c.github.io/webrtc-stats/#msstats-dict*
hbos0adb8282016-11-23 02:32:06 -0800246// TODO(hbos): Tracking bug crbug.com/660827
Mirko Bonadei276827c2018-10-16 14:13:50 +0200247class RTC_EXPORT RTCMediaStreamStats final : public RTCStats {
hbos09bc1282016-11-08 06:29:22 -0800248 public:
249 WEBRTC_RTCSTATS_DECL();
250
251 RTCMediaStreamStats(const std::string& id, int64_t timestamp_us);
252 RTCMediaStreamStats(std::string&& id, int64_t timestamp_us);
253 RTCMediaStreamStats(const RTCMediaStreamStats& other);
254 ~RTCMediaStreamStats() override;
255
256 RTCStatsMember<std::string> stream_identifier;
257 RTCStatsMember<std::vector<std::string>> track_ids;
258};
259
260// https://w3c.github.io/webrtc-stats/#mststats-dict*
hbos0adb8282016-11-23 02:32:06 -0800261// TODO(hbos): Tracking bug crbug.com/659137
Mirko Bonadei276827c2018-10-16 14:13:50 +0200262class RTC_EXPORT RTCMediaStreamTrackStats final : public RTCStats {
hbos09bc1282016-11-08 06:29:22 -0800263 public:
264 WEBRTC_RTCSTATS_DECL();
265
Yves Gerey665174f2018-06-19 15:03:05 +0200266 RTCMediaStreamTrackStats(const std::string& id,
267 int64_t timestamp_us,
hbos160e4a72017-01-17 02:53:23 -0800268 const char* kind);
Yves Gerey665174f2018-06-19 15:03:05 +0200269 RTCMediaStreamTrackStats(std::string&& id,
270 int64_t timestamp_us,
hbos160e4a72017-01-17 02:53:23 -0800271 const char* kind);
hbos09bc1282016-11-08 06:29:22 -0800272 RTCMediaStreamTrackStats(const RTCMediaStreamTrackStats& other);
273 ~RTCMediaStreamTrackStats() override;
274
275 RTCStatsMember<std::string> track_identifier;
276 RTCStatsMember<bool> remote_source;
277 RTCStatsMember<bool> ended;
278 // TODO(hbos): |RTCStatsCollector| does not return stats for detached tracks.
279 // crbug.com/659137
280 RTCStatsMember<bool> detached;
hbos160e4a72017-01-17 02:53:23 -0800281 // See |RTCMediaStreamTrackKind| for valid values.
282 RTCStatsMember<std::string> kind;
Gustaf Ullbergb0a02072017-10-02 12:00:34 +0200283 // TODO(gustaf): Implement jitter_buffer_delay for video (currently
284 // implemented for audio only).
285 // https://crbug.com/webrtc/8318
286 RTCStatsMember<double> jitter_buffer_delay;
Chen Xing0acffb52019-01-15 15:46:29 +0100287 RTCStatsMember<uint64_t> jitter_buffer_emitted_count;
hbos09bc1282016-11-08 06:29:22 -0800288 // Video-only members
289 RTCStatsMember<uint32_t> frame_width;
290 RTCStatsMember<uint32_t> frame_height;
291 // TODO(hbos): Not collected by |RTCStatsCollector|. crbug.com/659137
292 RTCStatsMember<double> frames_per_second;
hbos09bc1282016-11-08 06:29:22 -0800293 RTCStatsMember<uint32_t> frames_sent;
Ilya Nikolaevskiy70473fc2018-02-28 16:35:03 +0100294 RTCStatsMember<uint32_t> huge_frames_sent;
hbos09bc1282016-11-08 06:29:22 -0800295 RTCStatsMember<uint32_t> frames_received;
hbos09bc1282016-11-08 06:29:22 -0800296 RTCStatsMember<uint32_t> frames_decoded;
hbos09bc1282016-11-08 06:29:22 -0800297 RTCStatsMember<uint32_t> frames_dropped;
298 // TODO(hbos): Not collected by |RTCStatsCollector|. crbug.com/659137
299 RTCStatsMember<uint32_t> frames_corrupted;
300 // TODO(hbos): Not collected by |RTCStatsCollector|. crbug.com/659137
301 RTCStatsMember<uint32_t> partial_frames_lost;
302 // TODO(hbos): Not collected by |RTCStatsCollector|. crbug.com/659137
303 RTCStatsMember<uint32_t> full_frames_lost;
304 // Audio-only members
305 RTCStatsMember<double> audio_level;
zsteine76bd3a2017-07-14 12:17:49 -0700306 RTCStatsMember<double> total_audio_energy;
hbos09bc1282016-11-08 06:29:22 -0800307 RTCStatsMember<double> echo_return_loss;
308 RTCStatsMember<double> echo_return_loss_enhancement;
Steve Anton2dbc69f2017-08-24 17:15:13 -0700309 RTCStatsMember<uint64_t> total_samples_received;
310 RTCStatsMember<double> total_samples_duration;
311 RTCStatsMember<uint64_t> concealed_samples;
Gustaf Ullberg9a2e9062017-09-18 09:28:20 +0200312 RTCStatsMember<uint64_t> concealment_events;
Ruslan Burakov8af88962018-11-22 17:21:10 +0100313 // Non-standard audio-only member
Jakob Ivarsson352ce5c2018-11-27 12:52:16 +0100314 // TODO(kuddai): Add description to standard. crbug.com/webrtc/10042
Ruslan Burakov8af88962018-11-22 17:21:10 +0100315 RTCNonStandardStatsMember<uint64_t> jitter_buffer_flushes;
Jakob Ivarsson352ce5c2018-11-27 12:52:16 +0100316 RTCNonStandardStatsMember<uint64_t> delayed_packet_outage_samples;
Jakob Ivarsson232b3fd2019-03-06 09:18:40 +0100317 RTCNonStandardStatsMember<double> relative_packet_arrival_delay;
Sergey Silkin02371062019-01-31 16:45:42 +0100318 // Non-standard video-only members.
319 // https://henbos.github.io/webrtc-provisional-stats/#RTCVideoReceiverStats-dict*
320 RTCNonStandardStatsMember<uint32_t> freeze_count;
321 RTCNonStandardStatsMember<uint32_t> pause_count;
322 RTCNonStandardStatsMember<double> total_freezes_duration;
323 RTCNonStandardStatsMember<double> total_pauses_duration;
324 RTCNonStandardStatsMember<double> total_frames_duration;
325 RTCNonStandardStatsMember<double> sum_squared_frame_durations;
hbos09bc1282016-11-08 06:29:22 -0800326};
327
hbos6ab97ce2016-10-03 14:16:56 -0700328// https://w3c.github.io/webrtc-stats/#pcstats-dict*
Mirko Bonadei276827c2018-10-16 14:13:50 +0200329class RTC_EXPORT RTCPeerConnectionStats final : public RTCStats {
hbosd565b732016-08-30 14:04:35 -0700330 public:
hbosfc5e0502016-10-06 02:06:10 -0700331 WEBRTC_RTCSTATS_DECL();
332
hbos0e6758d2016-08-31 07:57:36 -0700333 RTCPeerConnectionStats(const std::string& id, int64_t timestamp_us);
334 RTCPeerConnectionStats(std::string&& id, int64_t timestamp_us);
hbosfc5e0502016-10-06 02:06:10 -0700335 RTCPeerConnectionStats(const RTCPeerConnectionStats& other);
336 ~RTCPeerConnectionStats() override;
hbosd565b732016-08-30 14:04:35 -0700337
338 RTCStatsMember<uint32_t> data_channels_opened;
339 RTCStatsMember<uint32_t> data_channels_closed;
340};
341
hbos6ded1902016-11-01 01:50:46 -0700342// https://w3c.github.io/webrtc-stats/#streamstats-dict*
hbos0adb8282016-11-23 02:32:06 -0800343// TODO(hbos): Tracking bug crbug.com/657854
Mirko Bonadei276827c2018-10-16 14:13:50 +0200344class RTC_EXPORT RTCRTPStreamStats : public RTCStats {
hbos6ded1902016-11-01 01:50:46 -0700345 public:
346 WEBRTC_RTCSTATS_DECL();
347
348 RTCRTPStreamStats(const RTCRTPStreamStats& other);
349 ~RTCRTPStreamStats() override;
350
hbos3443bb72017-02-07 06:28:11 -0800351 RTCStatsMember<uint32_t> ssrc;
hbos6ded1902016-11-01 01:50:46 -0700352 // TODO(hbos): When the remote case is supported |RTCStatsCollector| needs to
353 // set this. crbug.com/657855, 657856
354 RTCStatsMember<std::string> associate_stats_id;
355 // TODO(hbos): Remote case not supported by |RTCStatsCollector|.
356 // crbug.com/657855, 657856
357 RTCStatsMember<bool> is_remote; // = false
Philipp Hancke3bc01662018-08-28 14:55:03 +0200358 RTCStatsMember<std::string> media_type; // renamed to kind.
359 RTCStatsMember<std::string> kind;
hbosb0ae9202017-01-27 06:35:16 -0800360 RTCStatsMember<std::string> track_id;
hbos6ded1902016-11-01 01:50:46 -0700361 RTCStatsMember<std::string> transport_id;
hbos6ded1902016-11-01 01:50:46 -0700362 RTCStatsMember<std::string> codec_id;
363 // FIR and PLI counts are only defined for |media_type == "video"|.
364 RTCStatsMember<uint32_t> fir_count;
365 RTCStatsMember<uint32_t> pli_count;
366 // TODO(hbos): NACK count should be collected by |RTCStatsCollector| for both
367 // audio and video but is only defined in the "video" case. crbug.com/657856
368 RTCStatsMember<uint32_t> nack_count;
369 // TODO(hbos): Not collected by |RTCStatsCollector|. crbug.com/657854
370 // SLI count is only defined for |media_type == "video"|.
371 RTCStatsMember<uint32_t> sli_count;
hbos6769c492017-01-02 08:35:13 -0800372 RTCStatsMember<uint64_t> qp_sum;
hbos6ded1902016-11-01 01:50:46 -0700373
374 protected:
375 RTCRTPStreamStats(const std::string& id, int64_t timestamp_us);
376 RTCRTPStreamStats(std::string&& id, int64_t timestamp_us);
377};
378
hboseeafe942016-11-01 03:00:17 -0700379// https://w3c.github.io/webrtc-stats/#inboundrtpstats-dict*
hbosa7a9be12017-03-01 01:02:45 -0800380// TODO(hbos): Support the remote case |is_remote = true|.
381// https://bugs.webrtc.org/7065
Mirko Bonadei276827c2018-10-16 14:13:50 +0200382class RTC_EXPORT RTCInboundRTPStreamStats final : public RTCRTPStreamStats {
hboseeafe942016-11-01 03:00:17 -0700383 public:
384 WEBRTC_RTCSTATS_DECL();
385
386 RTCInboundRTPStreamStats(const std::string& id, int64_t timestamp_us);
387 RTCInboundRTPStreamStats(std::string&& id, int64_t timestamp_us);
388 RTCInboundRTPStreamStats(const RTCInboundRTPStreamStats& other);
389 ~RTCInboundRTPStreamStats() override;
390
391 RTCStatsMember<uint32_t> packets_received;
392 RTCStatsMember<uint64_t> bytes_received;
Harald Alvestrand719487e2017-12-13 12:26:04 +0100393 RTCStatsMember<int32_t> packets_lost; // Signed per RFC 3550
hbosa7a9be12017-03-01 01:02:45 -0800394 // TODO(hbos): Collect and populate this value for both "audio" and "video",
395 // currently not collected for "video". https://bugs.webrtc.org/7065
hboseeafe942016-11-01 03:00:17 -0700396 RTCStatsMember<double> jitter;
397 RTCStatsMember<double> fraction_lost;
hbosa7a9be12017-03-01 01:02:45 -0800398 // TODO(hbos): Collect and populate this value. https://bugs.webrtc.org/7065
399 RTCStatsMember<double> round_trip_time;
400 // TODO(hbos): Collect and populate this value. https://bugs.webrtc.org/7065
hboseeafe942016-11-01 03:00:17 -0700401 RTCStatsMember<uint32_t> packets_discarded;
hbosa7a9be12017-03-01 01:02:45 -0800402 // TODO(hbos): Collect and populate this value. https://bugs.webrtc.org/7065
hboseeafe942016-11-01 03:00:17 -0700403 RTCStatsMember<uint32_t> packets_repaired;
hbosa7a9be12017-03-01 01:02:45 -0800404 // TODO(hbos): Collect and populate this value. https://bugs.webrtc.org/7065
hboseeafe942016-11-01 03:00:17 -0700405 RTCStatsMember<uint32_t> burst_packets_lost;
hbosa7a9be12017-03-01 01:02:45 -0800406 // TODO(hbos): Collect and populate this value. https://bugs.webrtc.org/7065
hboseeafe942016-11-01 03:00:17 -0700407 RTCStatsMember<uint32_t> burst_packets_discarded;
hbosa7a9be12017-03-01 01:02:45 -0800408 // TODO(hbos): Collect and populate this value. https://bugs.webrtc.org/7065
hboseeafe942016-11-01 03:00:17 -0700409 RTCStatsMember<uint32_t> burst_loss_count;
hbosa7a9be12017-03-01 01:02:45 -0800410 // TODO(hbos): Collect and populate this value. https://bugs.webrtc.org/7065
hboseeafe942016-11-01 03:00:17 -0700411 RTCStatsMember<uint32_t> burst_discard_count;
hbosa7a9be12017-03-01 01:02:45 -0800412 // TODO(hbos): Collect and populate this value. https://bugs.webrtc.org/7065
hboseeafe942016-11-01 03:00:17 -0700413 RTCStatsMember<double> burst_loss_rate;
hbosa7a9be12017-03-01 01:02:45 -0800414 // TODO(hbos): Collect and populate this value. https://bugs.webrtc.org/7065
hboseeafe942016-11-01 03:00:17 -0700415 RTCStatsMember<double> burst_discard_rate;
hbosa7a9be12017-03-01 01:02:45 -0800416 // TODO(hbos): Collect and populate this value. https://bugs.webrtc.org/7065
hboseeafe942016-11-01 03:00:17 -0700417 RTCStatsMember<double> gap_loss_rate;
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<double> gap_discard_rate;
hbos6769c492017-01-02 08:35:13 -0800420 RTCStatsMember<uint32_t> frames_decoded;
hboseeafe942016-11-01 03:00:17 -0700421};
422
hbos6ded1902016-11-01 01:50:46 -0700423// https://w3c.github.io/webrtc-stats/#outboundrtpstats-dict*
hbosa7a9be12017-03-01 01:02:45 -0800424// TODO(hbos): Support the remote case |is_remote = true|.
425// https://bugs.webrtc.org/7066
Mirko Bonadei276827c2018-10-16 14:13:50 +0200426class RTC_EXPORT RTCOutboundRTPStreamStats final : public RTCRTPStreamStats {
hbos6ded1902016-11-01 01:50:46 -0700427 public:
428 WEBRTC_RTCSTATS_DECL();
429
430 RTCOutboundRTPStreamStats(const std::string& id, int64_t timestamp_us);
431 RTCOutboundRTPStreamStats(std::string&& id, int64_t timestamp_us);
432 RTCOutboundRTPStreamStats(const RTCOutboundRTPStreamStats& other);
433 ~RTCOutboundRTPStreamStats() override;
434
435 RTCStatsMember<uint32_t> packets_sent;
436 RTCStatsMember<uint64_t> bytes_sent;
hbosa7a9be12017-03-01 01:02:45 -0800437 // TODO(hbos): Collect and populate this value. https://bugs.webrtc.org/7066
hbos6ded1902016-11-01 01:50:46 -0700438 RTCStatsMember<double> target_bitrate;
hbos6769c492017-01-02 08:35:13 -0800439 RTCStatsMember<uint32_t> frames_encoded;
Henrik Boströmf71362f2019-04-08 16:14:23 +0200440 RTCStatsMember<double> total_encode_time;
hbos6ded1902016-11-01 01:50:46 -0700441};
442
hbos2fa7c672016-10-24 04:00:05 -0700443// https://w3c.github.io/webrtc-stats/#transportstats-dict*
Mirko Bonadei276827c2018-10-16 14:13:50 +0200444class RTC_EXPORT RTCTransportStats final : public RTCStats {
hbos2fa7c672016-10-24 04:00:05 -0700445 public:
446 WEBRTC_RTCSTATS_DECL();
447
448 RTCTransportStats(const std::string& id, int64_t timestamp_us);
449 RTCTransportStats(std::string&& id, int64_t timestamp_us);
450 RTCTransportStats(const RTCTransportStats& other);
451 ~RTCTransportStats() override;
452
453 RTCStatsMember<uint64_t> bytes_sent;
454 RTCStatsMember<uint64_t> bytes_received;
455 RTCStatsMember<std::string> rtcp_transport_stats_id;
hbos7064d592017-01-16 07:38:02 -0800456 // TODO(hbos): Support enum types? "RTCStatsMember<RTCDtlsTransportState>"?
457 RTCStatsMember<std::string> dtls_state;
hbos2fa7c672016-10-24 04:00:05 -0700458 RTCStatsMember<std::string> selected_candidate_pair_id;
459 RTCStatsMember<std::string> local_certificate_id;
460 RTCStatsMember<std::string> remote_certificate_id;
461};
462
hbosd565b732016-08-30 14:04:35 -0700463} // namespace webrtc
464
Mirko Bonadei92ea95e2017-09-15 06:47:31 +0200465#endif // API_STATS_RTCSTATS_OBJECTS_H_