[getStats] Fix DCHECK crash in MergeInfoAboutOutboundRtpSubstreams().

It seems possible that getStats() and merging RTX/FlexFEC substream
stats into media substream stats can race with the creation or
destruction of the media substream that the RTX/FlexFEC substream is
associated with.

In other words, the DCHECK that ensures that there exists a stats object
to merge into is not always valid. Because there is no media stats
object to merge in to, and outbound-rtp stats objects only exists per
media SSRCs, the sensible thing to do is to RTC_LOG and ignore the
substream stats.

Bug: webrtc:11545
Change-Id: I4061d7190da7ab8bd33fa1fd92c9d819f35d76c7
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/174360
Reviewed-by: Ilya Nikolaevskiy <ilnik@webrtc.org>
Commit-Queue: Henrik Boström <hbos@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#31156}
This commit is contained in:
Henrik Boström 2020-05-04 16:10:41 +02:00 committed by Commit Bot
parent 455e80271c
commit d9255b1840

View file

@ -49,6 +49,19 @@ namespace {
const int kMinLayerSize = 16;
const char* StreamTypeToString(
webrtc::VideoSendStream::StreamStats::StreamType type) {
switch (type) {
case webrtc::VideoSendStream::StreamStats::StreamType::kMedia:
return "kMedia";
case webrtc::VideoSendStream::StreamStats::StreamType::kRtx:
return "kRtx";
case webrtc::VideoSendStream::StreamStats::StreamType::kFlexfec:
return "kFlexfec";
}
return nullptr;
}
// If this field trial is enabled, we will enable sending FlexFEC and disable
// sending ULPFEC whenever the former has been negotiated in the SDPs.
bool IsFlexfecFieldTrialEnabled() {
@ -372,7 +385,14 @@ MergeInfoAboutOutboundRtpSubstreams(
pair.second;
RTC_DCHECK(associated_substream.referenced_media_ssrc.has_value());
uint32_t media_ssrc = associated_substream.referenced_media_ssrc.value();
RTC_DCHECK(substreams.find(media_ssrc) != substreams.end());
if (substreams.find(media_ssrc) == substreams.end()) {
RTC_LOG(LS_WARNING) << "Substream [ssrc: " << pair.first << ", type: "
<< StreamTypeToString(associated_substream.type)
<< "] is associated with a media ssrc (" << media_ssrc
<< ") that does not have StreamStats. Ignoring its "
<< "RTP stats.";
continue;
}
webrtc::VideoSendStream::StreamStats& rtp_substream =
rtp_substreams[media_ssrc];