| 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 #ifndef REMOTING_PROTOCOL_JINGLE_CHROMOTOCOL_CONNECTION_H_ | 5 #ifndef REMOTING_PROTOCOL_JINGLE_SESSION_H_ |
| 6 #define REMOTING_PROTOCOL_JINGLE_CHROMOTOCOL_CONNECTION_H_ | 6 #define REMOTING_PROTOCOL_JINGLE_SESSION_H_ |
| 7 | 7 |
| 8 #include "base/lock.h" | 8 #include "base/lock.h" |
| 9 #include "base/ref_counted.h" | 9 #include "base/ref_counted.h" |
| 10 #include "remoting/protocol/chromotocol_connection.h" | 10 #include "remoting/protocol/session.h" |
| 11 #include "third_party/libjingle/source/talk/base/sigslot.h" | 11 #include "third_party/libjingle/source/talk/base/sigslot.h" |
| 12 #include "third_party/libjingle/source/talk/p2p/base/session.h" | 12 #include "third_party/libjingle/source/talk/p2p/base/session.h" |
| 13 | 13 |
| 14 namespace cricket { | 14 namespace cricket { |
| 15 class PseudoTcpChannel; | 15 class PseudoTcpChannel; |
| 16 } // namespace cricket | 16 } // namespace cricket |
| 17 | 17 |
| 18 namespace net { | 18 namespace net { |
| 19 class Socket; | 19 class Socket; |
| 20 } // namespace net | 20 } // namespace net |
| 21 | 21 |
| 22 namespace remoting { | 22 namespace remoting { |
| 23 | 23 |
| 24 class JingleChromotocolServer; | |
| 25 class StreamSocketAdapter; | 24 class StreamSocketAdapter; |
| 26 class TransportChannelSocketAdapter; | 25 class TransportChannelSocketAdapter; |
| 27 | 26 |
| 28 // Implements ChromotocolConnection that work over libjingle session (the | 27 namespace protocol { |
| 28 |
| 29 class JingleSessionManager; |
| 30 |
| 31 // Implements protocol::Session that work over libjingle session (the |
| 29 // cricket::Session object is passed to Init() method). Created | 32 // cricket::Session object is passed to Init() method). Created |
| 30 // by JingleChromotocolServer for incoming and outgoing connections. | 33 // by JingleSessionManager for incoming and outgoing connections. |
| 31 class JingleChromotocolConnection : public ChromotocolConnection, | 34 class JingleSession : public protocol::Session, |
| 32 public sigslot::has_slots<> { | 35 public sigslot::has_slots<> { |
| 33 public: | 36 public: |
| 34 static const char kChromotingContentName[]; | 37 static const char kChromotingContentName[]; |
| 35 | 38 |
| 36 explicit JingleChromotocolConnection(JingleChromotocolServer* client); | 39 explicit JingleSession(JingleSessionManager* client); |
| 37 | 40 |
| 38 // ChromotocolConnection interface. | 41 // Chromotocol Session interface. |
| 39 virtual void SetStateChangeCallback(StateChangeCallback* callback); | 42 virtual void SetStateChangeCallback(StateChangeCallback* callback); |
| 40 | 43 |
| 41 virtual net::Socket* control_channel(); | 44 virtual net::Socket* control_channel(); |
| 42 virtual net::Socket* event_channel(); | 45 virtual net::Socket* event_channel(); |
| 43 virtual net::Socket* video_channel(); | 46 virtual net::Socket* video_channel(); |
| 44 | 47 |
| 45 virtual net::Socket* video_rtp_channel(); | 48 virtual net::Socket* video_rtp_channel(); |
| 46 virtual net::Socket* video_rtcp_channel(); | 49 virtual net::Socket* video_rtcp_channel(); |
| 47 | 50 |
| 48 virtual const std::string& jid(); | 51 virtual const std::string& jid(); |
| 49 virtual MessageLoop* message_loop(); | 52 virtual MessageLoop* message_loop(); |
| 50 | 53 |
| 51 virtual const CandidateChromotocolConfig* candidate_config(); | 54 virtual const CandidateChromotocolConfig* candidate_config(); |
| 52 virtual const ChromotocolConfig* config(); | 55 virtual const ChromotocolConfig* config(); |
| 53 | 56 |
| 54 virtual void set_config(const ChromotocolConfig* config); | 57 virtual void set_config(const ChromotocolConfig* config); |
| 55 | 58 |
| 56 virtual void Close(Task* closed_task); | 59 virtual void Close(Task* closed_task); |
| 57 | 60 |
| 58 protected: | 61 protected: |
| 59 virtual ~JingleChromotocolConnection(); | 62 virtual ~JingleSession(); |
| 60 | 63 |
| 61 private: | 64 private: |
| 62 friend class JingleChromotocolServer; | 65 friend class JingleSessionManager; |
| 63 | 66 |
| 64 // Called by JingleChromotocolServer. | 67 // Called by JingleSessionManager. |
| 65 void set_candidate_config(const CandidateChromotocolConfig* candidate_config); | 68 void set_candidate_config(const CandidateChromotocolConfig* candidate_config); |
| 66 void Init(cricket::Session* session); | 69 void Init(cricket::Session* cricket_session); |
| 67 bool HasSession(cricket::Session* session); | 70 bool HasSession(cricket::Session* cricket_session); |
| 68 cricket::Session* ReleaseSession(); | 71 cricket::Session* ReleaseSession(); |
| 69 | 72 |
| 70 // Used for Session.SignalState sigslot. | 73 // Used for Session.SignalState sigslot. |
| 71 void OnSessionState(cricket::BaseSession* session, | 74 void OnSessionState(cricket::BaseSession* session, |
| 72 cricket::BaseSession::State state); | 75 cricket::BaseSession::State state); |
| 73 | 76 |
| 74 void OnInitiate(); | 77 void OnInitiate(); |
| 75 void OnAccept(); | 78 void OnAccept(); |
| 76 void OnTerminate(); | 79 void OnTerminate(); |
| 77 | 80 |
| 78 void SetState(State new_state); | 81 void SetState(State new_state); |
| 79 | 82 |
| 80 // JingleChromotocolServer that created this connection. | 83 // JingleSessionManager that created this session. |
| 81 scoped_refptr<JingleChromotocolServer> server_; | 84 scoped_refptr<JingleSessionManager> jingle_session_manager_; |
| 82 | 85 |
| 83 State state_; | 86 State state_; |
| 84 scoped_ptr<StateChangeCallback> state_change_callback_; | 87 scoped_ptr<StateChangeCallback> state_change_callback_; |
| 85 | 88 |
| 86 bool closed_; | 89 bool closed_; |
| 87 | 90 |
| 88 // JID of the other side. Set when the connection is initialized, | 91 // JID of the other side. Set when the connection is initialized, |
| 89 // and never changed after that. | 92 // and never changed after that. |
| 90 std::string jid_; | 93 std::string jid_; |
| 91 | 94 |
| 92 // The corresponding libjingle session. | 95 // The corresponding libjingle session. |
| 93 cricket::Session* session_; | 96 cricket::Session* cricket_session_; |
| 94 | 97 |
| 95 scoped_ptr<const CandidateChromotocolConfig> candidate_config_; | 98 scoped_ptr<const CandidateChromotocolConfig> candidate_config_; |
| 96 scoped_ptr<const ChromotocolConfig> config_; | 99 scoped_ptr<const ChromotocolConfig> config_; |
| 97 | 100 |
| 98 cricket::PseudoTcpChannel* control_channel_; | 101 cricket::PseudoTcpChannel* control_channel_; |
| 99 scoped_ptr<StreamSocketAdapter> control_channel_adapter_; | 102 scoped_ptr<StreamSocketAdapter> control_channel_adapter_; |
| 100 cricket::PseudoTcpChannel* event_channel_; | 103 cricket::PseudoTcpChannel* event_channel_; |
| 101 scoped_ptr<StreamSocketAdapter> event_channel_adapter_; | 104 scoped_ptr<StreamSocketAdapter> event_channel_adapter_; |
| 102 cricket::PseudoTcpChannel* video_channel_; | 105 cricket::PseudoTcpChannel* video_channel_; |
| 103 scoped_ptr<StreamSocketAdapter> video_channel_adapter_; | 106 scoped_ptr<StreamSocketAdapter> video_channel_adapter_; |
| 104 scoped_ptr<TransportChannelSocketAdapter> video_rtp_channel_; | 107 scoped_ptr<TransportChannelSocketAdapter> video_rtp_channel_; |
| 105 scoped_ptr<TransportChannelSocketAdapter> video_rtcp_channel_; | 108 scoped_ptr<TransportChannelSocketAdapter> video_rtcp_channel_; |
| 106 | 109 |
| 107 DISALLOW_COPY_AND_ASSIGN(JingleChromotocolConnection); | 110 DISALLOW_COPY_AND_ASSIGN(JingleSession); |
| 108 }; | 111 }; |
| 109 | 112 |
| 113 } // namespace protocol |
| 114 |
| 110 } // namespace remoting | 115 } // namespace remoting |
| 111 | 116 |
| 112 #endif // REMOTING_PROTOCOL_JINGLE_CHROMOTOCOL_CONNECTION_H_ | 117 #endif // REMOTING_PROTOCOL_JINGLE_SESSION_H_ |
| OLD | NEW |