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_WEBRTC_CONNECTION_TO_HOST_H_ | 5 #ifndef REMOTING_PROTOCOL_WEBRTC_CONNECTION_TO_HOST_H_ |
6 #define REMOTING_PROTOCOL_WEBRTC_CONNECTION_TO_HOST_H_ | 6 #define REMOTING_PROTOCOL_WEBRTC_CONNECTION_TO_HOST_H_ |
7 | 7 |
8 #include <string> | 8 #include <string> |
9 | 9 |
10 #include "base/macros.h" | 10 #include "base/macros.h" |
11 #include "base/memory/scoped_ptr.h" | 11 #include "base/memory/scoped_ptr.h" |
12 #include "remoting/protocol/channel_dispatcher_base.h" | 12 #include "remoting/protocol/channel_dispatcher_base.h" |
13 #include "remoting/protocol/clipboard_filter.h" | 13 #include "remoting/protocol/clipboard_filter.h" |
14 #include "remoting/protocol/connection_to_host.h" | 14 #include "remoting/protocol/connection_to_host.h" |
15 #include "remoting/protocol/errors.h" | 15 #include "remoting/protocol/errors.h" |
16 #include "remoting/protocol/input_filter.h" | 16 #include "remoting/protocol/input_filter.h" |
17 #include "remoting/protocol/session.h" | 17 #include "remoting/protocol/session.h" |
| 18 #include "remoting/protocol/webrtc_transport.h" |
18 | 19 |
19 namespace remoting { | 20 namespace remoting { |
20 namespace protocol { | 21 namespace protocol { |
21 | 22 |
22 class ClientControlDispatcher; | 23 class ClientControlDispatcher; |
23 class ClientEventDispatcher; | 24 class ClientEventDispatcher; |
24 class SessionConfig; | 25 class SessionConfig; |
25 | 26 |
26 class WebrtcConnectionToHost : public ConnectionToHost, | 27 class WebrtcConnectionToHost : public ConnectionToHost, |
27 public Session::EventHandler, | 28 public Session::EventHandler, |
| 29 public WebrtcTransport::EventHandler, |
28 public ChannelDispatcherBase::EventHandler { | 30 public ChannelDispatcherBase::EventHandler { |
29 public: | 31 public: |
30 WebrtcConnectionToHost(); | 32 WebrtcConnectionToHost(); |
31 ~WebrtcConnectionToHost() override; | 33 ~WebrtcConnectionToHost() override; |
32 | 34 |
33 // ConnectionToHost interface. | 35 // ConnectionToHost interface. |
34 void set_client_stub(ClientStub* client_stub) override; | 36 void set_client_stub(ClientStub* client_stub) override; |
35 void set_clipboard_stub(ClipboardStub* clipboard_stub) override; | 37 void set_clipboard_stub(ClipboardStub* clipboard_stub) override; |
36 void set_video_stub(VideoStub* video_stub) override; | 38 void set_video_stub(VideoStub* video_stub) override; |
37 void set_audio_stub(AudioStub* audio_stub) override; | 39 void set_audio_stub(AudioStub* audio_stub) override; |
38 void Connect(scoped_ptr<Session> session, | 40 void Connect(scoped_ptr<Session> session, |
| 41 scoped_refptr<TransportContext> transport_context, |
39 HostEventCallback* event_callback) override; | 42 HostEventCallback* event_callback) override; |
40 const SessionConfig& config() override; | 43 const SessionConfig& config() override; |
41 ClipboardStub* clipboard_forwarder() override; | 44 ClipboardStub* clipboard_forwarder() override; |
42 HostStub* host_stub() override; | 45 HostStub* host_stub() override; |
43 InputStub* input_stub() override; | 46 InputStub* input_stub() override; |
44 State state() const override; | 47 State state() const override; |
45 | 48 |
46 private: | 49 private: |
47 // Session::EventHandler interface. | 50 // Session::EventHandler interface. |
48 void OnSessionStateChange(Session::State state) override; | 51 void OnSessionStateChange(Session::State state) override; |
49 void OnSessionRouteChange(const std::string& channel_name, | 52 |
50 const TransportRoute& route) override; | 53 // WebrtcTransport::EventHandler interface. |
| 54 void OnWebrtcTransportConnected() override; |
| 55 void OnWebrtcTransportError(ErrorCode error) override; |
51 | 56 |
52 // ChannelDispatcherBase::EventHandler interface. | 57 // ChannelDispatcherBase::EventHandler interface. |
53 void OnChannelInitialized(ChannelDispatcherBase* channel_dispatcher) override; | 58 void OnChannelInitialized(ChannelDispatcherBase* channel_dispatcher) override; |
54 void OnChannelError(ChannelDispatcherBase* channel_dispatcher, | 59 void OnChannelError(ChannelDispatcherBase* channel_dispatcher, |
55 ErrorCode error) override; | 60 ErrorCode error) override; |
56 | 61 |
57 void NotifyIfChannelsReady(); | 62 void NotifyIfChannelsReady(); |
58 | 63 |
59 void CloseChannels(); | 64 void CloseChannels(); |
60 | 65 |
61 void SetState(State state, ErrorCode error); | 66 void SetState(State state, ErrorCode error); |
62 | 67 |
63 HostEventCallback* event_callback_ = nullptr; | 68 HostEventCallback* event_callback_ = nullptr; |
64 | 69 |
65 // Stub for incoming messages. | 70 // Stub for incoming messages. |
66 ClientStub* client_stub_ = nullptr; | 71 ClientStub* client_stub_ = nullptr; |
67 ClipboardStub* clipboard_stub_ = nullptr; | 72 ClipboardStub* clipboard_stub_ = nullptr; |
68 | 73 |
69 scoped_ptr<Session> session_; | 74 scoped_ptr<Session> session_; |
| 75 scoped_ptr<WebrtcTransport> transport_; |
70 | 76 |
71 scoped_ptr<ClientControlDispatcher> control_dispatcher_; | 77 scoped_ptr<ClientControlDispatcher> control_dispatcher_; |
72 scoped_ptr<ClientEventDispatcher> event_dispatcher_; | 78 scoped_ptr<ClientEventDispatcher> event_dispatcher_; |
73 ClipboardFilter clipboard_forwarder_; | 79 ClipboardFilter clipboard_forwarder_; |
74 InputFilter event_forwarder_; | 80 InputFilter event_forwarder_; |
75 | 81 |
76 // Internal state of the connection. | 82 // Internal state of the connection. |
77 State state_ = INITIALIZING; | 83 State state_ = INITIALIZING; |
78 ErrorCode error_ = OK; | 84 ErrorCode error_ = OK; |
79 | 85 |
80 private: | 86 private: |
81 DISALLOW_COPY_AND_ASSIGN(WebrtcConnectionToHost); | 87 DISALLOW_COPY_AND_ASSIGN(WebrtcConnectionToHost); |
82 }; | 88 }; |
83 | 89 |
84 } // namespace protocol | 90 } // namespace protocol |
85 } // namespace remoting | 91 } // namespace remoting |
86 | 92 |
87 #endif // REMOTING_PROTOCOL_WEBRTC_CONNECTION_TO_HOST_H_ | 93 #endif // REMOTING_PROTOCOL_WEBRTC_CONNECTION_TO_HOST_H_ |
OLD | NEW |