Skip to content
This repository has been archived by the owner on Oct 25, 2024. It is now read-only.

Add kType for RTCStats to fix GetStatsOfType build error. #642

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

JinChengShi
Copy link
Contributor

No description provided.

@jianjunz
Copy link
Collaborator

jianjunz commented Jan 3, 2023

RTCStats has a field type, why we need another type in its derived classes.

@JinChengShi
Copy link
Contributor Author

JinChengShi commented Jan 5, 2023

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>();

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants