Cleanup unused members in RtpRtcp::Configuration

They are now passed as part of the Environment

Bug: webrtc:362762208
Change-Id: I02868e9f41533a546f62fe30fdc6f3a7708eb346
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/362084
Reviewed-by: Åsa Persson <asapersson@webrtc.org>
Commit-Queue: Danil Chapovalov <danilchap@webrtc.org>
Cr-Commit-Position: refs/heads/main@{#43032}
diff --git a/modules/rtp_rtcp/BUILD.gn b/modules/rtp_rtcp/BUILD.gn
index 8297e2e..ab96148 100644
--- a/modules/rtp_rtcp/BUILD.gn
+++ b/modules/rtp_rtcp/BUILD.gn
@@ -282,6 +282,7 @@
     "../../api:field_trials_view",
     "../../api:frame_transformer_interface",
     "../../api:function_view",
+    "../../api:make_ref_counted",
     "../../api:rtp_headers",
     "../../api:rtp_packet_info",
     "../../api:rtp_packet_sender",
diff --git a/modules/rtp_rtcp/source/rtp_rtcp_impl.cc b/modules/rtp_rtcp/source/rtp_rtcp_impl.cc
index 164e3d1..2bfbb1a 100644
--- a/modules/rtp_rtcp/source/rtp_rtcp_impl.cc
+++ b/modules/rtp_rtcp/source/rtp_rtcp_impl.cc
@@ -74,15 +74,7 @@
 
 std::unique_ptr<RtpRtcp> RtpRtcp::Create(const Environment& env,
                                          const Configuration& configuration) {
-  RTC_DCHECK(configuration.field_trials == nullptr);
-  RTC_DCHECK(configuration.clock == nullptr);
-  RTC_DCHECK(configuration.event_log == nullptr);
-
-  Configuration config = configuration;
-  config.field_trials = &env.field_trials();
-  config.clock = &env.clock();
-  config.event_log = &env.event_log();
-  return std::make_unique<ModuleRtpRtcpImpl>(env, config);
+  return std::make_unique<ModuleRtpRtcpImpl>(env, configuration);
 }
 
 ModuleRtpRtcpImpl::ModuleRtpRtcpImpl(const Environment& env,
diff --git a/modules/rtp_rtcp/source/rtp_rtcp_impl2.cc b/modules/rtp_rtcp/source/rtp_rtcp_impl2.cc
index ae78e0e..4806c70 100644
--- a/modules/rtp_rtcp/source/rtp_rtcp_impl2.cc
+++ b/modules/rtp_rtcp/source/rtp_rtcp_impl2.cc
@@ -87,28 +87,8 @@
           &packet_history,
           config.paced_sender ? config.paced_sender : &non_paced_sender) {}
 
-// TODO: b/362762208 - Update ModuleRtpRtcpImpl2 including its members to query
-// Environment directly, and remove similar fields from the Configuration.
-// Merge two constructors into single one after that.
 ModuleRtpRtcpImpl2::ModuleRtpRtcpImpl2(const Environment& env,
                                        const Configuration& configuration)
-    : ModuleRtpRtcpImpl2({}, env, [&] {
-        // Check users of this constructor switch to not duplicate
-        // utilities passed with environment.
-        RTC_DCHECK(configuration.field_trials == nullptr);
-        RTC_DCHECK(configuration.clock == nullptr);
-        RTC_DCHECK(configuration.event_log == nullptr);
-
-        Configuration config = configuration;
-        config.field_trials = &env.field_trials();
-        config.clock = &env.clock();
-        config.event_log = &env.event_log();
-        return config;
-      }()) {}
-
-ModuleRtpRtcpImpl2::ModuleRtpRtcpImpl2(TagConfigurationIncludesEnvironment,
-                                       const Environment& env,
-                                       const Configuration& configuration)
     : env_(env),
       worker_queue_(TaskQueueBase::Current()),
       rtcp_sender_(env_,
diff --git a/modules/rtp_rtcp/source/rtp_rtcp_impl2.h b/modules/rtp_rtcp/source/rtp_rtcp_impl2.h
index 4951790..57139e2 100644
--- a/modules/rtp_rtcp/source/rtp_rtcp_impl2.h
+++ b/modules/rtp_rtcp/source/rtp_rtcp_impl2.h
@@ -50,7 +50,6 @@
 
 namespace webrtc {
 
-class Clock;
 struct PacedPacketInfo;
 struct RTPVideoHeader;
 
@@ -274,11 +273,6 @@
     RTPSender packet_generator;
   };
 
-  struct TagConfigurationIncludesEnvironment {};
-  explicit ModuleRtpRtcpImpl2(TagConfigurationIncludesEnvironment,
-                              const Environment& env,
-                              const Configuration& configuration);
-
   void set_rtt_ms(int64_t rtt_ms);
   int64_t rtt_ms() const;
 
diff --git a/modules/rtp_rtcp/source/rtp_rtcp_impl_unittest.cc b/modules/rtp_rtcp/source/rtp_rtcp_impl_unittest.cc
index 0e78a82..dd69312 100644
--- a/modules/rtp_rtcp/source/rtp_rtcp_impl_unittest.cc
+++ b/modules/rtp_rtcp/source/rtp_rtcp_impl_unittest.cc
@@ -131,8 +131,7 @@
   RtpRtcpModule(SimulatedClock* clock, bool is_sender)
       : env_(CreateEnvironment(clock)),
         is_sender_(is_sender),
-        receive_statistics_(ReceiveStatistics::Create(clock)),
-        clock_(clock) {
+        receive_statistics_(ReceiveStatistics::Create(clock)) {
     CreateModuleImpl();
     transport_.SimulateNetworkDelay(kOneWayNetworkDelay.ms(), clock);
   }
@@ -178,7 +177,6 @@
   void CreateModuleImpl() {
     RtpRtcpInterface::Configuration config;
     config.audio = false;
-    config.clock = clock_;
     config.outgoing_transport = &transport_;
     config.receive_statistics = receive_statistics_.get();
     config.rtcp_packet_type_counter_observer = this;
@@ -193,7 +191,6 @@
     impl_->SetRTCPStatus(RtcpMode::kCompound);
   }
 
-  SimulatedClock* const clock_;
   std::map<uint32_t, RtcpPacketTypeCounter> counter_map_;
 };
 }  // namespace
diff --git a/modules/rtp_rtcp/source/rtp_rtcp_interface.h b/modules/rtp_rtcp/source/rtp_rtcp_interface.h
index 15395b2..dd34cf7e 100644
--- a/modules/rtp_rtcp/source/rtp_rtcp_interface.h
+++ b/modules/rtp_rtcp/source/rtp_rtcp_interface.h
@@ -20,7 +20,6 @@
 
 #include "absl/strings/string_view.h"
 #include "api/array_view.h"
-#include "api/field_trials_view.h"
 #include "api/frame_transformer_interface.h"
 #include "api/rtp_headers.h"
 #include "api/rtp_packet_sender.h"
@@ -43,7 +42,6 @@
 // Forward declarations.
 class FrameEncryptorInterface;
 class RateLimiter;
-class RtcEventLog;
 class RTPSender;
 class Transport;
 class VideoBitrateAllocationObserver;
@@ -56,9 +54,6 @@
     bool audio = false;
     bool receiver_only = false;
 
-    // The clock to use to read time. If nullptr then system clock will be used.
-    Clock* clock = nullptr;
-
     ReceiveStatisticsProvider* receive_statistics = nullptr;
 
     // Transport object that will be called when packets are ready to be sent
@@ -101,7 +96,6 @@
     VideoFecGenerator* fec_generator = nullptr;
 
     BitrateStatisticsObserver* send_bitrate_observer = nullptr;
-    RtcEventLog* event_log = nullptr;
     SendPacketObserver* send_packet_observer = nullptr;
     RateLimiter* retransmission_rate_limiter = nullptr;
     StreamDataCountersCallback* rtp_stats_callback = nullptr;
@@ -128,9 +122,6 @@
     // done by RTCP RR acking.
     bool always_send_mid_and_rid = false;
 
-    // If set, field trials are read from `field_trials`.
-    const FieldTrialsView* field_trials = nullptr;
-
     // SSRCs for media and retransmission, respectively.
     // FlexFec SSRC is fetched from `flexfec_sender`.
     uint32_t local_media_ssrc = 0;
diff --git a/modules/rtp_rtcp/source/rtp_sender.cc b/modules/rtp_rtcp/source/rtp_sender.cc
index 9d1f423..c467cb7 100644
--- a/modules/rtp_rtcp/source/rtp_sender.cc
+++ b/modules/rtp_rtcp/source/rtp_sender.cc
@@ -157,18 +157,7 @@
                      const RtpRtcpInterface::Configuration& config,
                      RtpPacketHistory* packet_history,
                      RtpPacketSender* packet_sender)
