hbos | 74e1a4f | 2016-09-15 23:33:01 -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 | |
Steve Anton | 10542f2 | 2019-01-11 09:11:00 -0800 | [diff] [blame] | 11 | #ifndef API_STATS_RTC_STATS_H_ |
| 12 | #define API_STATS_RTC_STATS_H_ |
hbos | 74e1a4f | 2016-09-15 23:33:01 -0700 | [diff] [blame] | 13 | |
Yves Gerey | 3e70781 | 2018-11-28 16:47:49 +0100 | [diff] [blame] | 14 | #include <stddef.h> |
| 15 | #include <stdint.h> |
Jonas Olsson | a4d8737 | 2019-07-05 19:08:33 +0200 | [diff] [blame] | 16 | |
Byoungchan Lee | 0a52ede | 2021-05-22 08:41:02 +0900 | [diff] [blame] | 17 | #include <map> |
hbos | 74e1a4f | 2016-09-15 23:33:01 -0700 | [diff] [blame] | 18 | #include <memory> |
| 19 | #include <string> |
| 20 | #include <utility> |
| 21 | #include <vector> |
| 22 | |
Philipp Hancke | 8e7a105 | 2022-10-13 13:14:01 +0200 | [diff] [blame] | 23 | #include "absl/types/optional.h" |
Philipp Hancke | b81823a | 2023-01-04 15:17:42 +0100 | [diff] [blame] | 24 | #include "api/units/timestamp.h" |
Mirko Bonadei | 92ea95e | 2017-09-15 06:47:31 +0200 | [diff] [blame] | 25 | #include "rtc_base/checks.h" |
Mirko Bonadei | 276827c | 2018-10-16 14:13:50 +0200 | [diff] [blame] | 26 | #include "rtc_base/system/rtc_export.h" |
Mirko Bonadei | 054f185 | 2019-11-04 16:31:08 +0100 | [diff] [blame] | 27 | #include "rtc_base/system/rtc_export_template.h" |
hbos | 74e1a4f | 2016-09-15 23:33:01 -0700 | [diff] [blame] | 28 | |
| 29 | namespace webrtc { |
| 30 | |
| 31 | class RTCStatsMemberInterface; |
| 32 | |
| 33 | // Abstract base class for RTCStats-derived dictionaries, see |
| 34 | // https://w3c.github.io/webrtc-stats/. |
| 35 | // |
| 36 | // All derived classes must have the following static variable defined: |
| 37 | // static const char kType[]; |
| 38 | // It is used as a unique class identifier and a string representation of the |
| 39 | // class type, see https://w3c.github.io/webrtc-stats/#rtcstatstype-str*. |
Artem Titov | 0e61fdd | 2021-07-25 21:50:14 +0200 | [diff] [blame] | 40 | // Use the `WEBRTC_RTCSTATS_IMPL` macro when implementing subclasses, see macro |
hbos | 74e1a4f | 2016-09-15 23:33:01 -0700 | [diff] [blame] | 41 | // for details. |
| 42 | // |
| 43 | // Derived classes list their dictionary members, RTCStatsMember<T>, as public |
| 44 | // fields, allowing the following: |
| 45 | // |
Philipp Hancke | b81823a | 2023-01-04 15:17:42 +0100 | [diff] [blame] | 46 | // RTCFooStats foo("fooId", Timestamp::Micros(GetCurrentTime())); |
hbos | 74e1a4f | 2016-09-15 23:33:01 -0700 | [diff] [blame] | 47 | // foo.bar = 42; |
| 48 | // foo.baz = std::vector<std::string>(); |
| 49 | // foo.baz->push_back("hello world"); |
| 50 | // uint32_t x = *foo.bar; |
| 51 | // |
Artem Titov | 0e61fdd | 2021-07-25 21:50:14 +0200 | [diff] [blame] | 52 | // Pointers to all the members are available with `Members`, allowing iteration: |
hbos | 74e1a4f | 2016-09-15 23:33:01 -0700 | [diff] [blame] | 53 | // |
| 54 | // for (const RTCStatsMemberInterface* member : foo.Members()) { |
| 55 | // printf("%s = %s\n", member->name(), member->ValueToString().c_str()); |
| 56 | // } |
Mirko Bonadei | 276827c | 2018-10-16 14:13:50 +0200 | [diff] [blame] | 57 | class RTC_EXPORT RTCStats { |
hbos | 74e1a4f | 2016-09-15 23:33:01 -0700 | [diff] [blame] | 58 | public: |
Philipp Hancke | b81823a | 2023-01-04 15:17:42 +0100 | [diff] [blame] | 59 | RTCStats(const std::string& id, Timestamp timestamp) |
| 60 | : id_(id), timestamp_(timestamp) {} |
Philipp Hancke | e137c45 | 2023-01-10 13:06:02 +0100 | [diff] [blame^] | 61 | ABSL_DEPRECATED("Use constructor with Timestamp instead") |
Philipp Hancke | 7a5de44 | 2023-01-02 13:20:45 +0100 | [diff] [blame] | 62 | RTCStats(std::string id, int64_t timestamp_us) |
Philipp Hancke | b81823a | 2023-01-04 15:17:42 +0100 | [diff] [blame] | 63 | : RTCStats(std::move(id), Timestamp::Micros(timestamp_us)) {} |
| 64 | |
hbos | 74e1a4f | 2016-09-15 23:33:01 -0700 | [diff] [blame] | 65 | virtual ~RTCStats() {} |
| 66 | |
| 67 | virtual std::unique_ptr<RTCStats> copy() const = 0; |
| 68 | |
| 69 | const std::string& id() const { return id_; } |
| 70 | // Time relative to the UNIX epoch (Jan 1, 1970, UTC), in microseconds. |
Philipp Hancke | e137c45 | 2023-01-10 13:06:02 +0100 | [diff] [blame^] | 71 | ABSL_DEPRECATED("Use .timestamp().us() instead") |
Philipp Hancke | b81823a | 2023-01-04 15:17:42 +0100 | [diff] [blame] | 72 | int64_t timestamp_us() const { return timestamp_.us(); } |
| 73 | Timestamp timestamp() const { return timestamp_; } |
| 74 | |
Artem Titov | 0e61fdd | 2021-07-25 21:50:14 +0200 | [diff] [blame] | 75 | // Returns the static member variable `kType` of the implementing class. |
hbos | 74e1a4f | 2016-09-15 23:33:01 -0700 | [diff] [blame] | 76 | virtual const char* type() const = 0; |
Artem Titov | 0e61fdd | 2021-07-25 21:50:14 +0200 | [diff] [blame] | 77 | // Returns a vector of pointers to all the `RTCStatsMemberInterface` members |
hbos | 67c8bc4 | 2016-10-25 04:31:23 -0700 | [diff] [blame] | 78 | // of this class. This allows for iteration of members. For a given class, |
Artem Titov | 0e61fdd | 2021-07-25 21:50:14 +0200 | [diff] [blame] | 79 | // `Members` always returns the same members in the same order. |
hbos | 74e1a4f | 2016-09-15 23:33:01 -0700 | [diff] [blame] | 80 | std::vector<const RTCStatsMemberInterface*> Members() const; |
hbos | 67c8bc4 | 2016-10-25 04:31:23 -0700 | [diff] [blame] | 81 | // Checks if the two stats objects are of the same type and have the same |
hbos | 0583b28 | 2016-11-30 01:50:14 -0800 | [diff] [blame] | 82 | // member values. Timestamps are not compared. These operators are exposed for |
| 83 | // testing. |
hbos | 67c8bc4 | 2016-10-25 04:31:23 -0700 | [diff] [blame] | 84 | bool operator==(const RTCStats& other) const; |
| 85 | bool operator!=(const RTCStats& other) const; |
hbos | 74e1a4f | 2016-09-15 23:33:01 -0700 | [diff] [blame] | 86 | |
ehmaldonado | 35a872c | 2017-07-28 07:29:12 -0700 | [diff] [blame] | 87 | // Creates a JSON readable string representation of the stats |
| 88 | // object, listing all of its members (names and values). |
| 89 | std::string ToJson() const; |
hbos | 74e1a4f | 2016-09-15 23:33:01 -0700 | [diff] [blame] | 90 | |
Artem Titov | 0e61fdd | 2021-07-25 21:50:14 +0200 | [diff] [blame] | 91 | // Downcasts the stats object to an `RTCStats` subclass `T`. DCHECKs that the |
| 92 | // object is of type `T`. |
Yves Gerey | 665174f | 2018-06-19 15:03:05 +0200 | [diff] [blame] | 93 | template <typename T> |
hbos | 74e1a4f | 2016-09-15 23:33:01 -0700 | [diff] [blame] | 94 | const T& cast_to() const { |
| 95 | RTC_DCHECK_EQ(type(), T::kType); |
| 96 | return static_cast<const T&>(*this); |
| 97 | } |
| 98 | |
| 99 | protected: |
Artem Titov | 0e61fdd | 2021-07-25 21:50:14 +0200 | [diff] [blame] | 100 | // Gets a vector of all members of this `RTCStats` object, including members |
| 101 | // derived from parent classes. `additional_capacity` is how many more members |
hbos | 74e1a4f | 2016-09-15 23:33:01 -0700 | [diff] [blame] | 102 | // shall be reserved in the vector (so that subclasses can allocate a vector |
| 103 | // with room for both parent and child members without it having to resize). |
| 104 | virtual std::vector<const RTCStatsMemberInterface*> |
Yves Gerey | 665174f | 2018-06-19 15:03:05 +0200 | [diff] [blame] | 105 | MembersOfThisObjectAndAncestors(size_t additional_capacity) const; |
hbos | 74e1a4f | 2016-09-15 23:33:01 -0700 | [diff] [blame] | 106 | |
| 107 | std::string const id_; |
Philipp Hancke | b81823a | 2023-01-04 15:17:42 +0100 | [diff] [blame] | 108 | Timestamp timestamp_; |
hbos | 74e1a4f | 2016-09-15 23:33:01 -0700 | [diff] [blame] | 109 | }; |
| 110 | |
Artem Titov | 0e61fdd | 2021-07-25 21:50:14 +0200 | [diff] [blame] | 111 | // All `RTCStats` classes should use these macros. |
| 112 | // `WEBRTC_RTCSTATS_DECL` is placed in a public section of the class definition. |
| 113 | // `WEBRTC_RTCSTATS_IMPL` is placed outside the class definition (in a .cc). |
hbos | 74e1a4f | 2016-09-15 23:33:01 -0700 | [diff] [blame] | 114 | // |
Artem Titov | 0e61fdd | 2021-07-25 21:50:14 +0200 | [diff] [blame] | 115 | // These macros declare (in _DECL) and define (in _IMPL) the static `kType` and |
| 116 | // overrides methods as required by subclasses of `RTCStats`: `copy`, `type` and |
| 117 | // `MembersOfThisObjectAndAncestors`. The |...| argument is a list of addresses |
hbos | fc5e050 | 2016-10-06 02:06:10 -0700 | [diff] [blame] | 118 | // to each member defined in the implementing class. The list must have at least |
| 119 | // one member. |
hbos | 74e1a4f | 2016-09-15 23:33:01 -0700 | [diff] [blame] | 120 | // |
| 121 | // (Since class names need to be known to implement these methods this cannot be |
Artem Titov | 0e61fdd | 2021-07-25 21:50:14 +0200 | [diff] [blame] | 122 | // part of the base `RTCStats`. While these methods could be implemented using |
hbos | 74e1a4f | 2016-09-15 23:33:01 -0700 | [diff] [blame] | 123 | // templates, that would only work for immediate subclasses. Subclasses of |
| 124 | // subclasses also have to override these methods, resulting in boilerplate |
Artem Titov | 0e61fdd | 2021-07-25 21:50:14 +0200 | [diff] [blame] | 125 | // code. Using a macro avoids this and works for any `RTCStats` class, including |
hbos | 74e1a4f | 2016-09-15 23:33:01 -0700 | [diff] [blame] | 126 | // grandchildren.) |
| 127 | // |
| 128 | // Sample usage: |
| 129 | // |
| 130 | // rtcfoostats.h: |
| 131 | // class RTCFooStats : public RTCStats { |
| 132 | // public: |
hbos | fc5e050 | 2016-10-06 02:06:10 -0700 | [diff] [blame] | 133 | // WEBRTC_RTCSTATS_DECL(); |
hbos | 74e1a4f | 2016-09-15 23:33:01 -0700 | [diff] [blame] | 134 | // |
hbos | fc5e050 | 2016-10-06 02:06:10 -0700 | [diff] [blame] | 135 | // RTCFooStats(const std::string& id, int64_t timestamp_us); |
hbos | 74e1a4f | 2016-09-15 23:33:01 -0700 | [diff] [blame] | 136 | // |
| 137 | // RTCStatsMember<int32_t> foo; |
| 138 | // RTCStatsMember<int32_t> bar; |
| 139 | // }; |
| 140 | // |
| 141 | // rtcfoostats.cc: |
hbos | fc5e050 | 2016-10-06 02:06:10 -0700 | [diff] [blame] | 142 | // WEBRTC_RTCSTATS_IMPL(RTCFooStats, RTCStats, "foo-stats" |
| 143 | // &foo, |
| 144 | // &bar); |
hbos | 74e1a4f | 2016-09-15 23:33:01 -0700 | [diff] [blame] | 145 | // |
hbos | fc5e050 | 2016-10-06 02:06:10 -0700 | [diff] [blame] | 146 | // RTCFooStats::RTCFooStats(const std::string& id, int64_t timestamp_us) |
| 147 | // : RTCStats(id, timestamp_us), |
| 148 | // foo("foo"), |
| 149 | // bar("bar") { |
| 150 | // } |
| 151 | // |
Yves Gerey | 665174f | 2018-06-19 15:03:05 +0200 | [diff] [blame] | 152 | #define WEBRTC_RTCSTATS_DECL() \ |
Yves Gerey | 665174f | 2018-06-19 15:03:05 +0200 | [diff] [blame] | 153 | protected: \ |
| 154 | std::vector<const webrtc::RTCStatsMemberInterface*> \ |
| 155 | MembersOfThisObjectAndAncestors(size_t local_var_additional_capacity) \ |
| 156 | const override; \ |
| 157 | \ |
Nico Weber | 22f9925 | 2019-02-20 10:13:16 -0500 | [diff] [blame] | 158 | public: \ |
| 159 | static const char kType[]; \ |
| 160 | \ |
| 161 | std::unique_ptr<webrtc::RTCStats> copy() const override; \ |
| 162 | const char* type() const override |
hbos | fc5e050 | 2016-10-06 02:06:10 -0700 | [diff] [blame] | 163 | |
| 164 | #define WEBRTC_RTCSTATS_IMPL(this_class, parent_class, type_str, ...) \ |
| 165 | const char this_class::kType[] = type_str; \ |
| 166 | \ |
| 167 | std::unique_ptr<webrtc::RTCStats> this_class::copy() const { \ |
Philipp Hancke | b5cf12d | 2022-09-06 11:55:31 +0200 | [diff] [blame] | 168 | return std::make_unique<this_class>(*this); \ |
hbos | fc5e050 | 2016-10-06 02:06:10 -0700 | [diff] [blame] | 169 | } \ |
| 170 | \ |
Yves Gerey | 665174f | 2018-06-19 15:03:05 +0200 | [diff] [blame] | 171 | const char* this_class::type() const { return this_class::kType; } \ |
hbos | fc5e050 | 2016-10-06 02:06:10 -0700 | [diff] [blame] | 172 | \ |
| 173 | std::vector<const webrtc::RTCStatsMemberInterface*> \ |
| 174 | this_class::MembersOfThisObjectAndAncestors( \ |
| 175 | size_t local_var_additional_capacity) const { \ |
hbos | 74e1a4f | 2016-09-15 23:33:01 -0700 | [diff] [blame] | 176 | const webrtc::RTCStatsMemberInterface* local_var_members[] = { \ |
Yves Gerey | 665174f | 2018-06-19 15:03:05 +0200 | [diff] [blame] | 177 | __VA_ARGS__}; \ |
hbos | 74e1a4f | 2016-09-15 23:33:01 -0700 | [diff] [blame] | 178 | size_t local_var_members_count = \ |
| 179 | sizeof(local_var_members) / sizeof(local_var_members[0]); \ |
Yves Gerey | 665174f | 2018-06-19 15:03:05 +0200 | [diff] [blame] | 180 | std::vector<const webrtc::RTCStatsMemberInterface*> \ |
| 181 | local_var_members_vec = parent_class::MembersOfThisObjectAndAncestors( \ |
hbos | 74e1a4f | 2016-09-15 23:33:01 -0700 | [diff] [blame] | 182 | local_var_members_count + local_var_additional_capacity); \ |
| 183 | RTC_DCHECK_GE( \ |
| 184 | local_var_members_vec.capacity() - local_var_members_vec.size(), \ |
| 185 | local_var_members_count + local_var_additional_capacity); \ |
| 186 | local_var_members_vec.insert(local_var_members_vec.end(), \ |
| 187 | &local_var_members[0], \ |
| 188 | &local_var_members[local_var_members_count]); \ |
| 189 | return local_var_members_vec; \ |
hbos | fc5e050 | 2016-10-06 02:06:10 -0700 | [diff] [blame] | 190 | } |
hbos | 74e1a4f | 2016-09-15 23:33:01 -0700 | [diff] [blame] | 191 | |
Henrik Boström | 646fda0 | 2019-05-22 15:49:42 +0200 | [diff] [blame] | 192 | // A version of WEBRTC_RTCSTATS_IMPL() where "..." is omitted, used to avoid a |
| 193 | // compile error on windows. This is used if the stats dictionary does not |
| 194 | // declare any members of its own (but perhaps its parent dictionary does). |
| 195 | #define WEBRTC_RTCSTATS_IMPL_NO_MEMBERS(this_class, parent_class, type_str) \ |
| 196 | const char this_class::kType[] = type_str; \ |
| 197 | \ |
| 198 | std::unique_ptr<webrtc::RTCStats> this_class::copy() const { \ |
Philipp Hancke | b5cf12d | 2022-09-06 11:55:31 +0200 | [diff] [blame] | 199 | return std::make_unique<this_class>(*this); \ |
Henrik Boström | 646fda0 | 2019-05-22 15:49:42 +0200 | [diff] [blame] | 200 | } \ |
| 201 | \ |
| 202 | const char* this_class::type() const { return this_class::kType; } \ |
| 203 | \ |
| 204 | std::vector<const webrtc::RTCStatsMemberInterface*> \ |
| 205 | this_class::MembersOfThisObjectAndAncestors( \ |
| 206 | size_t local_var_additional_capacity) const { \ |
| 207 | return parent_class::MembersOfThisObjectAndAncestors(0); \ |
| 208 | } |
| 209 | |
Jakob Ivarsson | 2293622 | 2019-03-22 11:29:49 +0100 | [diff] [blame] | 210 | // Non-standard stats members can be exposed to the JavaScript API in Chrome |
| 211 | // e.g. through origin trials. The group ID can be used by the blink layer to |
| 212 | // determine if a stats member should be exposed or not. Multiple non-standard |
| 213 | // stats members can share the same group ID so that they are exposed together. |
| 214 | enum class NonStandardGroupId { |
Jakob Ivarsson | aa023e2 | 2019-03-27 10:17:31 +0100 | [diff] [blame] | 215 | // Group ID used for testing purposes only. |
| 216 | kGroupIdForTesting, |
Jakob Ivarsson | 2293622 | 2019-03-22 11:29:49 +0100 | [diff] [blame] | 217 | // I2E: |
| 218 | // https://groups.google.com/a/chromium.org/forum/#!topic/blink-dev/hE2B1iItPDk |
| 219 | kRtcAudioJitterBufferMaxPackets, |
| 220 | // I2E: |
| 221 | // https://groups.google.com/a/chromium.org/forum/#!topic/blink-dev/YbhMyqLXXXo |
| 222 | kRtcStatsRelativePacketArrivalDelay, |
| 223 | }; |
| 224 | |
Evan Shrubsole | 6c733ee | 2022-10-12 15:11:14 +0000 | [diff] [blame] | 225 | // Certain stat members should only be exposed to the JavaScript API in |
| 226 | // certain circumstances as to avoid passive fingerprinting. |
| 227 | enum class StatExposureCriteria : uint8_t { |
| 228 | // The stat should always be exposed. This is the default. |
| 229 | kAlways, |
| 230 | // The stat exposes hardware capabilities and thus should has limited exposure |
| 231 | // to JavaScript. The requirements for exposure are written in the spec at |
| 232 | // https://w3c.github.io/webrtc-stats/#limiting-exposure-of-hardware-capabilities. |
| 233 | kHardwareCapability, |
Evan Shrubsole | 7ef0c1a | 2022-10-31 11:05:33 +0000 | [diff] [blame] | 234 | // The stat is non-standard so user agents should filter these. |
| 235 | kNonStandard, |
Evan Shrubsole | 6c733ee | 2022-10-12 15:11:14 +0000 | [diff] [blame] | 236 | }; |
| 237 | |
Artem Titov | 0e61fdd | 2021-07-25 21:50:14 +0200 | [diff] [blame] | 238 | // Interface for `RTCStats` members, which have a name and a value of a type |
| 239 | // defined in a subclass. Only the types listed in `Type` are supported, these |
Artem Titov | cfea218 | 2021-08-10 01:22:31 +0200 | [diff] [blame] | 240 | // are implemented by `RTCStatsMember<T>`. The value of a member may be |
Artem Titov | 0e61fdd | 2021-07-25 21:50:14 +0200 | [diff] [blame] | 241 | // undefined, the value can only be read if `is_defined`. |
hbos | 74e1a4f | 2016-09-15 23:33:01 -0700 | [diff] [blame] | 242 | class RTCStatsMemberInterface { |
| 243 | public: |
| 244 | // Member value types. |
| 245 | enum Type { |
Yves Gerey | 665174f | 2018-06-19 15:03:05 +0200 | [diff] [blame] | 246 | kBool, // bool |
| 247 | kInt32, // int32_t |
| 248 | kUint32, // uint32_t |
| 249 | kInt64, // int64_t |
| 250 | kUint64, // uint64_t |
| 251 | kDouble, // double |
| 252 | kString, // std::string |
hbos | 74e1a4f | 2016-09-15 23:33:01 -0700 | [diff] [blame] | 253 | |
Yves Gerey | 665174f | 2018-06-19 15:03:05 +0200 | [diff] [blame] | 254 | kSequenceBool, // std::vector<bool> |
| 255 | kSequenceInt32, // std::vector<int32_t> |
| 256 | kSequenceUint32, // std::vector<uint32_t> |
| 257 | kSequenceInt64, // std::vector<int64_t> |
| 258 | kSequenceUint64, // std::vector<uint64_t> |
| 259 | kSequenceDouble, // std::vector<double> |
| 260 | kSequenceString, // std::vector<std::string> |
Byoungchan Lee | 0a52ede | 2021-05-22 08:41:02 +0900 | [diff] [blame] | 261 | |
| 262 | kMapStringUint64, // std::map<std::string, uint64_t> |
| 263 | kMapStringDouble, // std::map<std::string, double> |
hbos | 74e1a4f | 2016-09-15 23:33:01 -0700 | [diff] [blame] | 264 | }; |
| 265 | |
| 266 | virtual ~RTCStatsMemberInterface() {} |
| 267 | |
| 268 | const char* name() const { return name_; } |
| 269 | virtual Type type() const = 0; |
| 270 | virtual bool is_sequence() const = 0; |
| 271 | virtual bool is_string() const = 0; |
Philipp Hancke | 8e7a105 | 2022-10-13 13:14:01 +0200 | [diff] [blame] | 272 | virtual bool is_defined() const = 0; |
Taylor Brandstetter | e275174 | 2018-06-25 13:42:44 -0700 | [diff] [blame] | 273 | // Is this part of the stats spec? Used so that chromium can easily filter |
| 274 | // out anything unstandardized. |
Evan Shrubsole | 7ef0c1a | 2022-10-31 11:05:33 +0000 | [diff] [blame] | 275 | bool is_standardized() const { |
| 276 | return exposure_criteria() != StatExposureCriteria::kNonStandard; |
| 277 | } |
Jakob Ivarsson | 2293622 | 2019-03-22 11:29:49 +0100 | [diff] [blame] | 278 | // Non-standard stats members can have group IDs in order to be exposed in |
| 279 | // JavaScript through experiments. Standardized stats have no group IDs. |
| 280 | virtual std::vector<NonStandardGroupId> group_ids() const { return {}; } |
Evan Shrubsole | 6c733ee | 2022-10-12 15:11:14 +0000 | [diff] [blame] | 281 | // The conditions for exposing the statistic to JavaScript. Stats with |
| 282 | // criteria that is not kAlways has some restriction and should be filtered |
| 283 | // in accordance to the spec. |
| 284 | virtual StatExposureCriteria exposure_criteria() const { |
| 285 | return StatExposureCriteria::kAlways; |
| 286 | } |
hbos | 67c8bc4 | 2016-10-25 04:31:23 -0700 | [diff] [blame] | 287 | // Type and value comparator. The names are not compared. These operators are |
| 288 | // exposed for testing. |
Byoungchan Lee | 8c4601b | 2022-09-23 13:59:42 +0900 | [diff] [blame] | 289 | bool operator==(const RTCStatsMemberInterface& other) const { |
| 290 | return IsEqual(other); |
| 291 | } |
hbos | 67c8bc4 | 2016-10-25 04:31:23 -0700 | [diff] [blame] | 292 | bool operator!=(const RTCStatsMemberInterface& other) const { |
| 293 | return !(*this == other); |
| 294 | } |
hbos | 74e1a4f | 2016-09-15 23:33:01 -0700 | [diff] [blame] | 295 | virtual std::string ValueToString() const = 0; |
ehmaldonado | 35a872c | 2017-07-28 07:29:12 -0700 | [diff] [blame] | 296 | // This is the same as ValueToString except for kInt64 and kUint64 types, |
| 297 | // where the value is represented as a double instead of as an integer. |
| 298 | // Since JSON stores numbers as floating point numbers, very large integers |
| 299 | // cannot be accurately represented, so we prefer to display them as doubles |
| 300 | // instead. |
| 301 | virtual std::string ValueToJson() const = 0; |
hbos | 74e1a4f | 2016-09-15 23:33:01 -0700 | [diff] [blame] | 302 | |
Yves Gerey | 665174f | 2018-06-19 15:03:05 +0200 | [diff] [blame] | 303 | template <typename T> |
hbos | 74e1a4f | 2016-09-15 23:33:01 -0700 | [diff] [blame] | 304 | const T& cast_to() const { |
Mirko Bonadei | 054f185 | 2019-11-04 16:31:08 +0100 | [diff] [blame] | 305 | RTC_DCHECK_EQ(type(), T::StaticType()); |
hbos | 74e1a4f | 2016-09-15 23:33:01 -0700 | [diff] [blame] | 306 | return static_cast<const T&>(*this); |
| 307 | } |
| 308 | |
| 309 | protected: |
Philipp Hancke | 8e7a105 | 2022-10-13 13:14:01 +0200 | [diff] [blame] | 310 | explicit RTCStatsMemberInterface(const char* name) : name_(name) {} |
hbos | 74e1a4f | 2016-09-15 23:33:01 -0700 | [diff] [blame] | 311 | |
Byoungchan Lee | 8c4601b | 2022-09-23 13:59:42 +0900 | [diff] [blame] | 312 | virtual bool IsEqual(const RTCStatsMemberInterface& other) const = 0; |
| 313 | |
hbos | 74e1a4f | 2016-09-15 23:33:01 -0700 | [diff] [blame] | 314 | const char* const name_; |
hbos | 74e1a4f | 2016-09-15 23:33:01 -0700 | [diff] [blame] | 315 | }; |
| 316 | |
Artem Titov | 0e61fdd | 2021-07-25 21:50:14 +0200 | [diff] [blame] | 317 | // Template implementation of `RTCStatsMemberInterface`. |
Mirko Bonadei | 054f185 | 2019-11-04 16:31:08 +0100 | [diff] [blame] | 318 | // The supported types are the ones described by |
Artem Titov | cfea218 | 2021-08-10 01:22:31 +0200 | [diff] [blame] | 319 | // `RTCStatsMemberInterface::Type`. |
Yves Gerey | 665174f | 2018-06-19 15:03:05 +0200 | [diff] [blame] | 320 | template <typename T> |
Mirko Bonadei | 1e6aa1f | 2019-11-05 17:20:58 +0100 | [diff] [blame] | 321 | class RTCStatsMember : public RTCStatsMemberInterface { |
hbos | 74e1a4f | 2016-09-15 23:33:01 -0700 | [diff] [blame] | 322 | public: |
hbos | 74e1a4f | 2016-09-15 23:33:01 -0700 | [diff] [blame] | 323 | explicit RTCStatsMember(const char* name) |
Philipp Hancke | 8e7a105 | 2022-10-13 13:14:01 +0200 | [diff] [blame] | 324 | : RTCStatsMemberInterface(name), value_() {} |
hbos | 74e1a4f | 2016-09-15 23:33:01 -0700 | [diff] [blame] | 325 | RTCStatsMember(const char* name, const T& value) |
Philipp Hancke | 8e7a105 | 2022-10-13 13:14:01 +0200 | [diff] [blame] | 326 | : RTCStatsMemberInterface(name), value_(value) {} |
hbos | 74e1a4f | 2016-09-15 23:33:01 -0700 | [diff] [blame] | 327 | RTCStatsMember(const char* name, T&& value) |
Philipp Hancke | 8e7a105 | 2022-10-13 13:14:01 +0200 | [diff] [blame] | 328 | : RTCStatsMemberInterface(name), value_(std::move(value)) {} |
| 329 | explicit RTCStatsMember(const RTCStatsMember<T>& other) |
| 330 | : RTCStatsMemberInterface(other.name_), value_(other.value_) {} |
| 331 | explicit RTCStatsMember(RTCStatsMember<T>&& other) |
| 332 | : RTCStatsMemberInterface(other.name_), value_(std::move(other.value_)) {} |
hbos | 74e1a4f | 2016-09-15 23:33:01 -0700 | [diff] [blame] | 333 | |
Mirko Bonadei | 054f185 | 2019-11-04 16:31:08 +0100 | [diff] [blame] | 334 | static Type StaticType(); |
| 335 | Type type() const override { return StaticType(); } |
hbos | 74e1a4f | 2016-09-15 23:33:01 -0700 | [diff] [blame] | 336 | bool is_sequence() const override; |
| 337 | bool is_string() const override; |
Philipp Hancke | 8e7a105 | 2022-10-13 13:14:01 +0200 | [diff] [blame] | 338 | bool is_defined() const override { return value_.has_value(); } |
hbos | 74e1a4f | 2016-09-15 23:33:01 -0700 | [diff] [blame] | 339 | std::string ValueToString() const override; |
ehmaldonado | 35a872c | 2017-07-28 07:29:12 -0700 | [diff] [blame] | 340 | std::string ValueToJson() const override; |
hbos | 74e1a4f | 2016-09-15 23:33:01 -0700 | [diff] [blame] | 341 | |
Andrey Logvin | 1f0f59f | 2020-06-15 12:49:25 +0000 | [diff] [blame] | 342 | template <typename U> |
| 343 | inline T ValueOrDefault(U default_value) const { |
Philipp Hancke | 8e7a105 | 2022-10-13 13:14:01 +0200 | [diff] [blame] | 344 | return value_.value_or(default_value); |
Andrey Logvin | 1f0f59f | 2020-06-15 12:49:25 +0000 | [diff] [blame] | 345 | } |
| 346 | |
hbos | 74e1a4f | 2016-09-15 23:33:01 -0700 | [diff] [blame] | 347 | // Assignment operators. |
| 348 | T& operator=(const T& value) { |
| 349 | value_ = value; |
Philipp Hancke | 8e7a105 | 2022-10-13 13:14:01 +0200 | [diff] [blame] | 350 | return value_.value(); |
hbos | 74e1a4f | 2016-09-15 23:33:01 -0700 | [diff] [blame] | 351 | } |
| 352 | T& operator=(const T&& value) { |
| 353 | value_ = std::move(value); |
Philipp Hancke | 8e7a105 | 2022-10-13 13:14:01 +0200 | [diff] [blame] | 354 | return value_.value(); |
hbos | 74e1a4f | 2016-09-15 23:33:01 -0700 | [diff] [blame] | 355 | } |
hbos | 74e1a4f | 2016-09-15 23:33:01 -0700 | [diff] [blame] | 356 | |
| 357 | // Value getters. |
| 358 | T& operator*() { |
Philipp Hancke | 8e7a105 | 2022-10-13 13:14:01 +0200 | [diff] [blame] | 359 | RTC_DCHECK(value_); |
| 360 | return *value_; |
hbos | 74e1a4f | 2016-09-15 23:33:01 -0700 | [diff] [blame] | 361 | } |
| 362 | const T& operator*() const { |
Philipp Hancke | 8e7a105 | 2022-10-13 13:14:01 +0200 | [diff] [blame] | 363 | RTC_DCHECK(value_); |
| 364 | return *value_; |
hbos | 74e1a4f | 2016-09-15 23:33:01 -0700 | [diff] [blame] | 365 | } |
| 366 | |
| 367 | // Value getters, arrow operator. |
| 368 | T* operator->() { |
Philipp Hancke | 8e7a105 | 2022-10-13 13:14:01 +0200 | [diff] [blame] | 369 | RTC_DCHECK(value_); |
| 370 | return &(*value_); |
hbos | 74e1a4f | 2016-09-15 23:33:01 -0700 | [diff] [blame] | 371 | } |
| 372 | const T* operator->() const { |
Philipp Hancke | 8e7a105 | 2022-10-13 13:14:01 +0200 | [diff] [blame] | 373 | RTC_DCHECK(value_); |
| 374 | return &(*value_); |
hbos | 74e1a4f | 2016-09-15 23:33:01 -0700 | [diff] [blame] | 375 | } |
| 376 | |
Byoungchan Lee | 8c4601b | 2022-09-23 13:59:42 +0900 | [diff] [blame] | 377 | protected: |
| 378 | bool IsEqual(const RTCStatsMemberInterface& other) const override { |
Evan Shrubsole | 6c733ee | 2022-10-12 15:11:14 +0000 | [diff] [blame] | 379 | if (type() != other.type() || |
| 380 | is_standardized() != other.is_standardized() || |
| 381 | exposure_criteria() != other.exposure_criteria()) |
Byoungchan Lee | 8c4601b | 2022-09-23 13:59:42 +0900 | [diff] [blame] | 382 | return false; |
| 383 | const RTCStatsMember<T>& other_t = |
| 384 | static_cast<const RTCStatsMember<T>&>(other); |
Byoungchan Lee | 8c4601b | 2022-09-23 13:59:42 +0900 | [diff] [blame] | 385 | return value_ == other_t.value_; |
| 386 | } |
| 387 | |
hbos | 74e1a4f | 2016-09-15 23:33:01 -0700 | [diff] [blame] | 388 | private: |
Philipp Hancke | 8e7a105 | 2022-10-13 13:14:01 +0200 | [diff] [blame] | 389 | absl::optional<T> value_; |
hbos | 74e1a4f | 2016-09-15 23:33:01 -0700 | [diff] [blame] | 390 | }; |
| 391 | |
Byoungchan Lee | 0a52ede | 2021-05-22 08:41:02 +0900 | [diff] [blame] | 392 | namespace rtc_stats_internal { |
| 393 | |
| 394 | typedef std::map<std::string, uint64_t> MapStringUint64; |
| 395 | typedef std::map<std::string, double> MapStringDouble; |
| 396 | |
| 397 | } // namespace rtc_stats_internal |
| 398 | |
Mirko Bonadei | 62a19d0 | 2019-11-11 19:59:54 +0100 | [diff] [blame] | 399 | #define WEBRTC_DECLARE_RTCSTATSMEMBER(T) \ |
| 400 | template <> \ |
| 401 | RTC_EXPORT RTCStatsMemberInterface::Type RTCStatsMember<T>::StaticType(); \ |
| 402 | template <> \ |
Mirko Bonadei | 6dd488b | 2019-11-20 14:06:39 +0100 | [diff] [blame] | 403 | RTC_EXPORT bool RTCStatsMember<T>::is_sequence() const; \ |
Mirko Bonadei | 62a19d0 | 2019-11-11 19:59:54 +0100 | [diff] [blame] | 404 | template <> \ |
Mirko Bonadei | 6dd488b | 2019-11-20 14:06:39 +0100 | [diff] [blame] | 405 | RTC_EXPORT bool RTCStatsMember<T>::is_string() const; \ |
Mirko Bonadei | 62a19d0 | 2019-11-11 19:59:54 +0100 | [diff] [blame] | 406 | template <> \ |
Mirko Bonadei | 6dd488b | 2019-11-20 14:06:39 +0100 | [diff] [blame] | 407 | RTC_EXPORT std::string RTCStatsMember<T>::ValueToString() const; \ |
Mirko Bonadei | 62a19d0 | 2019-11-11 19:59:54 +0100 | [diff] [blame] | 408 | template <> \ |
Mirko Bonadei | 6dd488b | 2019-11-20 14:06:39 +0100 | [diff] [blame] | 409 | RTC_EXPORT std::string RTCStatsMember<T>::ValueToJson() const; \ |
Mirko Bonadei | 62a19d0 | 2019-11-11 19:59:54 +0100 | [diff] [blame] | 410 | extern template class RTC_EXPORT_TEMPLATE_DECLARE(RTC_EXPORT) \ |
Mirko Bonadei | 054f185 | 2019-11-04 16:31:08 +0100 | [diff] [blame] | 411 | RTCStatsMember<T> |
| 412 | |
| 413 | WEBRTC_DECLARE_RTCSTATSMEMBER(bool); |
| 414 | WEBRTC_DECLARE_RTCSTATSMEMBER(int32_t); |
| 415 | WEBRTC_DECLARE_RTCSTATSMEMBER(uint32_t); |
| 416 | WEBRTC_DECLARE_RTCSTATSMEMBER(int64_t); |
| 417 | WEBRTC_DECLARE_RTCSTATSMEMBER(uint64_t); |
| 418 | WEBRTC_DECLARE_RTCSTATSMEMBER(double); |
| 419 | WEBRTC_DECLARE_RTCSTATSMEMBER(std::string); |
| 420 | WEBRTC_DECLARE_RTCSTATSMEMBER(std::vector<bool>); |
| 421 | WEBRTC_DECLARE_RTCSTATSMEMBER(std::vector<int32_t>); |
| 422 | WEBRTC_DECLARE_RTCSTATSMEMBER(std::vector<uint32_t>); |
| 423 | WEBRTC_DECLARE_RTCSTATSMEMBER(std::vector<int64_t>); |
| 424 | WEBRTC_DECLARE_RTCSTATSMEMBER(std::vector<uint64_t>); |
| 425 | WEBRTC_DECLARE_RTCSTATSMEMBER(std::vector<double>); |
| 426 | WEBRTC_DECLARE_RTCSTATSMEMBER(std::vector<std::string>); |
Byoungchan Lee | 0a52ede | 2021-05-22 08:41:02 +0900 | [diff] [blame] | 427 | WEBRTC_DECLARE_RTCSTATSMEMBER(rtc_stats_internal::MapStringUint64); |
| 428 | WEBRTC_DECLARE_RTCSTATSMEMBER(rtc_stats_internal::MapStringDouble); |
Mirko Bonadei | 054f185 | 2019-11-04 16:31:08 +0100 | [diff] [blame] | 429 | |
Evan Shrubsole | 6c733ee | 2022-10-12 15:11:14 +0000 | [diff] [blame] | 430 | // For stats with restricted exposure. |
| 431 | template <typename T, StatExposureCriteria E> |
| 432 | class RTCRestrictedStatsMember : public RTCStatsMember<T> { |
| 433 | public: |
| 434 | explicit RTCRestrictedStatsMember(const char* name) |
| 435 | : RTCStatsMember<T>(name) {} |
| 436 | RTCRestrictedStatsMember(const char* name, const T& value) |
| 437 | : RTCStatsMember<T>(name, value) {} |
| 438 | RTCRestrictedStatsMember(const char* name, T&& value) |
| 439 | : RTCStatsMember<T>(name, std::move(value)) {} |
| 440 | RTCRestrictedStatsMember(const RTCRestrictedStatsMember<T, E>& other) |
| 441 | : RTCStatsMember<T>(other) {} |
| 442 | RTCRestrictedStatsMember(RTCRestrictedStatsMember<T, E>&& other) |
| 443 | : RTCStatsMember<T>(std::move(other)) {} |
| 444 | |
| 445 | StatExposureCriteria exposure_criteria() const override { return E; } |
| 446 | |
| 447 | T& operator=(const T& value) { return RTCStatsMember<T>::operator=(value); } |
| 448 | T& operator=(const T&& value) { |
| 449 | return RTCStatsMember<T>::operator=(std::move(value)); |
| 450 | } |
| 451 | |
| 452 | private: |
| 453 | static_assert(E != StatExposureCriteria::kAlways, |
| 454 | "kAlways is the default exposure criteria. Use " |
| 455 | "RTCStatMember<T> instead."); |
| 456 | }; |
| 457 | |
| 458 | extern template class RTC_EXPORT_TEMPLATE_DECLARE(RTC_EXPORT) |
| 459 | RTCRestrictedStatsMember<bool, StatExposureCriteria::kHardwareCapability>; |
| 460 | extern template class RTC_EXPORT_TEMPLATE_DECLARE(RTC_EXPORT) |
| 461 | RTCRestrictedStatsMember<int32_t, |
| 462 | StatExposureCriteria::kHardwareCapability>; |
| 463 | extern template class RTC_EXPORT_TEMPLATE_DECLARE(RTC_EXPORT) |
| 464 | RTCRestrictedStatsMember<uint32_t, |
| 465 | StatExposureCriteria::kHardwareCapability>; |
| 466 | extern template class RTC_EXPORT_TEMPLATE_DECLARE(RTC_EXPORT) |
| 467 | RTCRestrictedStatsMember<int64_t, |
| 468 | StatExposureCriteria::kHardwareCapability>; |
| 469 | extern template class RTC_EXPORT_TEMPLATE_DECLARE(RTC_EXPORT) |
| 470 | RTCRestrictedStatsMember<uint64_t, |
| 471 | StatExposureCriteria::kHardwareCapability>; |
| 472 | extern template class RTC_EXPORT_TEMPLATE_DECLARE(RTC_EXPORT) |
| 473 | RTCRestrictedStatsMember<double, StatExposureCriteria::kHardwareCapability>; |
| 474 | extern template class RTC_EXPORT_TEMPLATE_DECLARE(RTC_EXPORT) |
| 475 | RTCRestrictedStatsMember<std::string, |
| 476 | StatExposureCriteria::kHardwareCapability>; |
| 477 | extern template class RTC_EXPORT_TEMPLATE_DECLARE(RTC_EXPORT) |
| 478 | RTCRestrictedStatsMember<std::vector<bool>, |
| 479 | StatExposureCriteria::kHardwareCapability>; |
| 480 | extern template class RTC_EXPORT_TEMPLATE_DECLARE(RTC_EXPORT) |
| 481 | RTCRestrictedStatsMember<std::vector<int32_t>, |
| 482 | StatExposureCriteria::kHardwareCapability>; |
| 483 | extern template class RTC_EXPORT_TEMPLATE_DECLARE(RTC_EXPORT) |
| 484 | RTCRestrictedStatsMember<std::vector<uint32_t>, |
| 485 | StatExposureCriteria::kHardwareCapability>; |
| 486 | extern template class RTC_EXPORT_TEMPLATE_DECLARE(RTC_EXPORT) |
| 487 | RTCRestrictedStatsMember<std::vector<int64_t>, |
| 488 | StatExposureCriteria::kHardwareCapability>; |
| 489 | extern template class RTC_EXPORT_TEMPLATE_DECLARE(RTC_EXPORT) |
| 490 | RTCRestrictedStatsMember<std::vector<uint64_t>, |
| 491 | StatExposureCriteria::kHardwareCapability>; |
| 492 | extern template class RTC_EXPORT_TEMPLATE_DECLARE(RTC_EXPORT) |
| 493 | RTCRestrictedStatsMember<std::vector<double>, |
| 494 | StatExposureCriteria::kHardwareCapability>; |
| 495 | extern template class RTC_EXPORT_TEMPLATE_DECLARE(RTC_EXPORT) |
| 496 | RTCRestrictedStatsMember<std::vector<std::string>, |
| 497 | StatExposureCriteria::kHardwareCapability>; |
| 498 | extern template class RTC_EXPORT_TEMPLATE_DECLARE(RTC_EXPORT) |
| 499 | RTCRestrictedStatsMember<std::map<std::string, uint64_t>, |
| 500 | StatExposureCriteria::kHardwareCapability>; |
| 501 | extern template class RTC_EXPORT_TEMPLATE_DECLARE(RTC_EXPORT) |
| 502 | RTCRestrictedStatsMember<std::map<std::string, double>, |
| 503 | StatExposureCriteria::kHardwareCapability>; |
| 504 | |
Taylor Brandstetter | e275174 | 2018-06-25 13:42:44 -0700 | [diff] [blame] | 505 | // Using inheritance just so that it's obvious from the member's declaration |
| 506 | // whether it's standardized or not. |
| 507 | template <typename T> |
Evan Shrubsole | 7ef0c1a | 2022-10-31 11:05:33 +0000 | [diff] [blame] | 508 | class RTCNonStandardStatsMember |
| 509 | : public RTCRestrictedStatsMember<T, StatExposureCriteria::kNonStandard> { |
Taylor Brandstetter | e275174 | 2018-06-25 13:42:44 -0700 | [diff] [blame] | 510 | public: |
| 511 | explicit RTCNonStandardStatsMember(const char* name) |
Evan Shrubsole | 7ef0c1a | 2022-10-31 11:05:33 +0000 | [diff] [blame] | 512 | : RTCRestrictedStatsBase(name) {} |
Jakob Ivarsson | 758d946 | 2019-03-19 15:38:49 +0100 | [diff] [blame] | 513 | RTCNonStandardStatsMember(const char* name, |
| 514 | std::initializer_list<NonStandardGroupId> group_ids) |
Evan Shrubsole | 7ef0c1a | 2022-10-31 11:05:33 +0000 | [diff] [blame] | 515 | : RTCRestrictedStatsBase(name), group_ids_(group_ids) {} |
Taylor Brandstetter | e275174 | 2018-06-25 13:42:44 -0700 | [diff] [blame] | 516 | RTCNonStandardStatsMember(const char* name, const T& value) |
Evan Shrubsole | 7ef0c1a | 2022-10-31 11:05:33 +0000 | [diff] [blame] | 517 | : RTCRestrictedStatsBase(name, value) {} |
Taylor Brandstetter | e275174 | 2018-06-25 13:42:44 -0700 | [diff] [blame] | 518 | RTCNonStandardStatsMember(const char* name, T&& value) |
Evan Shrubsole | 7ef0c1a | 2022-10-31 11:05:33 +0000 | [diff] [blame] | 519 | : RTCRestrictedStatsBase(name, std::move(value)) {} |
| 520 | RTCNonStandardStatsMember(const RTCNonStandardStatsMember<T>& other) |
| 521 | : RTCRestrictedStatsBase(other), group_ids_(other.group_ids_) {} |
| 522 | RTCNonStandardStatsMember(RTCNonStandardStatsMember<T>&& other) |
| 523 | : RTCRestrictedStatsBase(std::move(other)), |
Mirko Bonadei | 759f161 | 2019-11-13 11:18:31 +0100 | [diff] [blame] | 524 | group_ids_(std::move(other.group_ids_)) {} |
Taylor Brandstetter | e275174 | 2018-06-25 13:42:44 -0700 | [diff] [blame] | 525 | |
Jakob Ivarsson | 2293622 | 2019-03-22 11:29:49 +0100 | [diff] [blame] | 526 | std::vector<NonStandardGroupId> group_ids() const override { |
| 527 | return group_ids_; |
| 528 | } |
Jakob Ivarsson | 758d946 | 2019-03-19 15:38:49 +0100 | [diff] [blame] | 529 | |
Evan Shrubsole | 7ef0c1a | 2022-10-31 11:05:33 +0000 | [diff] [blame] | 530 | T& operator=(const T& value) { |
| 531 | return RTCRestrictedStatsMember< |
| 532 | T, StatExposureCriteria::kNonStandard>::operator=(value); |
| 533 | } |
Ruslan Burakov | 8af8896 | 2018-11-22 17:21:10 +0100 | [diff] [blame] | 534 | T& operator=(const T&& value) { |
Evan Shrubsole | 7ef0c1a | 2022-10-31 11:05:33 +0000 | [diff] [blame] | 535 | return RTCRestrictedStatsMember< |
| 536 | T, StatExposureCriteria::kNonStandard>::operator=(std::move(value)); |
Ruslan Burakov | 8af8896 | 2018-11-22 17:21:10 +0100 | [diff] [blame] | 537 | } |
Jakob Ivarsson | 758d946 | 2019-03-19 15:38:49 +0100 | [diff] [blame] | 538 | |
| 539 | private: |
Evan Shrubsole | 7ef0c1a | 2022-10-31 11:05:33 +0000 | [diff] [blame] | 540 | using RTCRestrictedStatsBase = |
| 541 | RTCRestrictedStatsMember<T, StatExposureCriteria::kNonStandard>; |
Jakob Ivarsson | 758d946 | 2019-03-19 15:38:49 +0100 | [diff] [blame] | 542 | std::vector<NonStandardGroupId> group_ids_; |
Taylor Brandstetter | e275174 | 2018-06-25 13:42:44 -0700 | [diff] [blame] | 543 | }; |
Mirko Bonadei | 759f161 | 2019-11-13 11:18:31 +0100 | [diff] [blame] | 544 | |
| 545 | extern template class RTC_EXPORT_TEMPLATE_DECLARE(RTC_EXPORT) |
| 546 | RTCNonStandardStatsMember<bool>; |
| 547 | extern template class RTC_EXPORT_TEMPLATE_DECLARE(RTC_EXPORT) |
| 548 | RTCNonStandardStatsMember<int32_t>; |
| 549 | extern template class RTC_EXPORT_TEMPLATE_DECLARE(RTC_EXPORT) |
| 550 | RTCNonStandardStatsMember<uint32_t>; |
| 551 | extern template class RTC_EXPORT_TEMPLATE_DECLARE(RTC_EXPORT) |
| 552 | RTCNonStandardStatsMember<int64_t>; |
| 553 | extern template class RTC_EXPORT_TEMPLATE_DECLARE(RTC_EXPORT) |
| 554 | RTCNonStandardStatsMember<uint64_t>; |
| 555 | extern template class RTC_EXPORT_TEMPLATE_DECLARE(RTC_EXPORT) |
| 556 | RTCNonStandardStatsMember<double>; |
| 557 | extern template class RTC_EXPORT_TEMPLATE_DECLARE(RTC_EXPORT) |
| 558 | RTCNonStandardStatsMember<std::string>; |
| 559 | extern template class RTC_EXPORT_TEMPLATE_DECLARE(RTC_EXPORT) |
| 560 | RTCNonStandardStatsMember<std::vector<bool>>; |
| 561 | extern template class RTC_EXPORT_TEMPLATE_DECLARE(RTC_EXPORT) |
| 562 | RTCNonStandardStatsMember<std::vector<int32_t>>; |
| 563 | extern template class RTC_EXPORT_TEMPLATE_DECLARE(RTC_EXPORT) |
| 564 | RTCNonStandardStatsMember<std::vector<uint32_t>>; |
| 565 | extern template class RTC_EXPORT_TEMPLATE_DECLARE(RTC_EXPORT) |
| 566 | RTCNonStandardStatsMember<std::vector<int64_t>>; |
| 567 | extern template class RTC_EXPORT_TEMPLATE_DECLARE(RTC_EXPORT) |
| 568 | RTCNonStandardStatsMember<std::vector<uint64_t>>; |
| 569 | extern template class RTC_EXPORT_TEMPLATE_DECLARE(RTC_EXPORT) |
| 570 | RTCNonStandardStatsMember<std::vector<double>>; |
| 571 | extern template class RTC_EXPORT_TEMPLATE_DECLARE(RTC_EXPORT) |
| 572 | RTCNonStandardStatsMember<std::vector<std::string>>; |
Byoungchan Lee | 0a52ede | 2021-05-22 08:41:02 +0900 | [diff] [blame] | 573 | extern template class RTC_EXPORT_TEMPLATE_DECLARE(RTC_EXPORT) |
| 574 | RTCNonStandardStatsMember<std::map<std::string, uint64_t>>; |
| 575 | extern template class RTC_EXPORT_TEMPLATE_DECLARE(RTC_EXPORT) |
| 576 | RTCNonStandardStatsMember<std::map<std::string, double>>; |
Mirko Bonadei | 759f161 | 2019-11-13 11:18:31 +0100 | [diff] [blame] | 577 | |
hbos | 74e1a4f | 2016-09-15 23:33:01 -0700 | [diff] [blame] | 578 | } // namespace webrtc |
| 579 | |
Steve Anton | 10542f2 | 2019-01-11 09:11:00 -0800 | [diff] [blame] | 580 | #endif // API_STATS_RTC_STATS_H_ |