Make the JsepSessionDescription clone() method work for the rollback type.
Because clone() method didn't work for rollback type,
rollback using SLD/SRD was broken in iOS SDK after
https://webrtc-review.googlesource.com/c/src/+/209700.
Fixed: webrtc:12912
Change-Id: I84a1fe7b682b2a73657d2fa121e8e529bce219b3
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/226160
Reviewed-by: Harald Alvestrand <hta@webrtc.org>
Commit-Queue: Byoungchan Lee <daniel.l@hpcnt.com>
Cr-Commit-Position: refs/heads/master@{#34530}
diff --git a/pc/jsep_session_description.cc b/pc/jsep_session_description.cc
index 9de8194..ccba75b 100644
--- a/pc/jsep_session_description.cc
+++ b/pc/jsep_session_description.cc
@@ -220,7 +220,9 @@
auto new_description = std::make_unique<JsepSessionDescription>(type_);
new_description->session_id_ = session_id_;
new_description->session_version_ = session_version_;
- new_description->description_ = description_->Clone();
+ if (description_) {
+ new_description->description_ = description_->Clone();
+ }
for (const auto& collection : candidate_collection_) {
new_description->candidate_collection_.push_back(collection.Clone());
}
diff --git a/pc/jsep_session_description_unittest.cc b/pc/jsep_session_description_unittest.cc
index d922a58..2202aa8 100644
--- a/pc/jsep_session_description_unittest.cc
+++ b/pc/jsep_session_description_unittest.cc
@@ -129,6 +129,12 @@
EXPECT_EQ(jsep_desc_->session_version(), new_desc->session_version());
}
+TEST_F(JsepSessionDescriptionTest, CloneRollback) {
+ auto jsep_desc = std::make_unique<JsepSessionDescription>(SdpType::kRollback);
+ auto new_desc = jsep_desc->Clone();
+ EXPECT_EQ(jsep_desc->type(), new_desc->type());
+}
+
TEST_F(JsepSessionDescriptionTest, CloneWithCandidates) {
cricket::Candidate candidate_v4(
cricket::ICE_CANDIDATE_COMPONENT_RTP, "udp",