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 | c47a0c3 | 2016-10-11 14:54:49 -0700 | [diff] [blame] | 85 | class RTCIceCandidatePairStats : public RTCStats { |
| 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 | |
| 94 | RTCStatsMember<std::string> transport_id; |
| 95 | RTCStatsMember<std::string> local_candidate_id; |
| 96 | RTCStatsMember<std::string> remote_candidate_id; |
| 97 | // TODO(hbos): Support enum types? |
| 98 | // "RTCStatsMember<RTCStatsIceCandidatePairState>"? |
| 99 | RTCStatsMember<std::string> state; |
| 100 | RTCStatsMember<uint64_t> priority; |
| 101 | RTCStatsMember<bool> nominated; |
| 102 | RTCStatsMember<bool> writable; |
| 103 | RTCStatsMember<bool> readable; |
| 104 | RTCStatsMember<uint64_t> bytes_sent; |
| 105 | RTCStatsMember<uint64_t> bytes_received; |
| 106 | RTCStatsMember<double> total_rtt; |
| 107 | RTCStatsMember<double> current_rtt; |
| 108 | RTCStatsMember<double> available_outgoing_bitrate; |
| 109 | RTCStatsMember<double> available_incoming_bitrate; |
| 110 | RTCStatsMember<uint64_t> requests_received; |
| 111 | RTCStatsMember<uint64_t> requests_sent; |
| 112 | RTCStatsMember<uint64_t> responses_received; |
| 113 | RTCStatsMember<uint64_t> responses_sent; |
| 114 | RTCStatsMember<uint64_t> retransmissions_received; |
| 115 | RTCStatsMember<uint64_t> retransmissions_sent; |
| 116 | RTCStatsMember<uint64_t> consent_requests_received; |
| 117 | RTCStatsMember<uint64_t> consent_requests_sent; |
| 118 | RTCStatsMember<uint64_t> consent_responses_received; |
| 119 | RTCStatsMember<uint64_t> consent_responses_sent; |
| 120 | }; |
| 121 | |
hbos | ab9f6e4 | 2016-10-07 02:18:47 -0700 | [diff] [blame] | 122 | // https://w3c.github.io/webrtc-stats/#icecandidate-dict* |
hbos | 2fa7c67 | 2016-10-24 04:00:05 -0700 | [diff] [blame] | 123 | // TODO(hbos): Finish implementation. Tracking bug crbug.com/632723 |
hbos | ab9f6e4 | 2016-10-07 02:18:47 -0700 | [diff] [blame] | 124 | class RTCIceCandidateStats : public RTCStats { |
| 125 | public: |
| 126 | WEBRTC_RTCSTATS_DECL(); |
| 127 | |
| 128 | RTCIceCandidateStats(const RTCIceCandidateStats& other); |
| 129 | ~RTCIceCandidateStats() override; |
| 130 | |
| 131 | RTCStatsMember<std::string> ip; |
| 132 | RTCStatsMember<int32_t> port; |
| 133 | RTCStatsMember<std::string> protocol; |
| 134 | // TODO(hbos): Support enum types? "RTCStatsMember<RTCIceCandidateType>"? |
| 135 | RTCStatsMember<std::string> candidate_type; |
| 136 | RTCStatsMember<int32_t> priority; |
| 137 | RTCStatsMember<std::string> url; |
| 138 | |
| 139 | protected: |
| 140 | RTCIceCandidateStats(const std::string& id, int64_t timestamp_us); |
| 141 | RTCIceCandidateStats(std::string&& id, int64_t timestamp_us); |
| 142 | }; |
| 143 | |
| 144 | // In the spec both local and remote varieties are of type RTCIceCandidateStats. |
| 145 | // But here we define them as subclasses of |RTCIceCandidateStats| because the |
| 146 | // |kType| need to be different ("RTCStatsType type") in the local/remote case. |
| 147 | // https://w3c.github.io/webrtc-stats/#rtcstatstype-str* |
| 148 | class RTCLocalIceCandidateStats final : public RTCIceCandidateStats { |
| 149 | public: |
| 150 | static const char kType[]; |
| 151 | RTCLocalIceCandidateStats(const std::string& id, int64_t timestamp_us); |
| 152 | RTCLocalIceCandidateStats(std::string&& id, int64_t timestamp_us); |
| 153 | const char* type() const override; |
| 154 | }; |
| 155 | |
| 156 | class RTCRemoteIceCandidateStats final : public RTCIceCandidateStats { |
| 157 | public: |
| 158 | static const char kType[]; |
| 159 | RTCRemoteIceCandidateStats(const std::string& id, int64_t timestamp_us); |
| 160 | RTCRemoteIceCandidateStats(std::string&& id, int64_t timestamp_us); |
| 161 | const char* type() const override; |
| 162 | }; |
| 163 | |
hbos | 6ab97ce | 2016-10-03 14:16:56 -0700 | [diff] [blame] | 164 | // https://w3c.github.io/webrtc-stats/#pcstats-dict* |
hbos | 2fa7c67 | 2016-10-24 04:00:05 -0700 | [diff] [blame] | 165 | // TODO(hbos): Finish implementation. Tracking bug crbug.com/636818 |
hbos | ab9f6e4 | 2016-10-07 02:18:47 -0700 | [diff] [blame] | 166 | class RTCPeerConnectionStats final : public RTCStats { |
hbos | d565b73 | 2016-08-30 14:04:35 -0700 | [diff] [blame] | 167 | public: |
hbos | fc5e050 | 2016-10-06 02:06:10 -0700 | [diff] [blame] | 168 | WEBRTC_RTCSTATS_DECL(); |
| 169 | |
hbos | 0e6758d | 2016-08-31 07:57:36 -0700 | [diff] [blame] | 170 | RTCPeerConnectionStats(const std::string& id, int64_t timestamp_us); |
| 171 | RTCPeerConnectionStats(std::string&& id, int64_t timestamp_us); |
hbos | fc5e050 | 2016-10-06 02:06:10 -0700 | [diff] [blame] | 172 | RTCPeerConnectionStats(const RTCPeerConnectionStats& other); |
| 173 | ~RTCPeerConnectionStats() override; |
hbos | d565b73 | 2016-08-30 14:04:35 -0700 | [diff] [blame] | 174 | |
| 175 | RTCStatsMember<uint32_t> data_channels_opened; |
| 176 | RTCStatsMember<uint32_t> data_channels_closed; |
| 177 | }; |
| 178 | |
hbos | 2fa7c67 | 2016-10-24 04:00:05 -0700 | [diff] [blame] | 179 | // https://w3c.github.io/webrtc-stats/#transportstats-dict* |
| 180 | class RTCTransportStats final : public RTCStats { |
| 181 | public: |
| 182 | WEBRTC_RTCSTATS_DECL(); |
| 183 | |
| 184 | RTCTransportStats(const std::string& id, int64_t timestamp_us); |
| 185 | RTCTransportStats(std::string&& id, int64_t timestamp_us); |
| 186 | RTCTransportStats(const RTCTransportStats& other); |
| 187 | ~RTCTransportStats() override; |
| 188 | |
| 189 | RTCStatsMember<uint64_t> bytes_sent; |
| 190 | RTCStatsMember<uint64_t> bytes_received; |
| 191 | RTCStatsMember<std::string> rtcp_transport_stats_id; |
| 192 | RTCStatsMember<bool> active_connection; |
| 193 | RTCStatsMember<std::string> selected_candidate_pair_id; |
| 194 | RTCStatsMember<std::string> local_certificate_id; |
| 195 | RTCStatsMember<std::string> remote_certificate_id; |
| 196 | }; |
| 197 | |
hbos | d565b73 | 2016-08-30 14:04:35 -0700 | [diff] [blame] | 198 | } // namespace webrtc |
| 199 | |
hbos | 74e1a4f | 2016-09-15 23:33:01 -0700 | [diff] [blame] | 200 | #endif // WEBRTC_API_STATS_RTCSTATS_OBJECTS_H_ |