Add "ice-option:trickle" to generated offers/answers.
BUG=webrtc:7443 Review-Url: https://codereview.webrtc.org/2808913003 Cr-Commit-Position: refs/heads/master@{#17809}
This commit is contained in:
parent
d0de295119
commit
30952b460f
@ -87,7 +87,8 @@ extern const char CONNECTIONROLE_PASSIVE_STR[];
|
||||
extern const char CONNECTIONROLE_ACTPASS_STR[];
|
||||
extern const char CONNECTIONROLE_HOLDCONN_STR[];
|
||||
|
||||
constexpr auto ICE_RENOMINATION_STR = "renomination";
|
||||
constexpr auto ICE_OPTION_TRICKLE = "trickle";
|
||||
constexpr auto ICE_OPTION_RENOMINATION = "renomination";
|
||||
|
||||
bool StringToConnectionRole(const std::string& role_str, ConnectionRole* role);
|
||||
bool ConnectionRoleToString(const ConnectionRole& role, std::string* role_str);
|
||||
@ -140,6 +141,7 @@ struct TransportDescription {
|
||||
return *this;
|
||||
}
|
||||
|
||||
// TODO(deadbeef): Rename to HasIceOption, etc.
|
||||
bool HasOption(const std::string& option) const {
|
||||
return (std::find(transport_options.begin(), transport_options.end(),
|
||||
option) != transport_options.end());
|
||||
@ -150,7 +152,8 @@ struct TransportDescription {
|
||||
bool secure() const { return identity_fingerprint != nullptr; }
|
||||
|
||||
IceParameters GetIceParameters() {
|
||||
return IceParameters(ice_ufrag, ice_pwd, HasOption(ICE_RENOMINATION_STR));
|
||||
return IceParameters(ice_ufrag, ice_pwd,
|
||||
HasOption(ICE_OPTION_RENOMINATION));
|
||||
}
|
||||
|
||||
static rtc::SSLFingerprint* CopyFingerprint(
|
||||
@ -161,6 +164,9 @@ struct TransportDescription {
|
||||
return new rtc::SSLFingerprint(*from);
|
||||
}
|
||||
|
||||
// These are actually ICE options (appearing in the ice-options attribute in
|
||||
// SDP).
|
||||
// TODO(deadbeef): Rename to ice_options.
|
||||
std::vector<std::string> transport_options;
|
||||
std::string ice_ufrag;
|
||||
std::string ice_pwd;
|
||||
|
||||
@ -37,8 +37,9 @@ TransportDescription* TransportDescriptionFactory::CreateOffer(
|
||||
desc->ice_ufrag = current_description->ice_ufrag;
|
||||
desc->ice_pwd = current_description->ice_pwd;
|
||||
}
|
||||
desc->AddOption(ICE_OPTION_TRICKLE);
|
||||
if (options.enable_ice_renomination) {
|
||||
desc->AddOption(ICE_RENOMINATION_STR);
|
||||
desc->AddOption(ICE_OPTION_RENOMINATION);
|
||||
}
|
||||
|
||||
// If we are trying to establish a secure transport, add a fingerprint.
|
||||
@ -75,8 +76,9 @@ TransportDescription* TransportDescriptionFactory::CreateAnswer(
|
||||
desc->ice_ufrag = current_description->ice_ufrag;
|
||||
desc->ice_pwd = current_description->ice_pwd;
|
||||
}
|
||||
desc->AddOption(ICE_OPTION_TRICKLE);
|
||||
if (options.enable_ice_renomination) {
|
||||
desc->AddOption(ICE_RENOMINATION_STR);
|
||||
desc->AddOption(ICE_OPTION_RENOMINATION);
|
||||
}
|
||||
|
||||
// Negotiate security params.
|
||||
|
||||
@ -127,8 +127,7 @@ class TransportDescriptionFactoryTest : public testing::Test {
|
||||
bool renomination_expected) {
|
||||
ASSERT_TRUE(desc != nullptr);
|
||||
std::vector<std::string>& options = desc->transport_options;
|
||||
auto iter = std::find(options.begin(), options.end(),
|
||||
cricket::ICE_RENOMINATION_STR);
|
||||
auto iter = std::find(options.begin(), options.end(), "renomination");
|
||||
EXPECT_EQ(renomination_expected, iter != options.end());
|
||||
}
|
||||
|
||||
@ -300,3 +299,14 @@ TEST_F(TransportDescriptionFactoryTest, TestIceRenomination) {
|
||||
TEST_F(TransportDescriptionFactoryTest, TestIceRenominationWithDtls) {
|
||||
TestIceRenomination(true);
|
||||
}
|
||||
|
||||
// Test that offers and answers have ice-option:trickle.
|
||||
TEST_F(TransportDescriptionFactoryTest, AddsTrickleIceOption) {
|
||||
cricket::TransportOptions options;
|
||||
std::unique_ptr<TransportDescription> offer(
|
||||
f1_.CreateOffer(options, nullptr));
|
||||
EXPECT_TRUE(offer->HasOption("trickle"));
|
||||
std::unique_ptr<TransportDescription> answer(
|
||||
f2_.CreateAnswer(offer.get(), options, true, nullptr));
|
||||
EXPECT_TRUE(answer->HasOption("trickle"));
|
||||
}
|
||||
|
||||
@ -262,8 +262,8 @@ class MediaSessionDescriptionFactoryTest : public testing::Test {
|
||||
bool GetIceRenomination(const TransportInfo* transport_info) {
|
||||
const std::vector<std::string>& ice_options =
|
||||
transport_info->description.transport_options;
|
||||
auto iter = std::find(ice_options.begin(), ice_options.end(),
|
||||
cricket::ICE_RENOMINATION_STR);
|
||||
auto iter =
|
||||
std::find(ice_options.begin(), ice_options.end(), "renomination");
|
||||
return iter != ice_options.end();
|
||||
}
|
||||
|
||||
|
||||
@ -2508,17 +2508,17 @@ TEST_F(PeerConnectionIntegrationTest, EndToEndCallWithIceRenomination) {
|
||||
const cricket::SessionDescription* desc =
|
||||
caller()->pc()->local_description()->description();
|
||||
for (const cricket::TransportInfo& info : desc->transport_infos()) {
|
||||
ASSERT_NE(info.description.transport_options.end(),
|
||||
std::find(info.description.transport_options.begin(),
|
||||
info.description.transport_options.end(),
|
||||
cricket::ICE_RENOMINATION_STR));
|
||||
ASSERT_NE(
|
||||
info.description.transport_options.end(),
|
||||
std::find(info.description.transport_options.begin(),
|
||||
info.description.transport_options.end(), "renomination"));
|
||||
}
|
||||
desc = callee()->pc()->local_description()->description();
|
||||
for (const cricket::TransportInfo& info : desc->transport_infos()) {
|
||||
ASSERT_NE(info.description.transport_options.end(),
|
||||
std::find(info.description.transport_options.begin(),
|
||||
info.description.transport_options.end(),
|
||||
cricket::ICE_RENOMINATION_STR));
|
||||
ASSERT_NE(
|
||||
info.description.transport_options.end(),
|
||||
std::find(info.description.transport_options.begin(),
|
||||
info.description.transport_options.end(), "renomination"));
|
||||
}
|
||||
ExpectNewFramesReceivedWithWait(
|
||||
kDefaultExpectedAudioFrameCount, kDefaultExpectedVideoFrameCount,
|
||||
|
||||
@ -3165,6 +3165,31 @@ TEST_F(PeerConnectionInterfaceTest,
|
||||
pc_->StopRtcEventLog();
|
||||
}
|
||||
|
||||
// Test that generated offers/answers include "ice-option:trickle".
|
||||
TEST_F(PeerConnectionInterfaceTest, OffersAndAnswersHaveTrickleIceOption) {
|
||||
CreatePeerConnection();
|
||||
|
||||
// First, create an offer with audio/video.
|
||||
FakeConstraints constraints;
|
||||
constraints.SetMandatoryReceiveAudio(true);
|
||||
constraints.SetMandatoryReceiveVideo(true);
|
||||
std::unique_ptr<SessionDescriptionInterface> offer;
|
||||
ASSERT_TRUE(DoCreateOffer(&offer, &constraints));
|
||||
cricket::SessionDescription* desc = offer->description();
|
||||
ASSERT_EQ(2u, desc->transport_infos().size());
|
||||
EXPECT_TRUE(desc->transport_infos()[0].description.HasOption("trickle"));
|
||||
EXPECT_TRUE(desc->transport_infos()[1].description.HasOption("trickle"));
|
||||
|
||||
// Apply the offer as a remote description, then create an answer.
|
||||
EXPECT_TRUE(DoSetRemoteDescription(offer.release()));
|
||||
std::unique_ptr<SessionDescriptionInterface> answer;
|
||||
ASSERT_TRUE(DoCreateAnswer(&answer, &constraints));
|
||||
desc = answer->description();
|
||||
ASSERT_EQ(2u, desc->transport_infos().size());
|
||||
EXPECT_TRUE(desc->transport_infos()[0].description.HasOption("trickle"));
|
||||
EXPECT_TRUE(desc->transport_infos()[1].description.HasOption("trickle"));
|
||||
}
|
||||
|
||||
// Test that ICE renomination isn't offered if it's not enabled in the PC's
|
||||
// RTCConfiguration.
|
||||
TEST_F(PeerConnectionInterfaceTest, IceRenominationNotOffered) {
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user