diff --git a/pc/peer_connection_integrationtest.cc b/pc/peer_connection_integrationtest.cc index 7fa94527f1..bf2d77078f 100644 --- a/pc/peer_connection_integrationtest.cc +++ b/pc/peer_connection_integrationtest.cc @@ -1326,8 +1326,8 @@ TEST_F(PeerConnectionIntegrationTestUnifiedPlan, } // 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 @@ TEST_P(PeerConnectionIntegrationTest, NewGetStatsManyAudioAndManyVideoStreams) { 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( - *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( + 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 @@ TEST_P(PeerConnectionIntegrationTest, NewGetStatsManyAudioAndManyVideoStreams) { 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( - *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 @@ TEST_P(PeerConnectionIntegrationTest, callee()->NewGetStats(); ASSERT_NE(nullptr, report); - auto media_stats = - report->GetStatsOfType(); - 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(); + 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 @@ TEST_P(PeerConnectionIntegrationTest, DisableAndEnableAudioPlayout) { double GetAudioEnergyStat(PeerConnectionIntegrationWrapper* pc) { auto report = pc->NewGetStats(); - auto track_stats_list = - report->GetStatsOfType(); - 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(); + 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 a014d02d75..471271f068 100644 --- a/pc/test/integration_test_helpers.cc +++ b/pc/test/integration_test_helpers.cc @@ -46,10 +46,9 @@ void RemoveSsrcsAndKeepMsids(cricket::SessionDescription* desc) { int FindFirstMediaStatsIndexByKind( const std::string& kind, - const std::vector& - 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& 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 64a06ebb7d..4e01b333b9 100644 --- a/pc/test/integration_test_helpers.h +++ b/pc/test/integration_test_helpers.h @@ -171,12 +171,9 @@ void RemoveSsrcsAndMsids(cricket::SessionDescription* desc); // 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& - media_stats_vec); + const std::vector& inbound_rtps); class TaskQueueMetronome : public webrtc::Metronome { public: