Bug 1271669 - Don't rely on streams for getStats(). r?jib,bwc draft
authorAndreas Pehrson <pehrsons@gmail.com>
Wed, 18 May 2016 15:00:21 +0200
changeset 369105 769616e681a7bed46561d6935a5a7a5da86556bb
parent 369104 66235a4b84c1467dab257e1bc024ee899a2f7ec0
child 369106 2806803adf41e2463226421e9be602a9ba87343e
push id18740
push userpehrsons@gmail.com
push dateFri, 20 May 2016 08:44:08 +0000
reviewersjib, bwc
bugs1271669
milestone49.0a1
Bug 1271669 - Don't rely on streams for getStats(). r?jib,bwc MozReview-Commit-ID: 8I6YowAAGcW
media/webrtc/signaling/src/peerconnection/PeerConnectionImpl.cpp
--- 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;
   }