Allow single-mline offers without BUNDLE group when using max-bundle

since BUNDLE is not meaningful for those cases.
This matches Firefox behavior.

BUG=chromium:1444615

Change-Id: Id841b7e30a1c920efd977caebc71ab25d084577a
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/305640
Reviewed-by: Harald Alvestrand <hta@webrtc.org>
Reviewed-by: Florent Castelli <orphis@webrtc.org>
Commit-Queue: Philipp Hancke <phancke@microsoft.com>
Cr-Commit-Position: refs/heads/main@{#40151}
diff --git a/pc/jsep_transport_controller.cc b/pc/jsep_transport_controller.cc
index e36ecaf..6676680 100644
--- a/pc/jsep_transport_controller.cc
+++ b/pc/jsep_transport_controller.cc
@@ -813,7 +813,8 @@
 
   if (config_.bundle_policy ==
           PeerConnectionInterface::kBundlePolicyMaxBundle &&
-      !description->HasGroup(cricket::GROUP_TYPE_BUNDLE)) {
+      !description->HasGroup(cricket::GROUP_TYPE_BUNDLE) &&
+      description->contents().size() > 1) {
     return RTCError(RTCErrorType::INVALID_PARAMETER,
                     "max-bundle is used but no bundle group found.");
   }
diff --git a/pc/jsep_transport_controller_unittest.cc b/pc/jsep_transport_controller_unittest.cc
index 8aecf63..faa8842 100644
--- a/pc/jsep_transport_controller_unittest.cc
+++ b/pc/jsep_transport_controller_unittest.cc
@@ -2727,4 +2727,20 @@
           .ok());
 }
 
+// Test that with max-bundle a single unbundled m-line is accepted.
+TEST_F(JsepTransportControllerTest,
+       MaxBundleDoesNotRequireBundleForFirstMline) {
+  auto config = JsepTransportController::Config();
+  config.bundle_policy = PeerConnectionInterface::kBundlePolicyMaxBundle;
+  CreateJsepTransportController(std::move(config));
+
+  auto offer = std::make_unique<cricket::SessionDescription>();
+  AddAudioSection(offer.get(), kAudioMid1, kIceUfrag1, kIcePwd1,
+                  cricket::ICEMODE_FULL, cricket::CONNECTIONROLE_ACTPASS,
+                  nullptr);
+  EXPECT_TRUE(
+      transport_controller_->SetRemoteDescription(SdpType::kOffer, offer.get())
+          .ok());
+}
+
 }  // namespace webrtc