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