-    : RTPSender(&env.clock(), config, packet_history, packet_sender) {}
-
-RTPSender::RTPSender(const RtpRtcpInterface::Configuration& config,
-                     RtpPacketHistory* packet_history,
-                     RtpPacketSender* packet_sender)
-    : RTPSender(config.clock, config, packet_history, packet_sender) {}
-
-RTPSender::RTPSender(Clock* clock,
-                     const RtpRtcpInterface::Configuration& config,
-                     RtpPacketHistory* packet_history,
-                     RtpPacketSender* packet_sender)
-    : clock_(clock),
+    : clock_(&env.clock()),
       random_(clock_->TimeInMicroseconds()),
       audio_configured_(config.audio),
       ssrc_(config.local_media_ssrc),
diff --git a/modules/rtp_rtcp/source/rtp_sender.h b/modules/rtp_rtcp/source/rtp_sender.h
index d97e4ae..0a29968 100644
--- a/modules/rtp_rtcp/source/rtp_sender.h
+++ b/modules/rtp_rtcp/source/rtp_sender.h
@@ -49,10 +49,6 @@
             RtpPacketHistory* packet_history,
             RtpPacketSender* packet_sender);
 
-  [[deprecated("bugs.webrtc.org/362762208")]]  //
-  RTPSender(const RtpRtcpInterface::Configuration& config,
-            RtpPacketHistory* packet_history,
-            RtpPacketSender* packet_sender);
   RTPSender(const RTPSender&) = delete;
   RTPSender& operator=(const RTPSender&) = delete;
 
