Make SetLocalDescrption succeed with data-channel only offer and max-bundle policy.
This CL sets the data channel type of the session options before setting the bundle-enabled flag of the session options, so that bundle-enabled will be correctly set and the bundle group will be created.
BUG=webrtc:6218
Review-Url: https://codereview.webrtc.org/2473603002
Cr-Commit-Position: refs/heads/master@{#14904}
diff --git a/webrtc/api/peerconnection.cc b/webrtc/api/peerconnection.cc
index 830c301..34beeff 100644
--- a/webrtc/api/peerconnection.cc
+++ b/webrtc/api/peerconnection.cc
@@ -1643,10 +1643,6 @@
session_options->HasSendMediaStream(cricket::MEDIA_TYPE_VIDEO) ||
!remote_video_tracks_.empty();
}
- session_options->bundle_enabled =
- session_options->bundle_enabled &&
- (session_options->has_audio() || session_options->has_video() ||
- session_options->has_data());
// Intentionally unset the data channel type for RTP data channel with the
// second condition. Otherwise the RTP data channels would be successfully
@@ -1657,6 +1653,11 @@
session_options->data_channel_type = session_->data_channel_type();
}
+ session_options->bundle_enabled =
+ session_options->bundle_enabled &&
+ (session_options->has_audio() || session_options->has_video() ||
+ session_options->has_data());
+
session_options->rtcp_cname = rtcp_cname_;
session_options->crypto_options = factory_->options().crypto_options;
return true;
@@ -1682,11 +1683,6 @@
}
}
AddSendStreams(session_options, senders_, rtp_data_channels_);
- session_options->bundle_enabled =
- session_options->bundle_enabled &&
- (session_options->has_audio() || session_options->has_video() ||
- session_options->has_data());
-
// RTP data channel is handled in MediaSessionOptions::AddStream. SCTP streams
// are not signaled in the SDP so does not go through that path and must be
// handled here.
@@ -1697,6 +1693,11 @@
if (session_->data_channel_type() != cricket::DCT_RTP) {
session_options->data_channel_type = session_->data_channel_type();
}
+ session_options->bundle_enabled =
+ session_options->bundle_enabled &&
+ (session_options->has_audio() || session_options->has_video() ||
+ session_options->has_data());
+
session_options->crypto_options = factory_->options().crypto_options;
}
diff --git a/webrtc/api/peerconnection_unittest.cc b/webrtc/api/peerconnection_unittest.cc
index 981cec7..422d37c 100644
--- a/webrtc/api/peerconnection_unittest.cc
+++ b/webrtc/api/peerconnection_unittest.cc
@@ -1762,6 +1762,17 @@
VerifyRenderedSize(640, 480);
}
+// This test verifies that the negotiation will succeed with data channel only
+// in max-bundle mode.
+TEST_F(P2PTestConductor, LocalP2PTestOfferDataChannelOnly) {
+ webrtc::PeerConnectionInterface::RTCConfiguration rtc_config;
+ rtc_config.bundle_policy =
+ webrtc::PeerConnectionInterface::kBundlePolicyMaxBundle;
+ ASSERT_TRUE(CreateTestClients(rtc_config, rtc_config));
+ initializing_client()->CreateDataChannel();
+ initializing_client()->Negotiate();
+}
+
// This test sets up a Jsep call between two parties, and the callee only
// accept to receive video.
TEST_F(P2PTestConductor, LocalP2PTestAnswerVideo) {