Remove DataContentDescription shim

Bug: webrtc:10597
Change-Id: Id0cbb78846d2b248bc2ab650eb7c06b50bc825bb
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/140100
Commit-Queue: Harald Alvestrand <hta@webrtc.org>
Reviewed-by: Steve Anton <steveanton@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#28275}
This commit is contained in:
Harald Alvestrand 2019-06-11 11:46:59 +02:00 committed by Commit Bot
parent ef3fd9c8ad
commit c5effc2453
7 changed files with 3 additions and 654 deletions

View File

@ -2802,15 +2802,6 @@ const SctpDataContentDescription* GetFirstSctpDataContentDescription(
return desc ? desc->as_sctp() : nullptr;
}
// Returns a shim representing either an SctpDataContentDescription
// or an RtpDataContentDescription, as appropriate.
// TODO(bugs.webrtc.org/10597): Remove together with shim.
const DataContentDescription* GetFirstDataContentDescription(
const SessionDescription* sdesc) {
auto desc = GetFirstMediaContentDescription(sdesc, MEDIA_TYPE_DATA);
return desc ? desc->as_data() : nullptr;
}
//
// Non-const versions of the above functions.
//
@ -2889,11 +2880,4 @@ SctpDataContentDescription* GetFirstSctpDataContentDescription(
return desc ? desc->as_sctp() : nullptr;
}
// Returns shim
DataContentDescription* GetFirstDataContentDescription(
SessionDescription* sdesc) {
auto desc = GetFirstMediaContentDescription(sdesc, MEDIA_TYPE_DATA);
return desc ? desc->as_data() : nullptr;
}
} // namespace cricket

View File