@@ -161,11 +157,6 @@
   RtpState GetRtxRtpState() const RTC_LOCKS_EXCLUDED(send_mutex_);
 
  private:
-  RTPSender(Clock* clock,
-            const RtpRtcpInterface::Configuration& config,
-            RtpPacketHistory* packet_history,
-            RtpPacketSender* packet_sender);
-
   std::unique_ptr<RtpPacketToSend> BuildRtxPacket(
       const RtpPacketToSend& packet);
 
diff --git a/modules/rtp_rtcp/source/rtp_sender_egress.cc b/modules/rtp_rtcp/source/rtp_sender_egress.cc
index c29e391..e93d1b8 100644
--- a/modules/rtp_rtcp/source/rtp_sender_egress.cc
+++ b/modules/rtp_rtcp/source/rtp_sender_egress.cc
@@ -50,15 +50,6 @@
 constexpr TimeDelta kBitrateStatisticsWindow = TimeDelta::Seconds(1);
 constexpr size_t kRtpSequenceNumberMapMaxEntries = 1 << 13;
 constexpr TimeDelta kUpdateInterval = kBitrateStatisticsWindow;
-
-bool GetUseNtpTimeForAbsoluteSendTime(const FieldTrialsView* field_trials) {
-  if (field_trials != nullptr &&
-      field_trials->IsDisabled("WebRTC-UseNtpTimeAbsoluteSendTime")) {
-    return false;
-  }
-  return true;
-}
-
 }  // namespace
 
 RtpSenderEgress::NonPacedPacketSender::NonPacedPacketSender(
@@ -138,8 +129,8 @@
                                    ? std::make_unique<RtpSequenceNumberMap>(
                                          kRtpSequenceNumberMapMaxEntries)
                                    : nullptr),
