[Stats] Don't attempt to aggregate empty VideoSenderInfos.
This fixes a crash that could happen if substreams exist but there is no kMedia substream yet. There was an assumption that we either had no substreams or at least one kMedia substream, but this was not true. The correct thing to do is to ignore substream stats that are not associated with any kMedia substream, because we only produce "outbound-rtp" stats objects for existing kMedia substreams. A test is added to make sure no stats are returned. Prior to the fix, this test would crash. Bug: chromium:1090712 Change-Id: Ib1f8494a162542ae56bdd2df7618775a3473419b Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/176446 Commit-Queue: Henrik Boström <hbos@webrtc.org> Reviewed-by: Erik Språng <sprang@webrtc.org> Cr-Commit-Position: refs/heads/master@{#31442}
This commit is contained in:
parent
8b7cfa16aa
commit
e917379c5b
@ -1587,6 +1587,8 @@ void WebRtcVideoChannel::FillSenderStats(VideoMediaInfo* video_media_info,
|
||||
send_streams_.begin();
|
||||
it != send_streams_.end(); ++it) {
|
||||
auto infos = it->second->GetPerLayerVideoSenderInfos(log_stats);
|
||||
if (infos.empty())
|
||||
continue;
|
||||
video_media_info->aggregated_senders.push_back(
|
||||
it->second->GetAggregatedVideoSenderInfo(infos));
|
||||
for (auto&& info : infos) {
|
||||
@ -2594,7 +2596,7 @@ VideoSenderInfo
|
||||
WebRtcVideoChannel::WebRtcVideoSendStream::GetAggregatedVideoSenderInfo(
|
||||
const std::vector<VideoSenderInfo>& infos) const {
|
||||
RTC_DCHECK_RUN_ON(&thread_checker_);
|
||||
RTC_DCHECK(!infos.empty());
|
||||
RTC_CHECK(!infos.empty());
|
||||
if (infos.size() == 1) {
|
||||
return infos[0];
|
||||
}
|
||||
|
||||
@ -5599,6 +5599,27 @@ TEST_F(WebRtcVideoChannelTest, GetPerLayerStatsReportForSubStreams) {
|
||||
EXPECT_EQ(sender.rid, absl::nullopt);
|
||||
}
|
||||
|
||||
TEST_F(WebRtcVideoChannelTest, MediaSubstreamMissingProducesEmpyStats) {
|
||||
FakeVideoSendStream* stream = AddSendStream();
|
||||
|
||||
const uint32_t kRtxSsrc = 123u;
|
||||
const uint32_t kMissingMediaSsrc = 124u;
|
||||
|
||||
// Set up a scenarios where we have a substream that is not kMedia (in this
|
||||
// case: kRtx) but its associated kMedia stream does not exist yet. This
|
||||
// results in zero GetPerLayerVideoSenderInfos despite non-empty substreams.
|
||||
// Covers https://crbug.com/1090712.
|
||||
auto stats = GetInitialisedStats();
|
||||
auto& substream = stats.substreams[kRtxSsrc];
|
||||
substream.type = webrtc::VideoSendStream::StreamStats::StreamType::kRtx;
|
||||
substream.referenced_media_ssrc = kMissingMediaSsrc;
|
||||
stream->SetStats(stats);
|
||||
|
||||
cricket::VideoMediaInfo video_media_info;
|
||||
ASSERT_TRUE(channel_->GetStats(&video_media_info));
|
||||
EXPECT_TRUE(video_media_info.senders.empty());
|
||||
}
|
||||
|
||||
TEST_F(WebRtcVideoChannelTest, GetStatsReportsUpperResolution) {
|
||||
FakeVideoSendStream* stream = AddSendStream();
|
||||
webrtc::VideoSendStream::Stats stats;
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user