Don't crash if SetRemoteDescription is called first with BundlePolicy=max-bundle.
BUG=
R=decurtis@webrtc.org, juberti@google.com
Review URL: https://webrtc-codereview.appspot.com/46149004
Cr-Commit-Position: refs/heads/master@{#9124}
diff --git a/talk/app/webrtc/webrtcsession.cc b/talk/app/webrtc/webrtcsession.cc
index 9d0a8e4..f235cd5 100644
--- a/talk/app/webrtc/webrtcsession.cc
+++ b/talk/app/webrtc/webrtcsession.cc
@@ -1599,14 +1599,13 @@
// Enable bundle before when kMaxBundle policy is in effect.
if (bundle_policy_ == PeerConnectionInterface::kBundlePolicyMaxBundle) {
- const cricket::ContentGroup* local_bundle_group =
- BaseSession::local_description()->GetGroupByName(
- cricket::GROUP_TYPE_BUNDLE);
- if (!local_bundle_group) {
+ const cricket::ContentGroup* bundle_group = desc->GetGroupByName(
+ cricket::GROUP_TYPE_BUNDLE);
+ if (!bundle_group) {
LOG(LS_WARNING) << "max-bundle specified without BUNDLE specified";
return false;
}
- if (!BaseSession::BundleContentGroup(local_bundle_group)) {
+ if (!BaseSession::BundleContentGroup(bundle_group)) {
LOG(LS_WARNING) << "max-bundle failed to enable bundling.";
return false;
}
diff --git a/talk/app/webrtc/webrtcsession_unittest.cc b/talk/app/webrtc/webrtcsession_unittest.cc
index 4e0066b..3efc112 100644
--- a/talk/app/webrtc/webrtcsession_unittest.cc
+++ b/talk/app/webrtc/webrtcsession_unittest.cc
@@ -2595,7 +2595,7 @@
EXPECT_FALSE(session_->SetRemoteDescription(modified_offer, &error));
}
-// kBundlePolicyBalanced bundle policy with and answer contains BUNDLE.
+// kBundlePolicyBalanced bundle policy and answer contains BUNDLE.
TEST_F(WebRtcSessionTest, TestBalancedBundleInAnswer) {
InitWithBundlePolicy(PeerConnectionInterface::kBundlePolicyBalanced);
mediastream_signaling_.SendAudioVideoStream1();
@@ -2622,6 +2622,7 @@
TEST_F(WebRtcSessionTest, TestBalancedNoBundleInAnswer) {
InitWithBundlePolicy(PeerConnectionInterface::kBundlePolicyBalanced);
mediastream_signaling_.SendAudioVideoStream1();
+
PeerConnectionInterface::RTCOfferAnswerOptions options;
options.use_rtp_mux = true;
@@ -2674,6 +2675,7 @@
TEST_F(WebRtcSessionTest, TestMaxBundleNoBundleInAnswer) {
InitWithBundlePolicy(PeerConnectionInterface::kBundlePolicyMaxBundle);
mediastream_signaling_.SendAudioVideoStream1();
+
PeerConnectionInterface::RTCOfferAnswerOptions options;
options.use_rtp_mux = true;
@@ -2699,7 +2701,7 @@
session_->GetTransportProxy("video")->impl());
}
-// kBundlePolicyMaxCompat bundle policy with and answer contains BUNDLE.
+// kBundlePolicyMaxCompat bundle policy and answer contains BUNDLE.
TEST_F(WebRtcSessionTest, TestMaxCompatBundleInAnswer) {
InitWithBundlePolicy(PeerConnectionInterface::kBundlePolicyMaxCompat);
mediastream_signaling_.SendAudioVideoStream1();
@@ -2753,6 +2755,21 @@
session_->GetTransportProxy("video")->impl());
}
+// kBundlePolicyMaxbundle and then we call SetRemoteDescription first.
+TEST_F(WebRtcSessionTest, TestMaxBundleWithSetRemoteDescriptionFirst) {
+ InitWithBundlePolicy(PeerConnectionInterface::kBundlePolicyMaxBundle);
+ mediastream_signaling_.SendAudioVideoStream1();
+
+ PeerConnectionInterface::RTCOfferAnswerOptions options;
+ options.use_rtp_mux = true;
+
+ SessionDescriptionInterface* offer = CreateOffer(options);
+ SetRemoteDescriptionWithoutError(offer);
+
+ EXPECT_EQ(session_->GetTransportProxy("audio")->impl(),
+ session_->GetTransportProxy("video")->impl());
+}
+
// This test verifies that SetLocalDescription and SetRemoteDescription fails
// if BUNDLE is enabled but rtcp-mux is disabled in m-lines.
TEST_F(WebRtcSessionTest, TestDisabledRtcpMuxWithBundleEnabled) {
diff --git a/webrtc/p2p/base/session.cc b/webrtc/p2p/base/session.cc
index 136f391..38c9836 100644
--- a/webrtc/p2p/base/session.cc
+++ b/webrtc/p2p/base/session.cc
@@ -665,15 +665,6 @@
return true;
}
- const ContentInfo* content =
- local_description_->GetContentByName(*content_name);
- if (!content) {
- LOG(LS_WARNING) << "Content \"" << *content_name
- << "\" referenced in BUNDLE group"
- << " not present in local description";
- return false;
- }
-
TransportProxy* selected_proxy = GetTransportProxy(*content_name);
if (!selected_proxy) {
LOG(LS_WARNING) << "No transport found for content \""