Remove dependencies on 'track' stats from PC integration tests. This unblocks the deletion of this deprecated stats object. Bug: webrtc:14175 Change-Id: I850c028fc9556a36191909afa3d635a7e6b65b69 Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/288582 Reviewed-by: Harald Alvestrand <hta@webrtc.org> Commit-Queue: Henrik Boström <hbos@webrtc.org> Cr-Commit-Position: refs/heads/main@{#38983}
diff --git a/pc/peer_connection_integrationtest.cc b/pc/peer_connection_integrationtest.cc index 7fa9452..bf2d770 100644 --- a/pc/peer_connection_integrationtest.cc +++ b/pc/peer_connection_integrationtest.cc
@@ -1326,8 +1326,8 @@ } // Test that the new GetStats() returns stats for all outgoing/incoming streams -// with the correct track IDs if there are more than one audio and more than one -// video senders/receivers. +// with the correct track identifiers if there are more than one audio and more +// than one video senders/receivers. TEST_P(PeerConnectionIntegrationTest, NewGetStatsManyAudioAndManyVideoStreams) { ASSERT_TRUE(CreatePeerConnectionWrappers()); ConnectFakeSignaling(); @@ -1362,12 +1362,12 @@ ASSERT_TRUE(stat->frames_encoded.is_defined()); EXPECT_GE(*stat->frames_encoded, *stat->key_frames_encoded); } - ASSERT_TRUE(stat->track_id.is_defined()); - const auto* track_stat = - caller_report->GetAs<webrtc::DEPRECATED_RTCMediaStreamTrackStats>( - *stat->track_id); - ASSERT_TRUE(track_stat); - outbound_track_ids.push_back(*track_stat->track_identifier); + ASSERT_TRUE(stat->media_source_id.is_defined()); + const RTCMediaSourceStats* media_source = + static_cast<const RTCMediaSourceStats*>( + caller_report->Get(*stat->media_source_id)); + ASSERT_TRUE(media_source); + outbound_track_ids.push_back(*media_source->track_identifier); } EXPECT_THAT(outbound_track_ids, UnorderedElementsAreArray(track_ids)); @@ -1387,12 +1387,7 @@ ASSERT_TRUE(stat->frames_decoded.is_defined()); EXPECT_GE(*stat->frames_decoded, *stat->key_frames_decoded); } - ASSERT_TRUE(stat->track_id.is_defined()); - const auto* track_stat = - callee_report->GetAs<webrtc::DEPRECATED_RTCMediaStreamTrackStats>( - *stat->track_id); - ASSERT_TRUE(track_stat); - inbound_track_ids.push_back(*track_stat->track_identifier); + inbound_track_ids.push_back(*stat->track_identifier); } EXPECT_THAT(inbound_track_ids, UnorderedElementsAreArray(track_ids)); } @@ -1467,11 +1462,11 @@ callee()->NewGetStats(); ASSERT_NE(nullptr, report); - auto media_stats = - report->GetStatsOfType<webrtc::DEPRECATED_RTCMediaStreamTrackStats>(); - auto audio_index = FindFirstMediaStatsIndexByKind("audio", media_stats); - ASSERT_GE(audio_index, 0); - EXPECT_TRUE(media_stats[audio_index]->audio_level.is_defined()); + auto inbound_rtps = + report->GetStatsOfType<webrtc::RTCInboundRTPStreamStats>(); + auto index = FindFirstMediaStatsIndexByKind("audio", inbound_rtps); + ASSERT_GE(index, 0); + EXPECT_TRUE(inbound_rtps[index]->audio_level.is_defined()); } // Helper for test below. @@ -2882,22 +2877,14 @@ double GetAudioEnergyStat(PeerConnectionIntegrationWrapper* pc) { auto report = pc->NewGetStats(); - auto track_stats_list = - report->GetStatsOfType<webrtc::DEPRECATED_RTCMediaStreamTrackStats>(); - const webrtc::DEPRECATED_RTCMediaStreamTrackStats* remote_track_stats = - nullptr; - for (const auto* track_stats : track_stats_list) { - if (track_stats->remote_source.is_defined() && - *track_stats->remote_source) { - remote_track_stats = track_stats; - break; - } - } - - if (!remote_track_stats->total_audio_energy.is_defined()) { + auto inbound_rtps = + report->GetStatsOfType<webrtc::RTCInboundRTPStreamStats>(); + RTC_CHECK(!inbound_rtps.empty()); + auto* inbound_rtp = inbound_rtps[0]; + if (!inbound_rtp->total_audio_energy.is_defined()) { return 0.0; } - return *remote_track_stats->total_audio_energy; + return *inbound_rtp->total_audio_energy; } // Test that if audio playout is disabled via the SetAudioPlayout() method, then
diff --git a/pc/test/integration_test_helpers.cc b/pc/test/integration_test_helpers.cc index a014d02..471271f 100644 --- a/pc/test/integration_test_helpers.cc +++ b/pc/test/integration_test_helpers.cc
@@ -46,10 +46,9 @@ int FindFirstMediaStatsIndexByKind( const std::string& kind, - const std::vector<const webrtc::DEPRECATED_RTCMediaStreamTrackStats*>& - media_stats_vec) { - for (size_t i = 0; i < media_stats_vec.size(); i++) { - if (media_stats_vec[i]->kind.ValueToString() == kind) { + const std::vector<const webrtc::RTCInboundRTPStreamStats*>& inbound_rtps) { + for (size_t i = 0; i < inbound_rtps.size(); i++) { + if (*inbound_rtps[i]->kind == kind) { return i; } }
diff --git a/pc/test/integration_test_helpers.h b/pc/test/integration_test_helpers.h index 64a06eb..4e01b33 100644 --- a/pc/test/integration_test_helpers.h +++ b/pc/test/integration_test_helpers.h
@@ -171,12 +171,9 @@ // endpoint that only signals a=msid lines to convey stream_ids. void RemoveSsrcsAndKeepMsids(cricket::SessionDescription* desc); -// TODO(https://crbug.com/webrtc/14175): Stop depending on "track" stats, the -// metrics we're interested in are already available in "inbound-rtp". int FindFirstMediaStatsIndexByKind( const std::string& kind, - const std::vector<const webrtc::DEPRECATED_RTCMediaStreamTrackStats*>& - media_stats_vec); + const std::vector<const webrtc::RTCInboundRTPStreamStats*>& inbound_rtps); class TaskQueueMetronome : public webrtc::Metronome { public: