diff options
-rw-r--r-- | DEPS | 2 | ||||
-rw-r--r-- | content/renderer/p2p/ipc_socket_factory.cc | 16 | ||||
-rw-r--r-- | content/renderer/p2p/ipc_socket_factory.h | 6 | ||||
-rw-r--r-- | jingle/glue/fake_socket_factory.cc | 10 | ||||
-rw-r--r-- | jingle/glue/fake_socket_factory.h | 6 | ||||
-rw-r--r-- | remoting/host/chromoting_host.cc | 3 | ||||
-rw-r--r-- | remoting/jingle_glue/jingle_client.cc | 15 | ||||
-rw-r--r-- | remoting/jingle_glue/jingle_client.h | 6 | ||||
-rw-r--r-- | remoting/jingle_glue/jingle_client_unittest.cc | 4 | ||||
-rw-r--r-- | remoting/protocol/jingle_session.cc | 69 | ||||
-rw-r--r-- | remoting/protocol/jingle_session.h | 12 | ||||
-rw-r--r-- | remoting/protocol/protocol_test_client.cc | 2 |
12 files changed, 87 insertions, 64 deletions
@@ -12,7 +12,7 @@ vars = { "nacl_irt_hash_x86_64": "694c864d7c50a902abf627771021abe658f519b3", "nacl_revision": "5188", "nacl_tools_revision": "5025", - "libjingle_revision": "55", + "libjingle_revision": "59", "libvpx_revision": "81610", "ffmpeg_revision": "83815", "skia_revision": "1288", diff --git a/content/renderer/p2p/ipc_socket_factory.cc b/content/renderer/p2p/ipc_socket_factory.cc index 62507f4..703732e 100644 --- a/content/renderer/p2p/ipc_socket_factory.cc +++ b/content/renderer/p2p/ipc_socket_factory.cc @@ -29,7 +29,7 @@ class IpcPacketSocket : public talk_base::AsyncPacketSocket, const talk_base::SocketAddress& remote_address); // talk_base::AsyncPacketSocket interface. - virtual talk_base::SocketAddress GetLocalAddress(bool* allocated) const; + virtual bool GetLocalAddress(talk_base::SocketAddress* address) const; virtual talk_base::SocketAddress GetRemoteAddress() const; virtual int Send(const void *pv, size_t cb); virtual int SendTo(const void *pv, size_t cb, @@ -142,14 +142,14 @@ void IpcPacketSocket::InitAcceptedTcp( } // talk_base::AsyncPacketSocket interface. -talk_base::SocketAddress IpcPacketSocket::GetLocalAddress( - bool* allocated) const { +bool IpcPacketSocket::GetLocalAddress(talk_base::SocketAddress* address) const { DCHECK_EQ(MessageLoop::current(), message_loop_); - if (allocated) { - *allocated = address_initialized_; - } - return local_address_; + if (!address_initialized_) + return false; + + *address = local_address_; + return true; } talk_base::SocketAddress IpcPacketSocket::GetRemoteAddress() const { @@ -329,7 +329,7 @@ talk_base::AsyncPacketSocket* IpcPacketSocketFactory::CreateUdpSocket( talk_base::AsyncPacketSocket* IpcPacketSocketFactory::CreateServerTcpSocket( const talk_base::SocketAddress& local_address, int min_port, int max_port, - bool listen, bool ssl) { + bool ssl) { // TODO(sergeyu): Implement SSL support. if (ssl) return NULL; diff --git a/content/renderer/p2p/ipc_socket_factory.h b/content/renderer/p2p/ipc_socket_factory.h index 7f57348..db410d6 100644 --- a/content/renderer/p2p/ipc_socket_factory.h +++ b/content/renderer/p2p/ipc_socket_factory.h @@ -25,8 +25,10 @@ class IpcPacketSocketFactory : public talk_base::PacketSocketFactory { const talk_base::SocketAddress& local_address, int min_port, int max_port); virtual talk_base::AsyncPacketSocket* CreateServerTcpSocket( - const talk_base::SocketAddress& local_address, int min_port, int max_port, - bool listen, bool ssl); + const talk_base::SocketAddress& local_address, + int min_port, + int max_port, + bool ssl); virtual talk_base::AsyncPacketSocket* CreateClientTcpSocket( const talk_base::SocketAddress& local_address, const talk_base::SocketAddress& remote_address, diff --git a/jingle/glue/fake_socket_factory.cc b/jingle/glue/fake_socket_factory.cc index b0649ce..6139334 100644 --- a/jingle/glue/fake_socket_factory.cc +++ b/jingle/glue/fake_socket_factory.cc @@ -22,11 +22,11 @@ FakeUDPPacketSocket::~FakeUDPPacketSocket() { fake_socket_manager_->RemoveSocket(this); } -talk_base::SocketAddress FakeUDPPacketSocket::GetLocalAddress( - bool* allocated) const { +bool FakeUDPPacketSocket::GetLocalAddress( + talk_base::SocketAddress* address) const { DCHECK(CalledOnValidThread()); - *allocated = true; - return local_address_; + *address = local_address_; + return true; } talk_base::SocketAddress FakeUDPPacketSocket::GetRemoteAddress() const { @@ -178,7 +178,7 @@ talk_base::AsyncPacketSocket* FakeSocketFactory::CreateUdpSocket( talk_base::AsyncPacketSocket* FakeSocketFactory::CreateServerTcpSocket( const talk_base::SocketAddress& local_address, int min_port, int max_port, - bool listen, bool ssl) { + bool ssl) { // TODO(sergeyu): Implement fake TCP sockets. NOTIMPLEMENTED(); return NULL; diff --git a/jingle/glue/fake_socket_factory.h b/jingle/glue/fake_socket_factory.h index fee73bb..2be2d5c 100644 --- a/jingle/glue/fake_socket_factory.h +++ b/jingle/glue/fake_socket_factory.h @@ -34,8 +34,8 @@ class FakeUDPPacketSocket : public talk_base::AsyncPacketSocket, const std::vector<char>& data); // talk_base::AsyncPacketSocket implementation. - virtual talk_base::SocketAddress GetLocalAddress( - bool* allocated) const OVERRIDE; + virtual bool GetLocalAddress( + talk_base::SocketAddress* address) const OVERRIDE; virtual talk_base::SocketAddress GetRemoteAddress() const OVERRIDE; virtual int Send(const void *pv, size_t cb) OVERRIDE; virtual int SendTo(const void *pv, size_t cb, @@ -101,7 +101,7 @@ class FakeSocketFactory : public talk_base::PacketSocketFactory { int min_port, int max_port) OVERRIDE; virtual talk_base::AsyncPacketSocket* CreateServerTcpSocket( const talk_base::SocketAddress& local_address, int min_port, int max_port, - bool listen, bool ssl) OVERRIDE; + bool ssl) OVERRIDE; virtual talk_base::AsyncPacketSocket* CreateClientTcpSocket( const talk_base::SocketAddress& local_address, const talk_base::SocketAddress& remote_address, diff --git a/remoting/host/chromoting_host.cc b/remoting/host/chromoting_host.cc index 28e28d9..ceca4f6 100644 --- a/remoting/host/chromoting_host.cc +++ b/remoting/host/chromoting_host.cc @@ -104,8 +104,7 @@ void ChromotingHost::Start(Task* shutdown_task) { kChromotingTokenServiceName)); jingle_client_ = new JingleClient(context_->jingle_thread(), signal_strategy_.get(), - NULL, - this); + NULL, NULL, NULL, this); jingle_client_->Init(); } diff --git a/remoting/jingle_glue/jingle_client.cc b/remoting/jingle_glue/jingle_client.cc index b7b27c4..c2f9cd7 100644 --- a/remoting/jingle_glue/jingle_client.cc +++ b/remoting/jingle_glue/jingle_client.cc @@ -167,21 +167,6 @@ JavascriptIqRequest* JavascriptSignalStrategy::CreateIqRequest() { JingleClient::JingleClient(JingleThread* thread, SignalStrategy* signal_strategy, - PortAllocatorSessionFactory* session_factory, - Callback* callback) - : enable_nat_traversing_(false), - thread_(thread), - state_(START), - initialized_(false), - closed_(false), - initialized_finished_(false), - callback_(callback), - signal_strategy_(signal_strategy), - port_allocator_session_factory_(session_factory) { -} - -JingleClient::JingleClient(JingleThread* thread, - SignalStrategy* signal_strategy, talk_base::NetworkManager* network_manager, talk_base::PacketSocketFactory* socket_factory, PortAllocatorSessionFactory* session_factory, diff --git a/remoting/jingle_glue/jingle_client.h b/remoting/jingle_glue/jingle_client.h index a1d6806..cb7e2d3 100644 --- a/remoting/jingle_glue/jingle_client.h +++ b/remoting/jingle_glue/jingle_client.h @@ -137,14 +137,10 @@ class JingleClient : public base::RefCountedThreadSafe<JingleClient>, }; // Physical sockets are used if |network_manager| and - // |socket_factory| are not specified. Otherwise ownership of these + // |socket_factory| are set to NULL. Otherwise ownership of these // objects is given to JingleClient. JingleClient(JingleThread* thread, SignalStrategy* signal_strategy, - PortAllocatorSessionFactory* session_factory, - Callback* callback); - JingleClient(JingleThread* thread, - SignalStrategy* signal_strategy, talk_base::NetworkManager* network_manager, talk_base::PacketSocketFactory* socket_factory, PortAllocatorSessionFactory* session_factory, diff --git a/remoting/jingle_glue/jingle_client_unittest.cc b/remoting/jingle_glue/jingle_client_unittest.cc index 938e0a3..e6e79a3 100644 --- a/remoting/jingle_glue/jingle_client_unittest.cc +++ b/remoting/jingle_glue/jingle_client_unittest.cc @@ -41,8 +41,8 @@ class JingleClientTest : public testing::Test { virtual void SetUp() { signal_strategy_.reset(new XmppSignalStrategy(&thread_, "", "", "")); client_ = new JingleClient(&thread_, signal_strategy_.get(), NULL, - &callback_); - // Fake initialization + NULL, NULL, &callback_); + // Fake initialization. client_->initialized_ = true; signal_strategy_->observer_ = client_; } diff --git a/remoting/protocol/jingle_session.cc b/remoting/protocol/jingle_session.cc index 0f50bab..60fab26 100644 --- a/remoting/protocol/jingle_session.cc +++ b/remoting/protocol/jingle_session.cc @@ -23,6 +23,7 @@ #include "remoting/protocol/socket_wrapper.h" #include "third_party/libjingle/source/talk/base/thread.h" #include "third_party/libjingle/source/talk/p2p/base/session.h" +#include "third_party/libjingle/source/talk/p2p/base/p2ptransportchannel.h" using cricket::BaseSession; @@ -337,23 +338,33 @@ void JingleSession::OnInitiate() { } // Create video RTP channels. - video_rtp_channel_.reset(new jingle_glue::TransportChannelSocketAdapter( - cricket_session_->CreateChannel(content_name, kVideoRtpChannelName))); - video_rtcp_channel_.reset(new jingle_glue::TransportChannelSocketAdapter( - cricket_session_->CreateChannel(content_name, kVideoRtcpChannelName))); + raw_video_rtp_channel_ = + cricket_session_->CreateChannel(content_name, kVideoRtpChannelName); + video_rtp_channel_.reset( + new jingle_glue::TransportChannelSocketAdapter(raw_video_rtp_channel_)); + raw_video_rtcp_channel_ = + cricket_session_->CreateChannel(content_name, kVideoRtcpChannelName); + video_rtcp_channel_.reset( + new jingle_glue::TransportChannelSocketAdapter(raw_video_rtcp_channel_)); // Create control channel. - control_channel_.reset(new jingle_glue::TransportChannelSocketAdapter( - cricket_session_->CreateChannel(content_name, kControlChannelName))); + raw_control_channel_ = + cricket_session_->CreateChannel(content_name, kControlChannelName); + control_channel_.reset( + new jingle_glue::TransportChannelSocketAdapter(raw_control_channel_)); // Create event channel. - event_channel_.reset(new jingle_glue::TransportChannelSocketAdapter( - cricket_session_->CreateChannel(content_name, kEventChannelName))); + raw_event_channel_ = + cricket_session_->CreateChannel(content_name, kEventChannelName); + event_channel_.reset( + new jingle_glue::TransportChannelSocketAdapter(raw_event_channel_)); // Create video channel. // TODO(sergeyu): Remove video channel when we are ready to switch to RTP. - video_channel_.reset(new jingle_glue::TransportChannelSocketAdapter( - cricket_session_->CreateChannel(content_name, kVideoChannelName))); + raw_video_channel_ = + cricket_session_->CreateChannel(content_name, kVideoChannelName); + video_channel_.reset( + new jingle_glue::TransportChannelSocketAdapter(raw_video_channel_)); if (!cricket_session_->initiator()) jingle_session_manager_->AcceptConnection(this, cricket_session_); @@ -437,25 +448,42 @@ bool JingleSession::InitializeConfigFromDescription( return true; } -bool JingleSession::InitializeChannels() { +bool JingleSession::InitializeSSL() { if (!EstablishSSLConnection(control_channel_.release(), - &control_ssl_socket_)) { + &control_ssl_socket_)) { LOG(ERROR) << "Establish control channel failed"; return false; } if (!EstablishSSLConnection(event_channel_.release(), - &event_ssl_socket_)) { + &event_ssl_socket_)) { LOG(ERROR) << "Establish event channel failed"; return false; } if (!EstablishSSLConnection(video_channel_.release(), - &video_ssl_socket_)) { + &video_ssl_socket_)) { LOG(ERROR) << "Establish video channel failed"; return false; } return true; } +void JingleSession::InitializeChannels() { + // Disable incoming connections on the host so that we don't travers + // the firewall. + if (!cricket_session_->initiator()) { + raw_control_channel_->GetP2PChannel()->set_incoming_only(true); + raw_event_channel_->GetP2PChannel()->set_incoming_only(true); + raw_video_channel_->GetP2PChannel()->set_incoming_only(true); + raw_video_rtp_channel_->GetP2PChannel()->set_incoming_only(true); + raw_video_rtcp_channel_->GetP2PChannel()->set_incoming_only(true); + } + + if (!InitializeSSL()) { + CloseInternal(net::ERR_CONNECTION_FAILED, true); + return; + } +} + void JingleSession::OnAccept() { // If we initiated the session, store the candidate configuration that the // host responded with, to refer to later. @@ -467,10 +495,15 @@ void JingleSession::OnAccept() { } } - if (!InitializeChannels()) { - CloseInternal(net::ERR_CONNECTION_FAILED, true); - return; - } + // TODO(sergeyu): This is a hack: Currently set_incoming_only() + // needs to be called on each channel before the channel starts + // creating candidates but after session is accepted (after + // TransportChannelProxy::GetP2PChannel() starts returning actual + // P2P channel). By posting a task here we can call it at the right + // moment. This problem will go away when we switch to Pepper P2P + // API. + jingle_session_manager_->message_loop()->PostTask( + FROM_HERE, NewRunnableMethod(this, &JingleSession::InitializeChannels)); } void JingleSession::OnTerminate() { diff --git a/remoting/protocol/jingle_session.h b/remoting/protocol/jingle_session.h index 122aec8..3775d68 100644 --- a/remoting/protocol/jingle_session.h +++ b/remoting/protocol/jingle_session.h @@ -102,9 +102,12 @@ class JingleSession : public protocol::Session, bool InitializeConfigFromDescription( const cricket::SessionDescription* description); + // Configures channels and calls InitializeSSL(). + void InitializeChannels(); + // Initialize PseudoTCP + SSL on each of the video, control and input - // channels. The channels must have been created before this is called. - bool InitializeChannels(); + // channels. The channels must have been created before this is called. + bool InitializeSSL(); // Helper method to create and initialize PseudoTCP + SSL socket on // top of the provided |channel|. The resultant SSL socket is @@ -163,12 +166,15 @@ class JingleSession : public protocol::Session, // |control_channel_| holds a channel until SSL socket is // created. After that |control_ssl_socket_| owns the channel. The // same is the case fo |event_channel_| and |video_channel_|. + cricket::TransportChannel* raw_control_channel_; scoped_ptr<jingle_glue::TransportChannelSocketAdapter> control_channel_; scoped_ptr<SocketWrapper> control_ssl_socket_; + cricket::TransportChannel* raw_event_channel_; scoped_ptr<jingle_glue::TransportChannelSocketAdapter> event_channel_; scoped_ptr<SocketWrapper> event_ssl_socket_; + cricket::TransportChannel* raw_video_channel_; scoped_ptr<jingle_glue::TransportChannelSocketAdapter> video_channel_; scoped_ptr<SocketWrapper> video_ssl_socket_; @@ -178,7 +184,9 @@ class JingleSession : public protocol::Session, // Used to verify the certificate received in SSLClientSocket. scoped_ptr<net::CertVerifier> cert_verifier_; + cricket::TransportChannel* raw_video_rtp_channel_; scoped_ptr<jingle_glue::TransportChannelSocketAdapter> video_rtp_channel_; + cricket::TransportChannel* raw_video_rtcp_channel_; scoped_ptr<jingle_glue::TransportChannelSocketAdapter> video_rtcp_channel_; // Callback called by the SSL layer. diff --git a/remoting/protocol/protocol_test_client.cc b/remoting/protocol/protocol_test_client.cc index c481ca5..9d01c32 100644 --- a/remoting/protocol/protocol_test_client.cc +++ b/remoting/protocol/protocol_test_client.cc @@ -230,7 +230,7 @@ void ProtocolTestClient::Run(const std::string& username, new XmppSignalStrategy(&jingle_thread, username, auth_token, kChromotingTokenServiceName)); client_ = new JingleClient(&jingle_thread, signal_strategy_.get(), - NULL, this); + NULL, NULL, NULL, this); client_->Init(); session_manager_ = new JingleSessionManager(&jingle_thread); |