Add a Clone() method to SessionDescriptionInterface
This should allow us to remove some SDP parsing in Chromium. Bug: webrtc:12215 Change-Id: Ib85593d1c9226b29f2ec18617f945c76eca3b2d7 Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/197806 Reviewed-by: Henrik Boström <hbos@webrtc.org> Commit-Queue: Harald Alvestrand <hta@webrtc.org> Cr-Commit-Position: refs/heads/master@{#32840}
This commit is contained in:
committed by
Commit Bot
parent
ebe5acb27a
commit
0e7b3a9dad
@ -136,6 +136,13 @@ class RTC_EXPORT SessionDescriptionInterface {
|
||||
|
||||
virtual ~SessionDescriptionInterface() {}
|
||||
|
||||
// Create a new SessionDescriptionInterface object
|
||||
// with the same values as the old object.
|
||||
// TODO(bugs.webrtc.org:12215): Remove default implementation
|
||||
virtual std::unique_ptr<SessionDescriptionInterface> Clone() {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
// Only for use internally.
|
||||
virtual cricket::SessionDescription* description() = 0;
|
||||
virtual const cricket::SessionDescription* description() const = 0;
|
||||
|
||||
@ -49,6 +49,8 @@ class JsepSessionDescription : public SessionDescriptionInterface {
|
||||
const std::string& session_id,
|
||||
const std::string& session_version);
|
||||
|
||||
virtual std::unique_ptr<SessionDescriptionInterface> Clone();
|
||||
|
||||
virtual cricket::SessionDescription* description() {
|
||||
return description_.get();
|
||||
}
|
||||
|
||||
@ -215,6 +215,13 @@ bool JsepSessionDescription::Initialize(
|
||||
return true;
|
||||
}
|
||||
|
||||
std::unique_ptr<SessionDescriptionInterface> JsepSessionDescription::Clone() {
|
||||
auto new_description = std::make_unique<JsepSessionDescription>(type_);
|
||||
new_description->Initialize(description_->Clone(), session_id_,
|
||||
session_version_);
|
||||
return new_description;
|
||||
}
|
||||
|
||||
bool JsepSessionDescription::AddCandidate(
|
||||
const IceCandidateInterface* candidate) {
|
||||
if (!candidate)
|
||||
|
||||
@ -117,6 +117,18 @@ class JsepSessionDescriptionTest : public ::testing::Test {
|
||||
std::unique_ptr<JsepSessionDescription> jsep_desc_;
|
||||
};
|
||||
|
||||
TEST_F(JsepSessionDescriptionTest, CloneDefault) {
|
||||
auto new_desc = jsep_desc_->Clone();
|
||||
EXPECT_EQ(jsep_desc_->type(), new_desc->type());
|
||||
std::string old_desc_string;
|
||||
std::string new_desc_string;
|
||||
EXPECT_TRUE(jsep_desc_->ToString(&old_desc_string));
|
||||
EXPECT_TRUE(new_desc->ToString(&new_desc_string));
|
||||
EXPECT_EQ(old_desc_string, new_desc_string);
|
||||
EXPECT_EQ(jsep_desc_->session_id(), new_desc->session_id());
|
||||
EXPECT_EQ(jsep_desc_->session_version(), new_desc->session_version());
|
||||
}
|
||||
|
||||
// Test that number_of_mediasections() returns the number of media contents in
|
||||
// a session description.
|
||||
TEST_F(JsepSessionDescriptionTest, CheckSessionDescription) {
|
||||
|
||||
Reference in New Issue
Block a user