(Auto)update libjingle 62713454-> 62865357
git-svn-id: http://webrtc.googlecode.com/svn/trunk@5670 4adac7df-926f-26a2-2b94-8c16560cd09d
This commit is contained in:
@@ -1159,23 +1159,8 @@ void WebRtcSession::OnTransportConnecting(cricket::Transport* transport) {
|
|||||||
|
|
||||||
void WebRtcSession::OnTransportWritable(cricket::Transport* transport) {
|
void WebRtcSession::OnTransportWritable(cricket::Transport* transport) {
|
||||||
ASSERT(signaling_thread()->IsCurrent());
|
ASSERT(signaling_thread()->IsCurrent());
|
||||||
// TODO(bemasc): Expose more API from Transport to detect when
|
|
||||||
// candidate selection starts or stops, due to success or failure.
|
|
||||||
if (transport->all_channels_writable()) {
|
if (transport->all_channels_writable()) {
|
||||||
// By the time |SignalTransportWritable| arrives, the excess channels may
|
|
||||||
// already have been pruned, so that the Transport is Completed. The
|
|
||||||
// specification requires that transitions from Checking to Completed pass
|
|
||||||
// through Connected. This check enforces that requirement.
|
|
||||||
// (Direct transitions from Connected and Disconnected to Completed are
|
|
||||||
// allowed.)
|
|
||||||
if (ice_connection_state_ ==
|
|
||||||
PeerConnectionInterface::kIceConnectionChecking) {
|
|
||||||
SetIceConnectionState(PeerConnectionInterface::kIceConnectionConnected);
|
SetIceConnectionState(PeerConnectionInterface::kIceConnectionConnected);
|
||||||
}
|
|
||||||
|
|
||||||
SetIceConnectionState(transport->completed() ?
|
|
||||||
PeerConnectionInterface::kIceConnectionCompleted :
|
|
||||||
PeerConnectionInterface::kIceConnectionConnected);
|
|
||||||
} else if (transport->HasChannels()) {
|
} else if (transport->HasChannels()) {
|
||||||
// If the current state is Connected or Completed, then there were writable
|
// If the current state is Connected or Completed, then there were writable
|
||||||
// channels but now there are not, so the next state must be Disconnected.
|
// channels but now there are not, so the next state must be Disconnected.
|
||||||
|
@@ -497,6 +497,8 @@ void Transport::OnChannelReadableState_s() {
|
|||||||
void Transport::OnChannelWritableState(TransportChannel* channel) {
|
void Transport::OnChannelWritableState(TransportChannel* channel) {
|
||||||
ASSERT(worker_thread()->IsCurrent());
|
ASSERT(worker_thread()->IsCurrent());
|
||||||
signaling_thread()->Post(this, MSG_WRITESTATE, NULL);
|
signaling_thread()->Post(this, MSG_WRITESTATE, NULL);
|
||||||
|
|
||||||
|
MaybeCompleted_w();
|
||||||
}
|
}
|
||||||
|
|
||||||
void Transport::OnChannelWritableState_s() {
|
void Transport::OnChannelWritableState_s() {
|
||||||
@@ -612,6 +614,8 @@ void Transport::OnChannelCandidatesAllocationDone(
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
signaling_thread_->Post(this, MSG_CANDIDATEALLOCATIONCOMPLETE);
|
signaling_thread_->Post(this, MSG_CANDIDATEALLOCATIONCOMPLETE);
|
||||||
|
|
||||||
|
MaybeCompleted_w();
|
||||||
}
|
}
|
||||||
|
|
||||||
void Transport::OnChannelCandidatesAllocationDone_s() {
|
void Transport::OnChannelCandidatesAllocationDone_s() {
|
||||||
@@ -626,15 +630,17 @@ void Transport::OnRoleConflict(TransportChannelImpl* channel) {
|
|||||||
|
|
||||||
void Transport::OnChannelConnectionRemoved(TransportChannelImpl* channel) {
|
void Transport::OnChannelConnectionRemoved(TransportChannelImpl* channel) {
|
||||||
ASSERT(worker_thread()->IsCurrent());
|
ASSERT(worker_thread()->IsCurrent());
|
||||||
// Determine if the Transport should move to Completed or Failed. These
|
MaybeCompleted_w();
|
||||||
// states are only available in the Controlling ICE role.
|
|
||||||
|
// Check if the state is now Failed.
|
||||||
|
// Failed is only available in the Controlling ICE role.
|
||||||
if (channel->GetIceRole() != ICEROLE_CONTROLLING) {
|
if (channel->GetIceRole() != ICEROLE_CONTROLLING) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
ChannelMap::iterator iter = channels_.find(channel->component());
|
ChannelMap::iterator iter = channels_.find(channel->component());
|
||||||
ASSERT(iter != channels_.end());
|
ASSERT(iter != channels_.end());
|
||||||
// Completed and Failed can only occur after candidate allocation has stopped.
|
// Failed can only occur after candidate allocation has stopped.
|
||||||
if (!iter->second.candidates_allocated()) {
|
if (!iter->second.candidates_allocated()) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -644,28 +650,27 @@ void Transport::OnChannelConnectionRemoved(TransportChannelImpl* channel) {
|
|||||||
// A Transport has failed if any of its channels have no remaining
|
// A Transport has failed if any of its channels have no remaining
|
||||||
// connections.
|
// connections.
|
||||||
signaling_thread_->Post(this, MSG_FAILED);
|
signaling_thread_->Post(this, MSG_FAILED);
|
||||||
} else if (connections == 1 && completed()) {
|
|
||||||
signaling_thread_->Post(this, MSG_COMPLETED);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Transport::completed() const {
|
void Transport::MaybeCompleted_w() {
|
||||||
|
ASSERT(worker_thread()->IsCurrent());
|
||||||
|
|
||||||
// A Transport's ICE process is completed if all of its channels are writable,
|
// A Transport's ICE process is completed if all of its channels are writable,
|
||||||
// have finished allocating candidates, and have pruned all but one of their
|
// have finished allocating candidates, and have pruned all but one of their
|
||||||
// connections.
|
// connections.
|
||||||
if (!all_channels_writable())
|
|
||||||
return false;
|
|
||||||
|
|
||||||
ChannelMap::const_iterator iter;
|
ChannelMap::const_iterator iter;
|
||||||
for (iter = channels_.begin(); iter != channels_.end(); ++iter) {
|
for (iter = channels_.begin(); iter != channels_.end(); ++iter) {
|
||||||
const TransportChannelImpl* channel = iter->second.get();
|
const TransportChannelImpl* channel = iter->second.get();
|
||||||
if (!(channel->GetConnectionCount() == 1 &&
|
if (!(channel->writable() &&
|
||||||
|
channel->GetConnectionCount() == 1 &&
|
||||||
channel->GetIceRole() == ICEROLE_CONTROLLING &&
|
channel->GetIceRole() == ICEROLE_CONTROLLING &&
|
||||||
iter->second.candidates_allocated())) {
|
iter->second.candidates_allocated())) {
|
||||||
return false;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return true;
|
|
||||||
|
signaling_thread_->Post(this, MSG_COMPLETED);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Transport::SetIceRole_w(IceRole role) {
|
void Transport::SetIceRole_w(IceRole role) {
|
||||||
|
@@ -236,8 +236,6 @@ class Transport : public talk_base::MessageHandler,
|
|||||||
}
|
}
|
||||||
sigslot::signal1<Transport*> SignalReadableState;
|
sigslot::signal1<Transport*> SignalReadableState;
|
||||||
sigslot::signal1<Transport*> SignalWritableState;
|
sigslot::signal1<Transport*> SignalWritableState;
|
||||||
|
|
||||||
bool completed() const;
|
|
||||||
sigslot::signal1<Transport*> SignalCompleted;
|
sigslot::signal1<Transport*> SignalCompleted;
|
||||||
sigslot::signal1<Transport*> SignalFailed;
|
sigslot::signal1<Transport*> SignalFailed;
|
||||||
|
|
||||||
@@ -488,6 +486,8 @@ class Transport : public talk_base::MessageHandler,
|
|||||||
bool GetStats_w(TransportStats* infos);
|
bool GetStats_w(TransportStats* infos);
|
||||||
bool GetRemoteCertificate_w(talk_base::SSLCertificate** cert);
|
bool GetRemoteCertificate_w(talk_base::SSLCertificate** cert);
|
||||||
|
|
||||||
|
// Sends SignalCompleted if we are now in that state.
|
||||||
|
void MaybeCompleted_w();
|
||||||
|
|
||||||
talk_base::Thread* signaling_thread_;
|
talk_base::Thread* signaling_thread_;
|
||||||
talk_base::Thread* worker_thread_;
|
talk_base::Thread* worker_thread_;
|
||||||
|
@@ -206,21 +206,18 @@ TEST_F(TransportTest, TestChannelCompletedAndFailed) {
|
|||||||
EXPECT_TRUE_WAIT(transport_->all_channels_writable(), 100);
|
EXPECT_TRUE_WAIT(transport_->all_channels_writable(), 100);
|
||||||
// ICE is not yet completed because there is still more than one connection.
|
// ICE is not yet completed because there is still more than one connection.
|
||||||
EXPECT_FALSE(completed_);
|
EXPECT_FALSE(completed_);
|
||||||
EXPECT_FALSE(transport_->completed());
|
|
||||||
EXPECT_FALSE(failed_);
|
EXPECT_FALSE(failed_);
|
||||||
|
|
||||||
// When the connection count drops to 1, SignalCompleted should be emitted,
|
// When the connection count drops to 1, SignalCompleted should be emitted,
|
||||||
// and completed() should be true.
|
// and completed() should be true.
|
||||||
channel_->SetConnectionCount(1);
|
channel_->SetConnectionCount(1);
|
||||||
EXPECT_TRUE_WAIT(completed_, 100);
|
EXPECT_TRUE_WAIT(completed_, 100);
|
||||||
EXPECT_TRUE(transport_->completed());
|
|
||||||
completed_ = false;
|
completed_ = false;
|
||||||
|
|
||||||
// When the connection count drops to 0, SignalFailed should be emitted, and
|
// When the connection count drops to 0, SignalFailed should be emitted, and
|
||||||
// completed() should be false.
|
// completed() should be false.
|
||||||
channel_->SetConnectionCount(0);
|
channel_->SetConnectionCount(0);
|
||||||
EXPECT_TRUE_WAIT(failed_, 100);
|
EXPECT_TRUE_WAIT(failed_, 100);
|
||||||
EXPECT_FALSE(transport_->completed());
|
|
||||||
EXPECT_FALSE(completed_);
|
EXPECT_FALSE(completed_);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -465,8 +465,6 @@ bool BaseChannel::SendPacket(bool rtcp, talk_base::Buffer* packet,
|
|||||||
}
|
}
|
||||||
|
|
||||||
talk_base::PacketOptions options(dscp);
|
talk_base::PacketOptions options(dscp);
|
||||||
options.packet_time_params.rtp_sendtime_extension_id =
|
|
||||||
rtp_abs_sendtime_extn_id_;
|
|
||||||
// Protect if needed.
|
// Protect if needed.
|
||||||
if (srtp_filter_.IsActive()) {
|
if (srtp_filter_.IsActive()) {
|
||||||
bool res;
|
bool res;
|
||||||
@@ -482,6 +480,8 @@ bool BaseChannel::SendPacket(bool rtcp, talk_base::Buffer* packet,
|
|||||||
res = srtp_filter_.ProtectRtp(
|
res = srtp_filter_.ProtectRtp(
|
||||||
data, len, static_cast<int>(packet->capacity()), &len);
|
data, len, static_cast<int>(packet->capacity()), &len);
|
||||||
#else
|
#else
|
||||||
|
options.packet_time_params.rtp_sendtime_extension_id =
|
||||||
|
rtp_abs_sendtime_extn_id_;
|
||||||
res = srtp_filter_.ProtectRtp(
|
res = srtp_filter_.ProtectRtp(
|
||||||
data, len, static_cast<int>(packet->capacity()), &len,
|
data, len, static_cast<int>(packet->capacity()), &len,
|
||||||
&options.packet_time_params.srtp_packet_index);
|
&options.packet_time_params.srtp_packet_index);
|
||||||
|
@@ -620,7 +620,8 @@ bool SrtpSession::GetSendStreamPacketIndex(void* p, int in_len, int64* index) {
|
|||||||
if (stream == NULL)
|
if (stream == NULL)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
*index = rdbx_get_packet_index(&stream->rtp_rdbx);
|
// Shift packet index, put into network byte order
|
||||||
|
*index = be64_to_cpu(rdbx_get_packet_index(&stream->rtp_rdbx) << 16);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -671,7 +672,10 @@ bool SrtpSession::SetKey(int type, const std::string& cs,
|
|||||||
// We want to set this option only for rtp packets.
|
// We want to set this option only for rtp packets.
|
||||||
// By default policy structure is initialized to HMAC_SHA1.
|
// By default policy structure is initialized to HMAC_SHA1.
|
||||||
#if defined(ENABLE_EXTERNAL_AUTH)
|
#if defined(ENABLE_EXTERNAL_AUTH)
|
||||||
|
// Enable external HMAC authentication only for outgoing streams.
|
||||||
|
if (type == ssrc_any_outbound) {
|
||||||
policy.rtp.auth_type = EXTERNAL_HMAC_SHA1;
|
policy.rtp.auth_type = EXTERNAL_HMAC_SHA1;
|
||||||
|
}
|
||||||
#endif
|
#endif
|
||||||
policy.next = NULL;
|
policy.next = NULL;
|
||||||
|
|
||||||
|
@@ -631,7 +631,9 @@ TEST_F(SrtpSessionTest, TestGetSendStreamPacketIndex) {
|
|||||||
int out_len = 0;
|
int out_len = 0;
|
||||||
EXPECT_TRUE(s1_.ProtectRtp(rtp_packet_, rtp_len_,
|
EXPECT_TRUE(s1_.ProtectRtp(rtp_packet_, rtp_len_,
|
||||||
sizeof(rtp_packet_), &out_len, &index));
|
sizeof(rtp_packet_), &out_len, &index));
|
||||||
EXPECT_EQ(1, index);
|
// |index| will be shifted by 16.
|
||||||
|
int64 be64_index = be64_to_cpu(1 << 16);
|
||||||
|
EXPECT_EQ(be64_index, index);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Test that we fail to unprotect if someone tampers with the RTP/RTCP paylaods.
|
// Test that we fail to unprotect if someone tampers with the RTP/RTCP paylaods.
|
||||||
|
Reference in New Issue
Block a user