| OLD | NEW |
| 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 // JingleHostConnection implements the HostConnection interface using | 5 // JingleHostConnection implements the HostConnection interface using |
| 6 // libjingle as the transport protocol. | 6 // libjingle as the transport protocol. |
| 7 // | 7 // |
| 8 // Much of this class focuses on translating JingleClient and | 8 // Much of this class focuses on translating JingleClient and |
| 9 // ChromotingConnection callbacks into HostConnection::HostEventCallback | 9 // ChromotingConnection callbacks into HostConnection::HostEventCallback |
| 10 // messages. | 10 // messages. |
| (...skipping 11 matching lines...) Expand all Loading... |
| 22 #include "base/ref_counted.h" | 22 #include "base/ref_counted.h" |
| 23 #include "base/scoped_ptr.h" | 23 #include "base/scoped_ptr.h" |
| 24 #include "base/task.h" | 24 #include "base/task.h" |
| 25 #include "remoting/client/client_context.h" | 25 #include "remoting/client/client_context.h" |
| 26 #include "remoting/client/host_connection.h" | 26 #include "remoting/client/host_connection.h" |
| 27 #include "remoting/jingle_glue/jingle_client.h" | 27 #include "remoting/jingle_glue/jingle_client.h" |
| 28 #include "remoting/protocol/message_reader.h" | 28 #include "remoting/protocol/message_reader.h" |
| 29 #include "remoting/protocol/chromotocol_connection.h" | 29 #include "remoting/protocol/chromotocol_connection.h" |
| 30 #include "remoting/protocol/chromotocol_server.h" | 30 #include "remoting/protocol/chromotocol_server.h" |
| 31 #include "remoting/protocol/stream_writer.h" | 31 #include "remoting/protocol/stream_writer.h" |
| 32 #include "remoting/protocol/video_reader.h" |
| 32 | 33 |
| 33 class MessageLoop; | 34 class MessageLoop; |
| 34 | 35 |
| 35 namespace remoting { | 36 namespace remoting { |
| 36 | 37 |
| 37 class JingleThread; | 38 class JingleThread; |
| 39 class VideoStub; |
| 38 | 40 |
| 39 struct ClientConfig; | 41 struct ClientConfig; |
| 40 | 42 |
| 41 class JingleHostConnection : public HostConnection, | 43 class JingleHostConnection : public HostConnection, |
| 42 public JingleClient::Callback { | 44 public JingleClient::Callback { |
| 43 public: | 45 public: |
| 44 explicit JingleHostConnection(ClientContext* context); | 46 explicit JingleHostConnection(ClientContext* context); |
| 45 virtual ~JingleHostConnection(); | 47 virtual ~JingleHostConnection(); |
| 46 | 48 |
| 47 virtual void Connect(const ClientConfig& config, | 49 virtual void Connect(const ClientConfig& config, |
| 48 HostEventCallback* event_callback); | 50 HostEventCallback* event_callback, |
| 51 VideoStub* video_stub); |
| 49 virtual void Disconnect(); | 52 virtual void Disconnect(); |
| 50 | 53 |
| 51 virtual void SendEvent(const ChromotingClientMessage& msg); | 54 virtual void SendEvent(const ChromotingClientMessage& msg); |
| 52 | 55 |
| 53 // JingleClient::Callback interface. | 56 // JingleClient::Callback interface. |
| 54 virtual void OnStateChange(JingleClient* client, JingleClient::State state); | 57 virtual void OnStateChange(JingleClient* client, JingleClient::State state); |
| 55 | 58 |
| 56 // Callback for ChromotocolServer. | 59 // Callback for ChromotocolServer. |
| 57 void OnNewChromotocolConnection( | 60 void OnNewChromotocolConnection( |
| 58 ChromotocolConnection* connection, | 61 ChromotocolConnection* connection, |
| 59 ChromotocolServer::IncomingConnectionResponse* response); | 62 ChromotocolServer::IncomingConnectionResponse* response); |
| 60 | 63 |
| 61 // Callback for ChromotocolConnection. | 64 // Callback for ChromotocolConnection. |
| 62 void OnConnectionStateChange(ChromotocolConnection::State state); | 65 void OnConnectionStateChange(ChromotocolConnection::State state); |
| 63 | 66 |
| 64 private: | 67 private: |
| 65 // The message loop for the jingle thread this object works on. | 68 // The message loop for the jingle thread this object works on. |
| 66 MessageLoop* message_loop(); | 69 MessageLoop* message_loop(); |
| 67 | 70 |
| 68 // Called on the jingle thread after we've successfully to XMPP server. Starts | 71 // Called on the jingle thread after we've successfully to XMPP server. Starts |
| 69 // P2P connection to the host. | 72 // P2P connection to the host. |
| 70 void InitConnection(); | 73 void InitConnection(); |
| 71 | 74 |
| 75 // Callback for |control_reader_|. |
| 76 void OnControlMessage(ChromotingHostMessage* msg); |
| 77 |
| 72 // Callback for |video_reader_|. | 78 // Callback for |video_reader_|. |
| 73 // TODO(sergeyu): This should be replaced with RTP/RTCP handler. | 79 void OnVideoPacket(VideoPacket* packet); |
| 74 void OnVideoMessage(ChromotingHostMessage* msg); | |
| 75 | 80 |
| 76 // Used by Disconnect() to disconnect chromoting connection, stop chromoting | 81 // Used by Disconnect() to disconnect chromoting connection, stop chromoting |
| 77 // server, and then disconnect XMPP connection. | 82 // server, and then disconnect XMPP connection. |
| 78 void OnDisconnected(); | 83 void OnDisconnected(); |
| 79 void OnServerClosed(); | 84 void OnServerClosed(); |
| 80 | 85 |
| 81 ClientContext* context_; | 86 ClientContext* context_; |
| 82 | 87 |
| 83 scoped_refptr<JingleClient> jingle_client_; | 88 scoped_refptr<JingleClient> jingle_client_; |
| 84 scoped_refptr<ChromotocolServer> chromotocol_server_; | 89 scoped_refptr<ChromotocolServer> chromotocol_server_; |
| 85 scoped_refptr<ChromotocolConnection> connection_; | 90 scoped_refptr<ChromotocolConnection> connection_; |
| 86 | 91 |
| 92 MessageReader control_reader_; |
| 87 EventStreamWriter event_writer_; | 93 EventStreamWriter event_writer_; |
| 88 MessageReader video_reader_; | 94 scoped_ptr<VideoReader> video_reader_; |
| 89 | 95 |
| 90 HostEventCallback* event_callback_; | 96 HostEventCallback* event_callback_; |
| 97 VideoStub* video_stub_; |
| 91 | 98 |
| 92 std::string host_jid_; | 99 std::string host_jid_; |
| 93 | 100 |
| 94 DISALLOW_COPY_AND_ASSIGN(JingleHostConnection); | 101 DISALLOW_COPY_AND_ASSIGN(JingleHostConnection); |
| 95 }; | 102 }; |
| 96 | 103 |
| 97 } // namespace remoting | 104 } // namespace remoting |
| 98 | 105 |
| 99 DISABLE_RUNNABLE_METHOD_REFCOUNT(remoting::JingleHostConnection); | 106 DISABLE_RUNNABLE_METHOD_REFCOUNT(remoting::JingleHostConnection); |
| 100 | 107 |
| 101 #endif // REMOTING_CLIENT_JINGLE_HOST_CONNECTION_H_ | 108 #endif // REMOTING_CLIENT_JINGLE_HOST_CONNECTION_H_ |
| OLD | NEW |