blob: 232e66b388e62524acb27f68d2cdb9220cdce339 [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;
35 static const char* kCancelled;
36};
37
hboscc555c52016-10-18 12:48:31 -070038// https://w3c.github.io/webrtc-pc/#rtcicecandidatetype-enum
hbosab9f6e42016-10-07 02:18:47 -070039struct RTCIceCandidateType {
40 static const char* kHost;
41 static const char* kSrflx;
42 static const char* kPrflx;
43 static const char* kRelay;
44};
45
hbos2fa7c672016-10-24 04:00:05 -070046// https://w3c.github.io/webrtc-stats/#certificatestats-dict*
47class RTCCertificateStats final : public RTCStats {
48 public:
49 WEBRTC_RTCSTATS_DECL();
50
51 RTCCertificateStats(const std::string& id, int64_t timestamp_us);
52 RTCCertificateStats(std::string&& id, int64_t timestamp_us);
53 RTCCertificateStats(const RTCCertificateStats& other);
54 ~RTCCertificateStats() override;
55
56 RTCStatsMember<std::string> fingerprint;
57 RTCStatsMember<std::string> fingerprint_algorithm;
58 RTCStatsMember<std::string> base64_certificate;
59 RTCStatsMember<std::string> issuer_certificate_id;
60};
61
62// https://w3c.github.io/webrtc-stats/#dcstats-dict*
63class RTCDataChannelStats final : public RTCStats {
64 public:
65 WEBRTC_RTCSTATS_DECL();
66
67 RTCDataChannelStats(const std::string& id, int64_t timestamp_us);
68 RTCDataChannelStats(std::string&& id, int64_t timestamp_us);
69 RTCDataChannelStats(const RTCDataChannelStats& other);
70 ~RTCDataChannelStats() override;
71
72 RTCStatsMember<std::string> label;
73 RTCStatsMember<std::string> protocol;
74 RTCStatsMember<int32_t> datachannelid;
75 // TODO(hbos): Support enum types? "RTCStatsMember<RTCDataChannelState>"?
76 RTCStatsMember<std::string> state;
77 RTCStatsMember<uint32_t> messages_sent;
78 RTCStatsMember<uint64_t> bytes_sent;
79 RTCStatsMember<uint32_t> messages_received;
80 RTCStatsMember<uint64_t> bytes_received;
81};
82
83// https://w3c.github.io/webrtc-stats/#candidatepair-dict*
84// TODO(hbos): Finish implementation. Tracking bug crbug.com/633550
hbos6ded1902016-11-01 01:50:46 -070085class RTCIceCandidatePairStats final : public RTCStats {
hbosc47a0c32016-10-11 14:54:49 -070086 public:
87 WEBRTC_RTCSTATS_DECL();
88
89 RTCIceCandidatePairStats(const std::string& id, int64_t timestamp_us);
90 RTCIceCandidatePairStats(std::string&& id, int64_t timestamp_us);
91 RTCIceCandidatePairStats(const RTCIceCandidatePairStats& other);
92 ~RTCIceCandidatePairStats() override;
93
hbos5d79a7c2016-10-24 09:27:10 -070094 // TODO(hbos): Not collected by |RTCStatsCollector|. crbug.com/633550, 653873
hbosc47a0c32016-10-11 14:54:49 -070095 RTCStatsMember<std::string> transport_id;
96 RTCStatsMember<std::string> local_candidate_id;
97 RTCStatsMember<std::string> remote_candidate_id;
98 // TODO(hbos): Support enum types?
99 // "RTCStatsMember<RTCStatsIceCandidatePairState>"?
hbos5d79a7c2016-10-24 09:27:10 -0700100 // TODO(hbos): Not collected by |RTCStatsCollector|. crbug.com/633550
hbosc47a0c32016-10-11 14:54:49 -0700101 RTCStatsMember<std::string> state;
hbos5d79a7c2016-10-24 09:27:10 -0700102 // TODO(hbos): Not collected by |RTCStatsCollector|. crbug.com/633550
hbosc47a0c32016-10-11 14:54:49 -0700103 RTCStatsMember<uint64_t> priority;
hbos5d79a7c2016-10-24 09:27:10 -0700104 // TODO(hbos): Not collected by |RTCStatsCollector|. crbug.com/633550
hbosc47a0c32016-10-11 14:54:49 -0700105 RTCStatsMember<bool> nominated;
hbos5d79a7c2016-10-24 09:27:10 -0700106 // TODO(hbos): Collected by |RTCStatsCollector| but different than the spec.
107 // crbug.com/633550
hbosc47a0c32016-10-11 14:54:49 -0700108 RTCStatsMember<bool> writable;
hbos5d79a7c2016-10-24 09:27:10 -0700109 // TODO(hbos): Not collected by |RTCStatsCollector|. crbug.com/633550
hbosc47a0c32016-10-11 14:54:49 -0700110 RTCStatsMember<bool> readable;
111 RTCStatsMember<uint64_t> bytes_sent;
112 RTCStatsMember<uint64_t> bytes_received;
hbos5d79a7c2016-10-24 09:27:10 -0700113 // TODO(hbos): Not collected by |RTCStatsCollector|. crbug.com/633550
hbosc47a0c32016-10-11 14:54:49 -0700114 RTCStatsMember<double> total_rtt;
hbos5d79a7c2016-10-24 09:27:10 -0700115 // TODO(hbos): Collected by |RTCStatsCollector| but different than the spec.
116 // crbug.com/633550
hbosc47a0c32016-10-11 14:54:49 -0700117 RTCStatsMember<double> current_rtt;
hbos5d79a7c2016-10-24 09:27:10 -0700118 // TODO(hbos): Not collected by |RTCStatsCollector|. crbug.com/633550
hbosc47a0c32016-10-11 14:54:49 -0700119 RTCStatsMember<double> available_outgoing_bitrate;
hbos5d79a7c2016-10-24 09:27:10 -0700120 // TODO(hbos): Not collected by |RTCStatsCollector|. crbug.com/633550
hbosc47a0c32016-10-11 14:54:49 -0700121 RTCStatsMember<double> available_incoming_bitrate;
hbos5d79a7c2016-10-24 09:27:10 -0700122 // TODO(hbos): Not collected by |RTCStatsCollector|. crbug.com/633550
hbosc47a0c32016-10-11 14:54:49 -0700123 RTCStatsMember<uint64_t> requests_received;
124 RTCStatsMember<uint64_t> requests_sent;
125 RTCStatsMember<uint64_t> responses_received;
126 RTCStatsMember<uint64_t> responses_sent;
hbos5d79a7c2016-10-24 09:27:10 -0700127 // TODO(hbos): Not collected by |RTCStatsCollector|. crbug.com/633550
hbosc47a0c32016-10-11 14:54:49 -0700128 RTCStatsMember<uint64_t> retransmissions_received;
hbos5d79a7c2016-10-24 09:27:10 -0700129 // TODO(hbos): Not collected by |RTCStatsCollector|. crbug.com/633550
hbosc47a0c32016-10-11 14:54:49 -0700130 RTCStatsMember<uint64_t> retransmissions_sent;
hbos5d79a7c2016-10-24 09:27:10 -0700131 // TODO(hbos): Not collected by |RTCStatsCollector|. crbug.com/633550
hbosc47a0c32016-10-11 14:54:49 -0700132 RTCStatsMember<uint64_t> consent_requests_received;
hbos5d79a7c2016-10-24 09:27:10 -0700133 // TODO(hbos): Not collected by |RTCStatsCollector|. crbug.com/633550
hbosc47a0c32016-10-11 14:54:49 -0700134 RTCStatsMember<uint64_t> consent_requests_sent;
hbos5d79a7c2016-10-24 09:27:10 -0700135 // TODO(hbos): Not collected by |RTCStatsCollector|. crbug.com/633550
hbosc47a0c32016-10-11 14:54:49 -0700136 RTCStatsMember<uint64_t> consent_responses_received;
hbos5d79a7c2016-10-24 09:27:10 -0700137 // TODO(hbos): Not collected by |RTCStatsCollector|. crbug.com/633550
hbosc47a0c32016-10-11 14:54:49 -0700138 RTCStatsMember<uint64_t> consent_responses_sent;
139};
140
hbosab9f6e42016-10-07 02:18:47 -0700141// https://w3c.github.io/webrtc-stats/#icecandidate-dict*
hbos5d79a7c2016-10-24 09:27:10 -0700142// TODO(hbos): |RTCStatsCollector| only collects candidates that are part of
143// ice candidate pairs, but there could be candidates not paired with anything.
144// crbug.com/632723
hbosab9f6e42016-10-07 02:18:47 -0700145class RTCIceCandidateStats : public RTCStats {
146 public:
147 WEBRTC_RTCSTATS_DECL();
148
149 RTCIceCandidateStats(const RTCIceCandidateStats& other);
150 ~RTCIceCandidateStats() override;
151
152 RTCStatsMember<std::string> ip;
153 RTCStatsMember<int32_t> port;
154 RTCStatsMember<std::string> protocol;
155 // TODO(hbos): Support enum types? "RTCStatsMember<RTCIceCandidateType>"?
156 RTCStatsMember<std::string> candidate_type;
157 RTCStatsMember<int32_t> priority;
hbos5d79a7c2016-10-24 09:27:10 -0700158 // TODO(hbos): Not collected by |RTCStatsCollector|. crbug.com/632723
hbosab9f6e42016-10-07 02:18:47 -0700159 RTCStatsMember<std::string> url;
160
161 protected:
162 RTCIceCandidateStats(const std::string& id, int64_t timestamp_us);
163 RTCIceCandidateStats(std::string&& id, int64_t timestamp_us);
164};
165
166// In the spec both local and remote varieties are of type RTCIceCandidateStats.
167// But here we define them as subclasses of |RTCIceCandidateStats| because the
168// |kType| need to be different ("RTCStatsType type") in the local/remote case.
169// https://w3c.github.io/webrtc-stats/#rtcstatstype-str*
170class RTCLocalIceCandidateStats final : public RTCIceCandidateStats {
171 public:
172 static const char kType[];
173 RTCLocalIceCandidateStats(const std::string& id, int64_t timestamp_us);
174 RTCLocalIceCandidateStats(std::string&& id, int64_t timestamp_us);
175 const char* type() const override;
176};
177
178class RTCRemoteIceCandidateStats final : public RTCIceCandidateStats {
179 public:
180 static const char kType[];
181 RTCRemoteIceCandidateStats(const std::string& id, int64_t timestamp_us);
182 RTCRemoteIceCandidateStats(std::string&& id, int64_t timestamp_us);
183 const char* type() const override;
184};
185
hbos6ab97ce2016-10-03 14:16:56 -0700186// https://w3c.github.io/webrtc-stats/#pcstats-dict*
hbos2fa7c672016-10-24 04:00:05 -0700187// TODO(hbos): Finish implementation. Tracking bug crbug.com/636818
hbosab9f6e42016-10-07 02:18:47 -0700188class RTCPeerConnectionStats final : public RTCStats {
hbosd565b732016-08-30 14:04:35 -0700189 public:
hbosfc5e0502016-10-06 02:06:10 -0700190 WEBRTC_RTCSTATS_DECL();
191
hbos0e6758d2016-08-31 07:57:36 -0700192 RTCPeerConnectionStats(const std::string& id, int64_t timestamp_us);
193 RTCPeerConnectionStats(std::string&& id, int64_t timestamp_us);
hbosfc5e0502016-10-06 02:06:10 -0700194 RTCPeerConnectionStats(const RTCPeerConnectionStats& other);
195 ~RTCPeerConnectionStats() override;
hbosd565b732016-08-30 14:04:35 -0700196
hbos5d79a7c2016-10-24 09:27:10 -0700197 // TODO(hbos): Collected by |RTCStatsCollector| but different than the spec.
198 // crbug.com/636818
hbosd565b732016-08-30 14:04:35 -0700199 RTCStatsMember<uint32_t> data_channels_opened;
hbos5d79a7c2016-10-24 09:27:10 -0700200 // TODO(hbos): Collected by |RTCStatsCollector| but different than the spec.
201 // crbug.com/636818
hbosd565b732016-08-30 14:04:35 -0700202 RTCStatsMember<uint32_t> data_channels_closed;
203};
204
hbos6ded1902016-11-01 01:50:46 -0700205// https://w3c.github.io/webrtc-stats/#streamstats-dict*
206// TODO(hbos): Finish implementation. Tracking bug crbug.com/657854
207class RTCRTPStreamStats : public RTCStats {
208 public:
209 WEBRTC_RTCSTATS_DECL();
210
211 RTCRTPStreamStats(const RTCRTPStreamStats& other);
212 ~RTCRTPStreamStats() override;
213
214 RTCStatsMember<std::string> ssrc;
215 // TODO(hbos): When the remote case is supported |RTCStatsCollector| needs to
216 // set this. crbug.com/657855, 657856
217 RTCStatsMember<std::string> associate_stats_id;
218 // TODO(hbos): Remote case not supported by |RTCStatsCollector|.
219 // crbug.com/657855, 657856
220 RTCStatsMember<bool> is_remote; // = false
221 RTCStatsMember<std::string> media_type;
222 // TODO(hbos): Not collected by |RTCStatsCollector|. crbug.com/657854, 659137
223 RTCStatsMember<std::string> media_track_id;
224 RTCStatsMember<std::string> transport_id;
225 // TODO(hbos): Not collected by |RTCStatsCollector|. crbug.com/657854, 659117
226 RTCStatsMember<std::string> codec_id;
227 // FIR and PLI counts are only defined for |media_type == "video"|.
228 RTCStatsMember<uint32_t> fir_count;
229 RTCStatsMember<uint32_t> pli_count;
230 // TODO(hbos): NACK count should be collected by |RTCStatsCollector| for both
231 // audio and video but is only defined in the "video" case. crbug.com/657856
232 RTCStatsMember<uint32_t> nack_count;
233 // TODO(hbos): Not collected by |RTCStatsCollector|. crbug.com/657854
234 // SLI count is only defined for |media_type == "video"|.
235 RTCStatsMember<uint32_t> sli_count;
236
237 protected:
238 RTCRTPStreamStats(const std::string& id, int64_t timestamp_us);
239 RTCRTPStreamStats(std::string&& id, int64_t timestamp_us);
240};
241
242// https://w3c.github.io/webrtc-stats/#outboundrtpstats-dict*
243// TODO(hbos): Finish implementation and support the remote case
244// |is_remote = true|. Tracking bug crbug.com/657856
245class RTCOutboundRTPStreamStats final : public RTCRTPStreamStats {
246 public:
247 WEBRTC_RTCSTATS_DECL();
248
249 RTCOutboundRTPStreamStats(const std::string& id, int64_t timestamp_us);
250 RTCOutboundRTPStreamStats(std::string&& id, int64_t timestamp_us);
251 RTCOutboundRTPStreamStats(const RTCOutboundRTPStreamStats& other);
252 ~RTCOutboundRTPStreamStats() override;
253
254 RTCStatsMember<uint32_t> packets_sent;
255 RTCStatsMember<uint64_t> bytes_sent;
256 // TODO(hbos): Not collected by |RTCStatsCollector|. crbug.com/657856
257 RTCStatsMember<double> target_bitrate;
258 RTCStatsMember<double> round_trip_time;
259};
260
hbos2fa7c672016-10-24 04:00:05 -0700261// https://w3c.github.io/webrtc-stats/#transportstats-dict*
262class RTCTransportStats final : public RTCStats {
263 public:
264 WEBRTC_RTCSTATS_DECL();
265
266 RTCTransportStats(const std::string& id, int64_t timestamp_us);
267 RTCTransportStats(std::string&& id, int64_t timestamp_us);
268 RTCTransportStats(const RTCTransportStats& other);
269 ~RTCTransportStats() override;
270
271 RTCStatsMember<uint64_t> bytes_sent;
272 RTCStatsMember<uint64_t> bytes_received;
273 RTCStatsMember<std::string> rtcp_transport_stats_id;
274 RTCStatsMember<bool> active_connection;
275 RTCStatsMember<std::string> selected_candidate_pair_id;
276 RTCStatsMember<std::string> local_certificate_id;
277 RTCStatsMember<std::string> remote_certificate_id;
278};
279
hbosd565b732016-08-30 14:04:35 -0700280} // namespace webrtc
281
hbos74e1a4f2016-09-15 23:33:01 -0700282#endif // WEBRTC_API_STATS_RTCSTATS_OBJECTS_H_