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_CLIENT_H_ | 5 #ifndef REMOTING_PROTOCOL_ICE_CONNECTION_TO_CLIENT_H_ |
6 #define REMOTING_PROTOCOL_ICE_CONNECTION_TO_CLIENT_H_ | 6 #define REMOTING_PROTOCOL_ICE_CONNECTION_TO_CLIENT_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 "base/threading/thread_checker.h" | 12 #include "base/threading/thread_checker.h" |
13 #include "remoting/protocol/channel_dispatcher_base.h" | 13 #include "remoting/protocol/channel_dispatcher_base.h" |
14 #include "remoting/protocol/connection_to_client.h" | 14 #include "remoting/protocol/connection_to_client.h" |
| 15 #include "remoting/protocol/ice_transport.h" |
15 #include "remoting/protocol/session.h" | 16 #include "remoting/protocol/session.h" |
16 | 17 |
17 namespace remoting { | 18 namespace remoting { |
18 namespace protocol { | 19 namespace protocol { |
19 | 20 |
20 class AudioWriter; | 21 class AudioWriter; |
21 class HostControlDispatcher; | 22 class HostControlDispatcher; |
22 class HostEventDispatcher; | 23 class HostEventDispatcher; |
23 class HostVideoDispatcher; | 24 class HostVideoDispatcher; |
24 class VideoFeedbackStub; | 25 class VideoFeedbackStub; |
25 class VideoFramePump; | 26 class VideoFramePump; |
26 | 27 |
27 // This class represents a remote viewer connection to the chromoting | 28 // This class represents a remote viewer connection to the chromoting |
28 // host. It sets up all protocol channels and connects them to the | 29 // host. It sets up all protocol channels and connects them to the |
29 // stubs. | 30 // stubs. |
30 class IceConnectionToClient : public ConnectionToClient, | 31 class IceConnectionToClient : public ConnectionToClient, |
31 public Session::EventHandler, | 32 public Session::EventHandler, |
| 33 public IceTransport::EventHandler, |
32 public ChannelDispatcherBase::EventHandler { | 34 public ChannelDispatcherBase::EventHandler { |
33 public: | 35 public: |
34 IceConnectionToClient( | 36 IceConnectionToClient( |
35 scoped_ptr<Session> session, | 37 scoped_ptr<Session> session, |
| 38 scoped_refptr<TransportContext> transport_context, |
36 scoped_refptr<base::SingleThreadTaskRunner> video_encode_task_runner); | 39 scoped_refptr<base::SingleThreadTaskRunner> video_encode_task_runner); |
37 ~IceConnectionToClient() override; | 40 ~IceConnectionToClient() override; |
38 | 41 |
39 // ConnectionToClient interface. | 42 // ConnectionToClient interface. |
40 void SetEventHandler( | 43 void SetEventHandler( |
41 ConnectionToClient::EventHandler* event_handler) override; | 44 ConnectionToClient::EventHandler* event_handler) override; |
42 Session* session() override; | 45 Session* session() override; |
43 void Disconnect(ErrorCode error) override; | 46 void Disconnect(ErrorCode error) override; |
44 void OnInputEventReceived(int64_t timestamp) override; | 47 void OnInputEventReceived(int64_t timestamp) override; |
45 scoped_ptr<VideoStream> StartVideoStream( | 48 scoped_ptr<VideoStream> StartVideoStream( |
46 scoped_ptr<webrtc::DesktopCapturer> desktop_capturer) override; | 49 scoped_ptr<webrtc::DesktopCapturer> desktop_capturer) override; |
47 AudioStub* audio_stub() override; | 50 AudioStub* audio_stub() override; |
48 ClientStub* client_stub() override; | 51 ClientStub* client_stub() override; |
49 void set_clipboard_stub(ClipboardStub* clipboard_stub) override; | 52 void set_clipboard_stub(ClipboardStub* clipboard_stub) override; |
50 void set_host_stub(HostStub* host_stub) override; | 53 void set_host_stub(HostStub* host_stub) override; |
51 void set_input_stub(InputStub* input_stub) override; | 54 void set_input_stub(InputStub* input_stub) override; |
52 | 55 |
53 // Session::EventHandler interface. | 56 // Session::EventHandler interface. |
54 void OnSessionStateChange(Session::State state) override; | 57 void OnSessionStateChange(Session::State state) override; |
55 void OnSessionRouteChange(const std::string& channel_name, | 58 |
56 const TransportRoute& route) override; | 59 // IceTransport::EventHandler interface. |
| 60 void OnIceTransportRouteChange(const std::string& channel_name, |
| 61 const TransportRoute& route) override; |
| 62 void OnIceTransportError(ErrorCode error) override; |
57 | 63 |
58 // ChannelDispatcherBase::EventHandler interface. | 64 // ChannelDispatcherBase::EventHandler interface. |
59 void OnChannelInitialized(ChannelDispatcherBase* channel_dispatcher) override; | 65 void OnChannelInitialized(ChannelDispatcherBase* channel_dispatcher) override; |
60 void OnChannelError(ChannelDispatcherBase* channel_dispatcher, | 66 void OnChannelError(ChannelDispatcherBase* channel_dispatcher, |
61 ErrorCode error) override; | 67 ErrorCode error) override; |
62 | 68 |
63 private: | 69 private: |
64 void NotifyIfChannelsReady(); | 70 void NotifyIfChannelsReady(); |
65 | 71 |
66 void Close(ErrorCode error); | |
67 | |
68 // Stops writing in the channels. | |
69 void CloseChannels(); | 72 void CloseChannels(); |
70 | 73 |
71 base::ThreadChecker thread_checker_; | 74 base::ThreadChecker thread_checker_; |
72 | 75 |
73 // Event handler for handling events sent from this object. | 76 // Event handler for handling events sent from this object. |
74 ConnectionToClient::EventHandler* event_handler_; | 77 ConnectionToClient::EventHandler* event_handler_; |
75 | 78 |
76 scoped_ptr<Session> session_; | 79 scoped_ptr<Session> session_; |
77 | 80 |
78 scoped_refptr<base::SingleThreadTaskRunner> video_encode_task_runner_; | 81 scoped_refptr<base::SingleThreadTaskRunner> video_encode_task_runner_; |
79 | 82 |
| 83 IceTransport transport_; |
| 84 |
80 scoped_ptr<HostControlDispatcher> control_dispatcher_; | 85 scoped_ptr<HostControlDispatcher> control_dispatcher_; |
81 scoped_ptr<HostEventDispatcher> event_dispatcher_; | 86 scoped_ptr<HostEventDispatcher> event_dispatcher_; |
82 scoped_ptr<HostVideoDispatcher> video_dispatcher_; | 87 scoped_ptr<HostVideoDispatcher> video_dispatcher_; |
83 scoped_ptr<AudioWriter> audio_writer_; | 88 scoped_ptr<AudioWriter> audio_writer_; |
84 | 89 |
85 DISALLOW_COPY_AND_ASSIGN(IceConnectionToClient); | 90 DISALLOW_COPY_AND_ASSIGN(IceConnectionToClient); |
86 }; | 91 }; |
87 | 92 |
88 } // namespace protocol | 93 } // namespace protocol |
89 } // namespace remoting | 94 } // namespace remoting |
90 | 95 |
91 #endif // REMOTING_PROTOCOL_ICE_CONNECTION_TO_CLIENT_H_ | 96 #endif // REMOTING_PROTOCOL_ICE_CONNECTION_TO_CLIENT_H_ |
OLD | NEW |