Fire OnRenegotiationNeeded only for the first SCTP DataChannel.
Subsequent DataChannels do not need renegotiation since SCTP data streams are not negotiated through SDP. BUG=2431 R=pthatcher@google.com, wu@webrtc.org Review URL: https://webrtc-codereview.appspot.com/12629004 git-svn-id: http://webrtc.googlecode.com/svn/trunk@6268 4adac7df-926f-26a2-2b94-8c16560cd09d
This commit is contained in:
parent
9aa7d8df95
commit
001fd2d503
talk/app/webrtc
@ -482,6 +482,8 @@ talk_base::scoped_refptr<DataChannelInterface>
|
||||
PeerConnection::CreateDataChannel(
|
||||
const std::string& label,
|
||||
const DataChannelInit* config) {
|
||||
bool first_datachannel = !mediastream_signaling_->HasDataChannels();
|
||||
|
||||
talk_base::scoped_ptr<InternalDataChannelInit> internal_config;
|
||||
if (config) {
|
||||
internal_config.reset(new InternalDataChannelInit(*config));
|
||||
@ -491,7 +493,11 @@ PeerConnection::CreateDataChannel(
|
||||
if (!channel.get())
|
||||
return NULL;
|
||||
|
||||
observer_->OnRenegotiationNeeded();
|
||||
// Trigger the onRenegotiationNeeded event for every new RTP DataChannel, or
|
||||
// the first SCTP DataChannel.
|
||||
if (session_->data_channel_type() == cricket::DCT_RTP || first_datachannel) {
|
||||
observer_->OnRenegotiationNeeded();
|
||||
}
|
||||
|
||||
return DataChannelProxy::Create(signaling_thread(), channel.get());
|
||||
}
|
||||
|
@ -946,23 +946,28 @@ TEST_F(PeerConnectionInterfaceTest, CreateSctpDataChannel) {
|
||||
pc_->CreateDataChannel("1", &config);
|
||||
EXPECT_TRUE(channel != NULL);
|
||||
EXPECT_TRUE(channel->reliable());
|
||||
EXPECT_TRUE(observer_.renegotiation_needed_);
|
||||
observer_.renegotiation_needed_ = false;
|
||||
|
||||
config.ordered = false;
|
||||
channel = pc_->CreateDataChannel("2", &config);
|
||||
EXPECT_TRUE(channel != NULL);
|
||||
EXPECT_TRUE(channel->reliable());
|
||||
EXPECT_FALSE(observer_.renegotiation_needed_);
|
||||
|
||||
config.ordered = true;
|
||||
config.maxRetransmits = 0;
|
||||
channel = pc_->CreateDataChannel("3", &config);
|
||||
EXPECT_TRUE(channel != NULL);
|
||||
EXPECT_FALSE(channel->reliable());
|
||||
EXPECT_FALSE(observer_.renegotiation_needed_);
|
||||
|
||||
config.maxRetransmits = -1;
|
||||
config.maxRetransmitTime = 0;
|
||||
channel = pc_->CreateDataChannel("4", &config);
|
||||
EXPECT_TRUE(channel != NULL);
|
||||
EXPECT_FALSE(channel->reliable());
|
||||
EXPECT_FALSE(observer_.renegotiation_needed_);
|
||||
}
|
||||
|
||||
// This tests that no data channel is returned if both maxRetransmits and
|
||||
@ -1012,6 +1017,23 @@ TEST_F(PeerConnectionInterfaceTest,
|
||||
EXPECT_TRUE(channel == NULL);
|
||||
}
|
||||
|
||||
// This test verifies that OnRenegotiationNeeded is fired for every new RTP
|
||||
// DataChannel.
|
||||
TEST_F(PeerConnectionInterfaceTest, RenegotiationNeededForNewRtpDataChannel) {
|
||||
FakeConstraints constraints;
|
||||
constraints.SetAllowRtpDataChannels();
|
||||
CreatePeerConnection(&constraints);
|
||||
|
||||
scoped_refptr<DataChannelInterface> dc1 =
|
||||
pc_->CreateDataChannel("test1", NULL);
|
||||
EXPECT_TRUE(observer_.renegotiation_needed_);
|
||||
observer_.renegotiation_needed_ = false;
|
||||
|
||||
scoped_refptr<DataChannelInterface> dc2 =
|
||||
pc_->CreateDataChannel("test2", NULL);
|
||||
EXPECT_TRUE(observer_.renegotiation_needed_);
|
||||
}
|
||||
|
||||
// This test that a data channel closes when a PeerConnection is deleted/closed.
|
||||
TEST_F(PeerConnectionInterfaceTest, DataChannelCloseWhenPeerConnectionClose) {
|
||||
FakeConstraints constraints;
|
||||
|
Loading…
x
Reference in New Issue
Block a user