Dont require CCFB on none RTP m lines.

Bug: webrtc:436452760
Change-Id: I609355595cef755f2fa341298e9db0fb1ec67b02
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/403261
Reviewed-by: Harald Alvestrand <hta@webrtc.org>
Commit-Queue: Per Kjellander <perkj@webrtc.org>
Cr-Commit-Position: refs/heads/main@{#45297}
diff --git a/pc/congestion_control_integrationtest.cc b/pc/congestion_control_integrationtest.cc
index e93151c..437186b 100644
--- a/pc/congestion_control_integrationtest.cc
+++ b/pc/congestion_control_integrationtest.cc
@@ -22,6 +22,7 @@
 #include "api/rtp_parameters.h"
 #include "api/rtp_transceiver_direction.h"
 #include "api/test/rtc_error_matchers.h"
+#include "pc/session_description.h"
 #include "pc/test/integration_test_helpers.h"
 #include "test/gmock.h"
 #include "test/gtest.h"
@@ -121,6 +122,57 @@
   EXPECT_THAT(answer_str, HasSubstr("transport-cc"));
 }
 
+#ifdef WEBRTC_HAVE_SCTP
+TEST_F(PeerConnectionCongestionControlTest,
+       ReceiveOfferWithDataChannelsSetsCcfbFlag) {
+  SetFieldTrials("WebRTC-RFC8888CongestionControlFeedback/Enabled/");
+  ASSERT_TRUE(CreatePeerConnectionWrappers());
+  ConnectFakeSignalingForSdpOnly();
+  caller()->AddAudioVideoTracks();
+  caller()->CreateDataChannel();
+  callee()->CreateDataChannel();
+  caller()->CreateAndSetAndSignalOffer();
+  ASSERT_THAT(WaitUntil([&] { return SignalingStateStable(); }, IsTrue()),
+              IsRtcOk());
+  {
+    // Check that the callee parsed it.
+    auto parsed_contents =
+        callee()->pc()->remote_description()->description()->contents();
+    EXPECT_FALSE(parsed_contents.empty());
+    bool has_data_channel = false;
+    for (const auto& content : parsed_contents) {
+      if (content.type == MediaProtocolType::kSctp) {
+        EXPECT_FALSE(content.media_description()->rtcp_fb_ack_ccfb());
+        has_data_channel = true;
+      } else {
+        EXPECT_TRUE(content.media_description()->rtcp_fb_ack_ccfb());
+      }
+    }
+    ASSERT_TRUE(has_data_channel);
+  }
+
+  {
+    // Check that the caller also parsed the answer.
+    auto parsed_contents =
+        caller()->pc()->remote_description()->description()->contents();
+    EXPECT_FALSE(parsed_contents.empty());
+    bool has_data_channel = false;
+    for (const auto& content : parsed_contents) {
+      if (content.type == MediaProtocolType::kSctp) {
+        EXPECT_FALSE(content.media_description()->rtcp_fb_ack_ccfb());
+        has_data_channel = true;
+      } else {
+        EXPECT_TRUE(content.media_description()->rtcp_fb_ack_ccfb());
+      }
+    }
+    ASSERT_TRUE(has_data_channel);
+  }
+  // Check that the answer does not contain transport-cc
+  std::string answer_str = absl::StrCat(*caller()->pc()->remote_description());
+  EXPECT_THAT(answer_str, Not(HasSubstr("transport-cc")));
+}
+#endif
+
 TEST_F(PeerConnectionCongestionControlTest, NegotiatingCcfbRemovesTsn) {
   SetFieldTrials("WebRTC-RFC8888CongestionControlFeedback/Enabled/");
   ASSERT_TRUE(CreatePeerConnectionWrappers());
diff --git a/pc/media_session.cc b/pc/media_session.cc
index a0d2543..a7bad0f 100644
--- a/pc/media_session.cc
+++ b/pc/media_session.cc
@@ -847,6 +847,9 @@
   if (transport_desc_factory_->trials().IsEnabled(
           "WebRTC-RFC8888CongestionControlFeedback")) {
     for (const auto& content : offer->contents()) {
+      if (content.type != MediaProtocolType::kRtp) {
+        continue;
+      }
       if (content.media_description()->rtcp_fb_ack_ccfb()) {
         has_ack_ccfb = true;
       } else if (has_ack_ccfb) {