Bug 1271669 - Don't rely on streams for getStats(). r?jib,bwc
MozReview-Commit-ID: 8I6YowAAGcW
--- a/media/webrtc/signaling/src/peerconnection/PeerConnectionImpl.cpp
+++ b/media/webrtc/signaling/src/peerconnection/PeerConnectionImpl.cpp
@@ -3333,45 +3333,26 @@ PeerConnectionImpl::BuildStatsQuery_m(
// Gather up pipelines from mMedia so they may be inspected on STS
std::string trackId;
if (aSelector) {
trackId = PeerConnectionImpl::GetTrackId(*aSelector);
}
for (int i = 0, len = mMedia->LocalStreamsLength(); i < len; i++) {
- auto& pipelines = mMedia->GetLocalStreamByIndex(i)->GetPipelines();
- if (aSelector) {
- if (mMedia->GetLocalStreamByIndex(i)->GetMediaStream()->
- HasTrack(*aSelector)) {
- auto it = pipelines.find(trackId);
- if (it != pipelines.end()) {
- query->pipelines.AppendElement(it->second);
- }
- }
- } else {
- for (auto it = pipelines.begin(); it != pipelines.end(); ++it) {
- query->pipelines.AppendElement(it->second);
+ for (auto pipeline : mMedia->GetLocalStreamByIndex(i)->GetPipelines()) {
+ if (!aSelector || pipeline.second->trackid() == trackId) {
+ query->pipelines.AppendElement(pipeline.second);
}
}
}
-
- for (size_t i = 0, len = mMedia->RemoteStreamsLength(); i < len; i++) {
- auto& pipelines = mMedia->GetRemoteStreamByIndex(i)->GetPipelines();
- if (aSelector) {
- if (mMedia->GetRemoteStreamByIndex(i)->
- GetMediaStream()->HasTrack(*aSelector)) {
- auto it = pipelines.find(trackId);
- if (it != pipelines.end()) {
- query->pipelines.AppendElement(it->second);
- }
- }
- } else {
- for (auto it = pipelines.begin(); it != pipelines.end(); ++it) {
- query->pipelines.AppendElement(it->second);
+ for (int i = 0, len = mMedia->RemoteStreamsLength(); i < len; i++) {
+ for (auto pipeline : mMedia->GetRemoteStreamByIndex(i)->GetPipelines()) {
+ if (!aSelector || pipeline.second->trackid() == trackId) {
+ query->pipelines.AppendElement(pipeline.second);
}
}
}
if (!aSelector) {
query->grabAllLevels = true;
}