hbos | d565b73 | 2016-08-30 14:04:35 -0700 | [diff] [blame] | 1 | /* |
| 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 | |
hbos | 74e1a4f | 2016-09-15 23:33:01 -0700 | [diff] [blame] | 11 | #ifndef WEBRTC_API_STATS_RTCSTATS_OBJECTS_H_ |
| 12 | #define WEBRTC_API_STATS_RTCSTATS_OBJECTS_H_ |
hbos | d565b73 | 2016-08-30 14:04:35 -0700 | [diff] [blame] | 13 | |
| 14 | #include <string> |
| 15 | |
hbos | 74e1a4f | 2016-09-15 23:33:01 -0700 | [diff] [blame] | 16 | #include "webrtc/api/stats/rtcstats.h" |
hbos | d565b73 | 2016-08-30 14:04:35 -0700 | [diff] [blame] | 17 | |
| 18 | namespace webrtc { |
| 19 | |
hbos | cc555c5 | 2016-10-18 12:48:31 -0700 | [diff] [blame] | 20 | // https://w3c.github.io/webrtc-pc/#idl-def-rtcdatachannelstate |
| 21 | struct RTCDataChannelState { |
| 22 | static const char* kConnecting; |
| 23 | static const char* kOpen; |
| 24 | static const char* kClosing; |
| 25 | static const char* kClosed; |
| 26 | }; |
| 27 | |
hbos | c47a0c3 | 2016-10-11 14:54:49 -0700 | [diff] [blame] | 28 | // https://w3c.github.io/webrtc-stats/#dom-rtcstatsicecandidatepairstate |
| 29 | struct 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 | |
hbos | cc555c5 | 2016-10-18 12:48:31 -0700 | [diff] [blame] | 38 | // https://w3c.github.io/webrtc-pc/#rtcicecandidatetype-enum |
hbos | ab9f6e4 | 2016-10-07 02:18:47 -0700 | [diff] [blame] | 39 | struct RTCIceCandidateType { |
| 40 | static const char* kHost; |
| 41 | static const char* kSrflx; |
| 42 | static const char* kPrflx; |
| 43 | static const char* kRelay; |
| 44 | }; |
| 45 | |
hbos | 2fa7c67 | 2016-10-24 04:00:05 -0700 | [diff] [blame] | 46 | // https://w3c.github.io/webrtc-stats/#certificatestats-dict* |
| 47 | class 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* |
| 63 | class 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 |
hbos | 6ded190 | 2016-11-01 01:50:46 -0700 | [diff] [blame^] | 85 | class RTCIceCandidatePairStats final : public RTCStats { |
hbos | c47a0c3 | 2016-10-11 14:54:49 -0700 | [diff] [blame] | 86 | 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 | |
hbos | 5d79a7c | 2016-10-24 09:27:10 -0700 | [diff] [blame] | 94 | // TODO(hbos): Not collected by |RTCStatsCollector|. crbug.com/633550, 653873 |
hbos | c47a0c3 | 2016-10-11 14:54:49 -0700 | [diff] [blame] | 95 | 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>"? |
hbos | 5d79a7c | 2016-10-24 09:27:10 -0700 | [diff] [blame] | 100 | // TODO(hbos): Not collected by |RTCStatsCollector|. crbug.com/633550 |
hbos | c47a0c3 | 2016-10-11 14:54:49 -0700 | [diff] [blame] | 101 | RTCStatsMember<std::string> state; |
hbos | 5d79a7c | 2016-10-24 09:27:10 -0700 | [diff] [blame] | 102 | // TODO(hbos): Not collected by |RTCStatsCollector|. crbug.com/633550 |
hbos | c47a0c3 | 2016-10-11 14:54:49 -0700 | [diff] [blame] | 103 | RTCStatsMember<uint64_t> priority; |
hbos | 5d79a7c | 2016-10-24 09:27:10 -0700 | [diff] [blame] | 104 | // TODO(hbos): Not collected by |RTCStatsCollector|. crbug.com/633550 |
hbos | c47a0c3 | 2016-10-11 14:54:49 -0700 | [diff] [blame] | 105 | RTCStatsMember<bool> nominated; |
hbos | 5d79a7c | 2016-10-24 09:27:10 -0700 | [diff] [blame] | 106 | // TODO(hbos): Collected by |RTCStatsCollector| but different than the spec. |
| 107 | // crbug.com/633550 |
hbos | c47a0c3 | 2016-10-11 14:54:49 -0700 | [diff] [blame] | 108 | RTCStatsMember<bool> writable; |
hbos | 5d79a7c | 2016-10-24 09:27:10 -0700 | [diff] [blame] | 109 | // TODO(hbos): Not collected by |RTCStatsCollector|. crbug.com/633550 |
hbos | c47a0c3 | 2016-10-11 14:54:49 -0700 | [diff] [blame] | 110 | RTCStatsMember<bool> readable; |
| 111 | RTCStatsMember<uint64_t> bytes_sent; |
| 112 | RTCStatsMember<uint64_t> bytes_received; |
hbos | 5d79a7c | 2016-10-24 09:27:10 -0700 | [diff] [blame] | 113 | // TODO(hbos): Not collected by |RTCStatsCollector|. crbug.com/633550 |
hbos | c47a0c3 | 2016-10-11 14:54:49 -0700 | [diff] [blame] | 114 | RTCStatsMember<double> total_rtt; |
hbos | 5d79a7c | 2016-10-24 09:27:10 -0700 | [diff] [blame] | 115 | // TODO(hbos): Collected by |RTCStatsCollector| but different than the spec. |
| 116 | // crbug.com/633550 |
hbos | c47a0c3 | 2016-10-11 14:54:49 -0700 | [diff] [blame] | 117 | RTCStatsMember<double> current_rtt; |
hbos | 5d79a7c | 2016-10-24 09:27:10 -0700 | [diff] [blame] | 118 | // TODO(hbos): Not collected by |RTCStatsCollector|. crbug.com/633550 |
hbos | c47a0c3 | 2016-10-11 14:54:49 -0700 | [diff] [blame] | 119 | RTCStatsMember<double> available_outgoing_bitrate; |
hbos | 5d79a7c | 2016-10-24 09:27:10 -0700 | [diff] [blame] | 120 | // TODO(hbos): Not collected by |RTCStatsCollector|. crbug.com/633550 |
hbos | c47a0c3 | 2016-10-11 14:54:49 -0700 | [diff] [blame] | 121 | RTCStatsMember<double> available_incoming_bitrate; |
hbos | 5d79a7c | 2016-10-24 09:27:10 -0700 | [diff] [blame] | 122 | // TODO(hbos): Not collected by |RTCStatsCollector|. crbug.com/633550 |
hbos | c47a0c3 | 2016-10-11 14:54:49 -0700 | [diff] [blame] | 123 | RTCStatsMember<uint64_t> requests_received; |
| 124 | RTCStatsMember<uint64_t> requests_sent; |
| 125 | RTCStatsMember<uint64_t> responses_received; |
| 126 | RTCStatsMember<uint64_t> responses_sent; |
hbos | 5d79a7c | 2016-10-24 09:27:10 -0700 | [diff] [blame] | 127 | // TODO(hbos): Not collected by |RTCStatsCollector|. crbug.com/633550 |
hbos | c47a0c3 | 2016-10-11 14:54:49 -0700 | [diff] [blame] | 128 | RTCStatsMember<uint64_t> retransmissions_received; |
hbos | 5d79a7c | 2016-10-24 09:27:10 -0700 | [diff] [blame] | 129 | // TODO(hbos): Not collected by |RTCStatsCollector|. crbug.com/633550 |
hbos | c47a0c3 | 2016-10-11 14:54:49 -0700 | [diff] [blame] | 130 | RTCStatsMember<uint64_t> retransmissions_sent; |
hbos | 5d79a7c | 2016-10-24 09:27:10 -0700 | [diff] [blame] | 131 | // TODO(hbos): Not collected by |RTCStatsCollector|. crbug.com/633550 |
hbos | c47a0c3 | 2016-10-11 14:54:49 -0700 | [diff] [blame] | 132 | RTCStatsMember<uint64_t> consent_requests_received; |
hbos | 5d79a7c | 2016-10-24 09:27:10 -0700 | [diff] [blame] | 133 | // TODO(hbos): Not collected by |RTCStatsCollector|. crbug.com/633550 |
hbos | c47a0c3 | 2016-10-11 14:54:49 -0700 | [diff] [blame] | 134 | RTCStatsMember<uint64_t> consent_requests_sent; |
hbos | 5d79a7c | 2016-10-24 09:27:10 -0700 | [diff] [blame] | 135 | // TODO(hbos): Not collected by |RTCStatsCollector|. crbug.com/633550 |
hbos | c47a0c3 | 2016-10-11 14:54:49 -0700 | [diff] [blame] | 136 | RTCStatsMember<uint64_t> consent_responses_received; |
hbos | 5d79a7c | 2016-10-24 09:27:10 -0700 | [diff] [blame] | 137 | // TODO(hbos): Not collected by |RTCStatsCollector|. crbug.com/633550 |
hbos | c47a0c3 | 2016-10-11 14:54:49 -0700 | [diff] [blame] | 138 | RTCStatsMember<uint64_t> consent_responses_sent; |
| 139 | }; |
| 140 | |
hbos | ab9f6e4 | 2016-10-07 02:18:47 -0700 | [diff] [blame] | 141 | // https://w3c.github.io/webrtc-stats/#icecandidate-dict* |
hbos | 5d79a7c | 2016-10-24 09:27:10 -0700 | [diff] [blame] | 142 | // 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 |
hbos | ab9f6e4 | 2016-10-07 02:18:47 -0700 | [diff] [blame] | 145 | class 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; |
hbos | 5d79a7c | 2016-10-24 09:27:10 -0700 | [diff] [blame] | 158 | // TODO(hbos): Not collected by |RTCStatsCollector|. crbug.com/632723 |
hbos | ab9f6e4 | 2016-10-07 02:18:47 -0700 | [diff] [blame] | 159 | 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* |
| 170 | class 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 | |
| 178 | class 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 | |
hbos | 6ab97ce | 2016-10-03 14:16:56 -0700 | [diff] [blame] | 186 | // https://w3c.github.io/webrtc-stats/#pcstats-dict* |
hbos | 2fa7c67 | 2016-10-24 04:00:05 -0700 | [diff] [blame] | 187 | // TODO(hbos): Finish implementation. Tracking bug crbug.com/636818 |
hbos | ab9f6e4 | 2016-10-07 02:18:47 -0700 | [diff] [blame] | 188 | class RTCPeerConnectionStats final : public RTCStats { |
hbos | d565b73 | 2016-08-30 14:04:35 -0700 | [diff] [blame] | 189 | public: |
hbos | fc5e050 | 2016-10-06 02:06:10 -0700 | [diff] [blame] | 190 | WEBRTC_RTCSTATS_DECL(); |
| 191 | |
hbos | 0e6758d | 2016-08-31 07:57:36 -0700 | [diff] [blame] | 192 | RTCPeerConnectionStats(const std::string& id, int64_t timestamp_us); |
| 193 | RTCPeerConnectionStats(std::string&& id, int64_t timestamp_us); |
hbos | fc5e050 | 2016-10-06 02:06:10 -0700 | [diff] [blame] | 194 | RTCPeerConnectionStats(const RTCPeerConnectionStats& other); |
| 195 | ~RTCPeerConnectionStats() override; |
hbos | d565b73 | 2016-08-30 14:04:35 -0700 | [diff] [blame] | 196 | |
hbos | 5d79a7c | 2016-10-24 09:27:10 -0700 | [diff] [blame] | 197 | // TODO(hbos): Collected by |RTCStatsCollector| but different than the spec. |
| 198 | // crbug.com/636818 |
hbos | d565b73 | 2016-08-30 14:04:35 -0700 | [diff] [blame] | 199 | RTCStatsMember<uint32_t> data_channels_opened; |
hbos | 5d79a7c | 2016-10-24 09:27:10 -0700 | [diff] [blame] | 200 | // TODO(hbos): Collected by |RTCStatsCollector| but different than the spec. |
| 201 | // crbug.com/636818 |
hbos | d565b73 | 2016-08-30 14:04:35 -0700 | [diff] [blame] | 202 | RTCStatsMember<uint32_t> data_channels_closed; |
| 203 | }; |
| 204 | |
hbos | 6ded190 | 2016-11-01 01:50:46 -0700 | [diff] [blame^] | 205 | // https://w3c.github.io/webrtc-stats/#streamstats-dict* |
| 206 | // TODO(hbos): Finish implementation. Tracking bug crbug.com/657854 |
| 207 | class 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 |
| 245 | class 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 | |
hbos | 2fa7c67 | 2016-10-24 04:00:05 -0700 | [diff] [blame] | 261 | // https://w3c.github.io/webrtc-stats/#transportstats-dict* |
| 262 | class 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 | |
hbos | d565b73 | 2016-08-30 14:04:35 -0700 | [diff] [blame] | 280 | } // namespace webrtc |
| 281 | |
hbos | 74e1a4f | 2016-09-15 23:33:01 -0700 | [diff] [blame] | 282 | #endif // WEBRTC_API_STATS_RTCSTATS_OBJECTS_H_ |