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 | ab9f6e4 | 2016-10-07 02:18:47 -0700 | [diff] [blame] | 20 | // https://www.w3.org/TR/webrtc/#rtcicecandidatetype-enum |
| 21 | struct RTCIceCandidateType { |
| 22 | static const char* kHost; |
| 23 | static const char* kSrflx; |
| 24 | static const char* kPrflx; |
| 25 | static const char* kRelay; |
| 26 | }; |
| 27 | |
| 28 | // https://w3c.github.io/webrtc-stats/#icecandidate-dict* |
| 29 | class RTCIceCandidateStats : public RTCStats { |
| 30 | public: |
| 31 | WEBRTC_RTCSTATS_DECL(); |
| 32 | |
| 33 | RTCIceCandidateStats(const RTCIceCandidateStats& other); |
| 34 | ~RTCIceCandidateStats() override; |
| 35 | |
| 36 | RTCStatsMember<std::string> ip; |
| 37 | RTCStatsMember<int32_t> port; |
| 38 | RTCStatsMember<std::string> protocol; |
| 39 | // TODO(hbos): Support enum types? "RTCStatsMember<RTCIceCandidateType>"? |
| 40 | RTCStatsMember<std::string> candidate_type; |
| 41 | RTCStatsMember<int32_t> priority; |
| 42 | RTCStatsMember<std::string> url; |
| 43 | |
| 44 | protected: |
| 45 | RTCIceCandidateStats(const std::string& id, int64_t timestamp_us); |
| 46 | RTCIceCandidateStats(std::string&& id, int64_t timestamp_us); |
| 47 | }; |
| 48 | |
| 49 | // In the spec both local and remote varieties are of type RTCIceCandidateStats. |
| 50 | // But here we define them as subclasses of |RTCIceCandidateStats| because the |
| 51 | // |kType| need to be different ("RTCStatsType type") in the local/remote case. |
| 52 | // https://w3c.github.io/webrtc-stats/#rtcstatstype-str* |
| 53 | class RTCLocalIceCandidateStats final : public RTCIceCandidateStats { |
| 54 | public: |
| 55 | static const char kType[]; |
| 56 | RTCLocalIceCandidateStats(const std::string& id, int64_t timestamp_us); |
| 57 | RTCLocalIceCandidateStats(std::string&& id, int64_t timestamp_us); |
| 58 | const char* type() const override; |
| 59 | }; |
| 60 | |
| 61 | class RTCRemoteIceCandidateStats final : public RTCIceCandidateStats { |
| 62 | public: |
| 63 | static const char kType[]; |
| 64 | RTCRemoteIceCandidateStats(const std::string& id, int64_t timestamp_us); |
| 65 | RTCRemoteIceCandidateStats(std::string&& id, int64_t timestamp_us); |
| 66 | const char* type() const override; |
| 67 | }; |
| 68 | |
hbos | 6ab97ce | 2016-10-03 14:16:56 -0700 | [diff] [blame] | 69 | // https://w3c.github.io/webrtc-stats/#certificatestats-dict* |
hbos | ab9f6e4 | 2016-10-07 02:18:47 -0700 | [diff] [blame] | 70 | class RTCCertificateStats final : public RTCStats { |
hbos | 6ab97ce | 2016-10-03 14:16:56 -0700 | [diff] [blame] | 71 | public: |
hbos | fc5e050 | 2016-10-06 02:06:10 -0700 | [diff] [blame] | 72 | WEBRTC_RTCSTATS_DECL(); |
| 73 | |
hbos | 6ab97ce | 2016-10-03 14:16:56 -0700 | [diff] [blame] | 74 | RTCCertificateStats(const std::string& id, int64_t timestamp_us); |
| 75 | RTCCertificateStats(std::string&& id, int64_t timestamp_us); |
hbos | fc5e050 | 2016-10-06 02:06:10 -0700 | [diff] [blame] | 76 | RTCCertificateStats(const RTCCertificateStats& other); |
| 77 | ~RTCCertificateStats() override; |
hbos | 6ab97ce | 2016-10-03 14:16:56 -0700 | [diff] [blame] | 78 | |
| 79 | RTCStatsMember<std::string> fingerprint; |
| 80 | RTCStatsMember<std::string> fingerprint_algorithm; |
| 81 | RTCStatsMember<std::string> base64_certificate; |
| 82 | RTCStatsMember<std::string> issuer_certificate_id; |
| 83 | }; |
| 84 | |
| 85 | // https://w3c.github.io/webrtc-stats/#pcstats-dict* |
| 86 | // TODO(hbos): Tracking bug crbug.com/636818 |
hbos | ab9f6e4 | 2016-10-07 02:18:47 -0700 | [diff] [blame] | 87 | class RTCPeerConnectionStats final : public RTCStats { |
hbos | d565b73 | 2016-08-30 14:04:35 -0700 | [diff] [blame] | 88 | public: |
hbos | fc5e050 | 2016-10-06 02:06:10 -0700 | [diff] [blame] | 89 | WEBRTC_RTCSTATS_DECL(); |
| 90 | |
hbos | 0e6758d | 2016-08-31 07:57:36 -0700 | [diff] [blame] | 91 | RTCPeerConnectionStats(const std::string& id, int64_t timestamp_us); |
| 92 | RTCPeerConnectionStats(std::string&& id, int64_t timestamp_us); |
hbos | fc5e050 | 2016-10-06 02:06:10 -0700 | [diff] [blame] | 93 | RTCPeerConnectionStats(const RTCPeerConnectionStats& other); |
| 94 | ~RTCPeerConnectionStats() override; |
hbos | d565b73 | 2016-08-30 14:04:35 -0700 | [diff] [blame] | 95 | |
| 96 | RTCStatsMember<uint32_t> data_channels_opened; |
| 97 | RTCStatsMember<uint32_t> data_channels_closed; |
| 98 | }; |
| 99 | |
| 100 | } // namespace webrtc |
| 101 | |
hbos | 74e1a4f | 2016-09-15 23:33:01 -0700 | [diff] [blame] | 102 | #endif // WEBRTC_API_STATS_RTCSTATS_OBJECTS_H_ |