From cb42e108047d7d7c977ecd652db124da22311c5f Mon Sep 17 00:00:00 2001 From: Byoungchan Lee Date: Thu, 15 Jul 2021 14:09:40 +0900 Subject: [PATCH] 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 Commit-Queue: Byoungchan Lee Cr-Commit-Position: refs/heads/master@{#34530} --- pc/jsep_session_description.cc | 4 +++- pc/jsep_session_description_unittest.cc | 6 ++++++ 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/pc/jsep_session_description.cc b/pc/jsep_session_description.cc index 9de81947de..ccba75bc28 100644 --- a/pc/jsep_session_description.cc +++ b/pc/jsep_session_description.cc @@ -220,7 +220,9 @@ std::unique_ptr JsepSessionDescription::Clone() auto new_description = std::make_unique(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 d922a586c5..2202aa81d0 100644 --- a/pc/jsep_session_description_unittest.cc +++ b/pc/jsep_session_description_unittest.cc @@ -129,6 +129,12 @@ TEST_F(JsepSessionDescriptionTest, CloneDefault) { EXPECT_EQ(jsep_desc_->session_version(), new_desc->session_version()); } +TEST_F(JsepSessionDescriptionTest, CloneRollback) { + auto jsep_desc = std::make_unique(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",