RTCDataChannel: Ignore "id" when "negotiated" is false

This updates behavior to be aligned with the WebRTC spec.

Bug: chromium:948055
Change-Id: Id3bbf05b3df084c9b7f7d12598c09187679d60fc
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/130493
Reviewed-by: Henrik Boström <hbos@webrtc.org>
Commit-Queue: Harald Alvestrand <hta@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#27394}
This commit is contained in:
Harald Alvestrand
2019-04-01 12:58:15 +02:00
committed by Commit Bot
parent 4124dab7f3
commit 5c4d2ee615
3 changed files with 11 additions and 2 deletions

View File

@ -62,6 +62,10 @@ struct InternalDataChannelInit : public DataChannelInit {
// If the channel is externally negotiated, do not send the OPEN message. // If the channel is externally negotiated, do not send the OPEN message.
if (base.negotiated) { if (base.negotiated) {
open_handshake_role = kNone; open_handshake_role = kNone;
} else {
// Datachannel is externally negotiated. Ignore the id value.
// Specified in createDataChannel, WebRTC spec section 6.1 bullet 13.
id = -1;
} }
} }

View File

@ -3320,7 +3320,8 @@ TEST_P(PeerConnectionIntegrationTest, SctpDataChannelConfigSentToOtherSide) {
ASSERT_TRUE_WAIT(SignalingStateStable(), kDefaultTimeout); ASSERT_TRUE_WAIT(SignalingStateStable(), kDefaultTimeout);
ASSERT_TRUE_WAIT(callee()->data_channel() != nullptr, kDefaultTimeout); ASSERT_TRUE_WAIT(callee()->data_channel() != nullptr, kDefaultTimeout);
ASSERT_TRUE_WAIT(callee()->data_observer()->IsOpen(), kDefaultTimeout); ASSERT_TRUE_WAIT(callee()->data_observer()->IsOpen(), kDefaultTimeout);
EXPECT_EQ(init.id, callee()->data_channel()->id()); // Since "negotiated" is false, the "id" parameter should be ignored.
EXPECT_NE(init.id, callee()->data_channel()->id());
EXPECT_EQ("data-channel", callee()->data_channel()->label()); EXPECT_EQ("data-channel", callee()->data_channel()->label());
EXPECT_EQ(init.maxRetransmits, callee()->data_channel()->maxRetransmits()); EXPECT_EQ(init.maxRetransmits, callee()->data_channel()->maxRetransmits());
EXPECT_FALSE(callee()->data_channel()->negotiated()); EXPECT_FALSE(callee()->data_channel()->negotiated());
@ -3576,7 +3577,8 @@ TEST_P(PeerConnectionIntegrationTest,
// configuration. // configuration.
ASSERT_TRUE_WAIT(callee()->data_channel() != nullptr, kDefaultTimeout); ASSERT_TRUE_WAIT(callee()->data_channel() != nullptr, kDefaultTimeout);
ASSERT_TRUE_WAIT(callee()->data_observer()->IsOpen(), kDefaultTimeout); ASSERT_TRUE_WAIT(callee()->data_observer()->IsOpen(), kDefaultTimeout);
EXPECT_EQ(init.id, callee()->data_channel()->id()); // Since "negotiate" is false, the "id" parameter is ignored.
EXPECT_NE(init.id, callee()->data_channel()->id());
EXPECT_EQ("data-channel", callee()->data_channel()->label()); EXPECT_EQ("data-channel", callee()->data_channel()->label());
EXPECT_EQ(init.maxRetransmits, callee()->data_channel()->maxRetransmits()); EXPECT_EQ(init.maxRetransmits, callee()->data_channel()->maxRetransmits());
EXPECT_FALSE(callee()->data_channel()->negotiated()); EXPECT_FALSE(callee()->data_channel()->negotiated());

View File

@ -2141,6 +2141,7 @@ TEST_P(PeerConnectionInterfaceTest,
rtc::scoped_refptr<DataChannelInterface> channel; rtc::scoped_refptr<DataChannelInterface> channel;
config.id = 1; config.id = 1;
config.negotiated = true;
channel = pc_->CreateDataChannel("1", &config); channel = pc_->CreateDataChannel("1", &config);
EXPECT_TRUE(channel != NULL); EXPECT_TRUE(channel != NULL);
EXPECT_EQ(1, channel->id()); EXPECT_EQ(1, channel->id());
@ -2149,11 +2150,13 @@ TEST_P(PeerConnectionInterfaceTest,
EXPECT_TRUE(channel == NULL); EXPECT_TRUE(channel == NULL);
config.id = cricket::kMaxSctpSid; config.id = cricket::kMaxSctpSid;
config.negotiated = true;
channel = pc_->CreateDataChannel("max", &config); channel = pc_->CreateDataChannel("max", &config);
EXPECT_TRUE(channel != NULL); EXPECT_TRUE(channel != NULL);
EXPECT_EQ(config.id, channel->id()); EXPECT_EQ(config.id, channel->id());
config.id = cricket::kMaxSctpSid + 1; config.id = cricket::kMaxSctpSid + 1;
config.negotiated = true;
channel = pc_->CreateDataChannel("x", &config); channel = pc_->CreateDataChannel("x", &config);
EXPECT_TRUE(channel == NULL); EXPECT_TRUE(channel == NULL);
} }