From 7b0c6fa2743ee79f080723aed2d9bea3a8325313 Mon Sep 17 00:00:00 2001 From: hbos Date: Wed, 12 Jul 2017 16:22:34 -0700 Subject: [PATCH] RTCStatsCollector: Get track IDs from senders/receivers instead of streams. When addTrack/removeTrack is used instead of addStream/removeStream we an end up with tracks that are not contained within any local or remote stream. If all track IDs are not mapped when we produce RTCRTPStreamStats we'll hit a DCHECK. BUG=chromium:741638 Review-Url: https://codereview.webrtc.org/2978793002 Cr-Commit-Position: refs/heads/master@{#18991} --- webrtc/pc/rtcstatscollector.cc | 25 +++++++++---------------- 1 file changed, 9 insertions(+), 16 deletions(-) diff --git a/webrtc/pc/rtcstatscollector.cc b/webrtc/pc/rtcstatscollector.cc index f5b8c8a936..81b4d3e4d8 100644 --- a/webrtc/pc/rtcstatscollector.cc +++ b/webrtc/pc/rtcstatscollector.cc @@ -1201,22 +1201,15 @@ std::map RTCStatsCollector::PrepareTrackToID_s() const { RTC_DCHECK(signaling_thread_->IsCurrent()); std::map track_to_id; - StreamCollectionInterface* local_and_remote_streams[] = - { pc_->local_streams().get(), pc_->remote_streams().get() }; - for (auto& streams : local_and_remote_streams) { - if (streams) { - for (size_t i = 0; i < streams->count(); ++i) { - MediaStreamInterface* stream = streams->at(i); - for (const rtc::scoped_refptr& audio_track : - stream->GetAudioTracks()) { - track_to_id[audio_track.get()] = audio_track->id(); - } - for (const rtc::scoped_refptr& video_track : - stream->GetVideoTracks()) { - track_to_id[video_track.get()] = video_track->id(); - } - } - } + for (auto sender : pc_->GetSenders()) { + auto track = sender->track(); + if (track) + track_to_id[track.get()] = track->id(); + } + for (auto receiver : pc_->GetReceivers()) { + auto track = receiver->track(); + if (track) + track_to_id[track.get()] = track->id(); } return track_to_id; }