-      use_ntp_time_for_absolute_send_time_(
-          GetUseNtpTimeForAbsoluteSendTime(config.field_trials)) {
+      use_ntp_time_for_absolute_send_time_(!env_.field_trials().IsDisabled(
+          "WebRTC-UseNtpTimeAbsoluteSendTime")) {
   RTC_DCHECK(worker_queue_);
   RTC_DCHECK(config.transport_feedback_callback == nullptr)
       << "transport_feedback_callback is no longer used and will soon be "
diff --git a/modules/rtp_rtcp/source/rtp_sender_video.cc b/modules/rtp_rtcp/source/rtp_sender_video.cc
index e505e28..dfa8488 100644
--- a/modules/rtp_rtcp/source/rtp_sender_video.cc
+++ b/modules/rtp_rtcp/source/rtp_sender_video.cc
@@ -13,34 +13,57 @@
 #include <stdlib.h>
 #include <string.h>
 
-#include <algorithm>
-#include <limits>
+#include <cstdint>
 #include <memory>
-#include <string>
+#include <optional>
 #include <utility>
+#include <vector>
 
 #include "absl/algorithm/container.h"
 #include "absl/memory/memory.h"
 #include "absl/strings/match.h"
+#include "absl/types/variant.h"
+#include "api/array_view.h"
 #include "api/crypto/frame_encryptor_interface.h"
+#include "api/field_trials_view.h"
+#include "api/make_ref_counted.h"
+#include "api/media_types.h"
 #include "api/transport/rtp/dependency_descriptor.h"
+#include "api/units/data_rate.h"
 #include "api/units/frequency.h"
 #include "api/units/time_delta.h"
 #include "api/units/timestamp.h"
+#include "api/video/encoded_image.h"
+#include "api/video/video_codec_type.h"
+#include "api/video/video_content_type.h"
+#include "api/video/video_frame_type.h"
+#include "api/video/video_layers_allocation.h"
+#include "api/video/video_rotation.h"
+#include "api/video/video_timing.h"
 #include "modules/rtp_rtcp/include/rtp_rtcp_defines.h"
 #include "modules/rtp_rtcp/source/absolute_capture_time_sender.h"
-#include "modules/rtp_rtcp/source/byte_io.h"
-#include "modules/rtp_rtcp/source/ntp_time_util.h"
 #include "modules/rtp_rtcp/source/rtp_dependency_descriptor_extension.h"
 #include "modules/rtp_rtcp/source/rtp_descriptor_authentication.h"
 #include "modules/rtp_rtcp/source/rtp_format.h"
+#include "modules/rtp_rtcp/source/rtp_generic_frame_descriptor.h"
 #include "modules/rtp_rtcp/source/rtp_generic_frame_descriptor_extension.h"
 #include "modules/rtp_rtcp/source/rtp_header_extensions.h"
 #include "modules/rtp_rtcp/source/rtp_packet_to_send.h"
+#include "modules/rtp_rtcp/source/rtp_sender_video_frame_transformer_delegate.h"
+#include "modules/rtp_rtcp/source/rtp_video_header.h"
 #include "modules/rtp_rtcp/source/rtp_video_layers_allocation_extension.h"
+#include "modules/rtp_rtcp/source/video_fec_generator.h"
+#include "modules/video_coding/codecs/h264/include/h264_globals.h"
+#include "modules/video_coding/codecs/interface/common_constants.h"
+#include "modules/video_coding/codecs/vp8/include/vp8_globals.h"
+#include "modules/video_coding/codecs/vp9/include/vp9_globals.h"
+#include "rtc_base/buffer.h"
 #include "rtc_base/checks.h"
 #include "rtc_base/experiments/field_trial_parser.h"
 #include "rtc_base/logging.h"
+#include "rtc_base/race_checker.h"
+#include "rtc_base/synchronization/mutex.h"
+#include "system_wrappers/include/ntp_time.h"
 
 namespace webrtc {