Move more non-standard metrics to inbound-rtp.

They may be non-standard, but they shouldn't be on a stats dictionary
that is deprecated (track is going away soon-ish). By moving them to
inbound-rtp they can continue to exist beyond track deprecation and
live in the right place in case we decide to standardize them later.

To help downstream projects transitions, the metrics are temporarily
available in both old and new locations. Delete of old location will
happen in a follow-up CL. TODOs added.

Bug: webrtc:14524
Change-Id: I2008060fa4ba76cde859d9144d2bb9648c7ff9af
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/278200
Reviewed-by: Harald Alvestrand <hta@webrtc.org>
Commit-Queue: Henrik Boström <hbos@webrtc.org>
Cr-Commit-Position: refs/heads/main@{#38315}
diff --git a/pc/test/integration_test_helpers.h b/pc/test/integration_test_helpers.h
index 7e5cc74..1d9882e 100644
--- a/pc/test/integration_test_helpers.h
+++ b/pc/test/integration_test_helpers.h
@@ -171,6 +171,8 @@
 // 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::RTCMediaStreamTrackStats*>&
@@ -650,34 +652,26 @@
   void StartWatchingDelayStats() {
     // Get the baseline numbers for audio_packets and audio_delay.
     auto received_stats = NewGetStats();
-    auto track_stats =
-        received_stats->GetStatsOfType<webrtc::RTCMediaStreamTrackStats>()[0];
-    ASSERT_TRUE(track_stats->relative_packet_arrival_delay.is_defined());
     auto rtp_stats =
         received_stats->GetStatsOfType<webrtc::RTCInboundRTPStreamStats>()[0];
+    ASSERT_TRUE(rtp_stats->relative_packet_arrival_delay.is_defined());
     ASSERT_TRUE(rtp_stats->packets_received.is_defined());
     ASSERT_TRUE(rtp_stats->track_id.is_defined());
-    audio_track_stats_id_ = track_stats->id();
-    ASSERT_TRUE(received_stats->Get(audio_track_stats_id_));
     rtp_stats_id_ = rtp_stats->id();
-    ASSERT_EQ(audio_track_stats_id_, *rtp_stats->track_id);
     audio_packets_stat_ = *rtp_stats->packets_received;
-    audio_delay_stat_ = *track_stats->relative_packet_arrival_delay;
-    audio_samples_stat_ = *track_stats->total_samples_received;
-    audio_concealed_stat_ = *track_stats->concealed_samples;
+    audio_delay_stat_ = *rtp_stats->relative_packet_arrival_delay;
+    audio_samples_stat_ = *rtp_stats->total_samples_received;
+    audio_concealed_stat_ = *rtp_stats->concealed_samples;
   }
 
   void UpdateDelayStats(std::string tag, int desc_size) {
     auto report = NewGetStats();
-    auto track_stats =
-        report->GetAs<webrtc::RTCMediaStreamTrackStats>(audio_track_stats_id_);
-    ASSERT_TRUE(track_stats);
     auto rtp_stats =
         report->GetAs<webrtc::RTCInboundRTPStreamStats>(rtp_stats_id_);
     ASSERT_TRUE(rtp_stats);
     auto delta_packets = *rtp_stats->packets_received - audio_packets_stat_;
     auto delta_rpad =
-        *track_stats->relative_packet_arrival_delay - audio_delay_stat_;
+        *rtp_stats->relative_packet_arrival_delay - audio_delay_stat_;
     auto recent_delay = delta_packets > 0 ? delta_rpad / delta_packets : -1;
     // The purpose of these checks is to sound the alarm early if we introduce
     // serious regressions. The numbers are not acceptable for production, but
@@ -694,9 +688,9 @@
     EXPECT_GT(0.1, recent_delay) << tag << " size " << desc_size;
 #endif
     auto delta_samples =
-        *track_stats->total_samples_received - audio_samples_stat_;
+        *rtp_stats->total_samples_received - audio_samples_stat_;
     auto delta_concealed =
-        *track_stats->concealed_samples - audio_concealed_stat_;
+        *rtp_stats->concealed_samples - audio_concealed_stat_;
     // These limits should be adjusted down as we improve:
     //
     // Concealing more than 4000 samples during a renegotiation is unacceptable.
@@ -731,9 +725,9 @@
     }
     // Increment trailing counters
     audio_packets_stat_ = *rtp_stats->packets_received;
-    audio_delay_stat_ = *track_stats->relative_packet_arrival_delay;
-    audio_samples_stat_ = *track_stats->total_samples_received;
-    audio_concealed_stat_ = *track_stats->concealed_samples;
+    audio_delay_stat_ = *rtp_stats->relative_packet_arrival_delay;
+    audio_samples_stat_ = *rtp_stats->total_samples_received;
+    audio_concealed_stat_ = *rtp_stats->concealed_samples;
   }
 
   // Sets number of candidates expected
@@ -1240,7 +1234,6 @@
   uint64_t audio_samples_stat_ = 0;
   uint64_t audio_concealed_stat_ = 0;
   std::string rtp_stats_id_;
-  std::string audio_track_stats_id_;
 
   ScopedTaskSafety task_safety_;