@ -363,9 +363,6 @@ const RtpDataContentDescription* GetFirstRtpDataContentDescription(
const SessionDescription* sdesc);
const SctpDataContentDescription* GetFirstSctpDataContentDescription(
const SessionDescription* sdesc);
// Returns shim. Deprecated - ask for the right protocol instead.
RTC_DEPRECATED const DataContentDescription* GetFirstDataContentDescription(
const SessionDescription* sdesc);
// Non-const versions of the above functions.
// Useful when modifying an existing description.
ContentInfo* GetFirstMediaContent(ContentInfos* contents, MediaType media_type);
@ -385,8 +382,6 @@ RtpDataContentDescription* GetFirstRtpDataContentDescription(
SessionDescription* sdesc);
SctpDataContentDescription* GetFirstSctpDataContentDescription(
SessionDescription* sdesc);
RTC_DEPRECATED DataContentDescription* GetFirstDataContentDescription(
SessionDescription* sdesc);
// Helper functions to return crypto suites used for SDES.
void GetSupportedAudioSdesCryptoSuites(

View File

@ -1356,8 +1356,8 @@ TEST_F(MediaSessionDescriptionFactoryTest, TestCreateDataAnswerGcm) {
EXPECT_EQ(cricket::kMediaProtocolSavpf, dcd->protocol());
}
// The use_sctpmap flag should be set in a DataContentDescription by default.
// The answer's use_sctpmap flag should match the offer's.
// The use_sctpmap flag should be set in an Sctp DataContentDescription by
// default. The answer's use_sctpmap flag should match the offer's.
TEST_F(MediaSessionDescriptionFactoryTest, TestCreateDataAnswerUsesSctpmap) {
MediaSessionOptions opts;
AddDataSection(cricket::DCT_SCTP, RtpTransceiverDirection::kSendRecv, &opts);

View File

@ -174,30 +174,6 @@ void SessionDescription::AddContent(
}
void SessionDescription::AddContent(ContentInfo&& content) {
// Unwrap the as_data shim layer before using.
auto* description = content.media_description();
bool should_delete = false;
if (description->as_rtp_data()) {
if (description->as_rtp_data() != description) {
auto* media_description =
description->deprecated_as_data()->Unshim(&should_delete);
// If should_delete was false, the media description passed to
// AddContent is referenced from elsewhere, and double deletion
// is going to result. Don't allow this.
RTC_CHECK(should_delete)
<< "Non-owned shim description passed to AddContent";
// Setting the media description will delete the old description.
content.set_media_description(absl::WrapUnique(media_description));
}
} else if (description->as_sctp()) {
if (description->as_sctp() != description) {
auto* media_description =
description->deprecated_as_data()->Unshim(&should_delete);
RTC_CHECK(should_delete)
<< "Non-owned shim description passed to AddContent";
content.set_media_description(absl::WrapUnique(media_description));
}
}
if (extmap_allow_mixed()) {
// Mixed support on session level overrides setting on media level.
content.media_description()->set_extmap_allow_mixed_enum(
@ -286,416 +262,6 @@ const ContentGroup* SessionDescription::GetGroupByName(
return NULL;
}
// DataContentDescription shim creation
DataContentDescription* RtpDataContentDescription::deprecated_as_data() {
if (!shim_) {
shim_.reset(new DataContentDescription(this));
}
return shim_.get();
}
DataContentDescription* RtpDataContentDescription::as_data() {
return deprecated_as_data();
}
const DataContentDescription* RtpDataContentDescription::as_data() const {
return const_cast<RtpDataContentDescription*>(this)->as_data();
}
DataContentDescription* SctpDataContentDescription::deprecated_as_data() {
if (!shim_) {
shim_.reset(new DataContentDescription(this));
}
return shim_.get();
}
DataContentDescription* SctpDataContentDescription::as_data() {
return deprecated_as_data();
}
const DataContentDescription* SctpDataContentDescription::as_data() const {
return const_cast<SctpDataContentDescription*>(this)->deprecated_as_data();
}
DataContentDescription::DataContentDescription() {
// In this case, we will initialize |owned_description_| as soon as
// we are told what protocol to use via set_protocol or another function
// calling CreateShimTarget.
}
DataContentDescription::DataContentDescription(
SctpDataContentDescription* wrapped)
: real_description_(wrapped) {
// SctpDataContentDescription doesn't contain codecs, but code
// using DataContentDescription expects to see one.
Super::AddCodec(
cricket::DataCodec(kGoogleSctpDataCodecPlType, kGoogleSctpDataCodecName));
}
DataContentDescription::DataContentDescription(
RtpDataContentDescription* wrapped)
: real_description_(wrapped) {}
DataContentDescription::DataContentDescription(
const DataContentDescription* o) {
if (o->real_description_) {
owned_description_ = absl::WrapUnique(o->real_description_->Copy());
real_description_ = owned_description_.get();
} else {
// Copy all information collected so far, including codecs.
Super::operator=(*o);
}
}
void DataContentDescription::CreateShimTarget(bool is_sctp) {
RTC_LOG(LS_INFO) << "Creating shim target, is_sctp is " << is_sctp;
RTC_CHECK(!owned_description_.get());
if (is_sctp) {
owned_description_ = absl::make_unique<SctpDataContentDescription>();
// Copy all information collected so far, except codecs.
owned_description_->MediaContentDescription::operator=(*this);
} else {
owned_description_ = absl::make_unique<RtpDataContentDescription>();
// Copy all information collected so far, including codecs.
owned_description_->as_rtp_data()
->MediaContentDescriptionImpl<RtpDataCodec>::operator=(*this);
}
real_description_ = owned_description_.get();
}
MediaContentDescription* DataContentDescription::Unshim(bool* should_delete) {
// If protocol isn't decided at this point, we have a problem.
RTC_CHECK(real_description_);
if (owned_description_) {
// Pass ownership to caller, and remove myself.
// Since caller can't know if I was owner or owned, tell them.
MediaContentDescription* to_return = owned_description_.release();
*should_delete = true;
return to_return;
}
// Real object is owner, and presumably referenced from elsewhere.
*should_delete = false;
return real_description_;
}
void DataContentDescription::set_protocol(const std::string& protocol) {
if (!real_description_) {
CreateShimTarget(IsSctpProtocol(protocol));
}
real_description_->set_protocol(protocol);
}
bool DataContentDescription::IsSctp() const {
return (real_description_ && real_description_->as_sctp());
}
void DataContentDescription::EnsureIsRtp() {
RTC_CHECK(real_description_);
RTC_CHECK(real_description_->as_rtp_data());
}
RtpDataContentDescription* DataContentDescription::as_rtp_data() {
if (real_description_) {
return real_description_->as_rtp_data();
}
return nullptr;
}
SctpDataContentDescription* DataContentDescription::as_sctp() {
if (real_description_) {
return real_description_->as_sctp();
}
return nullptr;
}
// Override all methods defined in MediaContentDescription.
bool DataContentDescription::has_codecs() const {
if (!real_description_) {
return Super::has_codecs();
}
return real_description_->has_codecs();
}
std::string DataContentDescription::protocol() const {
if (!real_description_) {
return Super::protocol();
}
return real_description_->protocol();
}
webrtc::RtpTransceiverDirection DataContentDescription::direction() const {
if (!real_description_) {
return Super::direction();
}
return real_description_->direction();
}
void DataContentDescription::set_direction(
webrtc::RtpTransceiverDirection direction) {
if (!real_description_) {
return Super::set_direction(direction);
}
return real_description_->set_direction(direction);
}
bool DataContentDescription::rtcp_mux() const {
if (!real_description_) {
return Super::rtcp_mux();
}
return real_description_->rtcp_mux();
}
void DataContentDescription::set_rtcp_mux(bool mux) {
if (!real_description_) {
Super::set_rtcp_mux(mux);
return;
}
real_description_->set_rtcp_mux(mux);
}
bool DataContentDescription::rtcp_reduced_size() const {
if (!real_description_) {
return Super::rtcp_reduced_size();
}
return real_description_->rtcp_reduced_size();
}
void DataContentDescription::set_rtcp_reduced_size(bool reduced_size) {
if (!real_description_) {
return Super::set_rtcp_reduced_size(reduced_size);
}
return real_description_->set_rtcp_reduced_size(reduced_size);
}
int DataContentDescription::bandwidth() const {
if (!real_description_) {
return Super::bandwidth();
}
return real_description_->bandwidth();
}
void DataContentDescription::set_bandwidth(int bandwidth) {
if (!real_description_) {
return Super::set_bandwidth(bandwidth);
}
return real_description_->set_bandwidth(bandwidth);
}
const std::vector<CryptoParams>& DataContentDescription::cryptos() const {
if (!real_description_) {
return Super::cryptos();
}
return real_description_->cryptos();
}
void DataContentDescription::AddCrypto(const CryptoParams& params) {
if (!real_description_) {
return Super::AddCrypto(params);
}
return real_description_->AddCrypto(params);
}
void DataContentDescription::set_cryptos(
const std::vector<CryptoParams>& cryptos) {
if (!real_description_) {
return Super::set_cryptos(cryptos);
}
return real_description_->set_cryptos(cryptos);
}
const RtpHeaderExtensions& DataContentDescription::rtp_header_extensions()
const {
if (!real_description_) {
return Super::rtp_header_extensions();
}
return real_description_->rtp_header_extensions();
}
void DataContentDescription::set_rtp_header_extensions(
const RtpHeaderExtensions& extensions) {
if (!real_description_) {
return Super::set_rtp_header_extensions(extensions);
}
return real_description_->set_rtp_header_extensions(extensions);
}
void DataContentDescription::AddRtpHeaderExtension(
const webrtc::RtpExtension& ext) {
if (!real_description_) {
return Super::AddRtpHeaderExtension(ext);
}
return real_description_->AddRtpHeaderExtension(ext);
}
void DataContentDescription::AddRtpHeaderExtension(
const cricket::RtpHeaderExtension& ext) {
if (!real_description_) {
return Super::AddRtpHeaderExtension(ext);
}
return real_description_->AddRtpHeaderExtension(ext);
}
void DataContentDescription::ClearRtpHeaderExtensions() {
if (!real_description_) {
return Super::ClearRtpHeaderExtensions();
}
return real_description_->ClearRtpHeaderExtensions();
}
bool DataContentDescription::rtp_header_extensions_set() const {
if (!real_description_) {
return Super::rtp_header_extensions_set();
}
return real_description_->rtp_header_extensions_set();
}
const StreamParamsVec& DataContentDescription::streams() const {
if (!real_description_) {
return Super::streams();
}
return real_description_->streams();
}
StreamParamsVec& DataContentDescription::mutable_streams() {
if (!real_description_) {
return Super::mutable_streams();
}
return real_description_->mutable_streams();
}
void DataContentDescription::AddStream(const StreamParams& stream) {
if (!real_description_) {
return Super::AddStream(stream);
}
return real_description_->AddStream(stream);
}
void DataContentDescription::SetCnameIfEmpty(const std::string& cname) {
if (!real_description_) {
return Super::SetCnameIfEmpty(cname);
}
return real_description_->SetCnameIfEmpty(cname);
}
uint32_t DataContentDescription::first_ssrc() const {
if (!real_description_) {
return Super::first_ssrc();
}
return real_description_->first_ssrc();
}
bool DataContentDescription::has_ssrcs() const {
if (!real_description_) {
return Super::has_ssrcs();
}
return real_description_->has_ssrcs();
}
void DataContentDescription::set_conference_mode(bool enable) {
if (!real_description_) {
return Super::set_conference_mode(enable);
}
return real_description_->set_conference_mode(enable);
}
bool DataContentDescription::conference_mode() const {
if (!real_description_) {
return Super::conference_mode();
}
return real_description_->conference_mode();
}
void DataContentDescription::set_connection_address(
const rtc::SocketAddress& address) {
if (!real_description_) {
return Super::set_connection_address(address);
}
return real_description_->set_connection_address(address);
}
const rtc::SocketAddress& DataContentDescription::connection_address() const {
if (!real_description_) {
return Super::connection_address();
}
return real_description_->connection_address();
}
void DataContentDescription::set_extmap_allow_mixed_enum(
ExtmapAllowMixed mixed) {
if (!real_description_) {
return Super::set_extmap_allow_mixed_enum(mixed);
}
return real_description_->set_extmap_allow_mixed_enum(mixed);
}
MediaContentDescription::ExtmapAllowMixed
DataContentDescription::extmap_allow_mixed_enum() const {
if (!real_description_) {
return Super::extmap_allow_mixed_enum();
}
return real_description_->extmap_allow_mixed_enum();
}
bool DataContentDescription::HasSimulcast() const {
if (!real_description_) {
return Super::HasSimulcast();
}
return real_description_->HasSimulcast();
}
SimulcastDescription& DataContentDescription::simulcast_description() {
if (!real_description_) {
return Super::simulcast_description();
}
return real_description_->simulcast_description();
}
const SimulcastDescription& DataContentDescription::simulcast_description()
const {
if (!real_description_) {
return Super::simulcast_description();
}
return real_description_->simulcast_description();
}
void DataContentDescription::set_simulcast_description(
const SimulcastDescription& simulcast) {
if (!real_description_) {
return Super::set_simulcast_description(simulcast);
}
return real_description_->set_simulcast_description(simulcast);
}
// Methods defined in MediaContentDescriptionImpl.
// For SCTP, we implement codec handling.
// For RTP, we pass the codecs.
// In the cases where type hasn't been decided yet, we return dummies.
const std::vector<DataCodec>& DataContentDescription::codecs() const {
if (IsSctp() || !real_description_) {
return Super::codecs();
}
return real_description_->as_rtp_data()->codecs();
}
void DataContentDescription::set_codecs(const std::vector<DataCodec>& codecs) {
if (IsSctp() || !real_description_) {
Super::set_codecs(codecs);
} else {
EnsureIsRtp();
real_description_->as_rtp_data()->set_codecs(codecs);
}
}
bool DataContentDescription::HasCodec(int id) {
if (IsSctp() || !real_description_) {
return Super::HasCodec(id);
}
return real_description_->as_rtp_data()->HasCodec(id);
}
void DataContentDescription::AddCodec(const DataCodec& codec) {
if (IsSctp() || !real_description_) {
Super::AddCodec(codec);
} else {
EnsureIsRtp();
real_description_->as_rtp_data()->AddCodec(codec);
}
}
void DataContentDescription::AddOrReplaceCodec(const DataCodec& codec) {
if (IsSctp() || real_description_) {
Super::AddOrReplaceCodec(codec);
} else {
EnsureIsRtp();
real_description_->as_rtp_data()->AddOrReplaceCodec(codec);
}
}
void DataContentDescription::AddCodecs(const std::vector<DataCodec>& codecs) {
if (IsSctp() || !real_description_) {
Super::AddCodecs(codecs);
} else {
EnsureIsRtp();
real_description_->as_rtp_data()->AddCodecs(codecs);
}
}
ContentInfo::~ContentInfo() {
if (description_ && description_.get() != description) {
// If description_ is null, we assume that a move operator

View File

@ -54,7 +54,6 @@ const int kAutoBandwidth = -1;
class AudioContentDescription;
class VideoContentDescription;
class DataContentDescription;
class RtpDataContentDescription;
class SctpDataContentDescription;
@ -77,15 +76,6 @@ class MediaContentDescription {
virtual VideoContentDescription* as_video() { return nullptr; }
virtual const VideoContentDescription* as_video() const { return nullptr; }
// Backwards compatible shim: Return a shim object that allows
// callers to ignore the distinction between RtpDataContentDescription
// and SctpDataContentDescription objects.
RTC_DEPRECATED virtual DataContentDescription* as_data() { return nullptr; }
RTC_DEPRECATED virtual const DataContentDescription* as_data() const {
return nullptr;
}
virtual DataContentDescription* deprecated_as_data() { return nullptr; }
virtual RtpDataContentDescription* as_rtp_data() { return nullptr; }
virtual const RtpDataContentDescription* as_rtp_data() const {
return nullptr;
@ -340,135 +330,16 @@ class VideoContentDescription : public MediaContentDescriptionImpl<VideoCodec> {
virtual const VideoContentDescription* as_video() const { return this; }
};
// The DataContentDescription is a shim over the RtpDataContentDescription
// and SctpDataContentDescription classes that is used for external callers
// into this internal API.
// It is a templated derivation of MediaContentDescriptionImpl because
// that's what the external caller expects it to be.
// TODO(bugs.webrtc.org/10597): Declare this class obsolete and remove it
// once external callers have been updated.
class DataContentDescription : public MediaContentDescriptionImpl<DataCodec> {
public:
DataContentDescription();
MediaType type() const override { return MEDIA_TYPE_DATA; }
RTC_DEPRECATED DataContentDescription* as_data() override { return this; }
RTC_DEPRECATED const DataContentDescription* as_data() const override {
return this;
}
DataContentDescription* deprecated_as_data() override { return this; }
// Override all methods defined in MediaContentDescription.
bool has_codecs() const override;
DataContentDescription* Copy() const override {
return new DataContentDescription(this);
}
std::string protocol() const override;
void set_protocol(const std::string& protocol) override;
webrtc::RtpTransceiverDirection direction() const override;
void set_direction(webrtc::RtpTransceiverDirection direction) override;
bool rtcp_mux() const override;
void set_rtcp_mux(bool mux) override;
bool rtcp_reduced_size() const override;
void set_rtcp_reduced_size(bool) override;
int bandwidth() const override;
void set_bandwidth(int bandwidth) override;
const std::vector<CryptoParams>& cryptos() const override;
void AddCrypto(const CryptoParams& params) override;
void set_cryptos(const std::vector<CryptoParams>& cryptos) override;
const RtpHeaderExtensions& rtp_header_extensions() const override;
void set_rtp_header_extensions(
const RtpHeaderExtensions& extensions) override;
void AddRtpHeaderExtension(const webrtc::RtpExtension& ext) override;
void AddRtpHeaderExtension(const cricket::RtpHeaderExtension& ext) override;
void ClearRtpHeaderExtensions() override;
bool rtp_header_extensions_set() const override;
const StreamParamsVec& streams() const override;
StreamParamsVec& mutable_streams() override;
void AddStream(const StreamParams& stream) override;
void SetCnameIfEmpty(const std::string& cname) override;
uint32_t first_ssrc() const override;
bool has_ssrcs() const override;
void set_conference_mode(bool enable) override;
bool conference_mode() const override;
void set_connection_address(const rtc::SocketAddress& address) override;
const rtc::SocketAddress& connection_address() const override;
void set_extmap_allow_mixed_enum(ExtmapAllowMixed) override;
ExtmapAllowMixed extmap_allow_mixed_enum() const override;
bool HasSimulcast() const override;
SimulcastDescription& simulcast_description() override;
const SimulcastDescription& simulcast_description() const override;
void set_simulcast_description(
const SimulcastDescription& simulcast) override;
// Override all methods defined in MediaContentDescriptionImpl.
const std::vector<CodecType>& codecs() const override;
void set_codecs(const std::vector<CodecType>& codecs) override;
bool HasCodec(int id) override;
void AddCodec(const CodecType& codec) override;
void AddOrReplaceCodec(const CodecType& codec) override;
void AddCodecs(const std::vector<CodecType>& codec) override;
private:
typedef MediaContentDescriptionImpl<DataCodec> Super;
// Friend classes are allowed to create proxies for themselves.
friend class RtpDataContentDescription; // for constructors
friend class SctpDataContentDescription;
friend class SessionDescription; // for Unshim()
// Copy constructor. A copy results in an object that owns its
// real description, which is a copy of the original description
// (whether that was owned or not).
explicit DataContentDescription(const DataContentDescription* o);
explicit DataContentDescription(RtpDataContentDescription*);
explicit DataContentDescription(SctpDataContentDescription*);
// Exposed for internal use - new clients should not use this class.
RtpDataContentDescription* as_rtp_data() override;
SctpDataContentDescription* as_sctp() override;
// Create a shimmed object, owned by the shim.
void CreateShimTarget(bool is_sctp);
// Return the shimmed object, passing ownership if owned, and set
// |should_delete| to true if it was the owner. If |should_delete|
// is true on return, the caller should immediately delete the
// DataContentDescription object.
MediaContentDescription* Unshim(bool* should_delete);
// Returns whether SCTP is in use. False when it's not decided.
bool IsSctp() const;
// Check function for use when caller obviously assumes RTP.
void EnsureIsRtp();
MediaContentDescription* real_description_ = nullptr;
std::unique_ptr<MediaContentDescription> owned_description_;
};
class RtpDataContentDescription
: public MediaContentDescriptionImpl<RtpDataCodec> {
public:
RtpDataContentDescription() {}
RtpDataContentDescription(const RtpDataContentDescription& o)
: MediaContentDescriptionImpl<RtpDataCodec>(o), shim_(nullptr) {}
RtpDataContentDescription& operator=(const RtpDataContentDescription& o) {
this->MediaContentDescriptionImpl<RtpDataCodec>::operator=(o);
// Do not copy the shim.
return *this;
}
RtpDataContentDescription* Copy() const override {
return new RtpDataContentDescription(*this);
}
MediaType type() const override { return MEDIA_TYPE_DATA; }
RtpDataContentDescription* as_rtp_data() override { return this; }
const RtpDataContentDescription* as_rtp_data() const override { return this; }
// Shim support
RTC_DEPRECATED DataContentDescription* as_data() override;
RTC_DEPRECATED const DataContentDescription* as_data() const override;
DataContentDescription* deprecated_as_data() override;
private:
std::unique_ptr<DataContentDescription> shim_;
};
class SctpDataContentDescription : public MediaContentDescription {
@ -478,18 +349,13 @@ class SctpDataContentDescription : public MediaContentDescription {
: MediaContentDescription(o),
use_sctpmap_(o.use_sctpmap_),
port_(o.port_),
max_message_size_(o.max_message_size_),
shim_(nullptr) {}
max_message_size_(o.max_message_size_) {}
SctpDataContentDescription* Copy() const override {
return new SctpDataContentDescription(*this);
}
MediaType type() const override { return MEDIA_TYPE_DATA; }
SctpDataContentDescription* as_sctp() override { return this; }
const SctpDataContentDescription* as_sctp() const override { return this; }
// Shim support
RTC_DEPRECATED DataContentDescription* as_data() override;
RTC_DEPRECATED const DataContentDescription* as_data() const override;
DataContentDescription* deprecated_as_data() override;
bool has_codecs() const override { return false; }
void set_protocol(const std::string& protocol) override {
@ -512,7 +378,6 @@ class SctpDataContentDescription : public MediaContentDescription {
int port_ = 5000;
// draft-ietf-mmusic-sdp-sctp-23: Max message size default is 64K
int max_message_size_ = 64 * 1024;
std::unique_ptr<DataContentDescription> shim_;
};
// Protocol used for encoding media. This is the "top level" protocol that may

View File

@ -140,65 +140,5 @@ TEST(SessionDescriptionTest, AddContentTransfersExtmapAllowMixedSetting) {
->extmap_allow_mixed_enum());
}
// The tests for DataContentDescription will be deleted soon.
// TODO(bugs.webrtc.org/10597): Declare this class obsolete and remove it
TEST(SessionDescriptionTest, DataContentDescriptionCanAddStream) {
auto description = absl::make_unique<DataContentDescription>();
// Adding a stream without setting protocol first should work.
description->AddLegacyStream(1234);
EXPECT_EQ(1UL, description->streams().size());
}
TEST(SessionDescriptionTest, DataContentDescriptionCopyWorks) {
auto description = absl::make_unique<RtpDataContentDescription>();
auto shim_description = description->deprecated_as_data();
auto shim_copy = shim_description->Copy();
delete shim_copy;
}
TEST(SessionDescriptionTest, DataContentDescriptionCodecsCallableOnNull) {
auto shim_description = absl::make_unique<DataContentDescription>();
auto codec_list = shim_description->codecs();
EXPECT_EQ(0UL, codec_list.size());
}
TEST(SessionDescriptionTest, DataContentDescriptionSctpConferenceMode) {
auto description = absl::make_unique<SctpDataContentDescription>();
auto shim_description = description->deprecated_as_data();
EXPECT_FALSE(shim_description->conference_mode());
shim_description->set_conference_mode(true);
EXPECT_TRUE(shim_description->conference_mode());
}
TEST(SessionDescriptionTest, DataContentDesriptionInSessionIsUnwrapped) {
auto description = absl::make_unique<DataContentDescription>();
// Create a DTLS object behind the shim.
description->set_protocol(kMediaProtocolUdpDtlsSctp);
SessionDescription session;
session.AddContent("name", MediaProtocolType::kSctp, std::move(description));
ContentInfo* content = &(session.contents()[0]);
ASSERT_TRUE(content);
ASSERT_TRUE(content->media_description()->type() == MEDIA_TYPE_DATA);
ASSERT_TRUE(content->media_description()->as_sctp());
}
TEST(SessionDescriptionTest,
DataContentDescriptionInfoSurvivesInstantiationAsSctp) {
auto description = absl::make_unique<DataContentDescription>();
description->set_rtcp_mux(true);
description->set_protocol(kMediaProtocolUdpDtlsSctp);
EXPECT_TRUE(description->rtcp_mux());
}
TEST(SessionDescriptionTest,
DataContentDescriptionStreamInfoSurvivesInstantiationAsRtp) {
auto description = absl::make_unique<DataContentDescription>();
StreamParams stream;
description->AddLegacyStream(1234);
EXPECT_EQ(1UL, description->streams().size());
description->set_protocol(kMediaProtocolDtlsSavpf);
EXPECT_EQ(1UL, description->streams().size());
}
} // namespace cricket

View File

@ -54,7 +54,6 @@ using cricket::Candidate;
using cricket::Candidates;
using cricket::ContentInfo;
using cricket::CryptoParams;
using cricket::DataContentDescription;
using cricket::ICE_CANDIDATE_COMPONENT_RTCP;
using cricket::ICE_CANDIDATE_COMPONENT_RTP;
using cricket::kCodecParamAssociatedPayloadType;