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 | c47a0c3 | 2016-10-11 14:54:49 -0700 | [diff] [blame^] | 20 | // https://w3c.github.io/webrtc-stats/#dom-rtcstatsicecandidatepairstate |
| 21 | struct RTCStatsIceCandidatePairState { |
| 22 | static const char* kFrozen; |
| 23 | static const char* kWaiting; |
| 24 | static const char* kInProgress; |
| 25 | static const char* kFailed; |
| 26 | static const char* kSucceeded; |
| 27 | static const char* kCancelled; |
| 28 | }; |
| 29 | |
hbos | ab9f6e4 | 2016-10-07 02:18:47 -0700 | [diff] [blame] | 30 | // https://www.w3.org/TR/webrtc/#rtcicecandidatetype-enum |
| 31 | struct RTCIceCandidateType { |
| 32 | static const char* kHost; |
| 33 | static const char* kSrflx; |
| 34 | static const char* kPrflx; |
| 35 | static const char* kRelay; |
| 36 | }; |
| 37 | |
hbos | c47a0c3 | 2016-10-11 14:54:49 -0700 | [diff] [blame^] | 38 | class RTCIceCandidatePairStats : public RTCStats { |
| 39 | public: |
| 40 | WEBRTC_RTCSTATS_DECL(); |
| 41 | |
| 42 | RTCIceCandidatePairStats(const std::string& id, int64_t timestamp_us); |
| 43 | RTCIceCandidatePairStats(std::string&& id, int64_t timestamp_us); |
| 44 | RTCIceCandidatePairStats(const RTCIceCandidatePairStats& other); |
| 45 | ~RTCIceCandidatePairStats() override; |
| 46 | |
| 47 | RTCStatsMember<std::string> transport_id; |
| 48 | RTCStatsMember<std::string> local_candidate_id; |
| 49 | RTCStatsMember<std::string> remote_candidate_id; |
| 50 | // TODO(hbos): Support enum types? |
| 51 | // "RTCStatsMember<RTCStatsIceCandidatePairState>"? |
| 52 | RTCStatsMember<std::string> state; |
| 53 | RTCStatsMember<uint64_t> priority; |
| 54 | RTCStatsMember<bool> nominated; |
| 55 | RTCStatsMember<bool> writable; |
| 56 | RTCStatsMember<bool> readable; |
| 57 | RTCStatsMember<uint64_t> bytes_sent; |
| 58 | RTCStatsMember<uint64_t> bytes_received; |
| 59 | RTCStatsMember<double> total_rtt; |
| 60 | RTCStatsMember<double> current_rtt; |
| 61 | RTCStatsMember<double> available_outgoing_bitrate; |
| 62 | RTCStatsMember<double> available_incoming_bitrate; |
| 63 | RTCStatsMember<uint64_t> requests_received; |
| 64 | RTCStatsMember<uint64_t> requests_sent; |
| 65 | RTCStatsMember<uint64_t> responses_received; |
| 66 | RTCStatsMember<uint64_t> responses_sent; |
| 67 | RTCStatsMember<uint64_t> retransmissions_received; |
| 68 | RTCStatsMember<uint64_t> retransmissions_sent; |
| 69 | RTCStatsMember<uint64_t> consent_requests_received; |
| 70 | RTCStatsMember<uint64_t> consent_requests_sent; |
| 71 | RTCStatsMember<uint64_t> consent_responses_received; |
| 72 | RTCStatsMember<uint64_t> consent_responses_sent; |
| 73 | }; |
| 74 | |
hbos | ab9f6e4 | 2016-10-07 02:18:47 -0700 | [diff] [blame] | 75 | // https://w3c.github.io/webrtc-stats/#icecandidate-dict* |
| 76 | class RTCIceCandidateStats : public RTCStats { |
| 77 | public: |
| 78 | WEBRTC_RTCSTATS_DECL(); |
| 79 | |
| 80 | RTCIceCandidateStats(const RTCIceCandidateStats& other); |
| 81 | ~RTCIceCandidateStats() override; |
| 82 | |
| 83 | RTCStatsMember<std::string> ip; |
| 84 | RTCStatsMember<int32_t> port; |
| 85 | RTCStatsMember<std::string> protocol; |
| 86 | // TODO(hbos): Support enum types? "RTCStatsMember<RTCIceCandidateType>"? |
| 87 | RTCStatsMember<std::string> candidate_type; |
| 88 | RTCStatsMember<int32_t> priority; |
| 89 | RTCStatsMember<std::string> url; |
| 90 | |
| 91 | protected: |
| 92 | RTCIceCandidateStats(const std::string& id, int64_t timestamp_us); |
| 93 | RTCIceCandidateStats(std::string&& id, int64_t timestamp_us); |
| 94 | }; |
| 95 | |
| 96 | // In the spec both local and remote varieties are of type RTCIceCandidateStats. |
| 97 | // But here we define them as subclasses of |RTCIceCandidateStats| because the |
| 98 | // |kType| need to be different ("RTCStatsType type") in the local/remote case. |
| 99 | // https://w3c.github.io/webrtc-stats/#rtcstatstype-str* |
| 100 | class RTCLocalIceCandidateStats final : public RTCIceCandidateStats { |
| 101 | public: |
| 102 | static const char kType[]; |
| 103 | RTCLocalIceCandidateStats(const std::string& id, int64_t timestamp_us); |
| 104 | RTCLocalIceCandidateStats(std::string&& id, int64_t timestamp_us); |
| 105 | const char* type() const override; |
| 106 | }; |
| 107 | |
| 108 | class RTCRemoteIceCandidateStats final : public RTCIceCandidateStats { |
| 109 | public: |
| 110 | static const char kType[]; |
| 111 | RTCRemoteIceCandidateStats(const std::string& id, int64_t timestamp_us); |
| 112 | RTCRemoteIceCandidateStats(std::string&& id, int64_t timestamp_us); |
| 113 | const char* type() const override; |
| 114 | }; |
| 115 | |
hbos | 6ab97ce | 2016-10-03 14:16:56 -0700 | [diff] [blame] | 116 | // https://w3c.github.io/webrtc-stats/#certificatestats-dict* |
hbos | ab9f6e4 | 2016-10-07 02:18:47 -0700 | [diff] [blame] | 117 | class RTCCertificateStats final : public RTCStats { |
hbos | 6ab97ce | 2016-10-03 14:16:56 -0700 | [diff] [blame] | 118 | public: |
hbos | fc5e050 | 2016-10-06 02:06:10 -0700 | [diff] [blame] | 119 | WEBRTC_RTCSTATS_DECL(); |
| 120 | |
hbos | 6ab97ce | 2016-10-03 14:16:56 -0700 | [diff] [blame] | 121 | RTCCertificateStats(const std::string& id, int64_t timestamp_us); |
| 122 | RTCCertificateStats(std::string&& id, int64_t timestamp_us); |
hbos | fc5e050 | 2016-10-06 02:06:10 -0700 | [diff] [blame] | 123 | RTCCertificateStats(const RTCCertificateStats& other); |
| 124 | ~RTCCertificateStats() override; |
hbos | 6ab97ce | 2016-10-03 14:16:56 -0700 | [diff] [blame] | 125 | |
| 126 | RTCStatsMember<std::string> fingerprint; |
| 127 | RTCStatsMember<std::string> fingerprint_algorithm; |
| 128 | RTCStatsMember<std::string> base64_certificate; |
| 129 | RTCStatsMember<std::string> issuer_certificate_id; |
| 130 | }; |
| 131 | |
| 132 | // https://w3c.github.io/webrtc-stats/#pcstats-dict* |
| 133 | // TODO(hbos): Tracking bug crbug.com/636818 |
hbos | ab9f6e4 | 2016-10-07 02:18:47 -0700 | [diff] [blame] | 134 | class RTCPeerConnectionStats final : public RTCStats { |
hbos | d565b73 | 2016-08-30 14:04:35 -0700 | [diff] [blame] | 135 | public: |
hbos | fc5e050 | 2016-10-06 02:06:10 -0700 | [diff] [blame] | 136 | WEBRTC_RTCSTATS_DECL(); |
| 137 | |
hbos | 0e6758d | 2016-08-31 07:57:36 -0700 | [diff] [blame] | 138 | RTCPeerConnectionStats(const std::string& id, int64_t timestamp_us); |
| 139 | RTCPeerConnectionStats(std::string&& id, int64_t timestamp_us); |
hbos | fc5e050 | 2016-10-06 02:06:10 -0700 | [diff] [blame] | 140 | RTCPeerConnectionStats(const RTCPeerConnectionStats& other); |
| 141 | ~RTCPeerConnectionStats() override; |
hbos | d565b73 | 2016-08-30 14:04:35 -0700 | [diff] [blame] | 142 | |
| 143 | RTCStatsMember<uint32_t> data_channels_opened; |
| 144 | RTCStatsMember<uint32_t> data_channels_closed; |
| 145 | }; |
| 146 | |
| 147 | } // namespace webrtc |
| 148 | |
hbos | 74e1a4f | 2016-09-15 23:33:01 -0700 | [diff] [blame] | 149 | #endif // WEBRTC_API_STATS_RTCSTATS_OBJECTS_H_ |