OLD | NEW |
1 // Copyright 2017 The Chromium Authors. All rights reserved. | 1 // Copyright 2017 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 #if !defined(__has_feature) || !__has_feature(objc_arc) | 5 #if !defined(__has_feature) || !__has_feature(objc_arc) |
6 #error "This file requires ARC support." | 6 #error "This file requires ARC support." |
7 #endif | 7 #endif |
8 | 8 |
9 #import "remoting/client/ios/session/remoting_client.h" | 9 #import "remoting/client/ios/session/remoting_client.h" |
10 | 10 |
| 11 #include <memory> |
| 12 |
11 #import "base/mac/bind_objc_block.h" | 13 #import "base/mac/bind_objc_block.h" |
12 #import "ios/third_party/material_components_ios/src/components/Dialogs/src/Mate
rialDialogs.h" | 14 #import "ios/third_party/material_components_ios/src/components/Dialogs/src/Mate
rialDialogs.h" |
13 #import "remoting/client/ios/display/gl_display_handler.h" | 15 #import "remoting/client/ios/display/gl_display_handler.h" |
14 #import "remoting/client/ios/domain/client_session_details.h" | 16 #import "remoting/client/ios/domain/client_session_details.h" |
15 #import "remoting/client/ios/domain/host_info.h" | 17 #import "remoting/client/ios/domain/host_info.h" |
16 | 18 |
17 #include "base/strings/sys_string_conversions.h" | 19 #include "base/strings/sys_string_conversions.h" |
18 #include "remoting/client/chromoting_client_runtime.h" | 20 #include "remoting/client/chromoting_client_runtime.h" |
19 #include "remoting/client/chromoting_session.h" | 21 #include "remoting/client/chromoting_session.h" |
20 #include "remoting/client/connect_to_host_info.h" | 22 #include "remoting/client/connect_to_host_info.h" |
| 23 #include "remoting/client/gesture_interpreter.h" |
21 #include "remoting/client/ios/session/remoting_client_session_delegate.h" | 24 #include "remoting/client/ios/session/remoting_client_session_delegate.h" |
22 #include "remoting/protocol/session.h" | 25 #include "remoting/protocol/session.h" |
23 #include "remoting/protocol/video_renderer.h" | 26 #include "remoting/protocol/video_renderer.h" |
24 | 27 |
25 NSString* const kHostSessionStatusChanged = @"kHostSessionStatusChanged"; | 28 NSString* const kHostSessionStatusChanged = @"kHostSessionStatusChanged"; |
26 NSString* const kHostSessionPinProvided = @"kHostSessionPinProvided"; | 29 NSString* const kHostSessionPinProvided = @"kHostSessionPinProvided"; |
27 | 30 |
28 NSString* const kSessionDetails = @"kSessionDetails"; | 31 NSString* const kSessionDetails = @"kSessionDetails"; |
29 NSString* const kSessonStateErrorCode = @"kSessonStateErrorCode"; | 32 NSString* const kSessonStateErrorCode = @"kSessonStateErrorCode"; |
30 NSString* const kHostSessionPin = @"kHostSessionPin"; | 33 NSString* const kHostSessionPin = @"kHostSessionPin"; |
31 | 34 |
32 @interface RemotingClient () { | 35 @interface RemotingClient () { |
33 remoting::ChromotingClientRuntime* _runtime; | 36 remoting::ChromotingClientRuntime* _runtime; |
34 std::unique_ptr<remoting::ChromotingSession> _session; | 37 std::unique_ptr<remoting::ChromotingSession> _session; |
35 remoting::RemotingClientSessonDelegate* _sessonDelegate; | 38 remoting::RemotingClientSessonDelegate* _sessonDelegate; |
36 ClientSessionDetails* _sessionDetails; | 39 ClientSessionDetails* _sessionDetails; |
37 // Call _secretFetchedCallback on the network thread. | 40 // Call _secretFetchedCallback on the network thread. |
38 remoting::protocol::SecretFetchedCallback _secretFetchedCallback; | 41 remoting::protocol::SecretFetchedCallback _secretFetchedCallback; |
| 42 std::unique_ptr<remoting::GestureInterpreter> _gestureInterpreter; |
39 } | 43 } |
40 @end | 44 @end |
41 | 45 |
42 @implementation RemotingClient | 46 @implementation RemotingClient |
43 | 47 |
44 @synthesize displayHandler = _displayHandler; | 48 @synthesize displayHandler = _displayHandler; |
45 | 49 |
46 - (instancetype)init { | 50 - (instancetype)init { |
47 self = [super init]; | 51 self = [super init]; |
48 if (self) { | 52 if (self) { |
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
101 object:self | 105 object:self |
102 userInfo:[NSDictionary | 106 userInfo:[NSDictionary |
103 dictionaryWithObject:_sessionDetails | 107 dictionaryWithObject:_sessionDetails |
104 forKey:kSessionDetails]]; | 108 forKey:kSessionDetails]]; |
105 }); | 109 }); |
106 | 110 |
107 // TODO(nicholss): Add audio support to iOS. | 111 // TODO(nicholss): Add audio support to iOS. |
108 base::WeakPtr<remoting::protocol::AudioStub> audioPlayer = nullptr; | 112 base::WeakPtr<remoting::protocol::AudioStub> audioPlayer = nullptr; |
109 | 113 |
110 _displayHandler = [[GlDisplayHandler alloc] init]; | 114 _displayHandler = [[GlDisplayHandler alloc] init]; |
| 115 _displayHandler.delegate = self; |
| 116 __weak GlDisplayHandler* weakDisplayHandler = _displayHandler; |
| 117 _gestureInterpreter.reset(new remoting::GestureInterpreter( |
| 118 base::BindBlockArc(^(const remoting::ViewMatrix& matrix) { |
| 119 [weakDisplayHandler onPixelTransformationChanged:matrix]; |
| 120 }))); |
111 | 121 |
112 _runtime->ui_task_runner()->PostTask( | 122 _runtime->ui_task_runner()->PostTask( |
113 FROM_HERE, base::BindBlockArc(^{ | 123 FROM_HERE, base::BindBlockArc(^{ |
114 _session.reset(new remoting::ChromotingSession( | 124 _session.reset(new remoting::ChromotingSession( |
115 _sessonDelegate->GetWeakPtr(), | 125 _sessonDelegate->GetWeakPtr(), |
116 [_displayHandler CreateCursorShapeStub], | 126 [_displayHandler CreateCursorShapeStub], |
117 [_displayHandler CreateVideoRenderer], audioPlayer, info, | 127 [_displayHandler CreateVideoRenderer], audioPlayer, info, |
118 client_auth_config)); | 128 client_auth_config)); |
119 _session->Connect(); | 129 _session->Connect(); |
120 })); | 130 })); |
(...skipping 10 matching lines...) Expand all Loading... |
131 })); | 141 })); |
132 } | 142 } |
133 } | 143 } |
134 | 144 |
135 #pragma mark - Properties | 145 #pragma mark - Properties |
136 | 146 |
137 - (HostInfo*)hostInfo { | 147 - (HostInfo*)hostInfo { |
138 return _sessionDetails.hostInfo; | 148 return _sessionDetails.hostInfo; |
139 } | 149 } |
140 | 150 |
| 151 - (remoting::GestureInterpreter*)gestureInterpreter { |
| 152 return _gestureInterpreter.get(); |
| 153 } |
| 154 |
141 #pragma mark - ChromotingSession::Delegate | 155 #pragma mark - ChromotingSession::Delegate |
142 | 156 |
143 - (void)onConnectionState:(remoting::protocol::ConnectionToHost::State)state | 157 - (void)onConnectionState:(remoting::protocol::ConnectionToHost::State)state |
144 error:(remoting::protocol::ErrorCode)error { | 158 error:(remoting::protocol::ErrorCode)error { |
145 switch (state) { | 159 switch (state) { |
146 case remoting::protocol::ConnectionToHost::INITIALIZING: | 160 case remoting::protocol::ConnectionToHost::INITIALIZING: |
147 NSLog(@"State --> INITIALIZING"); | 161 NSLog(@"State --> INITIALIZING"); |
148 _sessionDetails.state = SessionInitializing; | 162 _sessionDetails.state = SessionInitializing; |
149 break; | 163 break; |
150 case remoting::protocol::ConnectionToHost::CONNECTING: | 164 case remoting::protocol::ConnectionToHost::CONNECTING: |
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
194 - (void)setCapabilities:(NSString*)capabilities { | 208 - (void)setCapabilities:(NSString*)capabilities { |
195 NSLog(@"TODO(nicholss): implement this, setCapabilities."); | 209 NSLog(@"TODO(nicholss): implement this, setCapabilities."); |
196 } | 210 } |
197 | 211 |
198 - (void)handleExtensionMessageOfType:(NSString*)type | 212 - (void)handleExtensionMessageOfType:(NSString*)type |
199 message:(NSString*)message { | 213 message:(NSString*)message { |
200 NSLog(@"TODO(nicholss): implement this, handleExtensionMessageOfType %@:%@.", | 214 NSLog(@"TODO(nicholss): implement this, handleExtensionMessageOfType %@:%@.", |
201 type, message); | 215 type, message); |
202 } | 216 } |
203 | 217 |
| 218 - (void)surfaceChanged:(const CGRect&)frame { |
| 219 [_displayHandler onSurfaceChanged:frame]; |
| 220 _gestureInterpreter->OnSurfaceSizeChanged(frame.size.width, |
| 221 frame.size.height); |
| 222 } |
| 223 |
| 224 #pragma mark - GlDisplayHandlerDelegate |
| 225 |
| 226 - (void)canvasSizeChanged:(CGSize)size { |
| 227 if (_gestureInterpreter) { |
| 228 _gestureInterpreter->OnDesktopSizeChanged(size.width, size.height); |
| 229 } |
| 230 } |
| 231 |
204 @end | 232 @end |
OLD | NEW |