blob: e85119a2f24bd9e4c63daf252a14596d1c9451a2 [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
hbos74e1a4f2016-09-15 23:33:01 -070011#ifndef WEBRTC_API_STATS_RTCSTATS_OBJECTS_H_
12#define WEBRTC_API_STATS_RTCSTATS_OBJECTS_H_
hbosd565b732016-08-30 14:04:35 -070013
14#include <string>
15
hbos74e1a4f2016-09-15 23:33:01 -070016#include "webrtc/api/stats/rtcstats.h"
hbosd565b732016-08-30 14:04:35 -070017
18namespace webrtc {
19
hboscc555c52016-10-18 12:48:31 -070020// https://w3c.github.io/webrtc-pc/#idl-def-rtcdatachannelstate
21struct RTCDataChannelState {
22 static const char* kConnecting;
23 static const char* kOpen;
24 static const char* kClosing;
25 static const char* kClosed;
26};
27
hbosc47a0c32016-10-11 14:54:49 -070028// https://w3c.github.io/webrtc-stats/#dom-rtcstatsicecandidatepairstate
29struct RTCStatsIceCandidatePairState {
30 static const char* kFrozen;
31 static const char* kWaiting;
32 static const char* kInProgress;
33 static const char* kFailed;
34 static const char* kSucceeded;
hbosc47a0c32016-10-11 14:54:49 -070035};
36
hboscc555c52016-10-18 12:48:31 -070037// https://w3c.github.io/webrtc-pc/#rtcicecandidatetype-enum
hbosab9f6e42016-10-07 02:18:47 -070038struct RTCIceCandidateType {
39 static const char* kHost;
40 static const char* kSrflx;
41 static const char* kPrflx;
42 static const char* kRelay;
43};
44
hbos2fa7c672016-10-24 04:00:05 -070045// https://w3c.github.io/webrtc-stats/#certificatestats-dict*
46class RTCCertificateStats final : public RTCStats {
47 public:
48 WEBRTC_RTCSTATS_DECL();
49
50 RTCCertificateStats(const std::string& id, int64_t timestamp_us);
51 RTCCertificateStats(std::string&& id, int64_t timestamp_us);
52 RTCCertificateStats(const RTCCertificateStats& other);
53 ~RTCCertificateStats() override;
54
55 RTCStatsMember<std::string> fingerprint;
56 RTCStatsMember<std::string> fingerprint_algorithm;
57 RTCStatsMember<std::string> base64_certificate;
58 RTCStatsMember<std::string> issuer_certificate_id;
59};
60
hbos0adb8282016-11-23 02:32:06 -080061// https://w3c.github.io/webrtc-stats/#codec-dict*
62// Tracking bug crbug.com/659117
63// TODO(hbos): The present codec ID assignment is not sufficient to support
64// Unified Plan or unbundled connections in all cases. crbug.com/659117
65class RTCCodecStats final : public RTCStats {
66 public:
67 WEBRTC_RTCSTATS_DECL();
68
69 RTCCodecStats(const std::string& id, int64_t timestamp_us);
70 RTCCodecStats(std::string&& id, int64_t timestamp_us);
71 RTCCodecStats(const RTCCodecStats& other);
72 ~RTCCodecStats() override;
73
74 RTCStatsMember<uint32_t> payload_type;
75 RTCStatsMember<std::string> codec;
76 RTCStatsMember<uint32_t> clock_rate;
77 // TODO(hbos): Not collected by |RTCStatsCollector|. crbug.com/659117
78 RTCStatsMember<uint32_t> channels;
79 // TODO(hbos): Not collected by |RTCStatsCollector|. crbug.com/659117
80 RTCStatsMember<std::string> parameters;
81 // TODO(hbos): Not collected by |RTCStatsCollector|. crbug.com/659117
82 RTCStatsMember<std::string> implementation;
83};
84
hbos2fa7c672016-10-24 04:00:05 -070085// https://w3c.github.io/webrtc-stats/#dcstats-dict*
86class RTCDataChannelStats final : public RTCStats {
87 public:
88 WEBRTC_RTCSTATS_DECL();
89
90 RTCDataChannelStats(const std::string& id, int64_t timestamp_us);
91 RTCDataChannelStats(std::string&& id, int64_t timestamp_us);
92 RTCDataChannelStats(const RTCDataChannelStats& other);
93 ~RTCDataChannelStats() override;
94
95 RTCStatsMember<std::string> label;
96 RTCStatsMember<std::string> protocol;
97 RTCStatsMember<int32_t> datachannelid;
98 // TODO(hbos): Support enum types? "RTCStatsMember<RTCDataChannelState>"?
99 RTCStatsMember<std::string> state;
100 RTCStatsMember<uint32_t> messages_sent;
101 RTCStatsMember<uint64_t> bytes_sent;
102 RTCStatsMember<uint32_t> messages_received;
103 RTCStatsMember<uint64_t> bytes_received;
104};
105
106// https://w3c.github.io/webrtc-stats/#candidatepair-dict*
hbos0adb8282016-11-23 02:32:06 -0800107// TODO(hbos): Tracking bug crbug.com/633550
hbos6ded1902016-11-01 01:50:46 -0700108class RTCIceCandidatePairStats final : public RTCStats {
hbosc47a0c32016-10-11 14:54:49 -0700109 public:
110 WEBRTC_RTCSTATS_DECL();
111
112 RTCIceCandidatePairStats(const std::string& id, int64_t timestamp_us);
113 RTCIceCandidatePairStats(std::string&& id, int64_t timestamp_us);
114 RTCIceCandidatePairStats(const RTCIceCandidatePairStats& other);
115 ~RTCIceCandidatePairStats() override;
116
117 RTCStatsMember<std::string> transport_id;
118 RTCStatsMember<std::string> local_candidate_id;
119 RTCStatsMember<std::string> remote_candidate_id;
120 // TODO(hbos): Support enum types?
121 // "RTCStatsMember<RTCStatsIceCandidatePairState>"?
122 RTCStatsMember<std::string> state;
123 RTCStatsMember<uint64_t> priority;
hbos5d79a7c2016-10-24 09:27:10 -0700124 // TODO(hbos): Not collected by |RTCStatsCollector|. crbug.com/633550
hbosc47a0c32016-10-11 14:54:49 -0700125 RTCStatsMember<bool> nominated;
hbos5d79a7c2016-10-24 09:27:10 -0700126 // TODO(hbos): Collected by |RTCStatsCollector| but different than the spec.
127 // crbug.com/633550
hbosc47a0c32016-10-11 14:54:49 -0700128 RTCStatsMember<bool> writable;
hbos5d79a7c2016-10-24 09:27:10 -0700129 // TODO(hbos): Not collected by |RTCStatsCollector|. crbug.com/633550
hbosc47a0c32016-10-11 14:54:49 -0700130 RTCStatsMember<bool> readable;
131 RTCStatsMember<uint64_t> bytes_sent;
132 RTCStatsMember<uint64_t> bytes_received;
hbos5d79a7c2016-10-24 09:27:10 -0700133 // TODO(hbos): Not collected by |RTCStatsCollector|. crbug.com/633550
hbos3168c7a2016-12-15 06:17:08 -0800134 RTCStatsMember<double> total_round_trip_time;
hbos5d79a7c2016-10-24 09:27:10 -0700135 // TODO(hbos): Collected by |RTCStatsCollector| but different than the spec.
136 // crbug.com/633550
hbos3168c7a2016-12-15 06:17:08 -0800137 RTCStatsMember<double> current_round_trip_time;
hbos5d79a7c2016-10-24 09:27:10 -0700138 // TODO(hbos): Not collected by |RTCStatsCollector|. crbug.com/633550
hbosc47a0c32016-10-11 14:54:49 -0700139 RTCStatsMember<double> available_outgoing_bitrate;
hbos5d79a7c2016-10-24 09:27:10 -0700140 // TODO(hbos): Not collected by |RTCStatsCollector|. crbug.com/633550
hbosc47a0c32016-10-11 14:54:49 -0700141 RTCStatsMember<double> available_incoming_bitrate;
142 RTCStatsMember<uint64_t> requests_received;
143 RTCStatsMember<uint64_t> requests_sent;
144 RTCStatsMember<uint64_t> responses_received;
145 RTCStatsMember<uint64_t> responses_sent;
hbos5d79a7c2016-10-24 09:27:10 -0700146 // TODO(hbos): Not collected by |RTCStatsCollector|. crbug.com/633550
hbosc47a0c32016-10-11 14:54:49 -0700147 RTCStatsMember<uint64_t> retransmissions_received;
hbos5d79a7c2016-10-24 09:27:10 -0700148 // TODO(hbos): Not collected by |RTCStatsCollector|. crbug.com/633550
hbosc47a0c32016-10-11 14:54:49 -0700149 RTCStatsMember<uint64_t> retransmissions_sent;
hbos5d79a7c2016-10-24 09:27:10 -0700150 // TODO(hbos): Not collected by |RTCStatsCollector|. crbug.com/633550
hbosc47a0c32016-10-11 14:54:49 -0700151 RTCStatsMember<uint64_t> consent_requests_received;
152 RTCStatsMember<uint64_t> consent_requests_sent;
hbos5d79a7c2016-10-24 09:27:10 -0700153 // TODO(hbos): Not collected by |RTCStatsCollector|. crbug.com/633550
hbosc47a0c32016-10-11 14:54:49 -0700154 RTCStatsMember<uint64_t> consent_responses_received;
hbos5d79a7c2016-10-24 09:27:10 -0700155 // TODO(hbos): Not collected by |RTCStatsCollector|. crbug.com/633550
hbosc47a0c32016-10-11 14:54:49 -0700156 RTCStatsMember<uint64_t> consent_responses_sent;
157};
158
hbosab9f6e42016-10-07 02:18:47 -0700159// https://w3c.github.io/webrtc-stats/#icecandidate-dict*
hbos5d79a7c2016-10-24 09:27:10 -0700160// TODO(hbos): |RTCStatsCollector| only collects candidates that are part of
161// ice candidate pairs, but there could be candidates not paired with anything.
162// crbug.com/632723
hbosab9f6e42016-10-07 02:18:47 -0700163class RTCIceCandidateStats : public RTCStats {
164 public:
165 WEBRTC_RTCSTATS_DECL();
166
167 RTCIceCandidateStats(const RTCIceCandidateStats& other);
168 ~RTCIceCandidateStats() override;
169
hbosc3a2b7f2017-01-02 04:46:15 -0800170 RTCStatsMember<bool> is_remote;
hbosab9f6e42016-10-07 02:18:47 -0700171 RTCStatsMember<std::string> ip;
172 RTCStatsMember<int32_t> port;
173 RTCStatsMember<std::string> protocol;
174 // TODO(hbos): Support enum types? "RTCStatsMember<RTCIceCandidateType>"?
175 RTCStatsMember<std::string> candidate_type;
176 RTCStatsMember<int32_t> priority;
hbos5d79a7c2016-10-24 09:27:10 -0700177 // TODO(hbos): Not collected by |RTCStatsCollector|. crbug.com/632723
hbosab9f6e42016-10-07 02:18:47 -0700178 RTCStatsMember<std::string> url;
179
180 protected:
hbosc3a2b7f2017-01-02 04:46:15 -0800181 RTCIceCandidateStats(
182 const std::string& id, int64_t timestamp_us, bool is_remote);
183 RTCIceCandidateStats(std::string&& id, int64_t timestamp_us, bool is_remote);
hbosab9f6e42016-10-07 02:18:47 -0700184};
185
186// In the spec both local and remote varieties are of type RTCIceCandidateStats.
187// But here we define them as subclasses of |RTCIceCandidateStats| because the
188// |kType| need to be different ("RTCStatsType type") in the local/remote case.
189// https://w3c.github.io/webrtc-stats/#rtcstatstype-str*
190class RTCLocalIceCandidateStats final : public RTCIceCandidateStats {
191 public:
192 static const char kType[];
193 RTCLocalIceCandidateStats(const std::string& id, int64_t timestamp_us);
194 RTCLocalIceCandidateStats(std::string&& id, int64_t timestamp_us);
195 const char* type() const override;
196};
197
198class RTCRemoteIceCandidateStats final : public RTCIceCandidateStats {
199 public:
200 static const char kType[];
201 RTCRemoteIceCandidateStats(const std::string& id, int64_t timestamp_us);
202 RTCRemoteIceCandidateStats(std::string&& id, int64_t timestamp_us);
203 const char* type() const override;
204};
205
hbos09bc1282016-11-08 06:29:22 -0800206// https://w3c.github.io/webrtc-stats/#msstats-dict*
hbos0adb8282016-11-23 02:32:06 -0800207// TODO(hbos): Tracking bug crbug.com/660827
hbos09bc1282016-11-08 06:29:22 -0800208class RTCMediaStreamStats final : public RTCStats {
209 public:
210 WEBRTC_RTCSTATS_DECL();
211
212 RTCMediaStreamStats(const std::string& id, int64_t timestamp_us);
213 RTCMediaStreamStats(std::string&& id, int64_t timestamp_us);
214 RTCMediaStreamStats(const RTCMediaStreamStats& other);
215 ~RTCMediaStreamStats() override;
216
217 RTCStatsMember<std::string> stream_identifier;
218 RTCStatsMember<std::vector<std::string>> track_ids;
219};
220
221// https://w3c.github.io/webrtc-stats/#mststats-dict*
hbos0adb8282016-11-23 02:32:06 -0800222// TODO(hbos): Tracking bug crbug.com/659137
hbos09bc1282016-11-08 06:29:22 -0800223class RTCMediaStreamTrackStats final : public RTCStats {
224 public:
225 WEBRTC_RTCSTATS_DECL();
226
227 RTCMediaStreamTrackStats(const std::string& id, int64_t timestamp_us);
228 RTCMediaStreamTrackStats(std::string&& id, int64_t timestamp_us);
229 RTCMediaStreamTrackStats(const RTCMediaStreamTrackStats& other);
230 ~RTCMediaStreamTrackStats() override;
231
232 RTCStatsMember<std::string> track_identifier;
233 RTCStatsMember<bool> remote_source;
234 RTCStatsMember<bool> ended;
235 // TODO(hbos): |RTCStatsCollector| does not return stats for detached tracks.
236 // crbug.com/659137
237 RTCStatsMember<bool> detached;
238 // TODO(hbos): Not collected by |RTCStatsCollector|. crbug.com/659137
239 RTCStatsMember<std::vector<std::string>> ssrc_ids;
240 // Video-only members
241 RTCStatsMember<uint32_t> frame_width;
242 RTCStatsMember<uint32_t> frame_height;
243 // TODO(hbos): Not collected by |RTCStatsCollector|. crbug.com/659137
244 RTCStatsMember<double> frames_per_second;
245 // TODO(hbos): Not collected by |RTCStatsCollector|. crbug.com/659137
246 RTCStatsMember<uint32_t> frames_sent;
247 // TODO(hbos): Not collected by |RTCStatsCollector|. crbug.com/659137
248 RTCStatsMember<uint32_t> frames_received;
249 // TODO(hbos): Not collected by |RTCStatsCollector|. crbug.com/659137
250 RTCStatsMember<uint32_t> frames_decoded;
251 // TODO(hbos): Not collected by |RTCStatsCollector|. crbug.com/659137
252 RTCStatsMember<uint32_t> frames_dropped;
253 // TODO(hbos): Not collected by |RTCStatsCollector|. crbug.com/659137
254 RTCStatsMember<uint32_t> frames_corrupted;
255 // TODO(hbos): Not collected by |RTCStatsCollector|. crbug.com/659137
256 RTCStatsMember<uint32_t> partial_frames_lost;
257 // TODO(hbos): Not collected by |RTCStatsCollector|. crbug.com/659137
258 RTCStatsMember<uint32_t> full_frames_lost;
259 // Audio-only members
260 RTCStatsMember<double> audio_level;
261 RTCStatsMember<double> echo_return_loss;
262 RTCStatsMember<double> echo_return_loss_enhancement;
263};
264
hbos6ab97ce2016-10-03 14:16:56 -0700265// https://w3c.github.io/webrtc-stats/#pcstats-dict*
hbosab9f6e42016-10-07 02:18:47 -0700266class RTCPeerConnectionStats final : public RTCStats {
hbosd565b732016-08-30 14:04:35 -0700267 public:
hbosfc5e0502016-10-06 02:06:10 -0700268 WEBRTC_RTCSTATS_DECL();
269
hbos0e6758d2016-08-31 07:57:36 -0700270 RTCPeerConnectionStats(const std::string& id, int64_t timestamp_us);
271 RTCPeerConnectionStats(std::string&& id, int64_t timestamp_us);
hbosfc5e0502016-10-06 02:06:10 -0700272 RTCPeerConnectionStats(const RTCPeerConnectionStats& other);
273 ~RTCPeerConnectionStats() override;
hbosd565b732016-08-30 14:04:35 -0700274
275 RTCStatsMember<uint32_t> data_channels_opened;
276 RTCStatsMember<uint32_t> data_channels_closed;
277};
278
hbos6ded1902016-11-01 01:50:46 -0700279// https://w3c.github.io/webrtc-stats/#streamstats-dict*
hbos0adb8282016-11-23 02:32:06 -0800280// TODO(hbos): Tracking bug crbug.com/657854
hbos6ded1902016-11-01 01:50:46 -0700281class RTCRTPStreamStats : public RTCStats {
282 public:
283 WEBRTC_RTCSTATS_DECL();
284
285 RTCRTPStreamStats(const RTCRTPStreamStats& other);
286 ~RTCRTPStreamStats() override;
287
288 RTCStatsMember<std::string> ssrc;
289 // TODO(hbos): When the remote case is supported |RTCStatsCollector| needs to
290 // set this. crbug.com/657855, 657856
291 RTCStatsMember<std::string> associate_stats_id;
292 // TODO(hbos): Remote case not supported by |RTCStatsCollector|.
293 // crbug.com/657855, 657856
294 RTCStatsMember<bool> is_remote; // = false
295 RTCStatsMember<std::string> media_type;
296 // TODO(hbos): Not collected by |RTCStatsCollector|. crbug.com/657854, 659137
297 RTCStatsMember<std::string> media_track_id;
298 RTCStatsMember<std::string> transport_id;
hbos6ded1902016-11-01 01:50:46 -0700299 RTCStatsMember<std::string> codec_id;
300 // FIR and PLI counts are only defined for |media_type == "video"|.
301 RTCStatsMember<uint32_t> fir_count;
302 RTCStatsMember<uint32_t> pli_count;
303 // TODO(hbos): NACK count should be collected by |RTCStatsCollector| for both
304 // audio and video but is only defined in the "video" case. crbug.com/657856
305 RTCStatsMember<uint32_t> nack_count;
306 // TODO(hbos): Not collected by |RTCStatsCollector|. crbug.com/657854
307 // SLI count is only defined for |media_type == "video"|.
308 RTCStatsMember<uint32_t> sli_count;
309
310 protected:
311 RTCRTPStreamStats(const std::string& id, int64_t timestamp_us);
312 RTCRTPStreamStats(std::string&& id, int64_t timestamp_us);
313};
314
hboseeafe942016-11-01 03:00:17 -0700315// https://w3c.github.io/webrtc-stats/#inboundrtpstats-dict*
hbos0adb8282016-11-23 02:32:06 -0800316// Tracking bug crbug.com/657855
317// TODO(hbos): Support the remote case |is_remote = true|. crbug.com/657855
hboseeafe942016-11-01 03:00:17 -0700318class RTCInboundRTPStreamStats final : public RTCRTPStreamStats {
319 public:
320 WEBRTC_RTCSTATS_DECL();
321
322 RTCInboundRTPStreamStats(const std::string& id, int64_t timestamp_us);
323 RTCInboundRTPStreamStats(std::string&& id, int64_t timestamp_us);
324 RTCInboundRTPStreamStats(const RTCInboundRTPStreamStats& other);
325 ~RTCInboundRTPStreamStats() override;
326
327 RTCStatsMember<uint32_t> packets_received;
328 RTCStatsMember<uint64_t> bytes_received;
hboseeafe942016-11-01 03:00:17 -0700329 RTCStatsMember<uint32_t> packets_lost;
330 // TODO(hbos): Not collected in the "video" case by |RTCStatsCollector|.
331 // crbug.com/657855
332 RTCStatsMember<double> jitter;
333 RTCStatsMember<double> fraction_lost;
334 // TODO(hbos): Not collected by |RTCStatsCollector|. crbug.com/657855
335 RTCStatsMember<uint32_t> packets_discarded;
336 // TODO(hbos): Not collected by |RTCStatsCollector|. crbug.com/657855
337 RTCStatsMember<uint32_t> packets_repaired;
338 // TODO(hbos): Not collected by |RTCStatsCollector|. crbug.com/657855
339 RTCStatsMember<uint32_t> burst_packets_lost;
340 // TODO(hbos): Not collected by |RTCStatsCollector|. crbug.com/657855
341 RTCStatsMember<uint32_t> burst_packets_discarded;
342 // TODO(hbos): Not collected by |RTCStatsCollector|. crbug.com/657855
343 RTCStatsMember<uint32_t> burst_loss_count;
344 // TODO(hbos): Not collected by |RTCStatsCollector|. crbug.com/657855
345 RTCStatsMember<uint32_t> burst_discard_count;
346 // TODO(hbos): Not collected by |RTCStatsCollector|. crbug.com/657855
347 RTCStatsMember<double> burst_loss_rate;
348 // TODO(hbos): Not collected by |RTCStatsCollector|. crbug.com/657855
349 RTCStatsMember<double> burst_discard_rate;
350 // TODO(hbos): Not collected by |RTCStatsCollector|. crbug.com/657855
351 RTCStatsMember<double> gap_loss_rate;
352 // TODO(hbos): Not collected by |RTCStatsCollector|. crbug.com/657855
353 RTCStatsMember<double> gap_discard_rate;
354};
355
hbos6ded1902016-11-01 01:50:46 -0700356// https://w3c.github.io/webrtc-stats/#outboundrtpstats-dict*
hbos0adb8282016-11-23 02:32:06 -0800357// Tracking bug crbug.com/657856
358// TODO(hbos): Support the remote case |is_remote = true|. crbug.com/657856
hbos6ded1902016-11-01 01:50:46 -0700359class RTCOutboundRTPStreamStats final : public RTCRTPStreamStats {
360 public:
361 WEBRTC_RTCSTATS_DECL();
362
363 RTCOutboundRTPStreamStats(const std::string& id, int64_t timestamp_us);
364 RTCOutboundRTPStreamStats(std::string&& id, int64_t timestamp_us);
365 RTCOutboundRTPStreamStats(const RTCOutboundRTPStreamStats& other);
366 ~RTCOutboundRTPStreamStats() override;
367
368 RTCStatsMember<uint32_t> packets_sent;
369 RTCStatsMember<uint64_t> bytes_sent;
370 // TODO(hbos): Not collected by |RTCStatsCollector|. crbug.com/657856
371 RTCStatsMember<double> target_bitrate;
372 RTCStatsMember<double> round_trip_time;
373};
374
hbos2fa7c672016-10-24 04:00:05 -0700375// https://w3c.github.io/webrtc-stats/#transportstats-dict*
376class RTCTransportStats final : public RTCStats {
377 public:
378 WEBRTC_RTCSTATS_DECL();
379
380 RTCTransportStats(const std::string& id, int64_t timestamp_us);
381 RTCTransportStats(std::string&& id, int64_t timestamp_us);
382 RTCTransportStats(const RTCTransportStats& other);
383 ~RTCTransportStats() override;
384
385 RTCStatsMember<uint64_t> bytes_sent;
386 RTCStatsMember<uint64_t> bytes_received;
387 RTCStatsMember<std::string> rtcp_transport_stats_id;
388 RTCStatsMember<bool> active_connection;
389 RTCStatsMember<std::string> selected_candidate_pair_id;
390 RTCStatsMember<std::string> local_certificate_id;
391 RTCStatsMember<std::string> remote_certificate_id;
392};
393
hbosd565b732016-08-30 14:04:35 -0700394} // namespace webrtc
395
hbos74e1a4f2016-09-15 23:33:01 -0700396#endif // WEBRTC_API_STATS_RTCSTATS_OBJECTS_H_