Add a transport_cc() getter and remove rtp_config().

Bug: webrtc:11993
Change-Id: Ie435a702c91b4d3827e528083f474e378fc75cc5
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/261318
Commit-Queue: Tomas Gunnarsson <tommi@webrtc.org>
Reviewed-by: Niels Moller <nisse@webrtc.org>
Cr-Commit-Position: refs/heads/main@{#36822}
diff --git a/audio/audio_receive_stream.cc b/audio/audio_receive_stream.cc
index f45f608..77031cd 100644
--- a/audio/audio_receive_stream.cc
+++ b/audio/audio_receive_stream.cc
@@ -211,6 +211,11 @@
   audio_state()->RemoveReceivingStream(this);
 }
 
+bool AudioReceiveStream::transport_cc() const {
+  RTC_DCHECK_RUN_ON(&packet_sequence_checker_);
+  return config_.rtp.transport_cc;
+}
+
 bool AudioReceiveStream::IsRunning() const {
   RTC_DCHECK_RUN_ON(&worker_thread_checker_);
   return playing_;
diff --git a/audio/audio_receive_stream.h b/audio/audio_receive_stream.h
index 6a4c022..0d18dc9 100644
--- a/audio/audio_receive_stream.h
+++ b/audio/audio_receive_stream.h
@@ -83,7 +83,7 @@
   // webrtc::AudioReceiveStream implementation.
   void Start() override;
   void Stop() override;
-  const RtpConfig& rtp_config() const override { return config_.rtp; }
+  bool transport_cc() const override;
   bool IsRunning() const override;
   void SetDepacketizerToDecoderFrameTransformer(
       rtc::scoped_refptr<webrtc::FrameTransformerInterface> frame_transformer)
diff --git a/call/audio_receive_stream.h b/call/audio_receive_stream.h
index b18e076..4846620 100644
--- a/call/audio_receive_stream.h
+++ b/call/audio_receive_stream.h
@@ -108,7 +108,7 @@
     std::string ToString() const;
 
     // Receive-stream specific RTP settings.
-    struct Rtp : public RtpConfig {
+    struct Rtp : public ReceiveStreamRtpConfig {
       Rtp();
       ~Rtp();
 
diff --git a/call/call.cc b/call/call.cc
index ae6c767..4c7bebc 100644
--- a/call/call.cc
+++ b/call/call.cc
@@ -80,7 +80,7 @@
 }
 
 bool UseSendSideBwe(const ReceiveStream* stream) {
-  if (!stream->rtp_config().transport_cc)
+  if (!stream->transport_cc())
     return false;
   for (const auto& extension : stream->GetRtpExtensions()) {
     if (extension.uri == RtpExtension::kTransportSequenceNumberUri ||
diff --git a/call/flexfec_receive_stream.h b/call/flexfec_receive_stream.h
index 72e544e..118eb0b 100644
--- a/call/flexfec_receive_stream.h
+++ b/call/flexfec_receive_stream.h
@@ -50,7 +50,7 @@
     // Payload type for FlexFEC.
     int payload_type = -1;
 
-    RtpConfig rtp;
+    ReceiveStreamRtpConfig rtp;
 
     // Vector containing a single element, corresponding to the SSRC of the
     // media stream being protected by this FlexFEC stream. The vector MUST have
diff --git a/call/flexfec_receive_stream_impl.h b/call/flexfec_receive_stream_impl.h
index 0bc9faa..1858da7 100644
--- a/call/flexfec_receive_stream_impl.h
+++ b/call/flexfec_receive_stream_impl.h
@@ -61,8 +61,11 @@
   // ReceiveStream impl.
   void SetRtpExtensions(std::vector<RtpExtension> extensions) override;
   const std::vector<RtpExtension>& GetRtpExtensions() const override;
-  const RtpConfig& rtp_config() const override { return config_.rtp; }
   uint32_t remote_ssrc() const { return config_.rtp.remote_ssrc; }
+  bool transport_cc() const override {
+    RTC_DCHECK_RUN_ON(&packet_sequence_checker_);
+    return config_.rtp.transport_cc;
+  }
 
  private:
   RTC_NO_UNIQUE_ADDRESS SequenceChecker packet_sequence_checker_;
diff --git a/call/receive_stream.h b/call/receive_stream.h
index 5413387..93ca03e 100644
--- a/call/receive_stream.h
+++ b/call/receive_stream.h
@@ -26,7 +26,9 @@
 class ReceiveStream {
  public:
   // Receive-stream specific RTP settings.
-  struct RtpConfig {
+  // TODO(tommi): This struct isn't needed at this level anymore. Move it closer
+  // to where it's used.
+  struct ReceiveStreamRtpConfig {
     // Synchronization source (stream identifier) to be received.
     // This member will not change mid-stream and can be assumed to be const
     // post initialization.
@@ -60,11 +62,13 @@
   // TODO(tommi): Consider using `RtpHeaderExtensionMap` instead.
   virtual const std::vector<RtpExtension>& GetRtpExtensions() const = 0;
 
-  // Called on the packet delivery thread since some members of the config may
-  // change mid-stream (e.g. the local ssrc). All mutation must also happen on
-  // the packet delivery thread. Return value can be assumed to
-  // only be used in the calling context (on the stack basically).
-  virtual const RtpConfig& rtp_config() const = 0;
+  // Returns a bool for whether feedback for send side bandwidth estimation is
+  // enabled. See
+  // https://tools.ietf.org/html/draft-holmer-rmcat-transport-wide-cc-extensions
+  // for details.
+  // This value may change mid-stream and must be done on the same thread
+  // that the value is read on (i.e. packet delivery).
+  virtual bool transport_cc() const = 0;
 
  protected:
   virtual ~ReceiveStream() {}
diff --git a/call/video_receive_stream.h b/call/video_receive_stream.h
index 7c66a4e..357b4e5 100644
--- a/call/video_receive_stream.h
+++ b/call/video_receive_stream.h
@@ -174,7 +174,7 @@
     VideoDecoderFactory* decoder_factory = nullptr;
 
     // Receive-stream specific RTP settings.
-    struct Rtp : public RtpConfig {
+    struct Rtp : public ReceiveStreamRtpConfig {
       Rtp();
       Rtp(const Rtp&);
       ~Rtp();
diff --git a/media/engine/fake_webrtc_call.h b/media/engine/fake_webrtc_call.h
index 47d7b18..64b9c0d 100644
--- a/media/engine/fake_webrtc_call.h
+++ b/media/engine/fake_webrtc_call.h
@@ -110,9 +110,7 @@
   }
 
  private:
-  const webrtc::ReceiveStream::RtpConfig& rtp_config() const override {
-    return config_.rtp;
-  }
+  bool transport_cc() const override { return config_.rtp.transport_cc; }
   uint32_t remote_ssrc() const override { return config_.rtp.remote_ssrc; }
   void Start() override { started_ = true; }
   void Stop() override { started_ = false; }
@@ -268,10 +266,7 @@
   // webrtc::VideoReceiveStream implementation.
   void SetRtpExtensions(std::vector<webrtc::RtpExtension> extensions) override;
   const std::vector<webrtc::RtpExtension>& GetRtpExtensions() const override;
-
-  const webrtc::ReceiveStream::RtpConfig& rtp_config() const override {
-    return config_.rtp;
-  }
+  bool transport_cc() const override { return config_.rtp.transport_cc; }
 
   void Start() override;
   void Stop() override;
@@ -301,10 +296,7 @@
 
   void SetRtpExtensions(std::vector<webrtc::RtpExtension> extensions) override;
   const std::vector<webrtc::RtpExtension>& GetRtpExtensions() const override;
-
-  const webrtc::ReceiveStream::RtpConfig& rtp_config() const override {
-    return config_.rtp;
-  }
+  bool transport_cc() const override { return config_.rtp.transport_cc; }
 
   const webrtc::FlexfecReceiveStream::Config& GetConfig() const;
 
diff --git a/video/video_receive_stream2.h b/video/video_receive_stream2.h
index e5acf30..9513626 100644
--- a/video/video_receive_stream2.h
+++ b/video/video_receive_stream2.h
@@ -136,8 +136,7 @@
 
   void SetRtpExtensions(std::vector<RtpExtension> extensions) override;
   const std::vector<RtpExtension>& GetRtpExtensions() const override;
-
-  const RtpConfig& rtp_config() const override { return rtp(); }
+  bool transport_cc() const override { return rtp().transport_cc; }
 
   webrtc::VideoReceiveStream::Stats GetStats() const override;