Open JinChengShi opened 1 year ago
RTCStats has a field
type
, why we need another type in its derived classes.
Because it will cause follow code build error:
const T* GetAs(const std::string& id) const {
const RTCStats* stats = Get(id);
if (!stats || stats->type != T::kType) {
return nullptr;
}
return &stats->cast_to<const T>();
}
std::vector<const T*> GetStatsOfType() const {
std::vector<const T*> stats_of_type;
for (const RTCStats& stats : *this) {
if (stats.type == T::kType)
stats_of_type.push_back(&stats.cast_to<const T>());
}
return stats_of_type;
}
when called GetStatsOfType in app:
std::vector<const RTCOutboundRTPStreamStats*> outboundRTPStreamStats = status->GetStatsOfType<RTCOutboundRTPStreamStats>();
RTCStats has a field
type
, why we need another type in its derived classes.