Remove the old `ContributingSources` class.

This change removes the old `ContributingSources` class. It has been replaced by the new `SourceTracker`.

Bug: webrtc:10793
Change-Id: Ibd481cf6584837c46b229b9fc2a071362f07d361
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/147878
Reviewed-by: Erik Språng <sprang@webrtc.org>
Commit-Queue: Chen Xing <chxg@google.com>
Cr-Commit-Position: refs/heads/master@{#28756}
diff --git a/modules/rtp_rtcp/BUILD.gn b/modules/rtp_rtcp/BUILD.gn
index 95d3801..fc782c2 100644
--- a/modules/rtp_rtcp/BUILD.gn
+++ b/modules/rtp_rtcp/BUILD.gn
@@ -131,8 +131,6 @@
     "include/rtp_header_parser.h",
     "include/rtp_rtcp.h",
     "include/ulpfec_receiver.h",
-    "source/contributing_sources.cc",
-    "source/contributing_sources.h",
     "source/dtmf_queue.cc",
     "source/dtmf_queue.h",
     "source/fec_private_tables_bursty.cc",
@@ -388,7 +386,6 @@
 
     sources = [
       "source/byte_io_unittest.cc",
-      "source/contributing_sources_unittest.cc",
       "source/fec_private_tables_bursty_unittest.cc",
       "source/flexfec_header_reader_writer_unittest.cc",
       "source/flexfec_receiver_unittest.cc",
diff --git a/modules/rtp_rtcp/source/contributing_sources.cc b/modules/rtp_rtcp/source/contributing_sources.cc
deleted file mode 100644
index 88274ff..0000000
--- a/modules/rtp_rtcp/source/contributing_sources.cc
+++ /dev/null
@@ -1,81 +0,0 @@
-/*
- *  Copyright (c) 2018 The WebRTC project authors. All Rights Reserved.
- *
- *  Use of this source code is governed by a BSD-style license
- *  that can be found in the LICENSE file in the root of the source
- *  tree. An additional intellectual property rights grant can be found
- *  in the file PATENTS.  All contributing project authors may
- *  be found in the AUTHORS file in the root of the source tree.
- */
-
-#include "modules/rtp_rtcp/source/contributing_sources.h"
-
-namespace webrtc {
-
-namespace {
-
-// Allow some stale records to accumulate before cleaning.
-constexpr int64_t kPruningIntervalMs = 15 * rtc::kNumMillisecsPerSec;
-
-}  // namespace
-
-constexpr int64_t ContributingSources::kHistoryMs;
-
-ContributingSources::ContributingSources() = default;
-ContributingSources::~ContributingSources() = default;
-
-void ContributingSources::Update(int64_t now_ms,
-                                 rtc::ArrayView<const uint32_t> csrcs,
-                                 absl::optional<uint8_t> audio_level,
-                                 uint32_t rtp_timestamp) {
-  Entry entry = {now_ms, audio_level, rtp_timestamp};
-  for (uint32_t csrc : csrcs) {
-    active_csrcs_[csrc] = entry;
-  }
-  if (!next_pruning_ms_) {
-    next_pruning_ms_ = now_ms + kPruningIntervalMs;
-  } else if (now_ms > next_pruning_ms_) {
-    // To prevent unlimited growth, prune it every 15 seconds.
-    DeleteOldEntries(now_ms);
-  }
-}
-
-// Return contributing sources seen the last 10 s.
-// TODO(nisse): It would be more efficient to delete any stale entries while
-// iterating over the mapping, but then we'd have to make the method
-// non-const.
-std::vector<RtpSource> ContributingSources::GetSources(int64_t now_ms) const {
-  std::vector<RtpSource> sources;
-  for (auto& record : active_csrcs_) {
-    if (record.second.last_seen_ms >= now_ms - kHistoryMs) {
-      sources.emplace_back(record.second.last_seen_ms, record.first,
-                           RtpSourceType::CSRC, record.second.audio_level,
-                           record.second.rtp_timestamp);
-    }
-  }
-
-  return sources;
-}
-
-// Delete stale entries.
-void ContributingSources::DeleteOldEntries(int64_t now_ms) {
-  for (auto it = active_csrcs_.begin(); it != active_csrcs_.end();) {
-    if (it->second.last_seen_ms >= now_ms - kHistoryMs) {
-      // Still relevant.
-      ++it;
-    } else {
-      it = active_csrcs_.erase(it);
-    }
-  }
-  next_pruning_ms_ = now_ms + kPruningIntervalMs;
-}
-
-ContributingSources::Entry::Entry() = default;
-ContributingSources::Entry::Entry(int64_t timestamp_ms,
-                                  absl::optional<uint8_t> audio_level_arg,
-                                  uint32_t rtp_timestamp)
-    : last_seen_ms(timestamp_ms),
-      audio_level(audio_level_arg),
-      rtp_timestamp(rtp_timestamp) {}
-
-}  // namespace webrtc
diff --git a/modules/rtp_rtcp/source/contributing_sources.h b/modules/rtp_rtcp/source/contributing_sources.h
deleted file mode 100644
index 67e8967..0000000
--- a/modules/rtp_rtcp/source/contributing_sources.h
+++ /dev/null
@@ -1,64 +0,0 @@
-/*
- *  Copyright (c) 2018 The WebRTC project authors. All Rights Reserved.
- *
- *  Use of this source code is governed by a BSD-style license
- *  that can be found in the LICENSE file in the root of the source
- *  tree. An additional intellectual property rights grant can be found
- *  in the file PATENTS.  All contributing project authors may
- *  be found in the AUTHORS file in the root of the source tree.
- */
-
-#ifndef MODULES_RTP_RTCP_SOURCE_CONTRIBUTING_SOURCES_H_
-#define MODULES_RTP_RTCP_SOURCE_CONTRIBUTING_SOURCES_H_
-
-#include <stdint.h>
-
-#include <map>
-#include <vector>
-
-#include "absl/types/optional.h"
-#include "api/array_view.h"
-#include "api/rtp_receiver_interface.h"  // For RtpSource
-#include "rtc_base/time_utils.h"         // For kNumMillisecsPerSec
-
-namespace webrtc {
-
-class ContributingSources {
- public:
-  // Set by the spec, see
-  // https://www.w3.org/TR/webrtc/#dom-rtcrtpreceiver-getcontributingsources
-  static constexpr int64_t kHistoryMs = 10 * rtc::kNumMillisecsPerSec;
-
-  ContributingSources();
-  ~ContributingSources();
-
-  void Update(int64_t now_ms,
-              rtc::ArrayView<const uint32_t> csrcs,
-              absl::optional<uint8_t> audio_level,
-              uint32_t rtp_timestamp);
-
-  // Returns contributing sources seen the last 10 s.
-  std::vector<RtpSource> GetSources(int64_t now_ms) const;
-
- private:
-  struct Entry {
-    Entry();
-    Entry(int64_t timestamp_ms,
-          absl::optional<uint8_t> audio_level,
-          uint32_t rtp_timestamp);
-
-    int64_t last_seen_ms;
-    absl::optional<uint8_t> audio_level;
-    uint32_t rtp_timestamp;
-  };
-
-  void DeleteOldEntries(int64_t now_ms);
-
-  // Indexed by csrc.
-  std::map<uint32_t, Entry> active_csrcs_;
-  absl::optional<int64_t> next_pruning_ms_;
-};
-
-}  // namespace webrtc
-
-#endif  // MODULES_RTP_RTCP_SOURCE_CONTRIBUTING_SOURCES_H_
diff --git a/modules/rtp_rtcp/source/contributing_sources_unittest.cc b/modules/rtp_rtcp/source/contributing_sources_unittest.cc
deleted file mode 100644
index fa8b97b..0000000
--- a/modules/rtp_rtcp/source/contributing_sources_unittest.cc
+++ /dev/null
@@ -1,154 +0,0 @@
-/*
- *  Copyright (c) 2018 The WebRTC project authors. All Rights Reserved.
- *
- *  Use of this source code is governed by a BSD-style license
- *  that can be found in the LICENSE file in the root of the source
- *  tree. An additional intellectual property rights grant can be found
- *  in the file PATENTS.  All contributing project authors may
- *  be found in the AUTHORS file in the root of the source tree.
- */
-
-#include "modules/rtp_rtcp/source/contributing_sources.h"
-
-#include "rtc_base/time_utils.h"
-#include "test/gmock.h"
-#include "test/gtest.h"
-
-namespace webrtc {
-namespace {
-
-using ::testing::UnorderedElementsAre;
-
-constexpr uint32_t kCsrc1 = 111;
-constexpr uint32_t kCsrc2 = 222;
-constexpr uint32_t kCsrc3 = 333;
-constexpr uint32_t kRtpTimestamp1 = 314;
-constexpr uint32_t kRtpTimestamp2 = 315;
-constexpr uint32_t kRtpTimestamp3 = 316;
-
-}  // namespace
-
-TEST(ContributingSourcesTest, RecordSources) {
-  ContributingSources csrcs;
-  constexpr uint32_t kCsrcs[] = {kCsrc1, kCsrc2};
-  constexpr int64_t kTime1 = 10;
-  csrcs.Update(kTime1, kCsrcs, absl::nullopt, kRtpTimestamp1);
-  EXPECT_THAT(
-      csrcs.GetSources(kTime1),
-      UnorderedElementsAre(RtpSource(kTime1, kCsrc1, RtpSourceType::CSRC,
-                                     absl::nullopt, kRtpTimestamp1),
-                           RtpSource(kTime1, kCsrc2, RtpSourceType::CSRC,
-                                     absl::nullopt, kRtpTimestamp1)));
-}
-
-TEST(ContributingSourcesTest, UpdateSources) {
-  ContributingSources csrcs;
-  // TODO(nisse): When migrating to absl::Span, the named constant arrays should
-  // be replaced by unnamed literals where they are passed to csrcs.Update(...).
-  constexpr uint32_t kCsrcs1[] = {kCsrc1, kCsrc2};
-  constexpr uint32_t kCsrcs2[] = {kCsrc2, kCsrc3};
-  constexpr int64_t kTime1 = 10;
-  constexpr int64_t kTime2 = kTime1 + 5 * rtc::kNumMillisecsPerSec;
-  csrcs.Update(kTime1, kCsrcs1, absl::nullopt, kRtpTimestamp1);
-  EXPECT_THAT(
-      csrcs.GetSources(kTime1),
-      UnorderedElementsAre(RtpSource(kTime1, kCsrc1, RtpSourceType::CSRC,
-                                     absl::nullopt, kRtpTimestamp1),
-                           RtpSource(kTime1, kCsrc2, RtpSourceType::CSRC,
-                                     absl::nullopt, kRtpTimestamp1)));
-  csrcs.Update(kTime2, kCsrcs2, absl::nullopt, kRtpTimestamp2);
-  EXPECT_THAT(
-      csrcs.GetSources(kTime2),
-      UnorderedElementsAre(RtpSource(kTime1, kCsrc1, RtpSourceType::CSRC,
-                                     absl::nullopt, kRtpTimestamp1),
-                           RtpSource(kTime2, kCsrc2, RtpSourceType::CSRC,
-                                     absl::nullopt, kRtpTimestamp2),
-                           RtpSource(kTime2, kCsrc3, RtpSourceType::CSRC,
-                                     absl::nullopt, kRtpTimestamp2)));
-}
-
-TEST(ContributingSourcesTest, ReturnRecentOnly) {
-  ContributingSources csrcs;
-  constexpr uint32_t kCsrcs1[] = {kCsrc1, kCsrc2};
-  constexpr uint32_t kCsrcs2[] = {kCsrc2, kCsrc3};
-  constexpr int64_t kTime1 = 10;
-  constexpr int64_t kTime2 = kTime1 + 5 * rtc::kNumMillisecsPerSec;
-  constexpr int64_t kTime3 = kTime1 + 12 * rtc::kNumMillisecsPerSec;
-  csrcs.Update(kTime1, kCsrcs1, absl::nullopt, kRtpTimestamp1);
-  EXPECT_THAT(
-      csrcs.GetSources(kTime1),
-      UnorderedElementsAre(RtpSource(kTime1, kCsrc1, RtpSourceType::CSRC,
-                                     absl::nullopt, kRtpTimestamp1),
-                           RtpSource(kTime1, kCsrc2, RtpSourceType::CSRC,
-                                     absl::nullopt, kRtpTimestamp1)));
-  csrcs.Update(kTime2, kCsrcs2, absl::nullopt, kRtpTimestamp2);
-  EXPECT_THAT(
-      csrcs.GetSources(kTime3),
-      UnorderedElementsAre(RtpSource(kTime2, kCsrc2, RtpSourceType::CSRC,
-                                     absl::nullopt, kRtpTimestamp2),
-                           RtpSource(kTime2, kCsrc3, RtpSourceType::CSRC,
-                                     absl::nullopt, kRtpTimestamp2)));
-}
-
-TEST(ContributingSourcesTest, PurgeOldSources) {
-  ContributingSources csrcs;
-  constexpr uint32_t kCsrcs1[] = {kCsrc1, kCsrc2};
-  constexpr uint32_t kCsrcs2[] = {kCsrc2, kCsrc3};
-  constexpr int64_t kTime1 = 10;
-  constexpr int64_t kTime2 = kTime1 + 10 * rtc::kNumMillisecsPerSec;
-  constexpr int64_t kTime3 = kTime1 + 20 * rtc::kNumMillisecsPerSec;
-  csrcs.Update(kTime1, kCsrcs1, absl::nullopt, kRtpTimestamp1);
-  EXPECT_THAT(
-      csrcs.GetSources(kTime2),
-      UnorderedElementsAre(RtpSource(kTime1, kCsrc1, RtpSourceType::CSRC,
-                                     absl::nullopt, kRtpTimestamp1),
-                           RtpSource(kTime1, kCsrc2, RtpSourceType::CSRC,
-                                     absl::nullopt, kRtpTimestamp1)));
-  csrcs.Update(kTime2, kCsrcs2, absl::nullopt, kRtpTimestamp2);
-  EXPECT_THAT(
-      csrcs.GetSources(kTime2),
-      UnorderedElementsAre(RtpSource(kTime1, kCsrc1, RtpSourceType::CSRC,
-                                     absl::nullopt, kRtpTimestamp1),
-                           RtpSource(kTime2, kCsrc2, RtpSourceType::CSRC,
-                                     absl::nullopt, kRtpTimestamp2),
-                           RtpSource(kTime2, kCsrc3, RtpSourceType::CSRC,
-                                     absl::nullopt, kRtpTimestamp2)));
-  csrcs.Update(kTime3, kCsrcs2, absl::nullopt, kRtpTimestamp3);
-  EXPECT_THAT(
-      csrcs.GetSources(kTime3),
-      UnorderedElementsAre(RtpSource(kTime3, kCsrc2, RtpSourceType::CSRC,
-                                     absl::nullopt, kRtpTimestamp3),
-                           RtpSource(kTime3, kCsrc3, RtpSourceType::CSRC,
-                                     absl::nullopt, kRtpTimestamp3)));
-  // Query at an earlier time; check that old sources really have been purged
-  // and don't reappear.
-  EXPECT_THAT(
-      csrcs.GetSources(kTime2),
-      UnorderedElementsAre(RtpSource(kTime3, kCsrc2, RtpSourceType::CSRC,
-                                     absl::nullopt, kRtpTimestamp3),
-                           RtpSource(kTime3, kCsrc3, RtpSourceType::CSRC,
-                                     absl::nullopt, kRtpTimestamp3)));
-}
-
-TEST(ContributingSourcesTest, AudioLevel) {
-  ContributingSources csrcs;
-  constexpr uint32_t kCsrcs[] = {kCsrc1, kCsrc2};
-  constexpr int64_t kTime1 = 10;
-  csrcs.Update(kTime1, kCsrcs, 47, kRtpTimestamp1);
-  EXPECT_THAT(
-      csrcs.GetSources(kTime1),
-      UnorderedElementsAre(
-          RtpSource(kTime1, kCsrc1, RtpSourceType::CSRC, 47, kRtpTimestamp1),
-          RtpSource(kTime1, kCsrc2, RtpSourceType::CSRC, 47, kRtpTimestamp1)));
-
-  constexpr uint32_t kCsrcsSubset[] = {kCsrc1};
-  csrcs.Update(kTime1 + 1, kCsrcsSubset, absl::nullopt, kRtpTimestamp2);
-  EXPECT_THAT(
-      csrcs.GetSources(kTime1 + 1),
-      UnorderedElementsAre(
-          RtpSource(kTime1 + 1, kCsrc1, RtpSourceType::CSRC, absl::nullopt,
-                    kRtpTimestamp2),
-          RtpSource(kTime1, kCsrc2, RtpSourceType::CSRC, 47, kRtpTimestamp1)));
-}
-
-}  // namespace webrtc
diff --git a/video/rtp_video_stream_receiver.h b/video/rtp_video_stream_receiver.h
index 2c1f8ba..365be4a 100644
--- a/video/rtp_video_stream_receiver.h
+++ b/video/rtp_video_stream_receiver.h
@@ -30,7 +30,6 @@
 #include "modules/rtp_rtcp/include/rtp_header_extension_map.h"
 #include "modules/rtp_rtcp/include/rtp_rtcp.h"
 #include "modules/rtp_rtcp/include/rtp_rtcp_defines.h"
-#include "modules/rtp_rtcp/source/contributing_sources.h"
 #include "modules/video_coding/h264_sps_pps_tracker.h"
 #include "modules/video_coding/loss_notification_controller.h"
 #include "modules/video_coding/packet_buffer.h"