Update talk to 61549749.
TBR=wu@webrtc.org Review URL: https://webrtc-codereview.appspot.com/8709004 git-svn-id: http://webrtc.googlecode.com/svn/trunk@5549 4adac7df-926f-26a2-2b94-8c16560cd09d
This commit is contained in:
parent
b9a088b920
commit
385857dfd4
@ -969,12 +969,13 @@ class P2PTestConductor : public testing::Test {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (audio_frame_count != -1 || video_frame_count != -1) {
|
if (audio_frame_count != -1 || video_frame_count != -1) {
|
||||||
// Audio or video is expected to flow, so both sides should get to the
|
// Audio or video is expected to flow, so both clients should reach the
|
||||||
// Connected state.
|
// Connected state, and the offerer (ICE controller) should proceed to
|
||||||
|
// Completed.
|
||||||
// Note: These tests have been observed to fail under heavy load at
|
// Note: These tests have been observed to fail under heavy load at
|
||||||
// shorter timeouts, so they may be flaky.
|
// shorter timeouts, so they may be flaky.
|
||||||
EXPECT_EQ_WAIT(
|
EXPECT_EQ_WAIT(
|
||||||
webrtc::PeerConnectionInterface::kIceConnectionConnected,
|
webrtc::PeerConnectionInterface::kIceConnectionCompleted,
|
||||||
initiating_client_->ice_connection_state(),
|
initiating_client_->ice_connection_state(),
|
||||||
kMaxWaitForFramesMs);
|
kMaxWaitForFramesMs);
|
||||||
EXPECT_EQ_WAIT(
|
EXPECT_EQ_WAIT(
|
||||||
|
@ -204,7 +204,9 @@ void PeerConnectionTestWrapper::WaitForConnection() {
|
|||||||
|
|
||||||
bool PeerConnectionTestWrapper::CheckForConnection() {
|
bool PeerConnectionTestWrapper::CheckForConnection() {
|
||||||
return (peer_connection_->ice_connection_state() ==
|
return (peer_connection_->ice_connection_state() ==
|
||||||
PeerConnectionInterface::kIceConnectionConnected);
|
PeerConnectionInterface::kIceConnectionConnected) ||
|
||||||
|
(peer_connection_->ice_connection_state() ==
|
||||||
|
PeerConnectionInterface::kIceConnectionCompleted);
|
||||||
}
|
}
|
||||||
|
|
||||||
void PeerConnectionTestWrapper::WaitForAudio() {
|
void PeerConnectionTestWrapper::WaitForAudio() {
|
||||||
|
@ -1154,12 +1154,20 @@ void WebRtcSession::OnTransportWritable(cricket::Transport* transport) {
|
|||||||
// TODO(bemasc): Expose more API from Transport to detect when
|
// TODO(bemasc): Expose more API from Transport to detect when
|
||||||
// candidate selection starts or stops, due to success or failure.
|
// 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_ ==
|
if (ice_connection_state_ ==
|
||||||
PeerConnectionInterface::kIceConnectionChecking ||
|
PeerConnectionInterface::kIceConnectionChecking) {
|
||||||
ice_connection_state_ ==
|
|
||||||
PeerConnectionInterface::kIceConnectionDisconnected) {
|
|
||||||
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.
|
||||||
@ -1173,6 +1181,16 @@ void WebRtcSession::OnTransportWritable(cricket::Transport* transport) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void WebRtcSession::OnTransportCompleted(cricket::Transport* transport) {
|
||||||
|
ASSERT(signaling_thread()->IsCurrent());
|
||||||
|
SetIceConnectionState(PeerConnectionInterface::kIceConnectionCompleted);
|
||||||
|
}
|
||||||
|
|
||||||
|
void WebRtcSession::OnTransportFailed(cricket::Transport* transport) {
|
||||||
|
ASSERT(signaling_thread()->IsCurrent());
|
||||||
|
SetIceConnectionState(PeerConnectionInterface::kIceConnectionFailed);
|
||||||
|
}
|
||||||
|
|
||||||
void WebRtcSession::OnTransportProxyCandidatesReady(
|
void WebRtcSession::OnTransportProxyCandidatesReady(
|
||||||
cricket::TransportProxy* proxy, const cricket::Candidates& candidates) {
|
cricket::TransportProxy* proxy, const cricket::Candidates& candidates) {
|
||||||
ASSERT(signaling_thread()->IsCurrent());
|
ASSERT(signaling_thread()->IsCurrent());
|
||||||
|
@ -230,6 +230,8 @@ class WebRtcSession : public cricket::BaseSession,
|
|||||||
virtual void OnTransportRequestSignaling(cricket::Transport* transport);
|
virtual void OnTransportRequestSignaling(cricket::Transport* transport);
|
||||||
virtual void OnTransportConnecting(cricket::Transport* transport);
|
virtual void OnTransportConnecting(cricket::Transport* transport);
|
||||||
virtual void OnTransportWritable(cricket::Transport* transport);
|
virtual void OnTransportWritable(cricket::Transport* transport);
|
||||||
|
virtual void OnTransportCompleted(cricket::Transport* transport);
|
||||||
|
virtual void OnTransportFailed(cricket::Transport* transport);
|
||||||
virtual void OnTransportProxyCandidatesReady(
|
virtual void OnTransportProxyCandidatesReady(
|
||||||
cricket::TransportProxy* proxy,
|
cricket::TransportProxy* proxy,
|
||||||
const cricket::Candidates& candidates);
|
const cricket::Candidates& candidates);
|
||||||
|
@ -808,13 +808,15 @@ class WebRtcSessionTest : public testing::Test {
|
|||||||
|
|
||||||
// The method sets up a call from the session to itself, in a loopback
|
// The method sets up a call from the session to itself, in a loopback
|
||||||
// arrangement. It also uses a firewall rule to create a temporary
|
// arrangement. It also uses a firewall rule to create a temporary
|
||||||
// disconnection. This code is placed as a method so that it can be invoked
|
// disconnection, and then a permanent disconnection.
|
||||||
|
// This code is placed in a method so that it can be invoked
|
||||||
// by multiple tests with different allocators (e.g. with and without BUNDLE).
|
// by multiple tests with different allocators (e.g. with and without BUNDLE).
|
||||||
// While running the call, this method also checks if the session goes through
|
// While running the call, this method also checks if the session goes through
|
||||||
// the correct sequence of ICE states when a connection is established,
|
// the correct sequence of ICE states when a connection is established,
|
||||||
// broken, and re-established.
|
// broken, and re-established.
|
||||||
// The Connection state should go:
|
// The Connection state should go:
|
||||||
// New -> Checking -> Connected -> Disconnected -> Connected.
|
// New -> Checking -> (Connected) -> Completed -> Disconnected -> Completed
|
||||||
|
// -> Failed.
|
||||||
// The Gathering state should go: New -> Gathering -> Completed.
|
// The Gathering state should go: New -> Gathering -> Completed.
|
||||||
void TestLoopbackCall() {
|
void TestLoopbackCall() {
|
||||||
AddInterface(talk_base::SocketAddress(kClientAddrHost1, kClientAddrPort));
|
AddInterface(talk_base::SocketAddress(kClientAddrHost1, kClientAddrPort));
|
||||||
@ -845,10 +847,10 @@ class WebRtcSessionTest : public testing::Test {
|
|||||||
EXPECT_EQ_WAIT(PeerConnectionInterface::kIceConnectionChecking,
|
EXPECT_EQ_WAIT(PeerConnectionInterface::kIceConnectionChecking,
|
||||||
observer_.ice_connection_state_,
|
observer_.ice_connection_state_,
|
||||||
kIceCandidatesTimeout);
|
kIceCandidatesTimeout);
|
||||||
EXPECT_EQ_WAIT(PeerConnectionInterface::kIceConnectionConnected,
|
// The ice connection state is "Connected" too briefly to catch in a test.
|
||||||
|
EXPECT_EQ_WAIT(PeerConnectionInterface::kIceConnectionCompleted,
|
||||||
observer_.ice_connection_state_,
|
observer_.ice_connection_state_,
|
||||||
kIceCandidatesTimeout);
|
kIceCandidatesTimeout);
|
||||||
// TODO(bemasc): EXPECT(Completed) once the details are standardized.
|
|
||||||
|
|
||||||
// Adding firewall rule to block ping requests, which should cause
|
// Adding firewall rule to block ping requests, which should cause
|
||||||
// transport channel failure.
|
// transport channel failure.
|
||||||
@ -865,10 +867,21 @@ class WebRtcSessionTest : public testing::Test {
|
|||||||
// Session is automatically calling OnSignalingReady after creation of
|
// Session is automatically calling OnSignalingReady after creation of
|
||||||
// new portallocator session which will allocate new set of candidates.
|
// new portallocator session which will allocate new set of candidates.
|
||||||
|
|
||||||
// TODO(bemasc): Change this to Completed once the details are standardized.
|
EXPECT_EQ_WAIT(PeerConnectionInterface::kIceConnectionCompleted,
|
||||||
EXPECT_EQ_WAIT(PeerConnectionInterface::kIceConnectionConnected,
|
|
||||||
observer_.ice_connection_state_,
|
observer_.ice_connection_state_,
|
||||||
kIceCandidatesTimeout);
|
kIceCandidatesTimeout);
|
||||||
|
|
||||||
|
// Now we block ping requests and wait until the ICE connection transitions
|
||||||
|
// to the Failed state. This will take at least 30 seconds because it must
|
||||||
|
// wait for the Port to timeout.
|
||||||
|
int port_timeout = 30000;
|
||||||
|
fss_->AddRule(false,
|
||||||
|
talk_base::FP_ANY,
|
||||||
|
talk_base::FD_ANY,
|
||||||
|
talk_base::SocketAddress(kClientAddrHost1, kClientAddrPort));
|
||||||
|
EXPECT_EQ_WAIT(PeerConnectionInterface::kIceConnectionFailed,
|
||||||
|
observer_.ice_connection_state_,
|
||||||
|
kIceCandidatesTimeout + port_timeout);
|
||||||
}
|
}
|
||||||
|
|
||||||
void VerifyTransportType(const std::string& content_name,
|
void VerifyTransportType(const std::string& content_name,
|
||||||
@ -2601,6 +2614,14 @@ TEST_F(WebRtcSessionTest, TestIceStatesBasic) {
|
|||||||
TestLoopbackCall();
|
TestLoopbackCall();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Runs the loopback call test with BUNDLE, STUN, and TCP enabled.
|
||||||
|
TEST_F(WebRtcSessionTest, TestIceStatesBundle) {
|
||||||
|
allocator_.set_flags(cricket::PORTALLOCATOR_ENABLE_SHARED_UFRAG |
|
||||||
|
cricket::PORTALLOCATOR_ENABLE_BUNDLE |
|
||||||
|
cricket::PORTALLOCATOR_DISABLE_RELAY);
|
||||||
|
TestLoopbackCall();
|
||||||
|
}
|
||||||
|
|
||||||
TEST_F(WebRtcSessionTest, SetSdpFailedOnSessionError) {
|
TEST_F(WebRtcSessionTest, SetSdpFailedOnSessionError) {
|
||||||
Init(NULL);
|
Init(NULL);
|
||||||
cricket::MediaSessionOptions options;
|
cricket::MediaSessionOptions options;
|
||||||
|
@ -55,6 +55,8 @@ struct PacketTimeUpdateParams {
|
|||||||
// over network.
|
// over network.
|
||||||
struct PacketOptions {
|
struct PacketOptions {
|
||||||
PacketOptions() : dscp(DSCP_NO_CHANGE) {}
|
PacketOptions() : dscp(DSCP_NO_CHANGE) {}
|
||||||
|
explicit PacketOptions(DiffServCodePoint dscp) : dscp(dscp) {}
|
||||||
|
|
||||||
DiffServCodePoint dscp;
|
DiffServCodePoint dscp;
|
||||||
PacketTimeUpdateParams packet_time_params;
|
PacketTimeUpdateParams packet_time_params;
|
||||||
};
|
};
|
||||||
@ -102,9 +104,9 @@ class AsyncPacketSocket : public sigslot::has_slots<> {
|
|||||||
virtual SocketAddress GetRemoteAddress() const = 0;
|
virtual SocketAddress GetRemoteAddress() const = 0;
|
||||||
|
|
||||||
// Send a packet.
|
// Send a packet.
|
||||||
virtual int Send(const void *pv, size_t cb, DiffServCodePoint dscp) = 0;
|
virtual int Send(const void *pv, size_t cb, const PacketOptions& options) = 0;
|
||||||
virtual int SendTo(const void *pv, size_t cb, const SocketAddress& addr,
|
virtual int SendTo(const void *pv, size_t cb, const SocketAddress& addr,
|
||||||
DiffServCodePoint) = 0;
|
const PacketOptions& options) = 0;
|
||||||
|
|
||||||
// Close the socket.
|
// Close the socket.
|
||||||
virtual int Close() = 0;
|
virtual int Close() = 0;
|
||||||
|
@ -141,12 +141,11 @@ void AsyncTCPSocketBase::SetError(int error) {
|
|||||||
return socket_->SetError(error);
|
return socket_->SetError(error);
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO(mallinath) - Add support of setting DSCP code on AsyncSocket.
|
|
||||||
int AsyncTCPSocketBase::SendTo(const void *pv, size_t cb,
|
int AsyncTCPSocketBase::SendTo(const void *pv, size_t cb,
|
||||||
const SocketAddress& addr,
|
const SocketAddress& addr,
|
||||||
DiffServCodePoint dscp) {
|
const talk_base::PacketOptions& options) {
|
||||||
if (addr == GetRemoteAddress())
|
if (addr == GetRemoteAddress())
|
||||||
return Send(pv, cb, dscp);
|
return Send(pv, cb, options);
|
||||||
|
|
||||||
ASSERT(false);
|
ASSERT(false);
|
||||||
socket_->SetError(ENOTCONN);
|
socket_->SetError(ENOTCONN);
|
||||||
@ -263,8 +262,8 @@ AsyncTCPSocket::AsyncTCPSocket(AsyncSocket* socket, bool listen)
|
|||||||
: AsyncTCPSocketBase(socket, listen, kBufSize) {
|
: AsyncTCPSocketBase(socket, listen, kBufSize) {
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO(mallinath) - Add support of setting DSCP code on AsyncSocket.
|
int AsyncTCPSocket::Send(const void *pv, size_t cb,
|
||||||
int AsyncTCPSocket::Send(const void *pv, size_t cb, DiffServCodePoint dscp) {
|
const talk_base::PacketOptions& options) {
|
||||||
if (cb > kBufSize) {
|
if (cb > kBufSize) {
|
||||||
SetError(EMSGSIZE);
|
SetError(EMSGSIZE);
|
||||||
return -1;
|
return -1;
|
||||||
|
@ -43,7 +43,8 @@ class AsyncTCPSocketBase : public AsyncPacketSocket {
|
|||||||
virtual ~AsyncTCPSocketBase();
|
virtual ~AsyncTCPSocketBase();
|
||||||
|
|
||||||
// Pure virtual methods to send and recv data.
|
// Pure virtual methods to send and recv data.
|
||||||
virtual int Send(const void *pv, size_t cb, DiffServCodePoint dscp) = 0;
|
virtual int Send(const void *pv, size_t cb,
|
||||||
|
const talk_base::PacketOptions& options) = 0;
|
||||||
virtual void ProcessInput(char* data, size_t* len) = 0;
|
virtual void ProcessInput(char* data, size_t* len) = 0;
|
||||||
// Signals incoming connection.
|
// Signals incoming connection.
|
||||||
virtual void HandleIncomingConnection(AsyncSocket* socket) = 0;
|
virtual void HandleIncomingConnection(AsyncSocket* socket) = 0;
|
||||||
@ -51,7 +52,7 @@ class AsyncTCPSocketBase : public AsyncPacketSocket {
|
|||||||
virtual SocketAddress GetLocalAddress() const;
|
virtual SocketAddress GetLocalAddress() const;
|
||||||
virtual SocketAddress GetRemoteAddress() const;
|
virtual SocketAddress GetRemoteAddress() const;
|
||||||
virtual int SendTo(const void *pv, size_t cb, const SocketAddress& addr,
|
virtual int SendTo(const void *pv, size_t cb, const SocketAddress& addr,
|
||||||
DiffServCodePoint dscp);
|
const talk_base::PacketOptions& options);
|
||||||
virtual int Close();
|
virtual int Close();
|
||||||
|
|
||||||
virtual State GetState() const;
|
virtual State GetState() const;
|
||||||
@ -102,7 +103,8 @@ class AsyncTCPSocket : public AsyncTCPSocketBase {
|
|||||||
AsyncTCPSocket(AsyncSocket* socket, bool listen);
|
AsyncTCPSocket(AsyncSocket* socket, bool listen);
|
||||||
virtual ~AsyncTCPSocket() {}
|
virtual ~AsyncTCPSocket() {}
|
||||||
|
|
||||||
virtual int Send(const void* pv, size_t cb, DiffServCodePoint dscp);
|
virtual int Send(const void* pv, size_t cb,
|
||||||
|
const talk_base::PacketOptions& options);
|
||||||
virtual void ProcessInput(char* data, size_t* len);
|
virtual void ProcessInput(char* data, size_t* len);
|
||||||
virtual void HandleIncomingConnection(AsyncSocket* socket);
|
virtual void HandleIncomingConnection(AsyncSocket* socket);
|
||||||
|
|
||||||
|
@ -75,14 +75,14 @@ SocketAddress AsyncUDPSocket::GetRemoteAddress() const {
|
|||||||
return socket_->GetRemoteAddress();
|
return socket_->GetRemoteAddress();
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO(mallinath) - Add support of setting DSCP code on AsyncSocket.
|
int AsyncUDPSocket::Send(const void *pv, size_t cb,
|
||||||
int AsyncUDPSocket::Send(const void *pv, size_t cb, DiffServCodePoint dscp) {
|
const talk_base::PacketOptions& options) {
|
||||||
return socket_->Send(pv, cb);
|
return socket_->Send(pv, cb);
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO(mallinath) - Add support of setting DSCP code on AsyncSocket.
|
|
||||||
int AsyncUDPSocket::SendTo(const void *pv, size_t cb,
|
int AsyncUDPSocket::SendTo(const void *pv, size_t cb,
|
||||||
const SocketAddress& addr, DiffServCodePoint dscp) {
|
const SocketAddress& addr,
|
||||||
|
const talk_base::PacketOptions& options) {
|
||||||
return socket_->SendTo(pv, cb, addr);
|
return socket_->SendTo(pv, cb, addr);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -52,9 +52,10 @@ class AsyncUDPSocket : public AsyncPacketSocket {
|
|||||||
|
|
||||||
virtual SocketAddress GetLocalAddress() const;
|
virtual SocketAddress GetLocalAddress() const;
|
||||||
virtual SocketAddress GetRemoteAddress() const;
|
virtual SocketAddress GetRemoteAddress() const;
|
||||||
virtual int Send(const void *pv, size_t cb, DiffServCodePoint dscp);
|
virtual int Send(const void *pv, size_t cb,
|
||||||
|
const talk_base::PacketOptions& options);
|
||||||
virtual int SendTo(const void *pv, size_t cb, const SocketAddress& addr,
|
virtual int SendTo(const void *pv, size_t cb, const SocketAddress& addr,
|
||||||
DiffServCodePoint dscp);
|
const talk_base::PacketOptions& options);
|
||||||
virtual int Close();
|
virtual int Close();
|
||||||
|
|
||||||
virtual State GetState() const;
|
virtual State GetState() const;
|
||||||
|
@ -126,8 +126,8 @@ void NATServer::OnInternalPacket(
|
|||||||
iter->second->WhitelistInsert(dest_addr);
|
iter->second->WhitelistInsert(dest_addr);
|
||||||
|
|
||||||
// Send the packet to its intended destination.
|
// Send the packet to its intended destination.
|
||||||
iter->second->socket->SendTo(buf + length, size - length, dest_addr,
|
talk_base::PacketOptions options;
|
||||||
DSCP_NO_CHANGE);
|
iter->second->socket->SendTo(buf + length, size - length, dest_addr, options);
|
||||||
}
|
}
|
||||||
|
|
||||||
void NATServer::OnExternalPacket(
|
void NATServer::OnExternalPacket(
|
||||||
@ -154,9 +154,10 @@ void NATServer::OnExternalPacket(
|
|||||||
size + kNATEncodedIPv6AddressSize,
|
size + kNATEncodedIPv6AddressSize,
|
||||||
remote_addr);
|
remote_addr);
|
||||||
// Copy the data part after the address.
|
// Copy the data part after the address.
|
||||||
|
talk_base::PacketOptions options;
|
||||||
std::memcpy(real_buf.get() + addrlength, buf, size);
|
std::memcpy(real_buf.get() + addrlength, buf, size);
|
||||||
server_socket_->SendTo(real_buf.get(), size + addrlength,
|
server_socket_->SendTo(real_buf.get(), size + addrlength,
|
||||||
iter->second->route.source(), DSCP_NO_CHANGE);
|
iter->second->route.source(), options);
|
||||||
}
|
}
|
||||||
|
|
||||||
void NATServer::Translate(const SocketAddressPair& route) {
|
void NATServer::Translate(const SocketAddressPair& route) {
|
||||||
|
@ -25,7 +25,6 @@
|
|||||||
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "talk/base/dscp.h"
|
|
||||||
#include "talk/base/testclient.h"
|
#include "talk/base/testclient.h"
|
||||||
#include "talk/base/thread.h"
|
#include "talk/base/thread.h"
|
||||||
#include "talk/base/timeutils.h"
|
#include "talk/base/timeutils.h"
|
||||||
@ -59,12 +58,14 @@ bool TestClient::CheckConnState(AsyncPacketSocket::State state) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
int TestClient::Send(const char* buf, size_t size) {
|
int TestClient::Send(const char* buf, size_t size) {
|
||||||
return socket_->Send(buf, size, DSCP_NO_CHANGE);
|
talk_base::PacketOptions options;
|
||||||
|
return socket_->Send(buf, size, options);
|
||||||
}
|
}
|
||||||
|
|
||||||
int TestClient::SendTo(const char* buf, size_t size,
|
int TestClient::SendTo(const char* buf, size_t size,
|
||||||
const SocketAddress& dest) {
|
const SocketAddress& dest) {
|
||||||
return socket_->SendTo(buf, size, dest, DSCP_NO_CHANGE);
|
talk_base::PacketOptions options;
|
||||||
|
return socket_->SendTo(buf, size, dest, options);
|
||||||
}
|
}
|
||||||
|
|
||||||
TestClient::Packet* TestClient::NextPacket() {
|
TestClient::Packet* TestClient::NextPacket() {
|
||||||
|
@ -69,7 +69,8 @@ class TestEchoServer : public sigslot::has_slots<> {
|
|||||||
void OnPacket(AsyncPacketSocket* socket, const char* buf, size_t size,
|
void OnPacket(AsyncPacketSocket* socket, const char* buf, size_t size,
|
||||||
const SocketAddress& remote_addr,
|
const SocketAddress& remote_addr,
|
||||||
const PacketTime& packet_time) {
|
const PacketTime& packet_time) {
|
||||||
socket->Send(buf, size, DSCP_NO_CHANGE);
|
talk_base::PacketOptions options;
|
||||||
|
socket->Send(buf, size, options);
|
||||||
}
|
}
|
||||||
void OnClose(AsyncPacketSocket* socket, int err) {
|
void OnClose(AsyncPacketSocket* socket, int err) {
|
||||||
ClientList::iterator it =
|
ClientList::iterator it =
|
||||||
|
@ -69,7 +69,7 @@ struct Sender : public MessageHandler {
|
|||||||
|
|
||||||
count += size;
|
count += size;
|
||||||
memcpy(dummy, &cur_time, sizeof(cur_time));
|
memcpy(dummy, &cur_time, sizeof(cur_time));
|
||||||
socket->Send(dummy, size, DSCP_NO_CHANGE);
|
socket->Send(dummy, size, options);
|
||||||
|
|
||||||
last_send = cur_time;
|
last_send = cur_time;
|
||||||
thread->PostDelayed(NextDelay(), this, 1);
|
thread->PostDelayed(NextDelay(), this, 1);
|
||||||
@ -77,6 +77,7 @@ struct Sender : public MessageHandler {
|
|||||||
|
|
||||||
Thread* thread;
|
Thread* thread;
|
||||||
scoped_ptr<AsyncUDPSocket> socket;
|
scoped_ptr<AsyncUDPSocket> socket;
|
||||||
|
talk_base::PacketOptions options;
|
||||||
bool done;
|
bool done;
|
||||||
uint32 rate; // bytes per second
|
uint32 rate; // bytes per second
|
||||||
uint32 count;
|
uint32 count;
|
||||||
|
@ -65,9 +65,8 @@ AsyncStunTCPSocket::AsyncStunTCPSocket(
|
|||||||
: talk_base::AsyncTCPSocketBase(socket, listen, kBufSize) {
|
: talk_base::AsyncTCPSocketBase(socket, listen, kBufSize) {
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO(mallinath) - Add support of setting DSCP code on AsyncSocket.
|
|
||||||
int AsyncStunTCPSocket::Send(const void *pv, size_t cb,
|
int AsyncStunTCPSocket::Send(const void *pv, size_t cb,
|
||||||
talk_base::DiffServCodePoint dscp) {
|
const talk_base::PacketOptions& options) {
|
||||||
if (cb > kBufSize || cb < kPacketLenSize + kPacketLenOffset) {
|
if (cb > kBufSize || cb < kPacketLenSize + kPacketLenOffset) {
|
||||||
SetError(EMSGSIZE);
|
SetError(EMSGSIZE);
|
||||||
return -1;
|
return -1;
|
||||||
|
@ -48,7 +48,7 @@ class AsyncStunTCPSocket : public talk_base::AsyncTCPSocketBase {
|
|||||||
virtual ~AsyncStunTCPSocket() {}
|
virtual ~AsyncStunTCPSocket() {}
|
||||||
|
|
||||||
virtual int Send(const void* pv, size_t cb,
|
virtual int Send(const void* pv, size_t cb,
|
||||||
talk_base::DiffServCodePoint dscp);
|
const talk_base::PacketOptions& options);
|
||||||
virtual void ProcessInput(char* data, size_t* len);
|
virtual void ProcessInput(char* data, size_t* len);
|
||||||
virtual void HandleIncomingConnection(talk_base::AsyncSocket* socket);
|
virtual void HandleIncomingConnection(talk_base::AsyncSocket* socket);
|
||||||
|
|
||||||
|
@ -122,8 +122,9 @@ class AsyncStunTCPSocketTest : public testing::Test,
|
|||||||
}
|
}
|
||||||
|
|
||||||
bool Send(const void* data, size_t len) {
|
bool Send(const void* data, size_t len) {
|
||||||
|
talk_base::PacketOptions options;
|
||||||
size_t ret = send_socket_->Send(
|
size_t ret = send_socket_->Send(
|
||||||
reinterpret_cast<const char*>(data), len, talk_base::DSCP_NO_CHANGE);
|
reinterpret_cast<const char*>(data), len, options);
|
||||||
vss_->ProcessMessagesUntilIdle();
|
vss_->ProcessMessagesUntilIdle();
|
||||||
return (ret == len);
|
return (ret == len);
|
||||||
}
|
}
|
||||||
|
@ -71,8 +71,9 @@ talk_base::StreamResult StreamInterfaceChannel::Write(const void* data,
|
|||||||
int* error) {
|
int* error) {
|
||||||
// Always succeeds, since this is an unreliable transport anyway.
|
// Always succeeds, since this is an unreliable transport anyway.
|
||||||
// TODO: Should this block if channel_'s temporarily unwritable?
|
// TODO: Should this block if channel_'s temporarily unwritable?
|
||||||
channel_->SendPacket(
|
talk_base::PacketOptions packet_options;
|
||||||
static_cast<const char*>(data), data_len, talk_base::DSCP_NO_CHANGE);
|
channel_->SendPacket(static_cast<const char*>(data), data_len,
|
||||||
|
packet_options);
|
||||||
if (written) {
|
if (written) {
|
||||||
*written = data_len;
|
*written = data_len;
|
||||||
}
|
}
|
||||||
@ -124,6 +125,8 @@ DtlsTransportChannelWrapper::DtlsTransportChannelWrapper(
|
|||||||
&DtlsTransportChannelWrapper::OnRoleConflict);
|
&DtlsTransportChannelWrapper::OnRoleConflict);
|
||||||
channel_->SignalRouteChange.connect(this,
|
channel_->SignalRouteChange.connect(this,
|
||||||
&DtlsTransportChannelWrapper::OnRouteChange);
|
&DtlsTransportChannelWrapper::OnRouteChange);
|
||||||
|
channel_->SignalConnectionRemoved.connect(this,
|
||||||
|
&DtlsTransportChannelWrapper::OnConnectionRemoved);
|
||||||
}
|
}
|
||||||
|
|
||||||
DtlsTransportChannelWrapper::~DtlsTransportChannelWrapper() {
|
DtlsTransportChannelWrapper::~DtlsTransportChannelWrapper() {
|
||||||
@ -339,9 +342,9 @@ bool DtlsTransportChannelWrapper::GetSrtpCipher(std::string* cipher) {
|
|||||||
|
|
||||||
|
|
||||||
// Called from upper layers to send a media packet.
|
// Called from upper layers to send a media packet.
|
||||||
int DtlsTransportChannelWrapper::SendPacket(const char* data, size_t size,
|
int DtlsTransportChannelWrapper::SendPacket(
|
||||||
talk_base::DiffServCodePoint dscp,
|
const char* data, size_t size,
|
||||||
int flags) {
|
const talk_base::PacketOptions& options, int flags) {
|
||||||
int result = -1;
|
int result = -1;
|
||||||
|
|
||||||
switch (dtls_state_) {
|
switch (dtls_state_) {
|
||||||
@ -365,7 +368,7 @@ int DtlsTransportChannelWrapper::SendPacket(const char* data, size_t size,
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
result = channel_->SendPacket(data, size, dscp);
|
result = channel_->SendPacket(data, size, options);
|
||||||
} else {
|
} else {
|
||||||
result = (dtls_->WriteAll(data, size, NULL, NULL) ==
|
result = (dtls_->WriteAll(data, size, NULL, NULL) ==
|
||||||
talk_base::SR_SUCCESS) ? static_cast<int>(size) : -1;
|
talk_base::SR_SUCCESS) ? static_cast<int>(size) : -1;
|
||||||
@ -373,7 +376,7 @@ int DtlsTransportChannelWrapper::SendPacket(const char* data, size_t size,
|
|||||||
break;
|
break;
|
||||||
// Not doing DTLS.
|
// Not doing DTLS.
|
||||||
case STATE_NONE:
|
case STATE_NONE:
|
||||||
result = channel_->SendPacket(data, size, dscp);
|
result = channel_->SendPacket(data, size, options);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case STATE_CLOSED: // Can't send anything when we're closed.
|
case STATE_CLOSED: // Can't send anything when we're closed.
|
||||||
@ -621,4 +624,10 @@ void DtlsTransportChannelWrapper::OnRouteChange(
|
|||||||
SignalRouteChange(this, candidate);
|
SignalRouteChange(this, candidate);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void DtlsTransportChannelWrapper::OnConnectionRemoved(
|
||||||
|
TransportChannelImpl* channel) {
|
||||||
|
ASSERT(channel == channel_);
|
||||||
|
SignalConnectionRemoved(this);
|
||||||
|
}
|
||||||
|
|
||||||
} // namespace cricket
|
} // namespace cricket
|
||||||
|
@ -127,6 +127,9 @@ class DtlsTransportChannelWrapper : public TransportChannelImpl {
|
|||||||
virtual IceRole GetIceRole() const {
|
virtual IceRole GetIceRole() const {
|
||||||
return channel_->GetIceRole();
|
return channel_->GetIceRole();
|
||||||
}
|
}
|
||||||
|
virtual size_t GetConnectionCount() const {
|
||||||
|
return channel_->GetConnectionCount();
|
||||||
|
}
|
||||||
virtual bool SetLocalIdentity(talk_base::SSLIdentity *identity);
|
virtual bool SetLocalIdentity(talk_base::SSLIdentity *identity);
|
||||||
virtual bool GetLocalIdentity(talk_base::SSLIdentity** identity) const;
|
virtual bool GetLocalIdentity(talk_base::SSLIdentity** identity) const;
|
||||||
|
|
||||||
@ -137,7 +140,7 @@ class DtlsTransportChannelWrapper : public TransportChannelImpl {
|
|||||||
|
|
||||||
// Called to send a packet (via DTLS, if turned on).
|
// Called to send a packet (via DTLS, if turned on).
|
||||||
virtual int SendPacket(const char* data, size_t size,
|
virtual int SendPacket(const char* data, size_t size,
|
||||||
talk_base::DiffServCodePoint dscp,
|
const talk_base::PacketOptions& options,
|
||||||
int flags);
|
int flags);
|
||||||
|
|
||||||
// TransportChannel calls that we forward to the wrapped transport.
|
// TransportChannel calls that we forward to the wrapped transport.
|
||||||
@ -239,6 +242,7 @@ class DtlsTransportChannelWrapper : public TransportChannelImpl {
|
|||||||
void OnCandidatesAllocationDone(TransportChannelImpl* channel);
|
void OnCandidatesAllocationDone(TransportChannelImpl* channel);
|
||||||
void OnRoleConflict(TransportChannelImpl* channel);
|
void OnRoleConflict(TransportChannelImpl* channel);
|
||||||
void OnRouteChange(TransportChannel* channel, const Candidate& candidate);
|
void OnRouteChange(TransportChannel* channel, const Candidate& candidate);
|
||||||
|
void OnConnectionRemoved(TransportChannelImpl* channel);
|
||||||
|
|
||||||
Transport* transport_; // The transport_ that created us.
|
Transport* transport_; // The transport_ that created us.
|
||||||
talk_base::Thread* worker_thread_; // Everything should occur on this thread.
|
talk_base::Thread* worker_thread_; // Everything should occur on this thread.
|
||||||
|
@ -245,8 +245,9 @@ class DtlsTestClient : public sigslot::has_slots<> {
|
|||||||
|
|
||||||
// Only set the bypass flag if we've activated DTLS.
|
// Only set the bypass flag if we've activated DTLS.
|
||||||
int flags = (identity_.get() && srtp) ? cricket::PF_SRTP_BYPASS : 0;
|
int flags = (identity_.get() && srtp) ? cricket::PF_SRTP_BYPASS : 0;
|
||||||
|
talk_base::PacketOptions packet_options;
|
||||||
int rv = channels_[channel]->SendPacket(
|
int rv = channels_[channel]->SendPacket(
|
||||||
packet.get(), size, talk_base::DSCP_NO_CHANGE, flags);
|
packet.get(), size, packet_options, flags);
|
||||||
ASSERT_GT(rv, 0);
|
ASSERT_GT(rv, 0);
|
||||||
ASSERT_EQ(size, static_cast<size_t>(rv));
|
ASSERT_EQ(size, static_cast<size_t>(rv));
|
||||||
++sent;
|
++sent;
|
||||||
|
@ -73,7 +73,8 @@ class FakeTransportChannel : public TransportChannelImpl,
|
|||||||
ice_proto_(ICEPROTO_HYBRID),
|
ice_proto_(ICEPROTO_HYBRID),
|
||||||
remote_ice_mode_(ICEMODE_FULL),
|
remote_ice_mode_(ICEMODE_FULL),
|
||||||
dtls_fingerprint_("", NULL, 0),
|
dtls_fingerprint_("", NULL, 0),
|
||||||
ssl_role_(talk_base::SSL_CLIENT) {
|
ssl_role_(talk_base::SSL_CLIENT),
|
||||||
|
connection_count_(0) {
|
||||||
}
|
}
|
||||||
~FakeTransportChannel() {
|
~FakeTransportChannel() {
|
||||||
Reset();
|
Reset();
|
||||||
@ -100,6 +101,7 @@ class FakeTransportChannel : public TransportChannelImpl,
|
|||||||
|
|
||||||
virtual void SetIceRole(IceRole role) { role_ = role; }
|
virtual void SetIceRole(IceRole role) { role_ = role; }
|
||||||
virtual IceRole GetIceRole() const { return role_; }
|
virtual IceRole GetIceRole() const { return role_; }
|
||||||
|
virtual size_t GetConnectionCount() const { return connection_count_; }
|
||||||
virtual void SetIceTiebreaker(uint64 tiebreaker) { tiebreaker_ = tiebreaker; }
|
virtual void SetIceTiebreaker(uint64 tiebreaker) { tiebreaker_ = tiebreaker; }
|
||||||
virtual bool GetIceProtocolType(IceProtocolType* type) const {
|
virtual bool GetIceProtocolType(IceProtocolType* type) const {
|
||||||
*type = ice_proto_;
|
*type = ice_proto_;
|
||||||
@ -174,8 +176,15 @@ class FakeTransportChannel : public TransportChannelImpl,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void SetConnectionCount(size_t connection_count) {
|
||||||
|
size_t old_connection_count = connection_count_;
|
||||||
|
connection_count_ = connection_count;
|
||||||
|
if (connection_count_ < old_connection_count)
|
||||||
|
SignalConnectionRemoved(this);
|
||||||
|
}
|
||||||
|
|
||||||
virtual int SendPacket(const char* data, size_t len,
|
virtual int SendPacket(const char* data, size_t len,
|
||||||
talk_base::DiffServCodePoint dscp, int flags) {
|
const talk_base::PacketOptions& options, int flags) {
|
||||||
if (state_ != STATE_CONNECTED) {
|
if (state_ != STATE_CONNECTED) {
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
@ -313,6 +322,7 @@ class FakeTransportChannel : public TransportChannelImpl,
|
|||||||
IceMode remote_ice_mode_;
|
IceMode remote_ice_mode_;
|
||||||
talk_base::SSLFingerprint dtls_fingerprint_;
|
talk_base::SSLFingerprint dtls_fingerprint_;
|
||||||
talk_base::SSLRole ssl_role_;
|
talk_base::SSLRole ssl_role_;
|
||||||
|
size_t connection_count_;
|
||||||
};
|
};
|
||||||
|
|
||||||
// Fake transport class, which can be passed to anything that needs a Transport.
|
// Fake transport class, which can be passed to anything that needs a Transport.
|
||||||
|
@ -795,7 +795,7 @@ int P2PTransportChannel::SetOption(talk_base::Socket::Option opt, int value) {
|
|||||||
|
|
||||||
// Send data to the other side, using our best connection.
|
// Send data to the other side, using our best connection.
|
||||||
int P2PTransportChannel::SendPacket(const char *data, size_t len,
|
int P2PTransportChannel::SendPacket(const char *data, size_t len,
|
||||||
talk_base::DiffServCodePoint dscp,
|
const talk_base::PacketOptions& options,
|
||||||
int flags) {
|
int flags) {
|
||||||
ASSERT(worker_thread_ == talk_base::Thread::Current());
|
ASSERT(worker_thread_ == talk_base::Thread::Current());
|
||||||
if (flags != 0) {
|
if (flags != 0) {
|
||||||
@ -807,7 +807,7 @@ int P2PTransportChannel::SendPacket(const char *data, size_t len,
|
|||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
int sent = best_connection_->Send(data, len, dscp);
|
int sent = best_connection_->Send(data, len, options);
|
||||||
if (sent <= 0) {
|
if (sent <= 0) {
|
||||||
ASSERT(sent < 0);
|
ASSERT(sent < 0);
|
||||||
error_ = best_connection_->GetError();
|
error_ = best_connection_->GetError();
|
||||||
@ -1010,8 +1010,10 @@ void P2PTransportChannel::UpdateChannelState() {
|
|||||||
|
|
||||||
bool readable = false;
|
bool readable = false;
|
||||||
for (uint32 i = 0; i < connections_.size(); ++i) {
|
for (uint32 i = 0; i < connections_.size(); ++i) {
|
||||||
if (connections_[i]->read_state() == Connection::STATE_READABLE)
|
if (connections_[i]->read_state() == Connection::STATE_READABLE) {
|
||||||
readable = true;
|
readable = true;
|
||||||
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
set_readable(readable);
|
set_readable(readable);
|
||||||
}
|
}
|
||||||
@ -1224,6 +1226,8 @@ void P2PTransportChannel::OnConnectionDestroyed(Connection* connection) {
|
|||||||
SwitchBestConnectionTo(NULL);
|
SwitchBestConnectionTo(NULL);
|
||||||
RequestSort();
|
RequestSort();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
SignalConnectionRemoved(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
// When a port is destroyed remove it from our list of ports to use for
|
// When a port is destroyed remove it from our list of ports to use for
|
||||||
|
@ -79,6 +79,7 @@ class P2PTransportChannel : public TransportChannelImpl,
|
|||||||
virtual void SetIceRole(IceRole role);
|
virtual void SetIceRole(IceRole role);
|
||||||
virtual IceRole GetIceRole() const { return ice_role_; }
|
virtual IceRole GetIceRole() const { return ice_role_; }
|
||||||
virtual void SetIceTiebreaker(uint64 tiebreaker);
|
virtual void SetIceTiebreaker(uint64 tiebreaker);
|
||||||
|
virtual size_t GetConnectionCount() const { return connections_.size(); }
|
||||||
virtual bool GetIceProtocolType(IceProtocolType* type) const;
|
virtual bool GetIceProtocolType(IceProtocolType* type) const;
|
||||||
virtual void SetIceProtocolType(IceProtocolType type);
|
virtual void SetIceProtocolType(IceProtocolType type);
|
||||||
virtual void SetIceCredentials(const std::string& ice_ufrag,
|
virtual void SetIceCredentials(const std::string& ice_ufrag,
|
||||||
@ -93,7 +94,7 @@ class P2PTransportChannel : public TransportChannelImpl,
|
|||||||
|
|
||||||
// From TransportChannel:
|
// From TransportChannel:
|
||||||
virtual int SendPacket(const char *data, size_t len,
|
virtual int SendPacket(const char *data, size_t len,
|
||||||
talk_base::DiffServCodePoint dscp, int flags);
|
const talk_base::PacketOptions& options, int flags);
|
||||||
virtual int SetOption(talk_base::Socket::Option opt, int value);
|
virtual int SetOption(talk_base::Socket::Option opt, int value);
|
||||||
virtual int GetError() { return error_; }
|
virtual int GetError() { return error_; }
|
||||||
virtual bool GetStats(std::vector<ConnectionInfo>* stats);
|
virtual bool GetStats(std::vector<ConnectionInfo>* stats);
|
||||||
|
@ -671,7 +671,8 @@ class P2PTransportChannelTestBase : public testing::Test,
|
|||||||
}
|
}
|
||||||
int SendData(cricket::TransportChannel* channel,
|
int SendData(cricket::TransportChannel* channel,
|
||||||
const char* data, size_t len) {
|
const char* data, size_t len) {
|
||||||
return channel->SendPacket(data, len, talk_base::DSCP_NO_CHANGE, 0);
|
talk_base::PacketOptions options;
|
||||||
|
return channel->SendPacket(data, len, options, 0);
|
||||||
}
|
}
|
||||||
bool CheckDataOnChannel(cricket::TransportChannel* channel,
|
bool CheckDataOnChannel(cricket::TransportChannel* channel,
|
||||||
const char* data, int len) {
|
const char* data, int len) {
|
||||||
|
@ -630,7 +630,8 @@ void Port::SendBindingResponse(StunMessage* request,
|
|||||||
// Send the response message.
|
// Send the response message.
|
||||||
talk_base::ByteBuffer buf;
|
talk_base::ByteBuffer buf;
|
||||||
response.Write(&buf);
|
response.Write(&buf);
|
||||||
if (SendTo(buf.Data(), buf.Length(), addr, DefaultDscpValue(), false) < 0) {
|
talk_base::PacketOptions options(DefaultDscpValue());
|
||||||
|
if (SendTo(buf.Data(), buf.Length(), addr, options, false) < 0) {
|
||||||
LOG_J(LS_ERROR, this) << "Failed to send STUN ping response to "
|
LOG_J(LS_ERROR, this) << "Failed to send STUN ping response to "
|
||||||
<< addr.ToSensitiveString();
|
<< addr.ToSensitiveString();
|
||||||
}
|
}
|
||||||
@ -684,7 +685,8 @@ void Port::SendBindingErrorResponse(StunMessage* request,
|
|||||||
// Send the response message.
|
// Send the response message.
|
||||||
talk_base::ByteBuffer buf;
|
talk_base::ByteBuffer buf;
|
||||||
response.Write(&buf);
|
response.Write(&buf);
|
||||||
SendTo(buf.Data(), buf.Length(), addr, DefaultDscpValue(), false);
|
talk_base::PacketOptions options(DefaultDscpValue());
|
||||||
|
SendTo(buf.Data(), buf.Length(), addr, options, false);
|
||||||
LOG_J(LS_INFO, this) << "Sending STUN binding error: reason=" << reason
|
LOG_J(LS_INFO, this) << "Sending STUN binding error: reason=" << reason
|
||||||
<< " to " << addr.ToSensitiveString();
|
<< " to " << addr.ToSensitiveString();
|
||||||
}
|
}
|
||||||
@ -932,8 +934,9 @@ void Connection::set_use_candidate_attr(bool enable) {
|
|||||||
|
|
||||||
void Connection::OnSendStunPacket(const void* data, size_t size,
|
void Connection::OnSendStunPacket(const void* data, size_t size,
|
||||||
StunRequest* req) {
|
StunRequest* req) {
|
||||||
|
talk_base::PacketOptions options(port_->DefaultDscpValue());
|
||||||
if (port_->SendTo(data, size, remote_candidate_.address(),
|
if (port_->SendTo(data, size, remote_candidate_.address(),
|
||||||
port_->DefaultDscpValue(), false) < 0) {
|
options, false) < 0) {
|
||||||
LOG_J(LS_WARNING, this) << "Failed to send STUN ping " << req->id();
|
LOG_J(LS_WARNING, this) << "Failed to send STUN ping " << req->id();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1408,12 +1411,13 @@ ProxyConnection::ProxyConnection(Port* port, size_t index,
|
|||||||
}
|
}
|
||||||
|
|
||||||
int ProxyConnection::Send(const void* data, size_t size,
|
int ProxyConnection::Send(const void* data, size_t size,
|
||||||
talk_base::DiffServCodePoint dscp) {
|
const talk_base::PacketOptions& options) {
|
||||||
if (write_state_ == STATE_WRITE_INIT || write_state_ == STATE_WRITE_TIMEOUT) {
|
if (write_state_ == STATE_WRITE_INIT || write_state_ == STATE_WRITE_TIMEOUT) {
|
||||||
error_ = EWOULDBLOCK;
|
error_ = EWOULDBLOCK;
|
||||||
return SOCKET_ERROR;
|
return SOCKET_ERROR;
|
||||||
}
|
}
|
||||||
int sent = port_->SendTo(data, size, remote_candidate_.address(), dscp, true);
|
int sent = port_->SendTo(data, size, remote_candidate_.address(),
|
||||||
|
options, true);
|
||||||
if (sent <= 0) {
|
if (sent <= 0) {
|
||||||
ASSERT(sent < 0);
|
ASSERT(sent < 0);
|
||||||
error_ = port_->GetError();
|
error_ = port_->GetError();
|
||||||
|
@ -459,7 +459,7 @@ class Connection : public talk_base::MessageHandler,
|
|||||||
// the interface of AsyncPacketSocket, which may use UDP or TCP under the
|
// the interface of AsyncPacketSocket, which may use UDP or TCP under the
|
||||||
// covers.
|
// covers.
|
||||||
virtual int Send(const void* data, size_t size,
|
virtual int Send(const void* data, size_t size,
|
||||||
talk_base::DiffServCodePoint dscp) = 0;
|
const talk_base::PacketOptions& options) = 0;
|
||||||
|
|
||||||
// Error if Send() returns < 0
|
// Error if Send() returns < 0
|
||||||
virtual int GetError() = 0;
|
virtual int GetError() = 0;
|
||||||
@ -591,7 +591,7 @@ class ProxyConnection : public Connection {
|
|||||||
ProxyConnection(Port* port, size_t index, const Candidate& candidate);
|
ProxyConnection(Port* port, size_t index, const Candidate& candidate);
|
||||||
|
|
||||||
virtual int Send(const void* data, size_t size,
|
virtual int Send(const void* data, size_t size,
|
||||||
talk_base::DiffServCodePoint dscp);
|
const talk_base::PacketOptions& options);
|
||||||
virtual int GetError() { return error_; }
|
virtual int GetError() { return error_; }
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
@ -173,7 +173,7 @@ class TestPort : public Port {
|
|||||||
}
|
}
|
||||||
virtual int SendTo(
|
virtual int SendTo(
|
||||||
const void* data, size_t size, const talk_base::SocketAddress& addr,
|
const void* data, size_t size, const talk_base::SocketAddress& addr,
|
||||||
talk_base::DiffServCodePoint dscp, bool payload) {
|
const talk_base::PacketOptions& options, bool payload) {
|
||||||
if (!payload) {
|
if (!payload) {
|
||||||
IceMessage* msg = new IceMessage;
|
IceMessage* msg = new IceMessage;
|
||||||
ByteBuffer* buf = new ByteBuffer(static_cast<const char*>(data), size);
|
ByteBuffer* buf = new ByteBuffer(static_cast<const char*>(data), size);
|
||||||
@ -842,11 +842,11 @@ class FakeAsyncPacketSocket : public AsyncPacketSocket {
|
|||||||
|
|
||||||
// Send a packet.
|
// Send a packet.
|
||||||
virtual int Send(const void *pv, size_t cb,
|
virtual int Send(const void *pv, size_t cb,
|
||||||
talk_base::DiffServCodePoint dscp) {
|
const talk_base::PacketOptions& options) {
|
||||||
return static_cast<int>(cb);
|
return static_cast<int>(cb);
|
||||||
}
|
}
|
||||||
virtual int SendTo(const void *pv, size_t cb, const SocketAddress& addr,
|
virtual int SendTo(const void *pv, size_t cb, const SocketAddress& addr,
|
||||||
talk_base::DiffServCodePoint dscp) {
|
const talk_base::PacketOptions& options) {
|
||||||
return static_cast<int>(cb);
|
return static_cast<int>(cb);
|
||||||
}
|
}
|
||||||
virtual int Close() {
|
virtual int Close() {
|
||||||
@ -2297,16 +2297,15 @@ TEST_F(PortTest, TestWritableState) {
|
|||||||
// Data should be unsendable until the connection is accepted.
|
// Data should be unsendable until the connection is accepted.
|
||||||
char data[] = "abcd";
|
char data[] = "abcd";
|
||||||
int data_size = ARRAY_SIZE(data);
|
int data_size = ARRAY_SIZE(data);
|
||||||
EXPECT_EQ(SOCKET_ERROR,
|
talk_base::PacketOptions options;
|
||||||
ch1.conn()->Send(data, data_size, talk_base::DSCP_NO_CHANGE));
|
EXPECT_EQ(SOCKET_ERROR, ch1.conn()->Send(data, data_size, options));
|
||||||
|
|
||||||
// Accept the connection to return the binding response, transition to
|
// Accept the connection to return the binding response, transition to
|
||||||
// writable, and allow data to be sent.
|
// writable, and allow data to be sent.
|
||||||
ch2.AcceptConnection();
|
ch2.AcceptConnection();
|
||||||
EXPECT_EQ_WAIT(Connection::STATE_WRITABLE, ch1.conn()->write_state(),
|
EXPECT_EQ_WAIT(Connection::STATE_WRITABLE, ch1.conn()->write_state(),
|
||||||
kTimeout);
|
kTimeout);
|
||||||
EXPECT_EQ(data_size,
|
EXPECT_EQ(data_size, ch1.conn()->Send(data, data_size, options));
|
||||||
ch1.conn()->Send(data, data_size, talk_base::DSCP_NO_CHANGE));
|
|
||||||
|
|
||||||
// Ask the connection to update state as if enough time has passed to lose
|
// Ask the connection to update state as if enough time has passed to lose
|
||||||
// full writability and 5 pings went unresponded to. We'll accomplish the
|
// full writability and 5 pings went unresponded to. We'll accomplish the
|
||||||
@ -2319,8 +2318,7 @@ TEST_F(PortTest, TestWritableState) {
|
|||||||
EXPECT_EQ(Connection::STATE_WRITE_UNRELIABLE, ch1.conn()->write_state());
|
EXPECT_EQ(Connection::STATE_WRITE_UNRELIABLE, ch1.conn()->write_state());
|
||||||
|
|
||||||
// Data should be able to be sent in this state.
|
// Data should be able to be sent in this state.
|
||||||
EXPECT_EQ(data_size,
|
EXPECT_EQ(data_size, ch1.conn()->Send(data, data_size, options));
|
||||||
ch1.conn()->Send(data, data_size, talk_base::DSCP_NO_CHANGE));
|
|
||||||
|
|
||||||
// And now allow the other side to process the pings and send binding
|
// And now allow the other side to process the pings and send binding
|
||||||
// responses.
|
// responses.
|
||||||
@ -2337,8 +2335,7 @@ TEST_F(PortTest, TestWritableState) {
|
|||||||
EXPECT_EQ(Connection::STATE_WRITE_TIMEOUT, ch1.conn()->write_state());
|
EXPECT_EQ(Connection::STATE_WRITE_TIMEOUT, ch1.conn()->write_state());
|
||||||
|
|
||||||
// Now that the connection has completely timed out, data send should fail.
|
// Now that the connection has completely timed out, data send should fail.
|
||||||
EXPECT_EQ(SOCKET_ERROR,
|
EXPECT_EQ(SOCKET_ERROR, ch1.conn()->Send(data, data_size, options));
|
||||||
ch1.conn()->Send(data, data_size, talk_base::DSCP_NO_CHANGE));
|
|
||||||
|
|
||||||
ch1.Stop();
|
ch1.Stop();
|
||||||
ch2.Stop();
|
ch2.Stop();
|
||||||
|
@ -30,13 +30,12 @@
|
|||||||
|
|
||||||
#include <string>
|
#include <string>
|
||||||
|
|
||||||
#include "talk/base/dscp.h"
|
|
||||||
#include "talk/base/socketaddress.h"
|
#include "talk/base/socketaddress.h"
|
||||||
#include "talk/p2p/base/transport.h"
|
#include "talk/p2p/base/transport.h"
|
||||||
|
|
||||||
namespace talk_base {
|
namespace talk_base {
|
||||||
class Network;
|
class Network;
|
||||||
class PacketSocketFactory;
|
struct PacketOptions;
|
||||||
}
|
}
|
||||||
|
|
||||||
namespace cricket {
|
namespace cricket {
|
||||||
@ -100,7 +99,7 @@ class PortInterface {
|
|||||||
// that of a connection or an address that has sent to us already.
|
// that of a connection or an address that has sent to us already.
|
||||||
virtual int SendTo(const void* data, size_t size,
|
virtual int SendTo(const void* data, size_t size,
|
||||||
const talk_base::SocketAddress& addr,
|
const talk_base::SocketAddress& addr,
|
||||||
talk_base::DiffServCodePoint dscp, bool payload) = 0;
|
const talk_base::PacketOptions& options, bool payload) = 0;
|
||||||
|
|
||||||
// Indicates that we received a successful STUN binding request from an
|
// Indicates that we received a successful STUN binding request from an
|
||||||
// address that doesn't correspond to any current connection. To turn this
|
// address that doesn't correspond to any current connection. To turn this
|
||||||
|
@ -97,10 +97,10 @@ Connection* PortProxy::CreateConnection(const Candidate& remote_candidate,
|
|||||||
int PortProxy::SendTo(const void* data,
|
int PortProxy::SendTo(const void* data,
|
||||||
size_t size,
|
size_t size,
|
||||||
const talk_base::SocketAddress& addr,
|
const talk_base::SocketAddress& addr,
|
||||||
talk_base::DiffServCodePoint dscp,
|
const talk_base::PacketOptions& options,
|
||||||
bool payload) {
|
bool payload) {
|
||||||
ASSERT(impl_ != NULL);
|
ASSERT(impl_ != NULL);
|
||||||
return impl_->SendTo(data, size, addr, dscp, payload);
|
return impl_->SendTo(data, size, addr, options, payload);
|
||||||
}
|
}
|
||||||
|
|
||||||
int PortProxy::SetOption(talk_base::Socket::Option opt,
|
int PortProxy::SetOption(talk_base::Socket::Option opt,
|
||||||
|
@ -69,7 +69,7 @@ class PortProxy : public PortInterface, public sigslot::has_slots<> {
|
|||||||
|
|
||||||
virtual int SendTo(const void* data, size_t size,
|
virtual int SendTo(const void* data, size_t size,
|
||||||
const talk_base::SocketAddress& addr,
|
const talk_base::SocketAddress& addr,
|
||||||
talk_base::DiffServCodePoint dscp,
|
const talk_base::PacketOptions& options,
|
||||||
bool payload);
|
bool payload);
|
||||||
virtual int SetOption(talk_base::Socket::Option opt, int value);
|
virtual int SetOption(talk_base::Socket::Option opt, int value);
|
||||||
virtual int GetOption(talk_base::Socket::Option opt, int* value);
|
virtual int GetOption(talk_base::Socket::Option opt, int* value);
|
||||||
|
@ -75,7 +75,7 @@ RawTransportChannel::~RawTransportChannel() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
int RawTransportChannel::SendPacket(const char *data, size_t size,
|
int RawTransportChannel::SendPacket(const char *data, size_t size,
|
||||||
talk_base::DiffServCodePoint dscp,
|
const talk_base::PacketOptions& options,
|
||||||
int flags) {
|
int flags) {
|
||||||
if (port_ == NULL)
|
if (port_ == NULL)
|
||||||
return -1;
|
return -1;
|
||||||
@ -83,7 +83,7 @@ int RawTransportChannel::SendPacket(const char *data, size_t size,
|
|||||||
return -1;
|
return -1;
|
||||||
if (flags != 0)
|
if (flags != 0)
|
||||||
return -1;
|
return -1;
|
||||||
return port_->SendTo(data, size, remote_address_, dscp, true);
|
return port_->SendTo(data, size, remote_address_, options, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
int RawTransportChannel::SetOption(talk_base::Socket::Option opt, int value) {
|
int RawTransportChannel::SetOption(talk_base::Socket::Option opt, int value) {
|
||||||
|
@ -65,7 +65,7 @@ class RawTransportChannel : public TransportChannelImpl,
|
|||||||
|
|
||||||
// Implementation of normal channel packet sending.
|
// Implementation of normal channel packet sending.
|
||||||
virtual int SendPacket(const char *data, size_t len,
|
virtual int SendPacket(const char *data, size_t len,
|
||||||
talk_base::DiffServCodePoint dscp, int flags);
|
const talk_base::PacketOptions& options, int flags);
|
||||||
virtual int SetOption(talk_base::Socket::Option opt, int value);
|
virtual int SetOption(talk_base::Socket::Option opt, int value);
|
||||||
virtual int GetError();
|
virtual int GetError();
|
||||||
|
|
||||||
@ -104,6 +104,7 @@ class RawTransportChannel : public TransportChannelImpl,
|
|||||||
virtual void SetIceUfrag(const std::string& ice_ufrag) {}
|
virtual void SetIceUfrag(const std::string& ice_ufrag) {}
|
||||||
virtual void SetIcePwd(const std::string& ice_pwd) {}
|
virtual void SetIcePwd(const std::string& ice_pwd) {}
|
||||||
virtual void SetRemoteIceMode(IceMode mode) {}
|
virtual void SetRemoteIceMode(IceMode mode) {}
|
||||||
|
virtual size_t GetConnectionCount() const { return 1; }
|
||||||
|
|
||||||
virtual bool GetStats(ConnectionInfos* infos) {
|
virtual bool GetStats(ConnectionInfos* infos) {
|
||||||
return false;
|
return false;
|
||||||
|
@ -67,7 +67,7 @@ class RelayConnection : public sigslot::has_slots<> {
|
|||||||
bool CheckResponse(StunMessage* msg);
|
bool CheckResponse(StunMessage* msg);
|
||||||
|
|
||||||
// Sends data to the relay server.
|
// Sends data to the relay server.
|
||||||
int Send(const void* pv, size_t cb, talk_base::DiffServCodePoint dscp);
|
int Send(const void* pv, size_t cb, const talk_base::PacketOptions& options);
|
||||||
|
|
||||||
// Sends a STUN allocate request message to the relay server.
|
// Sends a STUN allocate request message to the relay server.
|
||||||
void SendAllocateRequest(RelayEntry* entry, int delay);
|
void SendAllocateRequest(RelayEntry* entry, int delay);
|
||||||
@ -124,7 +124,7 @@ class RelayEntry : public talk_base::MessageHandler,
|
|||||||
// entry. This will wrap the packet in STUN if necessary.
|
// entry. This will wrap the packet in STUN if necessary.
|
||||||
int SendTo(const void* data, size_t size,
|
int SendTo(const void* data, size_t size,
|
||||||
const talk_base::SocketAddress& addr,
|
const talk_base::SocketAddress& addr,
|
||||||
talk_base::DiffServCodePoint dscp);
|
const talk_base::PacketOptions& options);
|
||||||
|
|
||||||
// Schedules a keep-alive allocate request.
|
// Schedules a keep-alive allocate request.
|
||||||
void ScheduleKeepAlive();
|
void ScheduleKeepAlive();
|
||||||
@ -166,7 +166,7 @@ class RelayEntry : public talk_base::MessageHandler,
|
|||||||
// Sends the given data on the socket to the server with no wrapping. This
|
// Sends the given data on the socket to the server with no wrapping. This
|
||||||
// returns the number of bytes written or -1 if an error occurred.
|
// returns the number of bytes written or -1 if an error occurred.
|
||||||
int SendPacket(const void* data, size_t size,
|
int SendPacket(const void* data, size_t size,
|
||||||
talk_base::DiffServCodePoint dscp);
|
const talk_base::PacketOptions& options);
|
||||||
};
|
};
|
||||||
|
|
||||||
// Handles an allocate request for a particular RelayEntry.
|
// Handles an allocate request for a particular RelayEntry.
|
||||||
@ -304,7 +304,7 @@ Connection* RelayPort::CreateConnection(const Candidate& address,
|
|||||||
|
|
||||||
int RelayPort::SendTo(const void* data, size_t size,
|
int RelayPort::SendTo(const void* data, size_t size,
|
||||||
const talk_base::SocketAddress& addr,
|
const talk_base::SocketAddress& addr,
|
||||||
talk_base::DiffServCodePoint dscp,
|
const talk_base::PacketOptions& options,
|
||||||
bool payload) {
|
bool payload) {
|
||||||
// Try to find an entry for this specific address. Note that the first entry
|
// Try to find an entry for this specific address. Note that the first entry
|
||||||
// created was not given an address initially, so it can be set to the first
|
// created was not given an address initially, so it can be set to the first
|
||||||
@ -346,7 +346,7 @@ int RelayPort::SendTo(const void* data, size_t size,
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Send the actual contents to the server using the usual mechanism.
|
// Send the actual contents to the server using the usual mechanism.
|
||||||
int sent = entry->SendTo(data, size, addr, dscp);
|
int sent = entry->SendTo(data, size, addr, options);
|
||||||
if (sent <= 0) {
|
if (sent <= 0) {
|
||||||
ASSERT(sent < 0);
|
ASSERT(sent < 0);
|
||||||
error_ = entry->GetError();
|
error_ = entry->GetError();
|
||||||
@ -426,8 +426,8 @@ bool RelayConnection::CheckResponse(StunMessage* msg) {
|
|||||||
void RelayConnection::OnSendPacket(const void* data, size_t size,
|
void RelayConnection::OnSendPacket(const void* data, size_t size,
|
||||||
StunRequest* req) {
|
StunRequest* req) {
|
||||||
// TODO(mallinath) Find a way to get DSCP value from Port.
|
// TODO(mallinath) Find a way to get DSCP value from Port.
|
||||||
int sent = socket_->SendTo(
|
talk_base::PacketOptions options; // Default dscp set to NO_CHANGE.
|
||||||
data, size, GetAddress(), talk_base::DSCP_NO_CHANGE);
|
int sent = socket_->SendTo(data, size, GetAddress(), options);
|
||||||
if (sent <= 0) {
|
if (sent <= 0) {
|
||||||
LOG(LS_VERBOSE) << "OnSendPacket: failed sending to " << GetAddress() <<
|
LOG(LS_VERBOSE) << "OnSendPacket: failed sending to " << GetAddress() <<
|
||||||
std::strerror(socket_->GetError());
|
std::strerror(socket_->GetError());
|
||||||
@ -436,8 +436,8 @@ void RelayConnection::OnSendPacket(const void* data, size_t size,
|
|||||||
}
|
}
|
||||||
|
|
||||||
int RelayConnection::Send(const void* pv, size_t cb,
|
int RelayConnection::Send(const void* pv, size_t cb,
|
||||||
talk_base::DiffServCodePoint dscp) {
|
const talk_base::PacketOptions& options) {
|
||||||
return socket_->SendTo(pv, cb, GetAddress(), dscp);
|
return socket_->SendTo(pv, cb, GetAddress(), options);
|
||||||
}
|
}
|
||||||
|
|
||||||
void RelayConnection::SendAllocateRequest(RelayEntry* entry, int delay) {
|
void RelayConnection::SendAllocateRequest(RelayEntry* entry, int delay) {
|
||||||
@ -557,11 +557,11 @@ void RelayEntry::OnConnect(const talk_base::SocketAddress& mapped_addr,
|
|||||||
|
|
||||||
int RelayEntry::SendTo(const void* data, size_t size,
|
int RelayEntry::SendTo(const void* data, size_t size,
|
||||||
const talk_base::SocketAddress& addr,
|
const talk_base::SocketAddress& addr,
|
||||||
talk_base::DiffServCodePoint dscp) {
|
const talk_base::PacketOptions& options) {
|
||||||
// If this connection is locked to the address given, then we can send the
|
// If this connection is locked to the address given, then we can send the
|
||||||
// packet with no wrapper.
|
// packet with no wrapper.
|
||||||
if (locked_ && (ext_addr_ == addr))
|
if (locked_ && (ext_addr_ == addr))
|
||||||
return SendPacket(data, size, dscp);
|
return SendPacket(data, size, options);
|
||||||
|
|
||||||
// Otherwise, we must wrap the given data in a STUN SEND request so that we
|
// Otherwise, we must wrap the given data in a STUN SEND request so that we
|
||||||
// can communicate the destination address to the server.
|
// can communicate the destination address to the server.
|
||||||
@ -609,7 +609,7 @@ int RelayEntry::SendTo(const void* data, size_t size,
|
|||||||
talk_base::ByteBuffer buf;
|
talk_base::ByteBuffer buf;
|
||||||
request.Write(&buf);
|
request.Write(&buf);
|
||||||
|
|
||||||
return SendPacket(buf.Data(), buf.Length(), dscp);
|
return SendPacket(buf.Data(), buf.Length(), options);
|
||||||
}
|
}
|
||||||
|
|
||||||
void RelayEntry::ScheduleKeepAlive() {
|
void RelayEntry::ScheduleKeepAlive() {
|
||||||
@ -758,12 +758,12 @@ void RelayEntry::OnReadyToSend(talk_base::AsyncPacketSocket* socket) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
int RelayEntry::SendPacket(const void* data, size_t size,
|
int RelayEntry::SendPacket(const void* data, size_t size,
|
||||||
talk_base::DiffServCodePoint dscp) {
|
const talk_base::PacketOptions& options) {
|
||||||
int sent = 0;
|
int sent = 0;
|
||||||
if (current_connection_) {
|
if (current_connection_) {
|
||||||
// We are connected, no need to send packets anywere else than to
|
// We are connected, no need to send packets anywere else than to
|
||||||
// the current connection.
|
// the current connection.
|
||||||
sent = current_connection_->Send(data, size, dscp);
|
sent = current_connection_->Send(data, size, options);
|
||||||
}
|
}
|
||||||
return sent;
|
return sent;
|
||||||
}
|
}
|
||||||
|
@ -93,7 +93,7 @@ class RelayPort : public Port {
|
|||||||
|
|
||||||
virtual int SendTo(const void* data, size_t size,
|
virtual int SendTo(const void* data, size_t size,
|
||||||
const talk_base::SocketAddress& addr,
|
const talk_base::SocketAddress& addr,
|
||||||
talk_base::DiffServCodePoint dscp,
|
const talk_base::PacketOptions& options,
|
||||||
bool payload);
|
bool payload);
|
||||||
|
|
||||||
// Dispatches the given packet to the port or connection as appropriate.
|
// Dispatches the given packet to the port or connection as appropriate.
|
||||||
|
@ -51,7 +51,8 @@ static const uint32 kMessageAcceptConnection = 1;
|
|||||||
// Calls SendTo on the given socket and logs any bad results.
|
// Calls SendTo on the given socket and logs any bad results.
|
||||||
void Send(talk_base::AsyncPacketSocket* socket, const char* bytes, size_t size,
|
void Send(talk_base::AsyncPacketSocket* socket, const char* bytes, size_t size,
|
||||||
const talk_base::SocketAddress& addr) {
|
const talk_base::SocketAddress& addr) {
|
||||||
int result = socket->SendTo(bytes, size, addr, talk_base::DSCP_NO_CHANGE);
|
talk_base::PacketOptions options;
|
||||||
|
int result = socket->SendTo(bytes, size, addr, options);
|
||||||
if (result < static_cast<int>(size)) {
|
if (result < static_cast<int>(size)) {
|
||||||
LOG(LS_ERROR) << "SendTo wrote only " << result << " of " << size
|
LOG(LS_ERROR) << "SendTo wrote only " << result << " of " << size
|
||||||
<< " bytes";
|
<< " bytes";
|
||||||
|
@ -539,6 +539,10 @@ TransportProxy* BaseSession::GetOrCreateTransportProxy(
|
|||||||
this, &BaseSession::OnTransportCandidatesAllocationDone);
|
this, &BaseSession::OnTransportCandidatesAllocationDone);
|
||||||
transport->SignalRoleConflict.connect(
|
transport->SignalRoleConflict.connect(
|
||||||
this, &BaseSession::OnRoleConflict);
|
this, &BaseSession::OnRoleConflict);
|
||||||
|
transport->SignalCompleted.connect(
|
||||||
|
this, &BaseSession::OnTransportCompleted);
|
||||||
|
transport->SignalFailed.connect(
|
||||||
|
this, &BaseSession::OnTransportFailed);
|
||||||
|
|
||||||
transproxy = new TransportProxy(worker_thread_, sid_, content_name,
|
transproxy = new TransportProxy(worker_thread_, sid_, content_name,
|
||||||
new TransportWrapper(transport));
|
new TransportWrapper(transport));
|
||||||
|
@ -432,6 +432,14 @@ class BaseSession : public sigslot::has_slots<>,
|
|||||||
virtual void OnTransportReadable(Transport* transport) {
|
virtual void OnTransportReadable(Transport* transport) {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Called when a transport has found its steady-state connections.
|
||||||
|
virtual void OnTransportCompleted(Transport* transport) {
|
||||||
|
}
|
||||||
|
|
||||||
|
// Called when a transport has failed permanently.
|
||||||
|
virtual void OnTransportFailed(Transport* transport) {
|
||||||
|
}
|
||||||
|
|
||||||
// Called when a transport signals that it has new candidates.
|
// Called when a transport signals that it has new candidates.
|
||||||
virtual void OnTransportProxyCandidatesReady(TransportProxy* proxy,
|
virtual void OnTransportProxyCandidatesReady(TransportProxy* proxy,
|
||||||
const Candidates& candidates) {
|
const Candidates& candidates) {
|
||||||
|
@ -32,7 +32,6 @@
|
|||||||
|
|
||||||
#include "talk/base/base64.h"
|
#include "talk/base/base64.h"
|
||||||
#include "talk/base/common.h"
|
#include "talk/base/common.h"
|
||||||
#include "talk/base/dscp.h"
|
|
||||||
#include "talk/base/gunit.h"
|
#include "talk/base/gunit.h"
|
||||||
#include "talk/base/helpers.h"
|
#include "talk/base/helpers.h"
|
||||||
#include "talk/base/logging.h"
|
#include "talk/base/logging.h"
|
||||||
@ -828,10 +827,11 @@ struct ChannelHandler : sigslot::has_slots<> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void Send(const char* data, size_t size) {
|
void Send(const char* data, size_t size) {
|
||||||
|
talk_base::PacketOptions options;
|
||||||
std::string data_with_id(name);
|
std::string data_with_id(name);
|
||||||
data_with_id += data;
|
data_with_id += data;
|
||||||
int result = channel->SendPacket(data_with_id.c_str(), data_with_id.size(),
|
int result = channel->SendPacket(data_with_id.c_str(), data_with_id.size(),
|
||||||
talk_base::DSCP_NO_CHANGE, 0);
|
options, 0);
|
||||||
EXPECT_EQ(static_cast<int>(data_with_id.size()), result);
|
EXPECT_EQ(static_cast<int>(data_with_id.size()), result);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -218,9 +218,9 @@ Connection* UDPPort::CreateConnection(const Candidate& address,
|
|||||||
|
|
||||||
int UDPPort::SendTo(const void* data, size_t size,
|
int UDPPort::SendTo(const void* data, size_t size,
|
||||||
const talk_base::SocketAddress& addr,
|
const talk_base::SocketAddress& addr,
|
||||||
talk_base::DiffServCodePoint dscp,
|
const talk_base::PacketOptions& options,
|
||||||
bool payload) {
|
bool payload) {
|
||||||
int sent = socket_->SendTo(data, size, addr, dscp);
|
int sent = socket_->SendTo(data, size, addr, options);
|
||||||
if (sent < 0) {
|
if (sent < 0) {
|
||||||
error_ = socket_->GetError();
|
error_ = socket_->GetError();
|
||||||
LOG_J(LS_ERROR, this) << "UDP send of " << size
|
LOG_J(LS_ERROR, this) << "UDP send of " << size
|
||||||
@ -354,7 +354,8 @@ void UDPPort::SetResult(bool success) {
|
|||||||
// TODO: merge this with SendTo above.
|
// TODO: merge this with SendTo above.
|
||||||
void UDPPort::OnSendPacket(const void* data, size_t size, StunRequest* req) {
|
void UDPPort::OnSendPacket(const void* data, size_t size, StunRequest* req) {
|
||||||
StunBindingRequest* sreq = static_cast<StunBindingRequest*>(req);
|
StunBindingRequest* sreq = static_cast<StunBindingRequest*>(req);
|
||||||
if (socket_->SendTo(data, size, sreq->server_addr(), DefaultDscpValue()) < 0)
|
talk_base::PacketOptions options(DefaultDscpValue());
|
||||||
|
if (socket_->SendTo(data, size, sreq->server_addr(), options) < 0)
|
||||||
PLOG(LERROR, socket_->GetError()) << "sendto";
|
PLOG(LERROR, socket_->GetError()) << "sendto";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -125,7 +125,7 @@ class UDPPort : public Port {
|
|||||||
|
|
||||||
virtual int SendTo(const void* data, size_t size,
|
virtual int SendTo(const void* data, size_t size,
|
||||||
const talk_base::SocketAddress& addr,
|
const talk_base::SocketAddress& addr,
|
||||||
talk_base::DiffServCodePoint dscp,
|
const talk_base::PacketOptions& options,
|
||||||
bool payload);
|
bool payload);
|
||||||
|
|
||||||
void OnLocalAddressReady(talk_base::AsyncPacketSocket* socket,
|
void OnLocalAddressReady(talk_base::AsyncPacketSocket* socket,
|
||||||
|
@ -103,8 +103,8 @@ void StunServer::SendResponse(
|
|||||||
const StunMessage& msg, const talk_base::SocketAddress& addr) {
|
const StunMessage& msg, const talk_base::SocketAddress& addr) {
|
||||||
talk_base::ByteBuffer buf;
|
talk_base::ByteBuffer buf;
|
||||||
msg.Write(&buf);
|
msg.Write(&buf);
|
||||||
if (socket_->SendTo(
|
talk_base::PacketOptions options;
|
||||||
buf.Data(), buf.Length(), addr, talk_base::DSCP_NO_CHANGE) < 0)
|
if (socket_->SendTo(buf.Data(), buf.Length(), addr, options) < 0)
|
||||||
LOG_ERR(LS_ERROR) << "sendto";
|
LOG_ERR(LS_ERROR) << "sendto";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -135,7 +135,7 @@ void TCPPort::PrepareAddress() {
|
|||||||
|
|
||||||
int TCPPort::SendTo(const void* data, size_t size,
|
int TCPPort::SendTo(const void* data, size_t size,
|
||||||
const talk_base::SocketAddress& addr,
|
const talk_base::SocketAddress& addr,
|
||||||
talk_base::DiffServCodePoint dscp,
|
const talk_base::PacketOptions& options,
|
||||||
bool payload) {
|
bool payload) {
|
||||||
talk_base::AsyncPacketSocket * socket = NULL;
|
talk_base::AsyncPacketSocket * socket = NULL;
|
||||||
if (TCPConnection * conn = static_cast<TCPConnection*>(GetConnection(addr))) {
|
if (TCPConnection * conn = static_cast<TCPConnection*>(GetConnection(addr))) {
|
||||||
@ -149,7 +149,7 @@ int TCPPort::SendTo(const void* data, size_t size,
|
|||||||
return -1; // TODO: Set error_
|
return -1; // TODO: Set error_
|
||||||
}
|
}
|
||||||
|
|
||||||
int sent = socket->Send(data, size, dscp);
|
int sent = socket->Send(data, size, options);
|
||||||
if (sent < 0) {
|
if (sent < 0) {
|
||||||
error_ = socket->GetError();
|
error_ = socket->GetError();
|
||||||
LOG_J(LS_ERROR, this) << "TCP send of " << size
|
LOG_J(LS_ERROR, this) << "TCP send of " << size
|
||||||
@ -265,7 +265,7 @@ TCPConnection::~TCPConnection() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
int TCPConnection::Send(const void* data, size_t size,
|
int TCPConnection::Send(const void* data, size_t size,
|
||||||
talk_base::DiffServCodePoint dscp) {
|
const talk_base::PacketOptions& options) {
|
||||||
if (!socket_) {
|
if (!socket_) {
|
||||||
error_ = ENOTCONN;
|
error_ = ENOTCONN;
|
||||||
return SOCKET_ERROR;
|
return SOCKET_ERROR;
|
||||||
@ -276,7 +276,7 @@ int TCPConnection::Send(const void* data, size_t size,
|
|||||||
error_ = EWOULDBLOCK;
|
error_ = EWOULDBLOCK;
|
||||||
return SOCKET_ERROR;
|
return SOCKET_ERROR;
|
||||||
}
|
}
|
||||||
int sent = socket_->Send(data, size, dscp);
|
int sent = socket_->Send(data, size, options);
|
||||||
if (sent < 0) {
|
if (sent < 0) {
|
||||||
error_ = socket_->GetError();
|
error_ = socket_->GetError();
|
||||||
} else {
|
} else {
|
||||||
|
@ -83,7 +83,7 @@ class TCPPort : public Port {
|
|||||||
// Handles sending using the local TCP socket.
|
// Handles sending using the local TCP socket.
|
||||||
virtual int SendTo(const void* data, size_t size,
|
virtual int SendTo(const void* data, size_t size,
|
||||||
const talk_base::SocketAddress& addr,
|
const talk_base::SocketAddress& addr,
|
||||||
talk_base::DiffServCodePoint dscp,
|
const talk_base::PacketOptions& options,
|
||||||
bool payload);
|
bool payload);
|
||||||
|
|
||||||
// Accepts incoming TCP connection.
|
// Accepts incoming TCP connection.
|
||||||
@ -128,7 +128,7 @@ class TCPConnection : public Connection {
|
|||||||
virtual ~TCPConnection();
|
virtual ~TCPConnection();
|
||||||
|
|
||||||
virtual int Send(const void* data, size_t size,
|
virtual int Send(const void* data, size_t size,
|
||||||
talk_base::DiffServCodePoint dscp);
|
const talk_base::PacketOptions& options);
|
||||||
virtual int GetError();
|
virtual int GetError();
|
||||||
|
|
||||||
talk_base::AsyncPacketSocket* socket() { return socket_; }
|
talk_base::AsyncPacketSocket* socket() { return socket_; }
|
||||||
|
@ -53,6 +53,8 @@ enum {
|
|||||||
MSG_CONNECTING,
|
MSG_CONNECTING,
|
||||||
MSG_CANDIDATEALLOCATIONCOMPLETE,
|
MSG_CANDIDATEALLOCATIONCOMPLETE,
|
||||||
MSG_ROLECONFLICT,
|
MSG_ROLECONFLICT,
|
||||||
|
MSG_COMPLETED,
|
||||||
|
MSG_FAILED,
|
||||||
};
|
};
|
||||||
|
|
||||||
struct ChannelParams : public talk_base::MessageData {
|
struct ChannelParams : public talk_base::MessageData {
|
||||||
@ -226,6 +228,8 @@ TransportChannelImpl* Transport::CreateChannel_w(int component) {
|
|||||||
impl->SignalCandidatesAllocationDone.connect(
|
impl->SignalCandidatesAllocationDone.connect(
|
||||||
this, &Transport::OnChannelCandidatesAllocationDone);
|
this, &Transport::OnChannelCandidatesAllocationDone);
|
||||||
impl->SignalRoleConflict.connect(this, &Transport::OnRoleConflict);
|
impl->SignalRoleConflict.connect(this, &Transport::OnRoleConflict);
|
||||||
|
impl->SignalConnectionRemoved.connect(
|
||||||
|
this, &Transport::OnChannelConnectionRemoved);
|
||||||
|
|
||||||
if (connect_requested_) {
|
if (connect_requested_) {
|
||||||
impl->Connect();
|
impl->Connect();
|
||||||
@ -620,6 +624,50 @@ void Transport::OnRoleConflict(TransportChannelImpl* channel) {
|
|||||||
signaling_thread_->Post(this, MSG_ROLECONFLICT);
|
signaling_thread_->Post(this, MSG_ROLECONFLICT);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Transport::OnChannelConnectionRemoved(TransportChannelImpl* channel) {
|
||||||
|
ASSERT(worker_thread()->IsCurrent());
|
||||||
|
// Determine if the Transport should move to Completed or Failed. These
|
||||||
|
// states are only available in the Controlling ICE role.
|
||||||
|
if (channel->GetIceRole() != ICEROLE_CONTROLLING) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
ChannelMap::iterator iter = channels_.find(channel->component());
|
||||||
|
ASSERT(iter != channels_.end());
|
||||||
|
// Completed and Failed can only occur after candidate allocation has stopped.
|
||||||
|
if (!iter->second.candidates_allocated()) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
size_t connections = channel->GetConnectionCount();
|
||||||
|
if (connections == 0) {
|
||||||
|
// A Transport has failed if any of its channels have no remaining
|
||||||
|
// connections.
|
||||||
|
signaling_thread_->Post(this, MSG_FAILED);
|
||||||
|
} else if (connections == 1 && completed()) {
|
||||||
|
signaling_thread_->Post(this, MSG_COMPLETED);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
bool Transport::completed() const {
|
||||||
|
// 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
|
||||||
|
// connections.
|
||||||
|
if (!all_channels_writable())
|
||||||
|
return false;
|
||||||
|
|
||||||
|
ChannelMap::const_iterator iter;
|
||||||
|
for (iter = channels_.begin(); iter != channels_.end(); ++iter) {
|
||||||
|
const TransportChannelImpl* channel = iter->second.get();
|
||||||
|
if (!(channel->GetConnectionCount() == 1 &&
|
||||||
|
channel->GetIceRole() == ICEROLE_CONTROLLING &&
|
||||||
|
iter->second.candidates_allocated())) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
void Transport::SetIceRole_w(IceRole role) {
|
void Transport::SetIceRole_w(IceRole role) {
|
||||||
talk_base::CritScope cs(&crit_);
|
talk_base::CritScope cs(&crit_);
|
||||||
ice_role_ = role;
|
ice_role_ = role;
|
||||||
@ -820,6 +868,12 @@ void Transport::OnMessage(talk_base::Message* msg) {
|
|||||||
case MSG_ROLECONFLICT:
|
case MSG_ROLECONFLICT:
|
||||||
SignalRoleConflict();
|
SignalRoleConflict();
|
||||||
break;
|
break;
|
||||||
|
case MSG_COMPLETED:
|
||||||
|
SignalCompleted(this);
|
||||||
|
break;
|
||||||
|
case MSG_FAILED:
|
||||||
|
SignalFailed(this);
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -237,6 +237,10 @@ 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*> SignalFailed;
|
||||||
|
|
||||||
// Returns whether the client has requested the channels to connect.
|
// Returns whether the client has requested the channels to connect.
|
||||||
bool connect_requested() const { return connect_requested_; }
|
bool connect_requested() const { return connect_requested_; }
|
||||||
|
|
||||||
@ -441,6 +445,8 @@ class Transport : public talk_base::MessageHandler,
|
|||||||
void OnChannelCandidatesAllocationDone(TransportChannelImpl* channel);
|
void OnChannelCandidatesAllocationDone(TransportChannelImpl* channel);
|
||||||
// Called when there is ICE role change.
|
// Called when there is ICE role change.
|
||||||
void OnRoleConflict(TransportChannelImpl* channel);
|
void OnRoleConflict(TransportChannelImpl* channel);
|
||||||
|
// Called when the channel removes a connection.
|
||||||
|
void OnChannelConnectionRemoved(TransportChannelImpl* channel);
|
||||||
|
|
||||||
// Dispatches messages to the appropriate handler (below).
|
// Dispatches messages to the appropriate handler (below).
|
||||||
void OnMessage(talk_base::Message* msg);
|
void OnMessage(talk_base::Message* msg);
|
||||||
|
@ -60,8 +60,12 @@ class TransportTest : public testing::Test,
|
|||||||
transport_(new FakeTransport(
|
transport_(new FakeTransport(
|
||||||
thread_, thread_, "test content name", NULL)),
|
thread_, thread_, "test content name", NULL)),
|
||||||
channel_(NULL),
|
channel_(NULL),
|
||||||
connecting_signalled_(false) {
|
connecting_signalled_(false),
|
||||||
|
completed_(false),
|
||||||
|
failed_(false) {
|
||||||
transport_->SignalConnecting.connect(this, &TransportTest::OnConnecting);
|
transport_->SignalConnecting.connect(this, &TransportTest::OnConnecting);
|
||||||
|
transport_->SignalCompleted.connect(this, &TransportTest::OnCompleted);
|
||||||
|
transport_->SignalFailed.connect(this, &TransportTest::OnFailed);
|
||||||
}
|
}
|
||||||
~TransportTest() {
|
~TransportTest() {
|
||||||
transport_->DestroyAllChannels();
|
transport_->DestroyAllChannels();
|
||||||
@ -83,11 +87,19 @@ class TransportTest : public testing::Test,
|
|||||||
void OnConnecting(Transport* transport) {
|
void OnConnecting(Transport* transport) {
|
||||||
connecting_signalled_ = true;
|
connecting_signalled_ = true;
|
||||||
}
|
}
|
||||||
|
void OnCompleted(Transport* transport) {
|
||||||
|
completed_ = true;
|
||||||
|
}
|
||||||
|
void OnFailed(Transport* transport) {
|
||||||
|
failed_ = true;
|
||||||
|
}
|
||||||
|
|
||||||
talk_base::Thread* thread_;
|
talk_base::Thread* thread_;
|
||||||
talk_base::scoped_ptr<FakeTransport> transport_;
|
talk_base::scoped_ptr<FakeTransport> transport_;
|
||||||
FakeTransportChannel* channel_;
|
FakeTransportChannel* channel_;
|
||||||
bool connecting_signalled_;
|
bool connecting_signalled_;
|
||||||
|
bool completed_;
|
||||||
|
bool failed_;
|
||||||
};
|
};
|
||||||
|
|
||||||
class FakeCandidateTranslator : public cricket::CandidateTranslator {
|
class FakeCandidateTranslator : public cricket::CandidateTranslator {
|
||||||
@ -172,6 +184,46 @@ TEST_F(TransportTest, TestChannelIceParameters) {
|
|||||||
EXPECT_EQ(kIcePwd1, channel_->remote_ice_pwd());
|
EXPECT_EQ(kIcePwd1, channel_->remote_ice_pwd());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// This test verifies that the Completed and Failed states can be reached.
|
||||||
|
TEST_F(TransportTest, TestChannelCompletedAndFailed) {
|
||||||
|
transport_->SetIceRole(cricket::ICEROLE_CONTROLLING);
|
||||||
|
cricket::TransportDescription local_desc(
|
||||||
|
cricket::NS_JINGLE_ICE_UDP, kIceUfrag1, kIcePwd1);
|
||||||
|
ASSERT_TRUE(transport_->SetLocalTransportDescription(local_desc,
|
||||||
|
cricket::CA_OFFER,
|
||||||
|
NULL));
|
||||||
|
EXPECT_TRUE(SetupChannel());
|
||||||
|
|
||||||
|
cricket::TransportDescription remote_desc(
|
||||||
|
cricket::NS_JINGLE_ICE_UDP, kIceUfrag1, kIcePwd1);
|
||||||
|
ASSERT_TRUE(transport_->SetRemoteTransportDescription(remote_desc,
|
||||||
|
cricket::CA_ANSWER,
|
||||||
|
NULL));
|
||||||
|
|
||||||
|
channel_->SetConnectionCount(2);
|
||||||
|
channel_->SignalCandidatesAllocationDone(channel_);
|
||||||
|
channel_->SetWritable(true);
|
||||||
|
EXPECT_TRUE_WAIT(transport_->all_channels_writable(), 100);
|
||||||
|
// ICE is not yet completed because there is still more than one connection.
|
||||||
|
EXPECT_FALSE(completed_);
|
||||||
|
EXPECT_FALSE(transport_->completed());
|
||||||
|
EXPECT_FALSE(failed_);
|
||||||
|
|
||||||
|
// When the connection count drops to 1, SignalCompleted should be emitted,
|
||||||
|
// and completed() should be true.
|
||||||
|
channel_->SetConnectionCount(1);
|
||||||
|
EXPECT_TRUE_WAIT(completed_, 100);
|
||||||
|
EXPECT_TRUE(transport_->completed());
|
||||||
|
completed_ = false;
|
||||||
|
|
||||||
|
// When the connection count drops to 0, SignalFailed should be emitted, and
|
||||||
|
// completed() should be false.
|
||||||
|
channel_->SetConnectionCount(0);
|
||||||
|
EXPECT_TRUE_WAIT(failed_, 100);
|
||||||
|
EXPECT_FALSE(transport_->completed());
|
||||||
|
EXPECT_FALSE(completed_);
|
||||||
|
}
|
||||||
|
|
||||||
// Tests channel role is reversed after receiving ice-lite from remote.
|
// Tests channel role is reversed after receiving ice-lite from remote.
|
||||||
TEST_F(TransportTest, TestSetRemoteIceLiteInOffer) {
|
TEST_F(TransportTest, TestSetRemoteIceLiteInOffer) {
|
||||||
transport_->SetIceRole(cricket::ICEROLE_CONTROLLED);
|
transport_->SetIceRole(cricket::ICEROLE_CONTROLLED);
|
||||||
|
@ -83,7 +83,7 @@ class TransportChannel : public sigslot::has_slots<> {
|
|||||||
// Attempts to send the given packet. The return value is < 0 on failure.
|
// Attempts to send the given packet. The return value is < 0 on failure.
|
||||||
// TODO: Remove the default argument once channel code is updated.
|
// TODO: Remove the default argument once channel code is updated.
|
||||||
virtual int SendPacket(const char* data, size_t len,
|
virtual int SendPacket(const char* data, size_t len,
|
||||||
talk_base::DiffServCodePoint dscp,
|
const talk_base::PacketOptions& options,
|
||||||
int flags = 0) = 0;
|
int flags = 0) = 0;
|
||||||
|
|
||||||
// Sets a socket option on this channel. Note that not all options are
|
// Sets a socket option on this channel. Note that not all options are
|
||||||
|
@ -53,6 +53,7 @@ class TransportChannelImpl : public TransportChannel {
|
|||||||
virtual IceRole GetIceRole() const = 0;
|
virtual IceRole GetIceRole() const = 0;
|
||||||
virtual void SetIceRole(IceRole role) = 0;
|
virtual void SetIceRole(IceRole role) = 0;
|
||||||
virtual void SetIceTiebreaker(uint64 tiebreaker) = 0;
|
virtual void SetIceTiebreaker(uint64 tiebreaker) = 0;
|
||||||
|
virtual size_t GetConnectionCount() const = 0;
|
||||||
// To toggle G-ICE/ICE.
|
// To toggle G-ICE/ICE.
|
||||||
virtual bool GetIceProtocolType(IceProtocolType* type) const = 0;
|
virtual bool GetIceProtocolType(IceProtocolType* type) const = 0;
|
||||||
virtual void SetIceProtocolType(IceProtocolType type) = 0;
|
virtual void SetIceProtocolType(IceProtocolType type) = 0;
|
||||||
@ -114,6 +115,10 @@ class TransportChannelImpl : public TransportChannel {
|
|||||||
// agents.
|
// agents.
|
||||||
sigslot::signal1<TransportChannelImpl*> SignalRoleConflict;
|
sigslot::signal1<TransportChannelImpl*> SignalRoleConflict;
|
||||||
|
|
||||||
|
// Emitted whenever the number of connections available to the transport
|
||||||
|
// channel decreases.
|
||||||
|
sigslot::signal1<TransportChannelImpl*> SignalConnectionRemoved;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
DISALLOW_EVIL_CONSTRUCTORS(TransportChannelImpl);
|
DISALLOW_EVIL_CONSTRUCTORS(TransportChannelImpl);
|
||||||
};
|
};
|
||||||
|
@ -102,14 +102,14 @@ void TransportChannelProxy::SetImplementation(TransportChannelImpl* impl) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
int TransportChannelProxy::SendPacket(const char* data, size_t len,
|
int TransportChannelProxy::SendPacket(const char* data, size_t len,
|
||||||
talk_base::DiffServCodePoint dscp,
|
const talk_base::PacketOptions& options,
|
||||||
int flags) {
|
int flags) {
|
||||||
ASSERT(talk_base::Thread::Current() == worker_thread_);
|
ASSERT(talk_base::Thread::Current() == worker_thread_);
|
||||||
// Fail if we don't have an impl yet.
|
// Fail if we don't have an impl yet.
|
||||||
if (!impl_) {
|
if (!impl_) {
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
return impl_->SendPacket(data, len, dscp, flags);
|
return impl_->SendPacket(data, len, options, flags);
|
||||||
}
|
}
|
||||||
|
|
||||||
int TransportChannelProxy::SetOption(talk_base::Socket::Option opt, int value) {
|
int TransportChannelProxy::SetOption(talk_base::Socket::Option opt, int value) {
|
||||||
|
@ -64,7 +64,7 @@ class TransportChannelProxy : public TransportChannel,
|
|||||||
// Implementation of the TransportChannel interface. These simply forward to
|
// Implementation of the TransportChannel interface. These simply forward to
|
||||||
// the implementation.
|
// the implementation.
|
||||||
virtual int SendPacket(const char* data, size_t len,
|
virtual int SendPacket(const char* data, size_t len,
|
||||||
talk_base::DiffServCodePoint dscp,
|
const talk_base::PacketOptions& options,
|
||||||
int flags);
|
int flags);
|
||||||
virtual int SetOption(talk_base::Socket::Option opt, int value);
|
virtual int SetOption(talk_base::Socket::Option opt, int value);
|
||||||
virtual int GetError();
|
virtual int GetError();
|
||||||
|
@ -153,7 +153,7 @@ class TurnEntry : public sigslot::has_slots<> {
|
|||||||
// Sends a packet to the given destination address.
|
// Sends a packet to the given destination address.
|
||||||
// This will wrap the packet in STUN if necessary.
|
// This will wrap the packet in STUN if necessary.
|
||||||
int Send(const void* data, size_t size, bool payload,
|
int Send(const void* data, size_t size, bool payload,
|
||||||
talk_base::DiffServCodePoint dscp);
|
const talk_base::PacketOptions& options);
|
||||||
|
|
||||||
void OnCreatePermissionSuccess();
|
void OnCreatePermissionSuccess();
|
||||||
void OnCreatePermissionError(StunMessage* response, int code);
|
void OnCreatePermissionError(StunMessage* response, int code);
|
||||||
@ -332,7 +332,7 @@ int TurnPort::GetError() {
|
|||||||
|
|
||||||
int TurnPort::SendTo(const void* data, size_t size,
|
int TurnPort::SendTo(const void* data, size_t size,
|
||||||
const talk_base::SocketAddress& addr,
|
const talk_base::SocketAddress& addr,
|
||||||
talk_base::DiffServCodePoint dscp,
|
const talk_base::PacketOptions& options,
|
||||||
bool payload) {
|
bool payload) {
|
||||||
// Try to find an entry for this specific address; we should have one.
|
// Try to find an entry for this specific address; we should have one.
|
||||||
TurnEntry* entry = FindEntry(addr);
|
TurnEntry* entry = FindEntry(addr);
|
||||||
@ -347,7 +347,7 @@ int TurnPort::SendTo(const void* data, size_t size,
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Send the actual contents to the server using the usual mechanism.
|
// Send the actual contents to the server using the usual mechanism.
|
||||||
int sent = entry->Send(data, size, payload, dscp);
|
int sent = entry->Send(data, size, payload, options);
|
||||||
if (sent <= 0) {
|
if (sent <= 0) {
|
||||||
return SOCKET_ERROR;
|
return SOCKET_ERROR;
|
||||||
}
|
}
|
||||||
@ -421,7 +421,8 @@ void TurnPort::OnResolveResult(talk_base::AsyncResolverInterface* resolver) {
|
|||||||
|
|
||||||
void TurnPort::OnSendStunPacket(const void* data, size_t size,
|
void TurnPort::OnSendStunPacket(const void* data, size_t size,
|
||||||
StunRequest* request) {
|
StunRequest* request) {
|
||||||
if (Send(data, size, DefaultDscpValue()) < 0) {
|
talk_base::PacketOptions options(DefaultDscpValue());
|
||||||
|
if (Send(data, size, options) < 0) {
|
||||||
LOG_J(LS_ERROR, this) << "Failed to send TURN message, err="
|
LOG_J(LS_ERROR, this) << "Failed to send TURN message, err="
|
||||||
<< socket_->GetError();
|
<< socket_->GetError();
|
||||||
}
|
}
|
||||||
@ -578,8 +579,8 @@ void TurnPort::AddRequestAuthInfo(StunMessage* msg) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
int TurnPort::Send(const void* data, size_t len,
|
int TurnPort::Send(const void* data, size_t len,
|
||||||
talk_base::DiffServCodePoint dscp) {
|
const talk_base::PacketOptions& options) {
|
||||||
return socket_->SendTo(data, len, server_address_.address, dscp);
|
return socket_->SendTo(data, len, server_address_.address, options);
|
||||||
}
|
}
|
||||||
|
|
||||||
void TurnPort::UpdateHash() {
|
void TurnPort::UpdateHash() {
|
||||||
@ -912,7 +913,7 @@ void TurnEntry::SendChannelBindRequest(int delay) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
int TurnEntry::Send(const void* data, size_t size, bool payload,
|
int TurnEntry::Send(const void* data, size_t size, bool payload,
|
||||||
talk_base::DiffServCodePoint dscp) {
|
const talk_base::PacketOptions& options) {
|
||||||
talk_base::ByteBuffer buf;
|
talk_base::ByteBuffer buf;
|
||||||
if (state_ != STATE_BOUND) {
|
if (state_ != STATE_BOUND) {
|
||||||
// If we haven't bound the channel yet, we have to use a Send Indication.
|
// If we haven't bound the channel yet, we have to use a Send Indication.
|
||||||
@ -937,7 +938,7 @@ int TurnEntry::Send(const void* data, size_t size, bool payload,
|
|||||||
buf.WriteUInt16(static_cast<uint16>(size));
|
buf.WriteUInt16(static_cast<uint16>(size));
|
||||||
buf.WriteBytes(reinterpret_cast<const char*>(data), size);
|
buf.WriteBytes(reinterpret_cast<const char*>(data), size);
|
||||||
}
|
}
|
||||||
return port_->Send(buf.Data(), buf.Length(), dscp);
|
return port_->Send(buf.Data(), buf.Length(), options);
|
||||||
}
|
}
|
||||||
|
|
||||||
void TurnEntry::OnCreatePermissionSuccess() {
|
void TurnEntry::OnCreatePermissionSuccess() {
|
||||||
|
@ -74,7 +74,7 @@ class TurnPort : public Port {
|
|||||||
const Candidate& c, PortInterface::CandidateOrigin origin);
|
const Candidate& c, PortInterface::CandidateOrigin origin);
|
||||||
virtual int SendTo(const void* data, size_t size,
|
virtual int SendTo(const void* data, size_t size,
|
||||||
const talk_base::SocketAddress& addr,
|
const talk_base::SocketAddress& addr,
|
||||||
talk_base::DiffServCodePoint dscp,
|
const talk_base::PacketOptions& options,
|
||||||
bool payload);
|
bool payload);
|
||||||
virtual int SetOption(talk_base::Socket::Option opt, int value);
|
virtual int SetOption(talk_base::Socket::Option opt, int value);
|
||||||
virtual int GetOption(talk_base::Socket::Option opt, int* value);
|
virtual int GetOption(talk_base::Socket::Option opt, int* value);
|
||||||
@ -145,7 +145,8 @@ class TurnPort : public Port {
|
|||||||
|
|
||||||
bool ScheduleRefresh(int lifetime);
|
bool ScheduleRefresh(int lifetime);
|
||||||
void SendRequest(StunRequest* request, int delay);
|
void SendRequest(StunRequest* request, int delay);
|
||||||
int Send(const void* data, size_t size, talk_base::DiffServCodePoint dscp);
|
int Send(const void* data, size_t size,
|
||||||
|
const talk_base::PacketOptions& options);
|
||||||
void UpdateHash();
|
void UpdateHash();
|
||||||
bool UpdateNonce(StunMessage* response);
|
bool UpdateNonce(StunMessage* response);
|
||||||
|
|
||||||
|
@ -272,8 +272,8 @@ class TurnPortTest : public testing::Test,
|
|||||||
for (size_t j = 0; j < i + 1; ++j) {
|
for (size_t j = 0; j < i + 1; ++j) {
|
||||||
buf[j] = 0xFF - j;
|
buf[j] = 0xFF - j;
|
||||||
}
|
}
|
||||||
conn1->Send(buf, i + 1, talk_base::DSCP_NO_CHANGE);
|
conn1->Send(buf, i + 1, options);
|
||||||
conn2->Send(buf, i + 1, talk_base::DSCP_NO_CHANGE);
|
conn2->Send(buf, i + 1, options);
|
||||||
main_->ProcessMessages(0);
|
main_->ProcessMessages(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -305,6 +305,7 @@ class TurnPortTest : public testing::Test,
|
|||||||
bool test_finish_;
|
bool test_finish_;
|
||||||
std::vector<talk_base::Buffer> turn_packets_;
|
std::vector<talk_base::Buffer> turn_packets_;
|
||||||
std::vector<talk_base::Buffer> udp_packets_;
|
std::vector<talk_base::Buffer> udp_packets_;
|
||||||
|
talk_base::PacketOptions options;
|
||||||
};
|
};
|
||||||
|
|
||||||
// Do a normal TURN allocation.
|
// Do a normal TURN allocation.
|
||||||
|
@ -566,8 +566,8 @@ void TurnServer::SendStun(Connection* conn, StunMessage* msg) {
|
|||||||
|
|
||||||
void TurnServer::Send(Connection* conn,
|
void TurnServer::Send(Connection* conn,
|
||||||
const talk_base::ByteBuffer& buf) {
|
const talk_base::ByteBuffer& buf) {
|
||||||
conn->socket()->SendTo(buf.Data(), buf.Length(), conn->src(),
|
talk_base::PacketOptions options;
|
||||||
talk_base::DSCP_NO_CHANGE);
|
conn->socket()->SendTo(buf.Data(), buf.Length(), conn->src(), options);
|
||||||
}
|
}
|
||||||
|
|
||||||
void TurnServer::OnAllocationDestroyed(Allocation* allocation) {
|
void TurnServer::OnAllocationDestroyed(Allocation* allocation) {
|
||||||
@ -940,7 +940,8 @@ void TurnServer::Allocation::SendErrorResponse(const TurnMessage* req, int code,
|
|||||||
|
|
||||||
void TurnServer::Allocation::SendExternal(const void* data, size_t size,
|
void TurnServer::Allocation::SendExternal(const void* data, size_t size,
|
||||||
const talk_base::SocketAddress& peer) {
|
const talk_base::SocketAddress& peer) {
|
||||||
external_socket_->SendTo(data, size, peer, talk_base::DSCP_NO_CHANGE);
|
talk_base::PacketOptions options;
|
||||||
|
external_socket_->SendTo(data, size, peer, options);
|
||||||
}
|
}
|
||||||
|
|
||||||
void TurnServer::Allocation::OnMessage(talk_base::Message* msg) {
|
void TurnServer::Allocation::OnMessage(talk_base::Message* msg) {
|
||||||
|
@ -511,7 +511,8 @@ bool BaseChannel::SendPacket(bool rtcp, talk_base::Buffer* packet,
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Bon voyage.
|
// Bon voyage.
|
||||||
int ret = channel->SendPacket(packet->data(), packet->length(), dscp,
|
talk_base::PacketOptions options(dscp);
|
||||||
|
int ret = channel->SendPacket(packet->data(), packet->length(), options,
|
||||||
(secure() && secure_dtls()) ? PF_SRTP_BYPASS : 0);
|
(secure() && secure_dtls()) ? PF_SRTP_BYPASS : 0);
|
||||||
if (ret != static_cast<int>(packet->length())) {
|
if (ret != static_cast<int>(packet->length())) {
|
||||||
if (channel->GetError() == EWOULDBLOCK) {
|
if (channel->GetError() == EWOULDBLOCK) {
|
||||||
|
@ -504,7 +504,8 @@ IPseudoTcpNotify::WriteResult PseudoTcpChannel::TcpWritePacket(
|
|||||||
ASSERT(cs_.CurrentThreadIsOwner());
|
ASSERT(cs_.CurrentThreadIsOwner());
|
||||||
ASSERT(tcp == tcp_);
|
ASSERT(tcp == tcp_);
|
||||||
ASSERT(NULL != channel_);
|
ASSERT(NULL != channel_);
|
||||||
int sent = channel_->SendPacket(buffer, len, talk_base::DSCP_NO_CHANGE);
|
talk_base::PacketOptions packet_options;
|
||||||
|
int sent = channel_->SendPacket(buffer, len, packet_options);
|
||||||
if (sent > 0) {
|
if (sent > 0) {
|
||||||
//LOG_F(LS_VERBOSE) << "(" << sent << ") Sent";
|
//LOG_F(LS_VERBOSE) << "(" << sent << ") Sent";
|
||||||
return IPseudoTcpNotify::WR_SUCCESS;
|
return IPseudoTcpNotify::WR_SUCCESS;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user