blob: cbcc8fa37dfe93972f87d7b14d6b9b7ce34c2c81 [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;
Henrik Boström646fda02019-05-22 15:49:42 +0200282 RTCStatsMember<std::string> media_source_id;
hbos09bc1282016-11-08 06:29:22 -0800283 RTCStatsMember<bool> remote_source;
284 RTCStatsMember<bool> ended;
285 // TODO(hbos): |RTCStatsCollector| does not return stats for detached tracks.
286 // crbug.com/659137
287 RTCStatsMember<bool> detached;
hbos160e4a72017-01-17 02:53:23 -0800288 // See |RTCMediaStreamTrackKind| for valid values.
289 RTCStatsMember<std::string> kind;
Gustaf Ullbergb0a02072017-10-02 12:00:34 +0200290 // TODO(gustaf): Implement jitter_buffer_delay for video (currently
291 // implemented for audio only).
292 // https://crbug.com/webrtc/8318
293 RTCStatsMember<double> jitter_buffer_delay;
Chen Xing0acffb52019-01-15 15:46:29 +0100294 RTCStatsMember<uint64_t> jitter_buffer_emitted_count;
hbos09bc1282016-11-08 06:29:22 -0800295 // Video-only members
296 RTCStatsMember<uint32_t> frame_width;
297 RTCStatsMember<uint32_t> frame_height;
298 // TODO(hbos): Not collected by |RTCStatsCollector|. crbug.com/659137
299 RTCStatsMember<double> frames_per_second;
hbos09bc1282016-11-08 06:29:22 -0800300 RTCStatsMember<uint32_t> frames_sent;
Ilya Nikolaevskiy70473fc2018-02-28 16:35:03 +0100301 RTCStatsMember<uint32_t> huge_frames_sent;
hbos09bc1282016-11-08 06:29:22 -0800302 RTCStatsMember<uint32_t> frames_received;
hbos09bc1282016-11-08 06:29:22 -0800303 RTCStatsMember<uint32_t> frames_decoded;
hbos09bc1282016-11-08 06:29:22 -0800304 RTCStatsMember<uint32_t> frames_dropped;
305 // TODO(hbos): Not collected by |RTCStatsCollector|. crbug.com/659137
306 RTCStatsMember<uint32_t> frames_corrupted;
307 // TODO(hbos): Not collected by |RTCStatsCollector|. crbug.com/659137
308 RTCStatsMember<uint32_t> partial_frames_lost;
309 // TODO(hbos): Not collected by |RTCStatsCollector|. crbug.com/659137
310 RTCStatsMember<uint32_t> full_frames_lost;
311 // Audio-only members
312 RTCStatsMember<double> audio_level;
zsteine76bd3a2017-07-14 12:17:49 -0700313 RTCStatsMember<double> total_audio_energy;
hbos09bc1282016-11-08 06:29:22 -0800314 RTCStatsMember<double> echo_return_loss;
315 RTCStatsMember<double> echo_return_loss_enhancement;
Steve Anton2dbc69f2017-08-24 17:15:13 -0700316 RTCStatsMember<uint64_t> total_samples_received;
317 RTCStatsMember<double> total_samples_duration;
318 RTCStatsMember<uint64_t> concealed_samples;
Ivo Creusen8d8ffdb2019-04-30 09:45:21 +0200319 RTCStatsMember<uint64_t> silent_concealed_samples;
Gustaf Ullberg9a2e9062017-09-18 09:28:20 +0200320 RTCStatsMember<uint64_t> concealment_events;
Ivo Creusen8d8ffdb2019-04-30 09:45:21 +0200321 RTCStatsMember<uint64_t> inserted_samples_for_deceleration;
322 RTCStatsMember<uint64_t> removed_samples_for_acceleration;
Ruslan Burakov8af88962018-11-22 17:21:10 +0100323 // Non-standard audio-only member
Jakob Ivarsson352ce5c2018-11-27 12:52:16 +0100324 // TODO(kuddai): Add description to standard. crbug.com/webrtc/10042
Ruslan Burakov8af88962018-11-22 17:21:10 +0100325 RTCNonStandardStatsMember<uint64_t> jitter_buffer_flushes;
Jakob Ivarsson352ce5c2018-11-27 12:52:16 +0100326 RTCNonStandardStatsMember<uint64_t> delayed_packet_outage_samples;
Jakob Ivarsson232b3fd2019-03-06 09:18:40 +0100327 RTCNonStandardStatsMember<double> relative_packet_arrival_delay;
Henrik Lundin44125fa2019-04-29 17:00:46 +0200328 // TODO(henrik.lundin): Add description of the interruption metrics at
329 // https://github.com/henbos/webrtc-provisional-stats/issues/17
330 RTCNonStandardStatsMember<uint32_t> interruption_count;
331 RTCNonStandardStatsMember<double> total_interruption_duration;
Sergey Silkin02371062019-01-31 16:45:42 +0100332 // Non-standard video-only members.
333 // https://henbos.github.io/webrtc-provisional-stats/#RTCVideoReceiverStats-dict*
334 RTCNonStandardStatsMember<uint32_t> freeze_count;
335 RTCNonStandardStatsMember<uint32_t> pause_count;
336 RTCNonStandardStatsMember<double> total_freezes_duration;
337 RTCNonStandardStatsMember<double> total_pauses_duration;
338 RTCNonStandardStatsMember<double> total_frames_duration;
339 RTCNonStandardStatsMember<double> sum_squared_frame_durations;
hbos09bc1282016-11-08 06:29:22 -0800340};
341
hbos6ab97ce2016-10-03 14:16:56 -0700342// https://w3c.github.io/webrtc-stats/#pcstats-dict*
Mirko Bonadei276827c2018-10-16 14:13:50 +0200343class RTC_EXPORT RTCPeerConnectionStats final : public RTCStats {
hbosd565b732016-08-30 14:04:35 -0700344 public:
hbosfc5e0502016-10-06 02:06:10 -0700345 WEBRTC_RTCSTATS_DECL();
346
hbos0e6758d2016-08-31 07:57:36 -0700347 RTCPeerConnectionStats(const std::string& id, int64_t timestamp_us);
348 RTCPeerConnectionStats(std::string&& id, int64_t timestamp_us);
hbosfc5e0502016-10-06 02:06:10 -0700349 RTCPeerConnectionStats(const RTCPeerConnectionStats& other);
350 ~RTCPeerConnectionStats() override;
hbosd565b732016-08-30 14:04:35 -0700351
352 RTCStatsMember<uint32_t> data_channels_opened;
353 RTCStatsMember<uint32_t> data_channels_closed;
354};
355
hbos6ded1902016-11-01 01:50:46 -0700356// https://w3c.github.io/webrtc-stats/#streamstats-dict*
hbos0adb8282016-11-23 02:32:06 -0800357// TODO(hbos): Tracking bug crbug.com/657854
Mirko Bonadei276827c2018-10-16 14:13:50 +0200358class RTC_EXPORT RTCRTPStreamStats : public RTCStats {
hbos6ded1902016-11-01 01:50:46 -0700359 public:
360 WEBRTC_RTCSTATS_DECL();
361
362 RTCRTPStreamStats(const RTCRTPStreamStats& other);
363 ~RTCRTPStreamStats() override;
364
hbos3443bb72017-02-07 06:28:11 -0800365 RTCStatsMember<uint32_t> ssrc;
hbos6ded1902016-11-01 01:50:46 -0700366 // TODO(hbos): When the remote case is supported |RTCStatsCollector| needs to
367 // set this. crbug.com/657855, 657856
368 RTCStatsMember<std::string> associate_stats_id;
369 // TODO(hbos): Remote case not supported by |RTCStatsCollector|.
370 // crbug.com/657855, 657856
371 RTCStatsMember<bool> is_remote; // = false
Philipp Hancke3bc01662018-08-28 14:55:03 +0200372 RTCStatsMember<std::string> media_type; // renamed to kind.
373 RTCStatsMember<std::string> kind;
hbosb0ae9202017-01-27 06:35:16 -0800374 RTCStatsMember<std::string> track_id;
hbos6ded1902016-11-01 01:50:46 -0700375 RTCStatsMember<std::string> transport_id;
hbos6ded1902016-11-01 01:50:46 -0700376 RTCStatsMember<std::string> codec_id;
377 // FIR and PLI counts are only defined for |media_type == "video"|.
378 RTCStatsMember<uint32_t> fir_count;
379 RTCStatsMember<uint32_t> pli_count;
380 // TODO(hbos): NACK count should be collected by |RTCStatsCollector| for both
381 // audio and video but is only defined in the "video" case. crbug.com/657856
382 RTCStatsMember<uint32_t> nack_count;
383 // TODO(hbos): Not collected by |RTCStatsCollector|. crbug.com/657854
384 // SLI count is only defined for |media_type == "video"|.
385 RTCStatsMember<uint32_t> sli_count;
hbos6769c492017-01-02 08:35:13 -0800386 RTCStatsMember<uint64_t> qp_sum;
hbos6ded1902016-11-01 01:50:46 -0700387
388 protected:
389 RTCRTPStreamStats(const std::string& id, int64_t timestamp_us);
390 RTCRTPStreamStats(std::string&& id, int64_t timestamp_us);
391};
392
hboseeafe942016-11-01 03:00:17 -0700393// https://w3c.github.io/webrtc-stats/#inboundrtpstats-dict*
hbosa7a9be12017-03-01 01:02:45 -0800394// TODO(hbos): Support the remote case |is_remote = true|.
395// https://bugs.webrtc.org/7065
Mirko Bonadei276827c2018-10-16 14:13:50 +0200396class RTC_EXPORT RTCInboundRTPStreamStats final : public RTCRTPStreamStats {
hboseeafe942016-11-01 03:00:17 -0700397 public:
398 WEBRTC_RTCSTATS_DECL();
399
400 RTCInboundRTPStreamStats(const std::string& id, int64_t timestamp_us);
401 RTCInboundRTPStreamStats(std::string&& id, int64_t timestamp_us);
402 RTCInboundRTPStreamStats(const RTCInboundRTPStreamStats& other);
403 ~RTCInboundRTPStreamStats() override;
404
405 RTCStatsMember<uint32_t> packets_received;
Ivo Creusen8d8ffdb2019-04-30 09:45:21 +0200406 RTCStatsMember<uint64_t> fec_packets_received;
407 RTCStatsMember<uint64_t> fec_packets_discarded;
hboseeafe942016-11-01 03:00:17 -0700408 RTCStatsMember<uint64_t> 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;
414 RTCStatsMember<double> fraction_lost;
hbosa7a9be12017-03-01 01:02:45 -0800415 // TODO(hbos): Collect and populate this value. https://bugs.webrtc.org/7065
416 RTCStatsMember<double> round_trip_time;
417 // TODO(hbos): Collect and populate this value. https://bugs.webrtc.org/7065
hboseeafe942016-11-01 03:00:17 -0700418 RTCStatsMember<uint32_t> packets_discarded;
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<uint32_t> packets_repaired;
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<uint32_t> burst_packets_lost;
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<uint32_t> burst_packets_discarded;
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<uint32_t> burst_loss_count;
hbosa7a9be12017-03-01 01:02:45 -0800427 // TODO(hbos): Collect and populate this value. https://bugs.webrtc.org/7065
hboseeafe942016-11-01 03:00:17 -0700428 RTCStatsMember<uint32_t> burst_discard_count;
hbosa7a9be12017-03-01 01:02:45 -0800429 // TODO(hbos): Collect and populate this value. https://bugs.webrtc.org/7065
hboseeafe942016-11-01 03:00:17 -0700430 RTCStatsMember<double> burst_loss_rate;
hbosa7a9be12017-03-01 01:02:45 -0800431 // TODO(hbos): Collect and populate this value. https://bugs.webrtc.org/7065
hboseeafe942016-11-01 03:00:17 -0700432 RTCStatsMember<double> burst_discard_rate;
hbosa7a9be12017-03-01 01:02:45 -0800433 // TODO(hbos): Collect and populate this value. https://bugs.webrtc.org/7065
hboseeafe942016-11-01 03:00:17 -0700434 RTCStatsMember<double> gap_loss_rate;
hbosa7a9be12017-03-01 01:02:45 -0800435 // TODO(hbos): Collect and populate this value. https://bugs.webrtc.org/7065
hboseeafe942016-11-01 03:00:17 -0700436 RTCStatsMember<double> gap_discard_rate;
hbos6769c492017-01-02 08:35:13 -0800437 RTCStatsMember<uint32_t> frames_decoded;
Henrik Boström2e069262019-04-09 13:59:31 +0200438 // https://henbos.github.io/webrtc-provisional-stats/#dom-rtcinboundrtpstreamstats-contenttype
439 RTCStatsMember<std::string> content_type;
hboseeafe942016-11-01 03:00:17 -0700440};
441
hbos6ded1902016-11-01 01:50:46 -0700442// https://w3c.github.io/webrtc-stats/#outboundrtpstats-dict*
hbosa7a9be12017-03-01 01:02:45 -0800443// TODO(hbos): Support the remote case |is_remote = true|.
444// https://bugs.webrtc.org/7066
Mirko Bonadei276827c2018-10-16 14:13:50 +0200445class RTC_EXPORT RTCOutboundRTPStreamStats final : public RTCRTPStreamStats {
hbos6ded1902016-11-01 01:50:46 -0700446 public:
447 WEBRTC_RTCSTATS_DECL();
448
449 RTCOutboundRTPStreamStats(const std::string& id, int64_t timestamp_us);
450 RTCOutboundRTPStreamStats(std::string&& id, int64_t timestamp_us);
451 RTCOutboundRTPStreamStats(const RTCOutboundRTPStreamStats& other);
452 ~RTCOutboundRTPStreamStats() override;
453
Henrik Boström646fda02019-05-22 15:49:42 +0200454 RTCStatsMember<std::string> media_source_id;
hbos6ded1902016-11-01 01:50:46 -0700455 RTCStatsMember<uint32_t> packets_sent;
Henrik Boströmcf96e0f2019-04-17 13:51:53 +0200456 RTCStatsMember<uint64_t> retransmitted_packets_sent;
hbos6ded1902016-11-01 01:50:46 -0700457 RTCStatsMember<uint64_t> bytes_sent;
Henrik Boströmcf96e0f2019-04-17 13:51:53 +0200458 RTCStatsMember<uint64_t> retransmitted_bytes_sent;
hbosa7a9be12017-03-01 01:02:45 -0800459 // TODO(hbos): Collect and populate this value. https://bugs.webrtc.org/7066
hbos6ded1902016-11-01 01:50:46 -0700460 RTCStatsMember<double> target_bitrate;
hbos6769c492017-01-02 08:35:13 -0800461 RTCStatsMember<uint32_t> frames_encoded;
Henrik Boströmf71362f2019-04-08 16:14:23 +0200462 RTCStatsMember<double> total_encode_time;
Henrik Boström23aff9b2019-05-20 15:15:38 +0200463 RTCStatsMember<uint64_t> total_encoded_bytes_target;
Henrik Boström9fe18342019-05-16 18:38:20 +0200464 // TODO(https://crbug.com/webrtc/10635): This is only implemented for video;
465 // implement it for audio as well.
466 RTCStatsMember<double> total_packet_send_delay;
Henrik Boström2e069262019-04-09 13:59:31 +0200467 // https://henbos.github.io/webrtc-provisional-stats/#dom-rtcoutboundrtpstreamstats-contenttype
468 RTCStatsMember<std::string> content_type;
hbos6ded1902016-11-01 01:50:46 -0700469};
470
Henrik Boström646fda02019-05-22 15:49:42 +0200471// https://w3c.github.io/webrtc-stats/#dom-rtcmediasourcestats
472class RTC_EXPORT RTCMediaSourceStats : public RTCStats {
473 public:
474 WEBRTC_RTCSTATS_DECL();
475
476 RTCMediaSourceStats(const RTCMediaSourceStats& other);
477 ~RTCMediaSourceStats() override;
478
479 RTCStatsMember<std::string> track_identifier;
480 RTCStatsMember<std::string> kind;
481
482 protected:
483 RTCMediaSourceStats(const std::string& id, int64_t timestamp_us);
484 RTCMediaSourceStats(std::string&& id, int64_t timestamp_us);
485};
486
487// https://w3c.github.io/webrtc-stats/#dom-rtcaudiosourcestats
488class RTC_EXPORT RTCAudioSourceStats final : public RTCMediaSourceStats {
489 public:
490 WEBRTC_RTCSTATS_DECL();
491
492 RTCAudioSourceStats(const std::string& id, int64_t timestamp_us);
493 RTCAudioSourceStats(std::string&& id, int64_t timestamp_us);
494 RTCAudioSourceStats(const RTCAudioSourceStats& other);
495 ~RTCAudioSourceStats() override;
496};
497
498// https://w3c.github.io/webrtc-stats/#dom-rtcvideosourcestats
499class RTC_EXPORT RTCVideoSourceStats final : public RTCMediaSourceStats {
500 public:
501 WEBRTC_RTCSTATS_DECL();
502
503 RTCVideoSourceStats(const std::string& id, int64_t timestamp_us);
504 RTCVideoSourceStats(std::string&& id, int64_t timestamp_us);
505 RTCVideoSourceStats(const RTCVideoSourceStats& other);
506 ~RTCVideoSourceStats() override;
507
508 RTCStatsMember<uint32_t> width;
509 RTCStatsMember<uint32_t> height;
510 // TODO(hbos): Implement this metric.
511 RTCStatsMember<uint32_t> frames;
512 RTCStatsMember<uint32_t> frames_per_second;
513};
514
hbos2fa7c672016-10-24 04:00:05 -0700515// https://w3c.github.io/webrtc-stats/#transportstats-dict*
Mirko Bonadei276827c2018-10-16 14:13:50 +0200516class RTC_EXPORT RTCTransportStats final : public RTCStats {
hbos2fa7c672016-10-24 04:00:05 -0700517 public:
518 WEBRTC_RTCSTATS_DECL();
519
520 RTCTransportStats(const std::string& id, int64_t timestamp_us);
521 RTCTransportStats(std::string&& id, int64_t timestamp_us);
522 RTCTransportStats(const RTCTransportStats& other);
523 ~RTCTransportStats() override;
524
525 RTCStatsMember<uint64_t> bytes_sent;
526 RTCStatsMember<uint64_t> bytes_received;
527 RTCStatsMember<std::string> rtcp_transport_stats_id;
hbos7064d592017-01-16 07:38:02 -0800528 // TODO(hbos): Support enum types? "RTCStatsMember<RTCDtlsTransportState>"?
529 RTCStatsMember<std::string> dtls_state;
hbos2fa7c672016-10-24 04:00:05 -0700530 RTCStatsMember<std::string> selected_candidate_pair_id;
531 RTCStatsMember<std::string> local_certificate_id;
532 RTCStatsMember<std::string> remote_certificate_id;
533};
534
hbosd565b732016-08-30 14:04:35 -0700535} // namespace webrtc
536
Mirko Bonadei92ea95e2017-09-15 06:47:31 +0200537#endif // API_STATS_RTCSTATS_OBJECTS_H_