| OLD | NEW |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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_ICE_CONNECTION_TO_HOST_H_ | 5 #ifndef REMOTING_PROTOCOL_ICE_CONNECTION_TO_HOST_H_ |
| 6 #define REMOTING_PROTOCOL_ICE_CONNECTION_TO_HOST_H_ | 6 #define REMOTING_PROTOCOL_ICE_CONNECTION_TO_HOST_H_ |
| 7 | 7 |
| 8 #include <set> | 8 #include <set> |
| 9 #include <string> | 9 #include <string> |
| 10 | 10 |
| 11 #include "base/callback_forward.h" | 11 #include "base/callback_forward.h" |
| 12 #include "base/memory/ref_counted.h" | 12 #include "base/memory/ref_counted.h" |
| 13 #include "base/memory/scoped_ptr.h" | 13 #include "base/memory/scoped_ptr.h" |
| 14 #include "base/threading/non_thread_safe.h" | 14 #include "base/threading/non_thread_safe.h" |
| 15 #include "remoting/proto/internal.pb.h" | 15 #include "remoting/proto/internal.pb.h" |
| 16 #include "remoting/protocol/channel_dispatcher_base.h" | 16 #include "remoting/protocol/channel_dispatcher_base.h" |
| 17 #include "remoting/protocol/clipboard_filter.h" | 17 #include "remoting/protocol/clipboard_filter.h" |
| 18 #include "remoting/protocol/connection_to_host.h" | 18 #include "remoting/protocol/connection_to_host.h" |
| 19 #include "remoting/protocol/errors.h" | 19 #include "remoting/protocol/errors.h" |
| 20 #include "remoting/protocol/ice_transport.h" |
| 20 #include "remoting/protocol/input_filter.h" | 21 #include "remoting/protocol/input_filter.h" |
| 21 #include "remoting/protocol/message_reader.h" | 22 #include "remoting/protocol/message_reader.h" |
| 22 #include "remoting/protocol/monitored_video_stub.h" | 23 #include "remoting/protocol/monitored_video_stub.h" |
| 23 #include "remoting/protocol/session.h" | 24 #include "remoting/protocol/session.h" |
| 24 #include "remoting/protocol/session_config.h" | 25 #include "remoting/protocol/session_config.h" |
| 25 | 26 |
| 26 namespace remoting { | 27 namespace remoting { |
| 27 namespace protocol { | 28 namespace protocol { |
| 28 | 29 |
| 29 class AudioReader; | 30 class AudioReader; |
| 30 class ClientControlDispatcher; | 31 class ClientControlDispatcher; |
| 31 class ClientEventDispatcher; | 32 class ClientEventDispatcher; |
| 32 class ClientVideoDispatcher; | 33 class ClientVideoDispatcher; |
| 33 | 34 |
| 34 class IceConnectionToHost : public ConnectionToHost, | 35 class IceConnectionToHost : public ConnectionToHost, |
| 35 public Session::EventHandler, | 36 public Session::EventHandler, |
| 37 public IceTransport::EventHandler, |
| 36 public ChannelDispatcherBase::EventHandler, | 38 public ChannelDispatcherBase::EventHandler, |
| 37 public base::NonThreadSafe { | 39 public base::NonThreadSafe { |
| 38 public: | 40 public: |
| 39 IceConnectionToHost(); | 41 IceConnectionToHost(); |
| 40 ~IceConnectionToHost() override; | 42 ~IceConnectionToHost() override; |
| 41 | 43 |
| 42 // ConnectionToHost interface. | 44 // ConnectionToHost interface. |
| 43 void set_client_stub(ClientStub* client_stub) override; | 45 void set_client_stub(ClientStub* client_stub) override; |
| 44 void set_clipboard_stub(ClipboardStub* clipboard_stub) override; | 46 void set_clipboard_stub(ClipboardStub* clipboard_stub) override; |
| 45 void set_video_stub(VideoStub* video_stub) override; | 47 void set_video_stub(VideoStub* video_stub) override; |
| 46 void set_audio_stub(AudioStub* audio_stub) override; | 48 void set_audio_stub(AudioStub* audio_stub) override; |
| 47 void Connect(scoped_ptr<Session> session, | 49 void Connect(scoped_ptr<Session> session, |
| 50 scoped_refptr<TransportContext> transport_context, |
| 48 HostEventCallback* event_callback) override; | 51 HostEventCallback* event_callback) override; |
| 49 const SessionConfig& config() override; | 52 const SessionConfig& config() override; |
| 50 ClipboardStub* clipboard_forwarder() override; | 53 ClipboardStub* clipboard_forwarder() override; |
| 51 HostStub* host_stub() override; | 54 HostStub* host_stub() override; |
| 52 InputStub* input_stub() override; | 55 InputStub* input_stub() override; |
| 53 State state() const override; | 56 State state() const override; |
| 54 | 57 |
| 55 private: | 58 private: |
| 56 // Session::EventHandler interface. | 59 // Session::EventHandler interface. |
| 57 void OnSessionStateChange(Session::State state) override; | 60 void OnSessionStateChange(Session::State state) override; |
| 58 void OnSessionRouteChange(const std::string& channel_name, | 61 |
| 59 const TransportRoute& route) override; | 62 // IceTransport::EventHandler interface. |
| 63 void OnIceTransportRouteChange(const std::string& channel_name, |
| 64 const TransportRoute& route) override; |
| 65 void OnIceTransportError(ErrorCode error) override; |
| 60 | 66 |
| 61 // ChannelDispatcherBase::EventHandler interface. | 67 // ChannelDispatcherBase::EventHandler interface. |
| 62 void OnChannelInitialized(ChannelDispatcherBase* channel_dispatcher) override; | 68 void OnChannelInitialized(ChannelDispatcherBase* channel_dispatcher) override; |
| 63 void OnChannelError(ChannelDispatcherBase* channel_dispatcher, | 69 void OnChannelError(ChannelDispatcherBase* channel_dispatcher, |
| 64 ErrorCode error) override; | 70 ErrorCode error) override; |
| 65 | 71 |
| 66 // MonitoredVideoStub::EventHandler interface. | 72 // MonitoredVideoStub::EventHandler interface. |
| 67 virtual void OnVideoChannelStatus(bool active); | 73 virtual void OnVideoChannelStatus(bool active); |
| 68 | 74 |
| 69 void NotifyIfChannelsReady(); | 75 void NotifyIfChannelsReady(); |
| 70 | 76 |
| 71 void CloseOnError(ErrorCode error); | 77 void CloseOnError(ErrorCode error); |
| 72 | 78 |
| 73 // Stops writing in the channels. | 79 // Closes the P2P connection. |
| 74 void CloseChannels(); | 80 void CloseChannels(); |
| 75 | 81 |
| 76 void SetState(State state, ErrorCode error); | 82 void SetState(State state, ErrorCode error); |
| 77 | 83 |
| 78 HostEventCallback* event_callback_ = nullptr; | 84 HostEventCallback* event_callback_ = nullptr; |
| 79 | 85 |
| 80 // Stub for incoming messages. | 86 // Stub for incoming messages. |
| 81 ClientStub* client_stub_ = nullptr; | 87 ClientStub* client_stub_ = nullptr; |
| 82 ClipboardStub* clipboard_stub_ = nullptr; | 88 ClipboardStub* clipboard_stub_ = nullptr; |
| 83 AudioStub* audio_stub_ = nullptr; | 89 AudioStub* audio_stub_ = nullptr; |
| 84 | 90 |
| 85 scoped_ptr<Session> session_; | 91 scoped_ptr<Session> session_; |
| 92 scoped_ptr<IceTransport> transport_; |
| 93 |
| 86 scoped_ptr<MonitoredVideoStub> monitored_video_stub_; | 94 scoped_ptr<MonitoredVideoStub> monitored_video_stub_; |
| 87 | |
| 88 scoped_ptr<ClientVideoDispatcher> video_dispatcher_; | 95 scoped_ptr<ClientVideoDispatcher> video_dispatcher_; |
| 89 scoped_ptr<AudioReader> audio_reader_; | 96 scoped_ptr<AudioReader> audio_reader_; |
| 90 scoped_ptr<ClientControlDispatcher> control_dispatcher_; | 97 scoped_ptr<ClientControlDispatcher> control_dispatcher_; |
| 91 scoped_ptr<ClientEventDispatcher> event_dispatcher_; | 98 scoped_ptr<ClientEventDispatcher> event_dispatcher_; |
| 92 ClipboardFilter clipboard_forwarder_; | 99 ClipboardFilter clipboard_forwarder_; |
| 93 InputFilter event_forwarder_; | 100 InputFilter event_forwarder_; |
| 94 | 101 |
| 95 // Internal state of the connection. | 102 // Internal state of the connection. |
| 96 State state_ = INITIALIZING; | 103 State state_ = INITIALIZING; |
| 97 ErrorCode error_ = OK; | 104 ErrorCode error_ = OK; |
| 98 | 105 |
| 99 private: | 106 private: |
| 100 DISALLOW_COPY_AND_ASSIGN(IceConnectionToHost); | 107 DISALLOW_COPY_AND_ASSIGN(IceConnectionToHost); |
| 101 }; | 108 }; |
| 102 | 109 |
| 103 } // namespace protocol | 110 } // namespace protocol |
| 104 } // namespace remoting | 111 } // namespace remoting |
| 105 | 112 |
| 106 #endif // REMOTING_PROTOCOL_ICE_CONNECTION_TO_HOST_H_ | 113 #endif // REMOTING_PROTOCOL_ICE_CONNECTION_TO_HOST_H_ |
| OLD | NEW |