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 | c47a0c3 | 2016-10-11 14:54:49 -0700 | [diff] [blame] | 46 | class RTCIceCandidatePairStats : public RTCStats { |
| 47 | public: |
| 48 | WEBRTC_RTCSTATS_DECL(); |
| 49 | |
| 50 | RTCIceCandidatePairStats(const std::string& id, int64_t timestamp_us); |
| 51 | RTCIceCandidatePairStats(std::string&& id, int64_t timestamp_us); |
| 52 | RTCIceCandidatePairStats(const RTCIceCandidatePairStats& other); |
| 53 | ~RTCIceCandidatePairStats() override; |
| 54 | |
| 55 | RTCStatsMember<std::string> transport_id; |
| 56 | RTCStatsMember<std::string> local_candidate_id; |
| 57 | RTCStatsMember<std::string> remote_candidate_id; |
| 58 | // TODO(hbos): Support enum types? |
| 59 | // "RTCStatsMember<RTCStatsIceCandidatePairState>"? |
| 60 | RTCStatsMember<std::string> state; |
| 61 | RTCStatsMember<uint64_t> priority; |
| 62 | RTCStatsMember<bool> nominated; |
| 63 | RTCStatsMember<bool> writable; |
| 64 | RTCStatsMember<bool> readable; |
| 65 | RTCStatsMember<uint64_t> bytes_sent; |
| 66 | RTCStatsMember<uint64_t> bytes_received; |
| 67 | RTCStatsMember<double> total_rtt; |
| 68 | RTCStatsMember<double> current_rtt; |
| 69 | RTCStatsMember<double> available_outgoing_bitrate; |
| 70 | RTCStatsMember<double> available_incoming_bitrate; |
| 71 | RTCStatsMember<uint64_t> requests_received; |
| 72 | RTCStatsMember<uint64_t> requests_sent; |
| 73 | RTCStatsMember<uint64_t> responses_received; |
| 74 | RTCStatsMember<uint64_t> responses_sent; |
| 75 | RTCStatsMember<uint64_t> retransmissions_received; |
| 76 | RTCStatsMember<uint64_t> retransmissions_sent; |
| 77 | RTCStatsMember<uint64_t> consent_requests_received; |
| 78 | RTCStatsMember<uint64_t> consent_requests_sent; |
| 79 | RTCStatsMember<uint64_t> consent_responses_received; |
| 80 | RTCStatsMember<uint64_t> consent_responses_sent; |
| 81 | }; |
| 82 | |
hbos | ab9f6e4 | 2016-10-07 02:18:47 -0700 | [diff] [blame] | 83 | // https://w3c.github.io/webrtc-stats/#icecandidate-dict* |
| 84 | class RTCIceCandidateStats : public RTCStats { |
| 85 | public: |
| 86 | WEBRTC_RTCSTATS_DECL(); |
| 87 | |
| 88 | RTCIceCandidateStats(const RTCIceCandidateStats& other); |
| 89 | ~RTCIceCandidateStats() override; |
| 90 | |
| 91 | RTCStatsMember<std::string> ip; |
| 92 | RTCStatsMember<int32_t> port; |
| 93 | RTCStatsMember<std::string> protocol; |
| 94 | // TODO(hbos): Support enum types? "RTCStatsMember<RTCIceCandidateType>"? |
| 95 | RTCStatsMember<std::string> candidate_type; |
| 96 | RTCStatsMember<int32_t> priority; |
| 97 | RTCStatsMember<std::string> url; |
| 98 | |
| 99 | protected: |
| 100 | RTCIceCandidateStats(const std::string& id, int64_t timestamp_us); |
| 101 | RTCIceCandidateStats(std::string&& id, int64_t timestamp_us); |
| 102 | }; |
| 103 | |
| 104 | // In the spec both local and remote varieties are of type RTCIceCandidateStats. |
| 105 | // But here we define them as subclasses of |RTCIceCandidateStats| because the |
| 106 | // |kType| need to be different ("RTCStatsType type") in the local/remote case. |
| 107 | // https://w3c.github.io/webrtc-stats/#rtcstatstype-str* |
| 108 | class RTCLocalIceCandidateStats final : public RTCIceCandidateStats { |
| 109 | public: |
| 110 | static const char kType[]; |
| 111 | RTCLocalIceCandidateStats(const std::string& id, int64_t timestamp_us); |
| 112 | RTCLocalIceCandidateStats(std::string&& id, int64_t timestamp_us); |
| 113 | const char* type() const override; |
| 114 | }; |
| 115 | |
| 116 | class RTCRemoteIceCandidateStats final : public RTCIceCandidateStats { |
| 117 | public: |
| 118 | static const char kType[]; |
| 119 | RTCRemoteIceCandidateStats(const std::string& id, int64_t timestamp_us); |
| 120 | RTCRemoteIceCandidateStats(std::string&& id, int64_t timestamp_us); |
| 121 | const char* type() const override; |
| 122 | }; |
| 123 | |
hbos | 6ab97ce | 2016-10-03 14:16:56 -0700 | [diff] [blame] | 124 | // https://w3c.github.io/webrtc-stats/#certificatestats-dict* |
hbos | ab9f6e4 | 2016-10-07 02:18:47 -0700 | [diff] [blame] | 125 | class RTCCertificateStats final : public RTCStats { |
hbos | 6ab97ce | 2016-10-03 14:16:56 -0700 | [diff] [blame] | 126 | public: |
hbos | fc5e050 | 2016-10-06 02:06:10 -0700 | [diff] [blame] | 127 | WEBRTC_RTCSTATS_DECL(); |
| 128 | |
hbos | 6ab97ce | 2016-10-03 14:16:56 -0700 | [diff] [blame] | 129 | RTCCertificateStats(const std::string& id, int64_t timestamp_us); |
| 130 | RTCCertificateStats(std::string&& id, int64_t timestamp_us); |
hbos | fc5e050 | 2016-10-06 02:06:10 -0700 | [diff] [blame] | 131 | RTCCertificateStats(const RTCCertificateStats& other); |
| 132 | ~RTCCertificateStats() override; |
hbos | 6ab97ce | 2016-10-03 14:16:56 -0700 | [diff] [blame] | 133 | |
| 134 | RTCStatsMember<std::string> fingerprint; |
| 135 | RTCStatsMember<std::string> fingerprint_algorithm; |
| 136 | RTCStatsMember<std::string> base64_certificate; |
| 137 | RTCStatsMember<std::string> issuer_certificate_id; |
| 138 | }; |
| 139 | |
hbos | cc555c5 | 2016-10-18 12:48:31 -0700 | [diff] [blame^] | 140 | // https://w3c.github.io/webrtc-stats/#dcstats-dict* |
| 141 | class RTCDataChannelStats final : public RTCStats { |
| 142 | public: |
| 143 | WEBRTC_RTCSTATS_DECL(); |
| 144 | |
| 145 | RTCDataChannelStats(const std::string& id, int64_t timestamp_us); |
| 146 | RTCDataChannelStats(std::string&& id, int64_t timestamp_us); |
| 147 | RTCDataChannelStats(const RTCDataChannelStats& other); |
| 148 | ~RTCDataChannelStats() override; |
| 149 | |
| 150 | RTCStatsMember<std::string> label; |
| 151 | RTCStatsMember<std::string> protocol; |
| 152 | RTCStatsMember<int32_t> datachannelid; |
| 153 | // TODO(hbos): Support enum types? "RTCStatsMember<RTCDataChannelState>"? |
| 154 | RTCStatsMember<std::string> state; |
| 155 | RTCStatsMember<uint32_t> messages_sent; |
| 156 | RTCStatsMember<uint64_t> bytes_sent; |
| 157 | RTCStatsMember<uint32_t> messages_received; |
| 158 | RTCStatsMember<uint64_t> bytes_received; |
| 159 | }; |
| 160 | |
hbos | 6ab97ce | 2016-10-03 14:16:56 -0700 | [diff] [blame] | 161 | // https://w3c.github.io/webrtc-stats/#pcstats-dict* |
| 162 | // TODO(hbos): Tracking bug crbug.com/636818 |
hbos | ab9f6e4 | 2016-10-07 02:18:47 -0700 | [diff] [blame] | 163 | class RTCPeerConnectionStats final : public RTCStats { |
hbos | d565b73 | 2016-08-30 14:04:35 -0700 | [diff] [blame] | 164 | public: |
hbos | fc5e050 | 2016-10-06 02:06:10 -0700 | [diff] [blame] | 165 | WEBRTC_RTCSTATS_DECL(); |
| 166 | |
hbos | 0e6758d | 2016-08-31 07:57:36 -0700 | [diff] [blame] | 167 | RTCPeerConnectionStats(const std::string& id, int64_t timestamp_us); |
| 168 | RTCPeerConnectionStats(std::string&& id, int64_t timestamp_us); |
hbos | fc5e050 | 2016-10-06 02:06:10 -0700 | [diff] [blame] | 169 | RTCPeerConnectionStats(const RTCPeerConnectionStats& other); |
| 170 | ~RTCPeerConnectionStats() override; |
hbos | d565b73 | 2016-08-30 14:04:35 -0700 | [diff] [blame] | 171 | |
| 172 | RTCStatsMember<uint32_t> data_channels_opened; |
| 173 | RTCStatsMember<uint32_t> data_channels_closed; |
| 174 | }; |
| 175 | |
| 176 | } // namespace webrtc |
| 177 | |
hbos | 74e1a4f | 2016-09-15 23:33:01 -0700 | [diff] [blame] | 178 | #endif // WEBRTC_API_STATS_RTCSTATS_OBJECTS_H_ |