Reland "[Stats] Move metric names to Attribute, constructed via AttributeInit."

This is a reland of commit 84c48ae751

Original change's description:
> [Stats] Move metric names to Attribute, constructed via AttributeInit.
>
> As of this CL, Attribute no longer implements RTCStatsMemberInterface
> and a member no longer owns knowing its own name. The attribute knows
> the name because we pass it down at construction time.
>
> To achieve this, the WEBRTC_RTCSTATS_IMPL() macro is updated to take
> AttributeInits instead of raw member pointers, i.e. (name, ptr) pairs.
>
> By constructing RTCStatsMember<T> without a name parameter, it does the
> same thing as the absl::optional<T> constructor. So RTCStatsMember<T>'s
> days are numbered!
>
> Bug: webrtc:15164
> Change-Id: I560c0134bae1c2d7218426a1576425ecc1b677a7
> Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/334203
> Commit-Queue: Henrik Boström <hbos@webrtc.org>
> Reviewed-by: Evan Shrubsole <eshr@google.com>
> Cr-Commit-Position: refs/heads/main@{#41540}

Bug: webrtc:15164
Change-Id: I28f3d588004ff185e5820347ad9513f2f7a6cc66
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/335020
Auto-Submit: Mirko Bonadei <mbonadei@webrtc.org>
Commit-Queue: Henrik Boström <hbos@webrtc.org>
Commit-Queue: Mirko Bonadei <mbonadei@webrtc.org>
Reviewed-by: Henrik Boström <hbos@webrtc.org>
Cr-Commit-Position: refs/heads/main@{#41556}
This commit is contained in:
Henrik Boström 2024-01-16 11:03:19 +01:00 committed by WebRTC LUCI CQ
parent 0f1b9a9589
commit c0ac4df7a5
11 changed files with 356 additions and 718 deletions

View file

@ -23,7 +23,7 @@
namespace webrtc { namespace webrtc {
// A light-weight wrapper of an RTCStats attribute (an individual metric). // A light-weight wrapper of an RTCStats attribute (an individual metric).
class RTC_EXPORT Attribute : public RTCStatsMemberInterface { class RTC_EXPORT Attribute {
public: public:
// TODO(https://crbug.com/webrtc/15164): Replace uses of RTCStatsMember<T> // TODO(https://crbug.com/webrtc/15164): Replace uses of RTCStatsMember<T>
// with absl::optional<T> and update these pointer types. // with absl::optional<T> and update these pointer types.
@ -46,9 +46,8 @@ class RTC_EXPORT Attribute : public RTCStatsMemberInterface {
StatVariant; StatVariant;
template <typename T> template <typename T>
explicit Attribute(const RTCStatsMember<T>* attribute) explicit Attribute(const char* name, const RTCStatsMember<T>* attribute)
: RTCStatsMemberInterface(attribute->name()), attribute_(attribute) {} : name_(name), attribute_(attribute) {}
~Attribute() override;
const char* name() const; const char* name() const;
const StatVariant& as_variant() const; const StatVariant& as_variant() const;
@ -59,32 +58,39 @@ class RTC_EXPORT Attribute : public RTCStatsMemberInterface {
return absl::holds_alternative<const RTCStatsMember<T>*>(attribute_); return absl::holds_alternative<const RTCStatsMember<T>*>(attribute_);
} }
template <typename T> template <typename T>
absl::optional<T> as_optional() const {
RTC_CHECK(holds_alternative<T>());
if (!has_value()) {
return absl::nullopt;
}
return absl::optional<T>(get<T>());
}
template <typename T>
const T& get() const { const T& get() const {
RTC_CHECK(holds_alternative<T>()); RTC_CHECK(holds_alternative<T>());
RTC_CHECK(has_value()); RTC_CHECK(has_value());
return absl::get<const RTCStatsMember<T>*>(attribute_)->value(); return absl::get<const RTCStatsMember<T>*>(attribute_)->value();
} }
static Attribute FromMemberInterface(const RTCStatsMemberInterface* member); bool is_sequence() const;
// RTCStatsMemberInterface implementation. bool is_string() const;
// TODO(https://crbug.com/webrtc/15164): Delete RTCStatsMemberInterface in std::string ValueToString() const;
// favor of absl::optional<T>. std::string ValueToJson() const;
RTCStatsMemberInterface::Type type() const override;
bool is_sequence() const override;
bool is_string() const override;
bool is_defined() const override;
std::string ValueToString() const override;
std::string ValueToJson() const override;
protected: bool operator==(const Attribute& other) const;
const RTCStatsMemberInterface* member_ptr() const override; bool operator!=(const Attribute& other) const;
bool IsEqual(const RTCStatsMemberInterface& other) const override;
private: private:
const char* name_;
StatVariant attribute_; StatVariant attribute_;
}; };
Attribute MemberToAttribute(const RTCStatsMemberInterface* member); struct RTC_EXPORT AttributeInit {
AttributeInit(const char* name, const Attribute::StatVariant& variant);
const char* name;
Attribute::StatVariant variant;
};
} // namespace webrtc } // namespace webrtc

View file

@ -162,28 +162,32 @@ class RTC_EXPORT RTCStats {
std::unique_ptr<webrtc::RTCStats> copy() const override; \ std::unique_ptr<webrtc::RTCStats> copy() const override; \
const char* type() const override const char* type() const override
#define WEBRTC_RTCSTATS_IMPL(this_class, parent_class, type_str, ...) \ #define WEBRTC_RTCSTATS_IMPL(this_class, parent_class, type_str, ...) \
const char this_class::kType[] = type_str; \ const char this_class::kType[] = type_str; \
\ \
std::unique_ptr<webrtc::RTCStats> this_class::copy() const { \ std::unique_ptr<webrtc::RTCStats> this_class::copy() const { \
return std::make_unique<this_class>(*this); \ return std::make_unique<this_class>(*this); \
} \ } \
\ \
const char* this_class::type() const { \ const char* this_class::type() const { \
return this_class::kType; \ return this_class::kType; \
} \ } \
\ \
std::vector<webrtc::Attribute> this_class::AttributesImpl( \ std::vector<webrtc::Attribute> this_class::AttributesImpl( \
size_t additional_capacity) const { \ size_t additional_capacity) const { \
const webrtc::RTCStatsMemberInterface* this_members[] = {__VA_ARGS__}; \ webrtc::AttributeInit attribute_inits[] = {__VA_ARGS__}; \
size_t this_members_size = sizeof(this_members) / sizeof(this_members[0]); \ size_t attribute_inits_size = \
std::vector<webrtc::Attribute> attributes = \ sizeof(attribute_inits) / sizeof(attribute_inits[0]); \
parent_class::AttributesImpl(this_members_size + additional_capacity); \ std::vector<webrtc::Attribute> attributes = parent_class::AttributesImpl( \
for (size_t i = 0; i < this_members_size; ++i) { \ attribute_inits_size + additional_capacity); \
attributes.push_back( \ for (size_t i = 0; i < attribute_inits_size; ++i) { \
webrtc::Attribute::FromMemberInterface(this_members[i])); \ attributes.push_back(absl::visit( \
} \ [&](const auto* field) { \
return attributes; \ return Attribute(attribute_inits[i].name, field); \
}, \
attribute_inits[i].variant)); \
} \
return attributes; \
} }
} // namespace webrtc } // namespace webrtc

View file

@ -53,7 +53,6 @@ class RTCStatsMemberInterface {
virtual ~RTCStatsMemberInterface() {} virtual ~RTCStatsMemberInterface() {}
const char* name() const { return name_; }
virtual Type type() const = 0; virtual Type type() const = 0;
virtual bool is_sequence() const = 0; virtual bool is_sequence() const = 0;
virtual bool is_string() const = 0; virtual bool is_string() const = 0;
@ -82,11 +81,7 @@ class RTCStatsMemberInterface {
} }
protected: protected:
explicit RTCStatsMemberInterface(const char* name) : name_(name) {}
virtual bool IsEqual(const RTCStatsMemberInterface& other) const = 0; virtual bool IsEqual(const RTCStatsMemberInterface& other) const = 0;
const char* const name_;
}; };
// Template implementation of `RTCStatsMemberInterface`. // Template implementation of `RTCStatsMemberInterface`.
@ -95,16 +90,8 @@ class RTCStatsMemberInterface {
template <typename T> template <typename T>
class RTCStatsMember : public RTCStatsMemberInterface { class RTCStatsMember : public RTCStatsMemberInterface {
public: public:
explicit RTCStatsMember(const char* name) RTCStatsMember() {}
: RTCStatsMemberInterface(name), value_() {} explicit RTCStatsMember(const T& value) : value_(value) {}
RTCStatsMember(const char* name, const T& value)
: RTCStatsMemberInterface(name), value_(value) {}
RTCStatsMember(const char* name, T&& value)
: RTCStatsMemberInterface(name), value_(std::move(value)) {}
explicit RTCStatsMember(const RTCStatsMember<T>& other)
: RTCStatsMemberInterface(other.name_), value_(other.value_) {}
explicit RTCStatsMember(RTCStatsMember<T>&& other)
: RTCStatsMemberInterface(other.name_), value_(std::move(other.value_)) {}
static Type StaticType(); static Type StaticType();
Type type() const override { return StaticType(); } Type type() const override { return StaticType(); }

View file

@ -27,9 +27,7 @@ namespace webrtc {
class RTC_EXPORT RTCCertificateStats final : public RTCStats { class RTC_EXPORT RTCCertificateStats final : public RTCStats {
public: public:
WEBRTC_RTCSTATS_DECL(); WEBRTC_RTCSTATS_DECL();
RTCCertificateStats(std::string id, Timestamp timestamp); RTCCertificateStats(std::string id, Timestamp timestamp);
RTCCertificateStats(const RTCCertificateStats& other);
~RTCCertificateStats() override; ~RTCCertificateStats() override;
RTCStatsMember<std::string> fingerprint; RTCStatsMember<std::string> fingerprint;
@ -42,9 +40,7 @@ class RTC_EXPORT RTCCertificateStats final : public RTCStats {
class RTC_EXPORT RTCCodecStats final : public RTCStats { class RTC_EXPORT RTCCodecStats final : public RTCStats {
public: public:
WEBRTC_RTCSTATS_DECL(); WEBRTC_RTCSTATS_DECL();
RTCCodecStats(std::string id, Timestamp timestamp); RTCCodecStats(std::string id, Timestamp timestamp);
RTCCodecStats(const RTCCodecStats& other);
~RTCCodecStats() override; ~RTCCodecStats() override;
RTCStatsMember<std::string> transport_id; RTCStatsMember<std::string> transport_id;
@ -59,9 +55,7 @@ class RTC_EXPORT RTCCodecStats final : public RTCStats {
class RTC_EXPORT RTCDataChannelStats final : public RTCStats { class RTC_EXPORT RTCDataChannelStats final : public RTCStats {
public: public:
WEBRTC_RTCSTATS_DECL(); WEBRTC_RTCSTATS_DECL();
RTCDataChannelStats(std::string id, Timestamp timestamp); RTCDataChannelStats(std::string id, Timestamp timestamp);
RTCDataChannelStats(const RTCDataChannelStats& other);
~RTCDataChannelStats() override; ~RTCDataChannelStats() override;
RTCStatsMember<std::string> label; RTCStatsMember<std::string> label;
@ -78,9 +72,7 @@ class RTC_EXPORT RTCDataChannelStats final : public RTCStats {
class RTC_EXPORT RTCIceCandidatePairStats final : public RTCStats { class RTC_EXPORT RTCIceCandidatePairStats final : public RTCStats {
public: public:
WEBRTC_RTCSTATS_DECL(); WEBRTC_RTCSTATS_DECL();
RTCIceCandidatePairStats(std::string id, Timestamp timestamp); RTCIceCandidatePairStats(std::string id, Timestamp timestamp);
RTCIceCandidatePairStats(const RTCIceCandidatePairStats& other);
~RTCIceCandidatePairStats() override; ~RTCIceCandidatePairStats() override;
RTCStatsMember<std::string> transport_id; RTCStatsMember<std::string> transport_id;
@ -118,8 +110,6 @@ class RTC_EXPORT RTCIceCandidatePairStats final : public RTCStats {
class RTC_EXPORT RTCIceCandidateStats : public RTCStats { class RTC_EXPORT RTCIceCandidateStats : public RTCStats {
public: public:
WEBRTC_RTCSTATS_DECL(); WEBRTC_RTCSTATS_DECL();
RTCIceCandidateStats(const RTCIceCandidateStats& other);
~RTCIceCandidateStats() override; ~RTCIceCandidateStats() override;
RTCStatsMember<std::string> transport_id; RTCStatsMember<std::string> transport_id;
@ -175,9 +165,7 @@ class RTC_EXPORT RTCRemoteIceCandidateStats final
class RTC_EXPORT RTCPeerConnectionStats final : public RTCStats { class RTC_EXPORT RTCPeerConnectionStats final : public RTCStats {
public: public:
WEBRTC_RTCSTATS_DECL(); WEBRTC_RTCSTATS_DECL();
RTCPeerConnectionStats(std::string id, Timestamp timestamp); RTCPeerConnectionStats(std::string id, Timestamp timestamp);
RTCPeerConnectionStats(const RTCPeerConnectionStats& other);
~RTCPeerConnectionStats() override; ~RTCPeerConnectionStats() override;
RTCStatsMember<uint32_t> data_channels_opened; RTCStatsMember<uint32_t> data_channels_opened;
@ -188,8 +176,6 @@ class RTC_EXPORT RTCPeerConnectionStats final : public RTCStats {
class RTC_EXPORT RTCRtpStreamStats : public RTCStats { class RTC_EXPORT RTCRtpStreamStats : public RTCStats {
public: public:
WEBRTC_RTCSTATS_DECL(); WEBRTC_RTCSTATS_DECL();
RTCRtpStreamStats(const RTCRtpStreamStats& other);
~RTCRtpStreamStats() override; ~RTCRtpStreamStats() override;
RTCStatsMember<uint32_t> ssrc; RTCStatsMember<uint32_t> ssrc;
@ -205,8 +191,6 @@ class RTC_EXPORT RTCRtpStreamStats : public RTCStats {
class RTC_EXPORT RTCReceivedRtpStreamStats : public RTCRtpStreamStats { class RTC_EXPORT RTCReceivedRtpStreamStats : public RTCRtpStreamStats {
public: public:
WEBRTC_RTCSTATS_DECL(); WEBRTC_RTCSTATS_DECL();
RTCReceivedRtpStreamStats(const RTCReceivedRtpStreamStats& other);
~RTCReceivedRtpStreamStats() override; ~RTCReceivedRtpStreamStats() override;
RTCStatsMember<double> jitter; RTCStatsMember<double> jitter;
@ -220,8 +204,6 @@ class RTC_EXPORT RTCReceivedRtpStreamStats : public RTCRtpStreamStats {
class RTC_EXPORT RTCSentRtpStreamStats : public RTCRtpStreamStats { class RTC_EXPORT RTCSentRtpStreamStats : public RTCRtpStreamStats {
public: public:
WEBRTC_RTCSTATS_DECL(); WEBRTC_RTCSTATS_DECL();
RTCSentRtpStreamStats(const RTCSentRtpStreamStats& other);
~RTCSentRtpStreamStats() override; ~RTCSentRtpStreamStats() override;
RTCStatsMember<uint64_t> packets_sent; RTCStatsMember<uint64_t> packets_sent;
@ -236,9 +218,7 @@ class RTC_EXPORT RTCInboundRtpStreamStats final
: public RTCReceivedRtpStreamStats { : public RTCReceivedRtpStreamStats {
public: public:
WEBRTC_RTCSTATS_DECL(); WEBRTC_RTCSTATS_DECL();
RTCInboundRtpStreamStats(std::string id, Timestamp timestamp); RTCInboundRtpStreamStats(std::string id, Timestamp timestamp);
RTCInboundRtpStreamStats(const RTCInboundRtpStreamStats& other);
~RTCInboundRtpStreamStats() override; ~RTCInboundRtpStreamStats() override;
RTCStatsMember<std::string> playout_id; RTCStatsMember<std::string> playout_id;
@ -341,9 +321,7 @@ class RTC_EXPORT RTCOutboundRtpStreamStats final
: public RTCSentRtpStreamStats { : public RTCSentRtpStreamStats {
public: public:
WEBRTC_RTCSTATS_DECL(); WEBRTC_RTCSTATS_DECL();
RTCOutboundRtpStreamStats(std::string id, Timestamp timestamp); RTCOutboundRtpStreamStats(std::string id, Timestamp timestamp);
RTCOutboundRtpStreamStats(const RTCOutboundRtpStreamStats& other);
~RTCOutboundRtpStreamStats() override; ~RTCOutboundRtpStreamStats() override;
RTCStatsMember<std::string> media_source_id; RTCStatsMember<std::string> media_source_id;
@ -393,9 +371,7 @@ class RTC_EXPORT RTCRemoteInboundRtpStreamStats final
: public RTCReceivedRtpStreamStats { : public RTCReceivedRtpStreamStats {
public: public:
WEBRTC_RTCSTATS_DECL(); WEBRTC_RTCSTATS_DECL();
RTCRemoteInboundRtpStreamStats(std::string id, Timestamp timestamp); RTCRemoteInboundRtpStreamStats(std::string id, Timestamp timestamp);
RTCRemoteInboundRtpStreamStats(const RTCRemoteInboundRtpStreamStats& other);
~RTCRemoteInboundRtpStreamStats() override; ~RTCRemoteInboundRtpStreamStats() override;
RTCStatsMember<std::string> local_id; RTCStatsMember<std::string> local_id;
@ -410,9 +386,7 @@ class RTC_EXPORT RTCRemoteOutboundRtpStreamStats final
: public RTCSentRtpStreamStats { : public RTCSentRtpStreamStats {
public: public:
WEBRTC_RTCSTATS_DECL(); WEBRTC_RTCSTATS_DECL();
RTCRemoteOutboundRtpStreamStats(std::string id, Timestamp timestamp); RTCRemoteOutboundRtpStreamStats(std::string id, Timestamp timestamp);
RTCRemoteOutboundRtpStreamStats(const RTCRemoteOutboundRtpStreamStats& other);
~RTCRemoteOutboundRtpStreamStats() override; ~RTCRemoteOutboundRtpStreamStats() override;
RTCStatsMember<std::string> local_id; RTCStatsMember<std::string> local_id;
@ -427,8 +401,6 @@ class RTC_EXPORT RTCRemoteOutboundRtpStreamStats final
class RTC_EXPORT RTCMediaSourceStats : public RTCStats { class RTC_EXPORT RTCMediaSourceStats : public RTCStats {
public: public:
WEBRTC_RTCSTATS_DECL(); WEBRTC_RTCSTATS_DECL();
RTCMediaSourceStats(const RTCMediaSourceStats& other);
~RTCMediaSourceStats() override; ~RTCMediaSourceStats() override;
RTCStatsMember<std::string> track_identifier; RTCStatsMember<std::string> track_identifier;
@ -442,9 +414,7 @@ class RTC_EXPORT RTCMediaSourceStats : public RTCStats {
class RTC_EXPORT RTCAudioSourceStats final : public RTCMediaSourceStats { class RTC_EXPORT RTCAudioSourceStats final : public RTCMediaSourceStats {
public: public:
WEBRTC_RTCSTATS_DECL(); WEBRTC_RTCSTATS_DECL();
RTCAudioSourceStats(std::string id, Timestamp timestamp); RTCAudioSourceStats(std::string id, Timestamp timestamp);
RTCAudioSourceStats(const RTCAudioSourceStats& other);
~RTCAudioSourceStats() override; ~RTCAudioSourceStats() override;
RTCStatsMember<double> audio_level; RTCStatsMember<double> audio_level;
@ -458,9 +428,7 @@ class RTC_EXPORT RTCAudioSourceStats final : public RTCMediaSourceStats {
class RTC_EXPORT RTCVideoSourceStats final : public RTCMediaSourceStats { class RTC_EXPORT RTCVideoSourceStats final : public RTCMediaSourceStats {
public: public:
WEBRTC_RTCSTATS_DECL(); WEBRTC_RTCSTATS_DECL();
RTCVideoSourceStats(std::string id, Timestamp timestamp); RTCVideoSourceStats(std::string id, Timestamp timestamp);
RTCVideoSourceStats(const RTCVideoSourceStats& other);
~RTCVideoSourceStats() override; ~RTCVideoSourceStats() override;
RTCStatsMember<uint32_t> width; RTCStatsMember<uint32_t> width;
@ -473,9 +441,7 @@ class RTC_EXPORT RTCVideoSourceStats final : public RTCMediaSourceStats {
class RTC_EXPORT RTCTransportStats final : public RTCStats { class RTC_EXPORT RTCTransportStats final : public RTCStats {
public: public:
WEBRTC_RTCSTATS_DECL(); WEBRTC_RTCSTATS_DECL();
RTCTransportStats(std::string id, Timestamp timestamp); RTCTransportStats(std::string id, Timestamp timestamp);
RTCTransportStats(const RTCTransportStats& other);
~RTCTransportStats() override; ~RTCTransportStats() override;
RTCStatsMember<uint64_t> bytes_sent; RTCStatsMember<uint64_t> bytes_sent;
@ -501,9 +467,7 @@ class RTC_EXPORT RTCTransportStats final : public RTCStats {
class RTC_EXPORT RTCAudioPlayoutStats final : public RTCStats { class RTC_EXPORT RTCAudioPlayoutStats final : public RTCStats {
public: public:
WEBRTC_RTCSTATS_DECL(); WEBRTC_RTCSTATS_DECL();
RTCAudioPlayoutStats(const std::string& id, Timestamp timestamp); RTCAudioPlayoutStats(const std::string& id, Timestamp timestamp);
RTCAudioPlayoutStats(const RTCAudioPlayoutStats& other);
~RTCAudioPlayoutStats() override; ~RTCAudioPlayoutStats() override;
RTCStatsMember<std::string> kind; RTCStatsMember<std::string> kind;

View file

@ -3721,12 +3721,15 @@ class RTCTestStats : public RTCStats {
WEBRTC_RTCSTATS_DECL(); WEBRTC_RTCSTATS_DECL();
RTCTestStats(const std::string& id, Timestamp timestamp) RTCTestStats(const std::string& id, Timestamp timestamp)
: RTCStats(id, timestamp), dummy_stat("dummyStat") {} : RTCStats(id, timestamp) {}
RTCStatsMember<int32_t> dummy_stat; RTCStatsMember<int32_t> dummy_stat;
}; };
WEBRTC_RTCSTATS_IMPL(RTCTestStats, RTCStats, "test-stats", &dummy_stat) WEBRTC_RTCSTATS_IMPL(RTCTestStats,
RTCStats,
"test-stats",
AttributeInit("dummyStat", &dummy_stat))
// Overrides the stats collection to verify thread usage and that the resulting // Overrides the stats collection to verify thread usage and that the resulting
// partial reports are merged. // partial reports are merged.

View file

@ -33,66 +33,22 @@ struct VisitIsSequence {
struct VisitIsEqual { struct VisitIsEqual {
template <typename T> template <typename T>
bool operator()(const RTCStatsMember<T>* attribute) { bool operator()(const RTCStatsMember<T>* attribute) {
return attribute->IsEqual(other); if (!other.holds_alternative<T>()) {
return false;
}
absl::optional<T> attribute_as_optional =
attribute->has_value() ? absl::optional<T>(attribute->value())
: absl::nullopt;
return attribute_as_optional == other.as_optional<T>();
} }
const RTCStatsMemberInterface& other; const Attribute& other;
}; };
} // namespace } // namespace
Attribute::~Attribute() {}
// static
Attribute Attribute::FromMemberInterface(
const RTCStatsMemberInterface* member) {
switch (member->type()) {
case RTCStatsMemberInterface::Type::kBool:
return Attribute(&member->cast_to<RTCStatsMember<bool>>());
case RTCStatsMemberInterface::Type::kInt32:
return Attribute(&member->cast_to<RTCStatsMember<int32_t>>());
case RTCStatsMemberInterface::Type::kUint32:
return Attribute(&member->cast_to<RTCStatsMember<uint32_t>>());
case RTCStatsMemberInterface::Type::kInt64:
return Attribute(&member->cast_to<RTCStatsMember<int64_t>>());
case RTCStatsMemberInterface::Type::kUint64:
return Attribute(&member->cast_to<RTCStatsMember<uint64_t>>());
case RTCStatsMemberInterface::Type::kDouble:
return Attribute(&member->cast_to<RTCStatsMember<double>>());
case RTCStatsMemberInterface::Type::kString:
return Attribute(&member->cast_to<RTCStatsMember<std::string>>());
case RTCStatsMemberInterface::Type::kSequenceBool:
return Attribute(&member->cast_to<RTCStatsMember<std::vector<bool>>>());
case RTCStatsMemberInterface::Type::kSequenceInt32:
return Attribute(
&member->cast_to<RTCStatsMember<std::vector<int32_t>>>());
case RTCStatsMemberInterface::Type::kSequenceUint32:
return Attribute(
&member->cast_to<RTCStatsMember<std::vector<uint32_t>>>());
case RTCStatsMemberInterface::Type::kSequenceInt64:
return Attribute(
&member->cast_to<RTCStatsMember<std::vector<int64_t>>>());
case RTCStatsMemberInterface::Type::kSequenceUint64:
return Attribute(
&member->cast_to<RTCStatsMember<std::vector<uint64_t>>>());
case RTCStatsMemberInterface::Type::kSequenceDouble:
return Attribute(&member->cast_to<RTCStatsMember<std::vector<double>>>());
case RTCStatsMemberInterface::Type::kSequenceString:
return Attribute(
&member->cast_to<RTCStatsMember<std::vector<std::string>>>());
case RTCStatsMemberInterface::Type::kMapStringUint64:
return Attribute(
&member->cast_to<RTCStatsMember<std::map<std::string, uint64_t>>>());
case RTCStatsMemberInterface::Type::kMapStringDouble:
return Attribute(
&member->cast_to<RTCStatsMember<std::map<std::string, double>>>());
default:
RTC_CHECK_NOTREACHED();
}
}
const char* Attribute::name() const { const char* Attribute::name() const {
return absl::visit([](const auto* attr) { return attr->name(); }, attribute_); return name_;
} }
const Attribute::StatVariant& Attribute::as_variant() const { const Attribute::StatVariant& Attribute::as_variant() const {
@ -104,18 +60,6 @@ bool Attribute::has_value() const {
attribute_); attribute_);
} }
RTCStatsMemberInterface::Type Attribute::type() const {
return absl::visit([](const auto* attr) { return attr->type(); }, attribute_);
}
const RTCStatsMemberInterface* Attribute::member_ptr() const {
return absl::visit(
[](const auto* attr) {
return static_cast<const RTCStatsMemberInterface*>(attr);
},
attribute_);
}
bool Attribute::is_sequence() const { bool Attribute::is_sequence() const {
return absl::visit(VisitIsSequence(), attribute_); return absl::visit(VisitIsSequence(), attribute_);
} }
@ -125,11 +69,6 @@ bool Attribute::is_string() const {
attribute_); attribute_);
} }
bool Attribute::is_defined() const {
return absl::visit([](const auto* attr) { return attr->is_defined(); },
attribute_);
}
std::string Attribute::ValueToString() const { std::string Attribute::ValueToString() const {
return absl::visit([](const auto* attr) { return attr->ValueToString(); }, return absl::visit([](const auto* attr) { return attr->ValueToString(); },
attribute_); attribute_);
@ -140,8 +79,16 @@ std::string Attribute::ValueToJson() const {
attribute_); attribute_);
} }
bool Attribute::IsEqual(const RTCStatsMemberInterface& other) const { bool Attribute::operator==(const Attribute& other) const {
return absl::visit(VisitIsEqual{.other = *other.member_ptr()}, attribute_); return absl::visit(VisitIsEqual{.other = other}, attribute_);
} }
bool Attribute::operator!=(const Attribute& other) const {
return !(*this == other);
}
AttributeInit::AttributeInit(const char* name,
const Attribute::StatVariant& variant)
: name(name), variant(variant) {}
} // namespace webrtc } // namespace webrtc

View file

@ -10,6 +10,7 @@
#include "api/stats/rtc_stats_report.h" #include "api/stats/rtc_stats_report.h"
#include "api/stats/attribute.h"
#include "api/stats/rtc_stats.h" #include "api/stats/rtc_stats.h"
#include "rtc_base/checks.h" #include "rtc_base/checks.h"
#include "test/gtest.h" #include "test/gtest.h"
@ -21,36 +22,45 @@ class RTCTestStats1 : public RTCStats {
WEBRTC_RTCSTATS_DECL(); WEBRTC_RTCSTATS_DECL();
RTCTestStats1(const std::string& id, Timestamp timestamp) RTCTestStats1(const std::string& id, Timestamp timestamp)
: RTCStats(id, timestamp), integer("integer") {} : RTCStats(id, timestamp) {}
RTCStatsMember<int32_t> integer; RTCStatsMember<int32_t> integer;
}; };
WEBRTC_RTCSTATS_IMPL(RTCTestStats1, RTCStats, "test-stats-1", &integer) WEBRTC_RTCSTATS_IMPL(RTCTestStats1,
RTCStats,
"test-stats-1",
AttributeInit("integer", &integer))
class RTCTestStats2 : public RTCStats { class RTCTestStats2 : public RTCStats {
public: public:
WEBRTC_RTCSTATS_DECL(); WEBRTC_RTCSTATS_DECL();
RTCTestStats2(const std::string& id, Timestamp timestamp) RTCTestStats2(const std::string& id, Timestamp timestamp)
: RTCStats(id, timestamp), number("number") {} : RTCStats(id, timestamp) {}
RTCStatsMember<double> number; RTCStatsMember<double> number;
}; };
WEBRTC_RTCSTATS_IMPL(RTCTestStats2, RTCStats, "test-stats-2", &number) WEBRTC_RTCSTATS_IMPL(RTCTestStats2,
RTCStats,
"test-stats-2",
AttributeInit("number", &number))
class RTCTestStats3 : public RTCStats { class RTCTestStats3 : public RTCStats {
public: public:
WEBRTC_RTCSTATS_DECL(); WEBRTC_RTCSTATS_DECL();
RTCTestStats3(const std::string& id, Timestamp timestamp) RTCTestStats3(const std::string& id, Timestamp timestamp)
: RTCStats(id, timestamp), string("string") {} : RTCStats(id, timestamp) {}
RTCStatsMember<std::string> string; RTCStatsMember<std::string> string;
}; };
WEBRTC_RTCSTATS_IMPL(RTCTestStats3, RTCStats, "test-stats-3", &string) WEBRTC_RTCSTATS_IMPL(RTCTestStats3,
RTCStats,
"test-stats-3",
AttributeInit("string", &string))
TEST(RTCStatsReport, AddAndGetStats) { TEST(RTCStatsReport, AddAndGetStats) {
rtc::scoped_refptr<RTCStatsReport> report = rtc::scoped_refptr<RTCStatsReport> report =

View file

@ -44,19 +44,22 @@ class RTCChildStats : public RTCStats {
WEBRTC_RTCSTATS_DECL(); WEBRTC_RTCSTATS_DECL();
RTCChildStats(const std::string& id, Timestamp timestamp) RTCChildStats(const std::string& id, Timestamp timestamp)
: RTCStats(id, timestamp), child_int("childInt") {} : RTCStats(id, timestamp) {}
RTCStatsMember<int32_t> child_int; RTCStatsMember<int32_t> child_int;
}; };
WEBRTC_RTCSTATS_IMPL(RTCChildStats, RTCStats, "child-stats", &child_int) WEBRTC_RTCSTATS_IMPL(RTCChildStats,
RTCStats,
"child-stats",
AttributeInit("childInt", &child_int))
class RTCGrandChildStats : public RTCChildStats { class RTCGrandChildStats : public RTCChildStats {
public: public:
WEBRTC_RTCSTATS_DECL(); WEBRTC_RTCSTATS_DECL();
RTCGrandChildStats(const std::string& id, Timestamp timestamp) RTCGrandChildStats(const std::string& id, Timestamp timestamp)
: RTCChildStats(id, timestamp), grandchild_int("grandchildInt") {} : RTCChildStats(id, timestamp) {}
RTCStatsMember<int32_t> grandchild_int; RTCStatsMember<int32_t> grandchild_int;
}; };
@ -64,7 +67,7 @@ class RTCGrandChildStats : public RTCChildStats {
WEBRTC_RTCSTATS_IMPL(RTCGrandChildStats, WEBRTC_RTCSTATS_IMPL(RTCGrandChildStats,
RTCChildStats, RTCChildStats,
"grandchild-stats", "grandchild-stats",
&grandchild_int) AttributeInit("grandchildInt", &grandchild_int))
TEST(RTCStatsTest, RTCStatsAndAttributes) { TEST(RTCStatsTest, RTCStatsAndAttributes) {
RTCTestStats stats("testId", Timestamp::Micros(42)); RTCTestStats stats("testId", Timestamp::Micros(42));

View file

@ -20,182 +20,110 @@ namespace webrtc {
// clang-format off // clang-format off
WEBRTC_RTCSTATS_IMPL(RTCCertificateStats, RTCStats, "certificate", WEBRTC_RTCSTATS_IMPL(RTCCertificateStats, RTCStats, "certificate",
&fingerprint, AttributeInit("fingerprint", &fingerprint),
&fingerprint_algorithm, AttributeInit("fingerprintAlgorithm", &fingerprint_algorithm),
&base64_certificate, AttributeInit("base64Certificate", &base64_certificate),
&issuer_certificate_id) AttributeInit("issuerCertificateId", &issuer_certificate_id))
// clang-format on // clang-format on
RTCCertificateStats::RTCCertificateStats(std::string id, Timestamp timestamp) RTCCertificateStats::RTCCertificateStats(std::string id, Timestamp timestamp)
: RTCStats(std::move(id), timestamp), : RTCStats(std::move(id), timestamp) {}
fingerprint("fingerprint"),
fingerprint_algorithm("fingerprintAlgorithm"),
base64_certificate("base64Certificate"),
issuer_certificate_id("issuerCertificateId") {}
RTCCertificateStats::RTCCertificateStats(const RTCCertificateStats& other) =
default;
RTCCertificateStats::~RTCCertificateStats() {} RTCCertificateStats::~RTCCertificateStats() {}
// clang-format off // clang-format off
WEBRTC_RTCSTATS_IMPL(RTCCodecStats, RTCStats, "codec", WEBRTC_RTCSTATS_IMPL(RTCCodecStats, RTCStats, "codec",
&transport_id, AttributeInit("transportId", &transport_id),
&payload_type, AttributeInit("payloadType", &payload_type),
&mime_type, AttributeInit("mimeType", &mime_type),
&clock_rate, AttributeInit("clockRate", &clock_rate),
&channels, AttributeInit("channels", &channels),
&sdp_fmtp_line) AttributeInit("sdpFmtpLine", &sdp_fmtp_line))
// clang-format on // clang-format on
RTCCodecStats::RTCCodecStats(std::string id, Timestamp timestamp) RTCCodecStats::RTCCodecStats(std::string id, Timestamp timestamp)
: RTCStats(std::move(id), timestamp), : RTCStats(std::move(id), timestamp) {}
transport_id("transportId"),
payload_type("payloadType"),
mime_type("mimeType"),
clock_rate("clockRate"),
channels("channels"),
sdp_fmtp_line("sdpFmtpLine") {}
RTCCodecStats::RTCCodecStats(const RTCCodecStats& other) = default;
RTCCodecStats::~RTCCodecStats() {} RTCCodecStats::~RTCCodecStats() {}
// clang-format off // clang-format off
WEBRTC_RTCSTATS_IMPL(RTCDataChannelStats, RTCStats, "data-channel", WEBRTC_RTCSTATS_IMPL(RTCDataChannelStats, RTCStats, "data-channel",
&label, AttributeInit("label", &label),
&protocol, AttributeInit("protocol", &protocol),
&data_channel_identifier, AttributeInit("dataChannelIdentifier", &data_channel_identifier),
&state, AttributeInit("state", &state),
&messages_sent, AttributeInit("messagesSent", &messages_sent),
&bytes_sent, AttributeInit("bytesSent", &bytes_sent),
&messages_received, AttributeInit("messagesReceived", &messages_received),
&bytes_received) AttributeInit("bytesReceived", &bytes_received))
// clang-format on // clang-format on
RTCDataChannelStats::RTCDataChannelStats(std::string id, Timestamp timestamp) RTCDataChannelStats::RTCDataChannelStats(std::string id, Timestamp timestamp)
: RTCStats(std::move(id), timestamp), : RTCStats(std::move(id), timestamp) {}
label("label"),
protocol("protocol"),
data_channel_identifier("dataChannelIdentifier"),
state("state"),
messages_sent("messagesSent"),
bytes_sent("bytesSent"),
messages_received("messagesReceived"),
bytes_received("bytesReceived") {}
RTCDataChannelStats::RTCDataChannelStats(const RTCDataChannelStats& other) =
default;
RTCDataChannelStats::~RTCDataChannelStats() {} RTCDataChannelStats::~RTCDataChannelStats() {}
// clang-format off // clang-format off
WEBRTC_RTCSTATS_IMPL(RTCIceCandidatePairStats, RTCStats, "candidate-pair", WEBRTC_RTCSTATS_IMPL(RTCIceCandidatePairStats, RTCStats, "candidate-pair",
&transport_id, AttributeInit("transportId", &transport_id),
&local_candidate_id, AttributeInit("localCandidateId", &local_candidate_id),
&remote_candidate_id, AttributeInit("remoteCandidateId", &remote_candidate_id),
&state, AttributeInit("state", &state),
&priority, AttributeInit("priority", &priority),
&nominated, AttributeInit("nominated", &nominated),
&writable, AttributeInit("writable", &writable),
&packets_sent, AttributeInit("packetsSent", &packets_sent),
&packets_received, AttributeInit("packetsReceived", &packets_received),
&bytes_sent, AttributeInit("bytesSent", &bytes_sent),
&bytes_received, AttributeInit("bytesReceived", &bytes_received),
&total_round_trip_time, AttributeInit("totalRoundTripTime", &total_round_trip_time),
&current_round_trip_time, AttributeInit("currentRoundTripTime", &current_round_trip_time),
&available_outgoing_bitrate, AttributeInit("availableOutgoingBitrate", &available_outgoing_bitrate),
&available_incoming_bitrate, AttributeInit("availableIncomingBitrate", &available_incoming_bitrate),
&requests_received, AttributeInit("requestsReceived", &requests_received),
&requests_sent, AttributeInit("requestsSent", &requests_sent),
&responses_received, AttributeInit("responsesReceived", &responses_received),
&responses_sent, AttributeInit("responsesSent", &responses_sent),
&consent_requests_sent, AttributeInit("consentRequestsSent", &consent_requests_sent),
&packets_discarded_on_send, AttributeInit("packetsDiscardedOnSend", &packets_discarded_on_send),
&bytes_discarded_on_send, AttributeInit("bytesDiscardedOnSend", &bytes_discarded_on_send),
&last_packet_received_timestamp, AttributeInit("lastPacketReceivedTimestamp",
&last_packet_sent_timestamp) &last_packet_received_timestamp),
AttributeInit("lastPacketSentTimestamp", &last_packet_sent_timestamp))
// clang-format on // clang-format on
RTCIceCandidatePairStats::RTCIceCandidatePairStats(std::string id, RTCIceCandidatePairStats::RTCIceCandidatePairStats(std::string id,
Timestamp timestamp) Timestamp timestamp)
: RTCStats(std::move(id), timestamp), : RTCStats(std::move(id), timestamp) {}
transport_id("transportId"),
local_candidate_id("localCandidateId"),
remote_candidate_id("remoteCandidateId"),
state("state"),
priority("priority"),
nominated("nominated"),
writable("writable"),
packets_sent("packetsSent"),
packets_received("packetsReceived"),
bytes_sent("bytesSent"),
bytes_received("bytesReceived"),
total_round_trip_time("totalRoundTripTime"),
current_round_trip_time("currentRoundTripTime"),
available_outgoing_bitrate("availableOutgoingBitrate"),
available_incoming_bitrate("availableIncomingBitrate"),
requests_received("requestsReceived"),
requests_sent("requestsSent"),
responses_received("responsesReceived"),
responses_sent("responsesSent"),
consent_requests_sent("consentRequestsSent"),
packets_discarded_on_send("packetsDiscardedOnSend"),
bytes_discarded_on_send("bytesDiscardedOnSend"),
last_packet_received_timestamp("lastPacketReceivedTimestamp"),
last_packet_sent_timestamp("lastPacketSentTimestamp") {}
RTCIceCandidatePairStats::RTCIceCandidatePairStats(
const RTCIceCandidatePairStats& other) = default;
RTCIceCandidatePairStats::~RTCIceCandidatePairStats() {} RTCIceCandidatePairStats::~RTCIceCandidatePairStats() {}
// clang-format off // clang-format off
WEBRTC_RTCSTATS_IMPL(RTCIceCandidateStats, RTCStats, "abstract-ice-candidate", WEBRTC_RTCSTATS_IMPL(RTCIceCandidateStats, RTCStats, "abstract-ice-candidate",
&transport_id, AttributeInit("transportId", &transport_id),
&is_remote, AttributeInit("isRemote", &is_remote),
&network_type, AttributeInit("networkType", &network_type),
&ip, AttributeInit("ip", &ip),
&address, AttributeInit("address", &address),
&port, AttributeInit("port", &port),
&protocol, AttributeInit("protocol", &protocol),
&relay_protocol, AttributeInit("relayProtocol", &relay_protocol),
&candidate_type, AttributeInit("candidateType", &candidate_type),
&priority, AttributeInit("priority", &priority),
&url, AttributeInit("url", &url),
&foundation, AttributeInit("foundation", &foundation),
&related_address, AttributeInit("relatedAddress", &related_address),
&related_port, AttributeInit("relatedPort", &related_port),
&username_fragment, AttributeInit("usernameFragment", &username_fragment),
&tcp_type, AttributeInit("tcpType", &tcp_type),
&vpn, AttributeInit("vpn", &vpn),
&network_adapter_type) AttributeInit("networkAdapterType", &network_adapter_type))
// clang-format on // clang-format on
RTCIceCandidateStats::RTCIceCandidateStats(std::string id, RTCIceCandidateStats::RTCIceCandidateStats(std::string id,
Timestamp timestamp, Timestamp timestamp,
bool is_remote) bool is_remote)
: RTCStats(std::move(id), timestamp), : RTCStats(std::move(id), timestamp), is_remote(is_remote) {}
transport_id("transportId"),
is_remote("isRemote", is_remote),
network_type("networkType"),
ip("ip"),
address("address"),
port("port"),
protocol("protocol"),
relay_protocol("relayProtocol"),
candidate_type("candidateType"),
priority("priority"),
url("url"),
foundation("foundation"),
related_address("relatedAddress"),
related_port("relatedPort"),
username_fragment("usernameFragment"),
tcp_type("tcpType"),
vpn("vpn"),
network_adapter_type("networkAdapterType") {}
RTCIceCandidateStats::RTCIceCandidateStats(const RTCIceCandidateStats& other) =
default;
RTCIceCandidateStats::~RTCIceCandidateStats() {} RTCIceCandidateStats::~RTCIceCandidateStats() {}
@ -229,286 +157,172 @@ const char* RTCRemoteIceCandidateStats::type() const {
// clang-format off // clang-format off
WEBRTC_RTCSTATS_IMPL(RTCPeerConnectionStats, RTCStats, "peer-connection", WEBRTC_RTCSTATS_IMPL(RTCPeerConnectionStats, RTCStats, "peer-connection",
&data_channels_opened, AttributeInit("dataChannelsOpened", &data_channels_opened),
&data_channels_closed) AttributeInit("dataChannelsClosed", &data_channels_closed))
// clang-format on // clang-format on
RTCPeerConnectionStats::RTCPeerConnectionStats(std::string id, RTCPeerConnectionStats::RTCPeerConnectionStats(std::string id,
Timestamp timestamp) Timestamp timestamp)
: RTCStats(std::move(id), timestamp), : RTCStats(std::move(id), timestamp) {}
data_channels_opened("dataChannelsOpened"),
data_channels_closed("dataChannelsClosed") {}
RTCPeerConnectionStats::RTCPeerConnectionStats(
const RTCPeerConnectionStats& other) = default;
RTCPeerConnectionStats::~RTCPeerConnectionStats() {} RTCPeerConnectionStats::~RTCPeerConnectionStats() {}
// clang-format off // clang-format off
WEBRTC_RTCSTATS_IMPL(RTCRtpStreamStats, RTCStats, "rtp", WEBRTC_RTCSTATS_IMPL(RTCRtpStreamStats, RTCStats, "rtp",
&ssrc, AttributeInit("ssrc", &ssrc),
&kind, AttributeInit("kind", &kind),
&transport_id, AttributeInit("transportId", &transport_id),
&codec_id) AttributeInit("codecId", &codec_id))
// clang-format on // clang-format on
RTCRtpStreamStats::RTCRtpStreamStats(std::string id, Timestamp timestamp) RTCRtpStreamStats::RTCRtpStreamStats(std::string id, Timestamp timestamp)
: RTCStats(std::move(id), timestamp), : RTCStats(std::move(id), timestamp) {}
ssrc("ssrc"),
kind("kind"),
transport_id("transportId"),
codec_id("codecId") {}
RTCRtpStreamStats::RTCRtpStreamStats(const RTCRtpStreamStats& other) = default;
RTCRtpStreamStats::~RTCRtpStreamStats() {} RTCRtpStreamStats::~RTCRtpStreamStats() {}
// clang-format off // clang-format off
WEBRTC_RTCSTATS_IMPL( WEBRTC_RTCSTATS_IMPL(
RTCReceivedRtpStreamStats, RTCRtpStreamStats, "received-rtp", RTCReceivedRtpStreamStats, RTCRtpStreamStats, "received-rtp",
&jitter, AttributeInit("jitter", &jitter),
&packets_lost) AttributeInit("packetsLost", &packets_lost))
// clang-format on // clang-format on
RTCReceivedRtpStreamStats::RTCReceivedRtpStreamStats(std::string id, RTCReceivedRtpStreamStats::RTCReceivedRtpStreamStats(std::string id,
Timestamp timestamp) Timestamp timestamp)
: RTCRtpStreamStats(std::move(id), timestamp), : RTCRtpStreamStats(std::move(id), timestamp) {}
jitter("jitter"),
packets_lost("packetsLost") {}
RTCReceivedRtpStreamStats::RTCReceivedRtpStreamStats(
const RTCReceivedRtpStreamStats& other) = default;
RTCReceivedRtpStreamStats::~RTCReceivedRtpStreamStats() {} RTCReceivedRtpStreamStats::~RTCReceivedRtpStreamStats() {}
// clang-format off // clang-format off
WEBRTC_RTCSTATS_IMPL( WEBRTC_RTCSTATS_IMPL(RTCSentRtpStreamStats, RTCRtpStreamStats, "sent-rtp",
RTCSentRtpStreamStats, RTCRtpStreamStats, "sent-rtp", AttributeInit("packetsSent", &packets_sent),
&packets_sent, AttributeInit("bytesSent", &bytes_sent))
&bytes_sent)
// clang-format on // clang-format on
RTCSentRtpStreamStats::RTCSentRtpStreamStats(std::string id, RTCSentRtpStreamStats::RTCSentRtpStreamStats(std::string id,
Timestamp timestamp) Timestamp timestamp)
: RTCRtpStreamStats(std::move(id), timestamp), : RTCRtpStreamStats(std::move(id), timestamp) {}
packets_sent("packetsSent"),
bytes_sent("bytesSent") {}
RTCSentRtpStreamStats::RTCSentRtpStreamStats(
const RTCSentRtpStreamStats& other) = default;
RTCSentRtpStreamStats::~RTCSentRtpStreamStats() {} RTCSentRtpStreamStats::~RTCSentRtpStreamStats() {}
// clang-format off // clang-format off
WEBRTC_RTCSTATS_IMPL( WEBRTC_RTCSTATS_IMPL(
RTCInboundRtpStreamStats, RTCReceivedRtpStreamStats, "inbound-rtp", RTCInboundRtpStreamStats, RTCReceivedRtpStreamStats, "inbound-rtp",
&track_identifier, AttributeInit("playoutId", &playout_id),
&mid, AttributeInit("trackIdentifier", &track_identifier),
&remote_id, AttributeInit("mid", &mid),
&packets_received, AttributeInit("remoteId", &remote_id),
&packets_discarded, AttributeInit("packetsReceived", &packets_received),
&fec_packets_received, AttributeInit("packetsDiscarded", &packets_discarded),
&fec_bytes_received, AttributeInit("fecPacketsReceived", &fec_packets_received),
&fec_packets_discarded, AttributeInit("fecBytesReceived", &fec_bytes_received),
&fec_ssrc, AttributeInit("fecPacketsDiscarded", &fec_packets_discarded),
&bytes_received, AttributeInit("fecSsrc", &fec_ssrc),
&header_bytes_received, AttributeInit("bytesReceived", &bytes_received),
&retransmitted_packets_received, AttributeInit("headerBytesReceived", &header_bytes_received),
&retransmitted_bytes_received, AttributeInit("retransmittedPacketsReceived",
&rtx_ssrc, &retransmitted_packets_received),
&last_packet_received_timestamp, AttributeInit("retransmittedBytesReceived", &retransmitted_bytes_received),
&jitter_buffer_delay, AttributeInit("rtxSsrc", &rtx_ssrc),
&jitter_buffer_target_delay, AttributeInit("lastPacketReceivedTimestamp",
&jitter_buffer_minimum_delay, &last_packet_received_timestamp),
&jitter_buffer_emitted_count, AttributeInit("jitterBufferDelay", &jitter_buffer_delay),
&total_samples_received, AttributeInit("jitterBufferTargetDelay", &jitter_buffer_target_delay),
&concealed_samples, AttributeInit("jitterBufferMinimumDelay", &jitter_buffer_minimum_delay),
&silent_concealed_samples, AttributeInit("jitterBufferEmittedCount", &jitter_buffer_emitted_count),
&concealment_events, AttributeInit("totalSamplesReceived", &total_samples_received),
&inserted_samples_for_deceleration, AttributeInit("concealedSamples", &concealed_samples),
&removed_samples_for_acceleration, AttributeInit("silentConcealedSamples", &silent_concealed_samples),
&audio_level, AttributeInit("concealmentEvents", &concealment_events),
&total_audio_energy, AttributeInit("insertedSamplesForDeceleration",
&total_samples_duration, &inserted_samples_for_deceleration),
&playout_id, AttributeInit("removedSamplesForAcceleration",
&frames_received, &removed_samples_for_acceleration),
&frame_width, AttributeInit("audioLevel", &audio_level),
&frame_height, AttributeInit("totalAudioEnergy", &total_audio_energy),
&frames_per_second, AttributeInit("totalSamplesDuration", &total_samples_duration),
&frames_decoded, AttributeInit("framesReceived", &frames_received),
&key_frames_decoded, AttributeInit("frameWidth", &frame_width),
&frames_dropped, AttributeInit("frameHeight", &frame_height),
&total_decode_time, AttributeInit("framesPerSecond", &frames_per_second),
&total_processing_delay, AttributeInit("framesDecoded", &frames_decoded),
&total_assembly_time, AttributeInit("keyFramesDecoded", &key_frames_decoded),
&frames_assembled_from_multiple_packets, AttributeInit("framesDropped", &frames_dropped),
&total_inter_frame_delay, AttributeInit("totalDecodeTime", &total_decode_time),
&total_squared_inter_frame_delay, AttributeInit("totalProcessingDelay", &total_processing_delay),
&pause_count, AttributeInit("totalAssemblyTime", &total_assembly_time),
&total_pauses_duration, AttributeInit("framesAssembledFromMultiplePackets",
&freeze_count, &frames_assembled_from_multiple_packets),
&total_freezes_duration, AttributeInit("totalInterFrameDelay", &total_inter_frame_delay),
&content_type, AttributeInit("totalSquaredInterFrameDelay",
&estimated_playout_timestamp, &total_squared_inter_frame_delay),
&decoder_implementation, AttributeInit("pauseCount", &pause_count),
&fir_count, AttributeInit("totalPausesDuration", &total_pauses_duration),
&pli_count, AttributeInit("freezeCount", &freeze_count),
&nack_count, AttributeInit("totalFreezesDuration", &total_freezes_duration),
&qp_sum, AttributeInit("contentType", &content_type),
&goog_timing_frame_info, AttributeInit("estimatedPlayoutTimestamp", &estimated_playout_timestamp),
&power_efficient_decoder, AttributeInit("decoderImplementation", &decoder_implementation),
&jitter_buffer_flushes, AttributeInit("firCount", &fir_count),
&delayed_packet_outage_samples, AttributeInit("pliCount", &pli_count),
&relative_packet_arrival_delay, AttributeInit("nackCount", &nack_count),
&interruption_count, AttributeInit("qpSum", &qp_sum),
&total_interruption_duration, AttributeInit("googTimingFrameInfo", &goog_timing_frame_info),
&min_playout_delay) AttributeInit("powerEfficientDecoder", &power_efficient_decoder),
AttributeInit("jitterBufferFlushes", &jitter_buffer_flushes),
AttributeInit("delayedPacketOutageSamples", &delayed_packet_outage_samples),
AttributeInit("relativePacketArrivalDelay", &relative_packet_arrival_delay),
AttributeInit("interruptionCount", &interruption_count),
AttributeInit("totalInterruptionDuration", &total_interruption_duration),
AttributeInit("minPlayoutDelay", &min_playout_delay))
// clang-format on // clang-format on
RTCInboundRtpStreamStats::RTCInboundRtpStreamStats(std::string id, RTCInboundRtpStreamStats::RTCInboundRtpStreamStats(std::string id,
Timestamp timestamp) Timestamp timestamp)
: RTCReceivedRtpStreamStats(std::move(id), timestamp), : RTCReceivedRtpStreamStats(std::move(id), timestamp) {}
playout_id("playoutId"),
track_identifier("trackIdentifier"),
mid("mid"),
remote_id("remoteId"),
packets_received("packetsReceived"),
packets_discarded("packetsDiscarded"),
fec_packets_received("fecPacketsReceived"),
fec_bytes_received("fecBytesReceived"),
fec_packets_discarded("fecPacketsDiscarded"),
fec_ssrc("fecSsrc"),
bytes_received("bytesReceived"),
header_bytes_received("headerBytesReceived"),
retransmitted_packets_received("retransmittedPacketsReceived"),
retransmitted_bytes_received("retransmittedBytesReceived"),
rtx_ssrc("rtxSsrc"),
last_packet_received_timestamp("lastPacketReceivedTimestamp"),
jitter_buffer_delay("jitterBufferDelay"),
jitter_buffer_target_delay("jitterBufferTargetDelay"),
jitter_buffer_minimum_delay("jitterBufferMinimumDelay"),
jitter_buffer_emitted_count("jitterBufferEmittedCount"),
total_samples_received("totalSamplesReceived"),
concealed_samples("concealedSamples"),
silent_concealed_samples("silentConcealedSamples"),
concealment_events("concealmentEvents"),
inserted_samples_for_deceleration("insertedSamplesForDeceleration"),
removed_samples_for_acceleration("removedSamplesForAcceleration"),
audio_level("audioLevel"),
total_audio_energy("totalAudioEnergy"),
total_samples_duration("totalSamplesDuration"),
frames_received("framesReceived"),
frame_width("frameWidth"),
frame_height("frameHeight"),
frames_per_second("framesPerSecond"),
frames_decoded("framesDecoded"),
key_frames_decoded("keyFramesDecoded"),
frames_dropped("framesDropped"),
total_decode_time("totalDecodeTime"),
total_processing_delay("totalProcessingDelay"),
total_assembly_time("totalAssemblyTime"),
frames_assembled_from_multiple_packets(
"framesAssembledFromMultiplePackets"),
total_inter_frame_delay("totalInterFrameDelay"),
total_squared_inter_frame_delay("totalSquaredInterFrameDelay"),
pause_count("pauseCount"),
total_pauses_duration("totalPausesDuration"),
freeze_count("freezeCount"),
total_freezes_duration("totalFreezesDuration"),
content_type("contentType"),
estimated_playout_timestamp("estimatedPlayoutTimestamp"),
decoder_implementation("decoderImplementation"),
fir_count("firCount"),
pli_count("pliCount"),
nack_count("nackCount"),
qp_sum("qpSum"),
goog_timing_frame_info("googTimingFrameInfo"),
power_efficient_decoder("powerEfficientDecoder"),
jitter_buffer_flushes("jitterBufferFlushes"),
delayed_packet_outage_samples("delayedPacketOutageSamples"),
relative_packet_arrival_delay("relativePacketArrivalDelay"),
interruption_count("interruptionCount"),
total_interruption_duration("totalInterruptionDuration"),
min_playout_delay("minPlayoutDelay") {}
RTCInboundRtpStreamStats::RTCInboundRtpStreamStats(
const RTCInboundRtpStreamStats& other) = default;
RTCInboundRtpStreamStats::~RTCInboundRtpStreamStats() {} RTCInboundRtpStreamStats::~RTCInboundRtpStreamStats() {}
// clang-format off // clang-format off
WEBRTC_RTCSTATS_IMPL( WEBRTC_RTCSTATS_IMPL(
RTCOutboundRtpStreamStats, RTCSentRtpStreamStats, "outbound-rtp", RTCOutboundRtpStreamStats, RTCSentRtpStreamStats, "outbound-rtp",
&media_source_id, AttributeInit("mediaSourceId", &media_source_id),
&remote_id, AttributeInit("remoteId", &remote_id),
&mid, AttributeInit("mid", &mid),
&rid, AttributeInit("rid", &rid),
&retransmitted_packets_sent, AttributeInit("retransmittedPacketsSent", &retransmitted_packets_sent),
&header_bytes_sent, AttributeInit("headerBytesSent", &header_bytes_sent),
&retransmitted_bytes_sent, AttributeInit("retransmittedBytesSent", &retransmitted_bytes_sent),
&target_bitrate, AttributeInit("targetBitrate", &target_bitrate),
&frames_encoded, AttributeInit("framesEncoded", &frames_encoded),
&key_frames_encoded, AttributeInit("keyFramesEncoded", &key_frames_encoded),
&total_encode_time, AttributeInit("totalEncodeTime", &total_encode_time),
&total_encoded_bytes_target, AttributeInit("totalEncodedBytesTarget", &total_encoded_bytes_target),
&frame_width, AttributeInit("frameWidth", &frame_width),
&frame_height, AttributeInit("frameHeight", &frame_height),
&frames_per_second, AttributeInit("framesPerSecond", &frames_per_second),
&frames_sent, AttributeInit("framesSent", &frames_sent),
&huge_frames_sent, AttributeInit("hugeFramesSent", &huge_frames_sent),
&total_packet_send_delay, AttributeInit("totalPacketSendDelay", &total_packet_send_delay),
&quality_limitation_reason, AttributeInit("qualityLimitationReason", &quality_limitation_reason),
&quality_limitation_durations, AttributeInit("qualityLimitationDurations", &quality_limitation_durations),
&quality_limitation_resolution_changes, AttributeInit("qualityLimitationResolutionChanges",
&content_type, &quality_limitation_resolution_changes),
&encoder_implementation, AttributeInit("contentType", &content_type),
&fir_count, AttributeInit("encoderImplementation", &encoder_implementation),
&pli_count, AttributeInit("firCount", &fir_count),
&nack_count, AttributeInit("pliCount", &pli_count),
&qp_sum, AttributeInit("nackCount", &nack_count),
&active, AttributeInit("qpSum", &qp_sum),
&power_efficient_encoder, AttributeInit("active", &active),
&scalability_mode, AttributeInit("powerEfficientEncoder", &power_efficient_encoder),
&rtx_ssrc) AttributeInit("scalabilityMode", &scalability_mode),
AttributeInit("rtxSsrc", &rtx_ssrc))
// clang-format on // clang-format on
RTCOutboundRtpStreamStats::RTCOutboundRtpStreamStats(std::string id, RTCOutboundRtpStreamStats::RTCOutboundRtpStreamStats(std::string id,
Timestamp timestamp) Timestamp timestamp)
: RTCSentRtpStreamStats(std::move(id), timestamp), : RTCSentRtpStreamStats(std::move(id), timestamp) {}
media_source_id("mediaSourceId"),
remote_id("remoteId"),
mid("mid"),
rid("rid"),
retransmitted_packets_sent("retransmittedPacketsSent"),
header_bytes_sent("headerBytesSent"),
retransmitted_bytes_sent("retransmittedBytesSent"),
target_bitrate("targetBitrate"),
frames_encoded("framesEncoded"),
key_frames_encoded("keyFramesEncoded"),
total_encode_time("totalEncodeTime"),
total_encoded_bytes_target("totalEncodedBytesTarget"),
frame_width("frameWidth"),
frame_height("frameHeight"),
frames_per_second("framesPerSecond"),
frames_sent("framesSent"),
huge_frames_sent("hugeFramesSent"),
total_packet_send_delay("totalPacketSendDelay"),
quality_limitation_reason("qualityLimitationReason"),
quality_limitation_durations("qualityLimitationDurations"),
quality_limitation_resolution_changes(
"qualityLimitationResolutionChanges"),
content_type("contentType"),
encoder_implementation("encoderImplementation"),
fir_count("firCount"),
pli_count("pliCount"),
nack_count("nackCount"),
qp_sum("qpSum"),
active("active"),
power_efficient_encoder("powerEfficientEncoder"),
scalability_mode("scalabilityMode"),
rtx_ssrc("rtxSsrc") {}
RTCOutboundRtpStreamStats::RTCOutboundRtpStreamStats(
const RTCOutboundRtpStreamStats& other) = default;
RTCOutboundRtpStreamStats::~RTCOutboundRtpStreamStats() {} RTCOutboundRtpStreamStats::~RTCOutboundRtpStreamStats() {}
@ -516,25 +330,17 @@ RTCOutboundRtpStreamStats::~RTCOutboundRtpStreamStats() {}
WEBRTC_RTCSTATS_IMPL( WEBRTC_RTCSTATS_IMPL(
RTCRemoteInboundRtpStreamStats, RTCReceivedRtpStreamStats, RTCRemoteInboundRtpStreamStats, RTCReceivedRtpStreamStats,
"remote-inbound-rtp", "remote-inbound-rtp",
&local_id, AttributeInit("localId", &local_id),
&round_trip_time, AttributeInit("roundTripTime", &round_trip_time),
&fraction_lost, AttributeInit("fractionLost", &fraction_lost),
&total_round_trip_time, AttributeInit("totalRoundTripTime", &total_round_trip_time),
&round_trip_time_measurements) AttributeInit("roundTripTimeMeasurements", &round_trip_time_measurements))
// clang-format on // clang-format on
RTCRemoteInboundRtpStreamStats::RTCRemoteInboundRtpStreamStats( RTCRemoteInboundRtpStreamStats::RTCRemoteInboundRtpStreamStats(
std::string id, std::string id,
Timestamp timestamp) Timestamp timestamp)
: RTCReceivedRtpStreamStats(std::move(id), timestamp), : RTCReceivedRtpStreamStats(std::move(id), timestamp) {}
local_id("localId"),
round_trip_time("roundTripTime"),
fraction_lost("fractionLost"),
total_round_trip_time("totalRoundTripTime"),
round_trip_time_measurements("roundTripTimeMeasurements") {}
RTCRemoteInboundRtpStreamStats::RTCRemoteInboundRtpStreamStats(
const RTCRemoteInboundRtpStreamStats& other) = default;
RTCRemoteInboundRtpStreamStats::~RTCRemoteInboundRtpStreamStats() {} RTCRemoteInboundRtpStreamStats::~RTCRemoteInboundRtpStreamStats() {}
@ -542,156 +348,100 @@ RTCRemoteInboundRtpStreamStats::~RTCRemoteInboundRtpStreamStats() {}
WEBRTC_RTCSTATS_IMPL( WEBRTC_RTCSTATS_IMPL(
RTCRemoteOutboundRtpStreamStats, RTCSentRtpStreamStats, RTCRemoteOutboundRtpStreamStats, RTCSentRtpStreamStats,
"remote-outbound-rtp", "remote-outbound-rtp",
&local_id, AttributeInit("localId", &local_id),
&remote_timestamp, AttributeInit("remoteTimestamp", &remote_timestamp),
&reports_sent, AttributeInit("reportsSent", &reports_sent),
&round_trip_time, AttributeInit("roundTripTime", &round_trip_time),
&round_trip_time_measurements, AttributeInit("roundTripTimeMeasurements", &round_trip_time_measurements),
&total_round_trip_time) AttributeInit("totalRoundTripTime", &total_round_trip_time))
// clang-format on // clang-format on
RTCRemoteOutboundRtpStreamStats::RTCRemoteOutboundRtpStreamStats( RTCRemoteOutboundRtpStreamStats::RTCRemoteOutboundRtpStreamStats(
std::string id, std::string id,
Timestamp timestamp) Timestamp timestamp)
: RTCSentRtpStreamStats(std::move(id), timestamp), : RTCSentRtpStreamStats(std::move(id), timestamp) {}
local_id("localId"),
remote_timestamp("remoteTimestamp"),
reports_sent("reportsSent"),
round_trip_time("roundTripTime"),
round_trip_time_measurements("roundTripTimeMeasurements"),
total_round_trip_time("totalRoundTripTime") {}
RTCRemoteOutboundRtpStreamStats::RTCRemoteOutboundRtpStreamStats(
const RTCRemoteOutboundRtpStreamStats& other) = default;
RTCRemoteOutboundRtpStreamStats::~RTCRemoteOutboundRtpStreamStats() {} RTCRemoteOutboundRtpStreamStats::~RTCRemoteOutboundRtpStreamStats() {}
// clang-format off // clang-format off
WEBRTC_RTCSTATS_IMPL(RTCMediaSourceStats, RTCStats, "parent-media-source", WEBRTC_RTCSTATS_IMPL(RTCMediaSourceStats, RTCStats, "parent-media-source",
&track_identifier, AttributeInit("trackIdentifier", &track_identifier),
&kind) AttributeInit("kind", &kind))
// clang-format on // clang-format on
RTCMediaSourceStats::RTCMediaSourceStats(std::string id, Timestamp timestamp) RTCMediaSourceStats::RTCMediaSourceStats(std::string id, Timestamp timestamp)
: RTCStats(std::move(id), timestamp), : RTCStats(std::move(id), timestamp) {}
track_identifier("trackIdentifier"),
kind("kind") {}
RTCMediaSourceStats::RTCMediaSourceStats(const RTCMediaSourceStats& other) =
default;
RTCMediaSourceStats::~RTCMediaSourceStats() {} RTCMediaSourceStats::~RTCMediaSourceStats() {}
// clang-format off // clang-format off
WEBRTC_RTCSTATS_IMPL(RTCAudioSourceStats, RTCMediaSourceStats, "media-source", WEBRTC_RTCSTATS_IMPL(RTCAudioSourceStats, RTCMediaSourceStats, "media-source",
&audio_level, AttributeInit("audioLevel", &audio_level),
&total_audio_energy, AttributeInit("totalAudioEnergy", &total_audio_energy),
&total_samples_duration, AttributeInit("totalSamplesDuration", &total_samples_duration),
&echo_return_loss, AttributeInit("echoReturnLoss", &echo_return_loss),
&echo_return_loss_enhancement) AttributeInit("echoReturnLossEnhancement", &echo_return_loss_enhancement))
// clang-format on // clang-format on
RTCAudioSourceStats::RTCAudioSourceStats(std::string id, Timestamp timestamp) RTCAudioSourceStats::RTCAudioSourceStats(std::string id, Timestamp timestamp)
: RTCMediaSourceStats(std::move(id), timestamp), : RTCMediaSourceStats(std::move(id), timestamp) {}
audio_level("audioLevel"),
total_audio_energy("totalAudioEnergy"),
total_samples_duration("totalSamplesDuration"),
echo_return_loss("echoReturnLoss"),
echo_return_loss_enhancement("echoReturnLossEnhancement") {}
RTCAudioSourceStats::RTCAudioSourceStats(const RTCAudioSourceStats& other) =
default;
RTCAudioSourceStats::~RTCAudioSourceStats() {} RTCAudioSourceStats::~RTCAudioSourceStats() {}
// clang-format off // clang-format off
WEBRTC_RTCSTATS_IMPL(RTCVideoSourceStats, RTCMediaSourceStats, "media-source", WEBRTC_RTCSTATS_IMPL(RTCVideoSourceStats, RTCMediaSourceStats, "media-source",
&width, AttributeInit("width", &width),
&height, AttributeInit("height", &height),
&frames, AttributeInit("frames", &frames),
&frames_per_second) AttributeInit("framesPerSecond", &frames_per_second))
// clang-format on // clang-format on
RTCVideoSourceStats::RTCVideoSourceStats(std::string id, Timestamp timestamp) RTCVideoSourceStats::RTCVideoSourceStats(std::string id, Timestamp timestamp)
: RTCMediaSourceStats(std::move(id), timestamp), : RTCMediaSourceStats(std::move(id), timestamp) {}
width("width"),
height("height"),
frames("frames"),
frames_per_second("framesPerSecond") {}
RTCVideoSourceStats::RTCVideoSourceStats(const RTCVideoSourceStats& other) =
default;
RTCVideoSourceStats::~RTCVideoSourceStats() {} RTCVideoSourceStats::~RTCVideoSourceStats() {}
// clang-format off // clang-format off
WEBRTC_RTCSTATS_IMPL(RTCTransportStats, RTCStats, "transport", WEBRTC_RTCSTATS_IMPL(RTCTransportStats, RTCStats, "transport",
&bytes_sent, AttributeInit("bytesSent", &bytes_sent),
&packets_sent, AttributeInit("packetsSent", &packets_sent),
&bytes_received, AttributeInit("bytesReceived", &bytes_received),
&packets_received, AttributeInit("packetsReceived", &packets_received),
&rtcp_transport_stats_id, AttributeInit("rtcpTransportStatsId", &rtcp_transport_stats_id),
&dtls_state, AttributeInit("dtlsState", &dtls_state),
&selected_candidate_pair_id, AttributeInit("selectedCandidatePairId", &selected_candidate_pair_id),
&local_certificate_id, AttributeInit("localCertificateId", &local_certificate_id),
&remote_certificate_id, AttributeInit("remoteCertificateId", &remote_certificate_id),
&tls_version, AttributeInit("tlsVersion", &tls_version),
&dtls_cipher, AttributeInit("dtlsCipher", &dtls_cipher),
&dtls_role, AttributeInit("dtlsRole", &dtls_role),
&srtp_cipher, AttributeInit("srtpCipher", &srtp_cipher),
&selected_candidate_pair_changes, AttributeInit("selectedCandidatePairChanges",
&ice_role, &selected_candidate_pair_changes),
&ice_local_username_fragment, AttributeInit("iceRole", &ice_role),
&ice_state) AttributeInit("iceLocalUsernameFragment", &ice_local_username_fragment),
AttributeInit("iceState", &ice_state))
// clang-format on // clang-format on
RTCTransportStats::RTCTransportStats(std::string id, Timestamp timestamp) RTCTransportStats::RTCTransportStats(std::string id, Timestamp timestamp)
: RTCStats(std::move(id), timestamp), : RTCStats(std::move(id), timestamp) {}
bytes_sent("bytesSent"),
packets_sent("packetsSent"),
bytes_received("bytesReceived"),
packets_received("packetsReceived"),
rtcp_transport_stats_id("rtcpTransportStatsId"),
dtls_state("dtlsState"),
selected_candidate_pair_id("selectedCandidatePairId"),
local_certificate_id("localCertificateId"),
remote_certificate_id("remoteCertificateId"),
tls_version("tlsVersion"),
dtls_cipher("dtlsCipher"),
dtls_role("dtlsRole"),
srtp_cipher("srtpCipher"),
selected_candidate_pair_changes("selectedCandidatePairChanges"),
ice_role("iceRole"),
ice_local_username_fragment("iceLocalUsernameFragment"),
ice_state("iceState") {}
RTCTransportStats::RTCTransportStats(const RTCTransportStats& other) = default;
RTCTransportStats::~RTCTransportStats() {} RTCTransportStats::~RTCTransportStats() {}
// clang-format off
WEBRTC_RTCSTATS_IMPL(RTCAudioPlayoutStats, RTCStats, "media-playout",
AttributeInit("kind", &kind),
AttributeInit("synthesizedSamplesDuration", &synthesized_samples_duration),
AttributeInit("synthesizedSamplesEvents", &synthesized_samples_events),
AttributeInit("totalSamplesDuration", &total_samples_duration),
AttributeInit("totalPlayoutDelay", &total_playout_delay),
AttributeInit("totalSamplesCount", &total_samples_count))
// clang-format on
RTCAudioPlayoutStats::RTCAudioPlayoutStats(const std::string& id, RTCAudioPlayoutStats::RTCAudioPlayoutStats(const std::string& id,
Timestamp timestamp) Timestamp timestamp)
: RTCStats(std::move(id), timestamp), : RTCStats(std::move(id), timestamp), kind("audio") {}
kind("kind", "audio"),
synthesized_samples_duration("synthesizedSamplesDuration"),
synthesized_samples_events("synthesizedSamplesEvents"),
total_samples_duration("totalSamplesDuration"),
total_playout_delay("totalPlayoutDelay"),
total_samples_count("totalSamplesCount") {}
RTCAudioPlayoutStats::RTCAudioPlayoutStats(const RTCAudioPlayoutStats& other) =
default;
RTCAudioPlayoutStats::~RTCAudioPlayoutStats() {} RTCAudioPlayoutStats::~RTCAudioPlayoutStats() {}
// clang-format off
WEBRTC_RTCSTATS_IMPL(RTCAudioPlayoutStats, RTCStats, "media-playout",
&kind,
&synthesized_samples_duration,
&synthesized_samples_events,
&total_samples_duration,
&total_playout_delay,
&total_samples_count)
// clang-format on
} // namespace webrtc } // namespace webrtc

View file

@ -10,6 +10,7 @@
#include "stats/test/rtc_test_stats.h" #include "stats/test/rtc_test_stats.h"
#include "api/stats/attribute.h"
#include "rtc_base/checks.h" #include "rtc_base/checks.h"
namespace webrtc { namespace webrtc {
@ -17,60 +18,25 @@ namespace webrtc {
WEBRTC_RTCSTATS_IMPL(RTCTestStats, WEBRTC_RTCSTATS_IMPL(RTCTestStats,
RTCStats, RTCStats,
"test-stats", "test-stats",
&m_bool, AttributeInit("mBool", &m_bool),
&m_int32, AttributeInit("mInt32", &m_int32),
&m_uint32, AttributeInit("mUint32", &m_uint32),
&m_int64, AttributeInit("mInt64", &m_int64),
&m_uint64, AttributeInit("mUint64", &m_uint64),
&m_double, AttributeInit("mDouble", &m_double),
&m_string, AttributeInit("mString", &m_string),
&m_sequence_bool, AttributeInit("mSequenceBool", &m_sequence_bool),
&m_sequence_int32, AttributeInit("mSequenceInt32", &m_sequence_int32),
&m_sequence_uint32, AttributeInit("mSequenceUint32", &m_sequence_uint32),
&m_sequence_int64, AttributeInit("mSequenceInt64", &m_sequence_int64),
&m_sequence_uint64, AttributeInit("mSequenceUint64", &m_sequence_uint64),
&m_sequence_double, AttributeInit("mSequenceDouble", &m_sequence_double),
&m_sequence_string, AttributeInit("mSequenceString", &m_sequence_string),
&m_map_string_uint64, AttributeInit("mMapStringUint64", &m_map_string_uint64),
&m_map_string_double) AttributeInit("mMapStringDouble", &m_map_string_double))
RTCTestStats::RTCTestStats(const std::string& id, Timestamp timestamp) RTCTestStats::RTCTestStats(const std::string& id, Timestamp timestamp)
: RTCStats(id, timestamp), : RTCStats(id, timestamp) {}
m_bool("mBool"),
m_int32("mInt32"),
m_uint32("mUint32"),
m_int64("mInt64"),
m_uint64("mUint64"),
m_double("mDouble"),
m_string("mString"),
m_sequence_bool("mSequenceBool"),
m_sequence_int32("mSequenceInt32"),
m_sequence_uint32("mSequenceUint32"),
m_sequence_int64("mSequenceInt64"),
m_sequence_uint64("mSequenceUint64"),
m_sequence_double("mSequenceDouble"),
m_sequence_string("mSequenceString"),
m_map_string_uint64("mMapStringUint64"),
m_map_string_double("mMapStringDouble") {}
RTCTestStats::RTCTestStats(const RTCTestStats& other)
: RTCStats(other.id(), other.timestamp()),
m_bool(other.m_bool),
m_int32(other.m_int32),
m_uint32(other.m_uint32),
m_int64(other.m_int64),
m_uint64(other.m_uint64),
m_double(other.m_double),
m_string(other.m_string),
m_sequence_bool(other.m_sequence_bool),
m_sequence_int32(other.m_sequence_int32),
m_sequence_uint32(other.m_sequence_uint32),
m_sequence_int64(other.m_sequence_int64),
m_sequence_uint64(other.m_sequence_uint64),
m_sequence_double(other.m_sequence_double),
m_sequence_string(other.m_sequence_string),
m_map_string_uint64(other.m_map_string_uint64),
m_map_string_double(other.m_map_string_double) {}
RTCTestStats::~RTCTestStats() {} RTCTestStats::~RTCTestStats() {}

View file

@ -24,9 +24,7 @@ namespace webrtc {
class RTC_EXPORT RTCTestStats : public RTCStats { class RTC_EXPORT RTCTestStats : public RTCStats {
public: public:
WEBRTC_RTCSTATS_DECL(); WEBRTC_RTCSTATS_DECL();
RTCTestStats(const std::string& id, Timestamp timestamp); RTCTestStats(const std::string& id, Timestamp timestamp);
RTCTestStats(const RTCTestStats& other);
~RTCTestStats() override; ~RTCTestStats() override;
RTCStatsMember<bool> m_bool; RTCStatsMember<bool> m_bool;