OLD | NEW |
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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_SESSION_CONFIG_H_ | 5 #ifndef REMOTING_PROTOCOL_SESSION_CONFIG_H_ |
6 #define REMOTING_PROTOCOL_SESSION_CONFIG_H_ | 6 #define REMOTING_PROTOCOL_SESSION_CONFIG_H_ |
7 | 7 |
8 #include <string> | 8 #include <string> |
9 #include <vector> | 9 #include <vector> |
10 | 10 |
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
54 bool IsValid() const; | 54 bool IsValid() const; |
55 | 55 |
56 int width; | 56 int width; |
57 int height; | 57 int height; |
58 }; | 58 }; |
59 | 59 |
60 // SessionConfig is used by the chromoting Session to store negotiated | 60 // SessionConfig is used by the chromoting Session to store negotiated |
61 // chromotocol configuration. | 61 // chromotocol configuration. |
62 class SessionConfig { | 62 class SessionConfig { |
63 public: | 63 public: |
| 64 SessionConfig(); |
64 ~SessionConfig(); | 65 ~SessionConfig(); |
65 | 66 |
66 const ChannelConfig& control_config() const { return control_config_; } | 67 const ChannelConfig& control_config() const { return control_config_; } |
67 const ChannelConfig& event_config() const { return event_config_; } | 68 const ChannelConfig& event_config() const { return event_config_; } |
68 const ChannelConfig& video_config() const { return video_config_; } | 69 const ChannelConfig& video_config() const { return video_config_; } |
69 const ScreenResolution& initial_resolution() const { | 70 const ScreenResolution& initial_resolution() const { |
70 return initial_resolution_; | 71 return initial_resolution_; |
71 } | 72 } |
72 | 73 |
73 void SetControlConfig(const ChannelConfig& control_config); | 74 void SetControlConfig(const ChannelConfig& control_config); |
74 void SetEventConfig(const ChannelConfig& event_config); | 75 void SetEventConfig(const ChannelConfig& event_config); |
75 void SetVideoConfig(const ChannelConfig& video_config); | 76 void SetVideoConfig(const ChannelConfig& video_config); |
76 void SetInitialResolution(const ScreenResolution& initial_resolution); | 77 void SetInitialResolution(const ScreenResolution& initial_resolution); |
77 | 78 |
78 SessionConfig* Clone() const; | 79 static SessionConfig GetDefault(); |
79 | |
80 static SessionConfig* CreateDefault(); | |
81 | 80 |
82 private: | 81 private: |
83 SessionConfig(); | |
84 explicit SessionConfig(const SessionConfig& config); | |
85 SessionConfig& operator=(const SessionConfig& b); | |
86 | |
87 ChannelConfig control_config_; | 82 ChannelConfig control_config_; |
88 ChannelConfig event_config_; | 83 ChannelConfig event_config_; |
89 ChannelConfig video_config_; | 84 ChannelConfig video_config_; |
90 ScreenResolution initial_resolution_; | 85 ScreenResolution initial_resolution_; |
91 }; | 86 }; |
92 | 87 |
93 // Defines session description that is sent from client to the host in the | 88 // Defines session description that is sent from client to the host in the |
94 // session-initiate message. It is different from the regular Config | 89 // session-initiate message. It is different from the regular Config |
95 // because it allows one to specify multiple configurations for each channel. | 90 // because it allows one to specify multiple configurations for each channel. |
96 class CandidateSessionConfig { | 91 class CandidateSessionConfig { |
(...skipping 29 matching lines...) Expand all Loading... |
126 } | 121 } |
127 | 122 |
128 ScreenResolution* mutable_initial_resolution() { | 123 ScreenResolution* mutable_initial_resolution() { |
129 return &initial_resolution_; | 124 return &initial_resolution_; |
130 } | 125 } |
131 | 126 |
132 // Selects session configuration that is supported by both participants. | 127 // Selects session configuration that is supported by both participants. |
133 // NULL is returned if such configuration doesn't exist. When selecting | 128 // NULL is returned if such configuration doesn't exist. When selecting |
134 // channel configuration priority is given to the configs listed first | 129 // channel configuration priority is given to the configs listed first |
135 // in |client_config|. | 130 // in |client_config|. |
136 SessionConfig* Select(const CandidateSessionConfig* client_config, | 131 bool Select(const CandidateSessionConfig* client_config, |
137 bool force_host_resolution); | 132 bool force_host_resolution, |
| 133 SessionConfig* result); |
138 | 134 |
139 // Returns true if |config| is supported. | 135 // Returns true if |config| is supported. |
140 bool IsSupported(const SessionConfig* config) const; | 136 bool IsSupported(const SessionConfig& config) const; |
141 | 137 |
142 // Extracts final protocol configuration. Must be used for the description | 138 // Extracts final protocol configuration. Must be used for the description |
143 // received in the session-accept stanza. If the selection is ambiguous | 139 // received in the session-accept stanza. If the selection is ambiguous |
144 // (e.g. there is more than one configuration for one of the channel) | 140 // (e.g. there is more than one configuration for one of the channel) |
145 // or undefined (e.g. no configurations for a channel) then NULL is returned. | 141 // or undefined (e.g. no configurations for a channel) then NULL is returned. |
146 SessionConfig* GetFinalConfig() const; | 142 bool GetFinalConfig(SessionConfig* result) const; |
147 | 143 |
148 CandidateSessionConfig* Clone() const; | 144 CandidateSessionConfig* Clone() const; |
149 | 145 |
150 static CandidateSessionConfig* CreateEmpty(); | 146 static CandidateSessionConfig* CreateEmpty(); |
151 static CandidateSessionConfig* CreateFrom(const SessionConfig* config); | 147 static CandidateSessionConfig* CreateFrom(const SessionConfig& config); |
152 static CandidateSessionConfig* CreateDefault(); | 148 static CandidateSessionConfig* CreateDefault(); |
153 | 149 |
154 private: | 150 private: |
155 CandidateSessionConfig(); | 151 CandidateSessionConfig(); |
156 explicit CandidateSessionConfig(const CandidateSessionConfig& config); | 152 explicit CandidateSessionConfig(const CandidateSessionConfig& config); |
157 CandidateSessionConfig& operator=(const CandidateSessionConfig& b); | 153 CandidateSessionConfig& operator=(const CandidateSessionConfig& b); |
158 | 154 |
159 static bool SelectCommonChannelConfig( | 155 static bool SelectCommonChannelConfig( |
160 const std::vector<ChannelConfig>& host_configs_, | 156 const std::vector<ChannelConfig>& host_configs_, |
161 const std::vector<ChannelConfig>& client_configs_, | 157 const std::vector<ChannelConfig>& client_configs_, |
162 ChannelConfig* config); | 158 ChannelConfig* config); |
163 static bool IsChannelConfigSupported(const std::vector<ChannelConfig>& vector, | 159 static bool IsChannelConfigSupported(const std::vector<ChannelConfig>& vector, |
164 const ChannelConfig& value); | 160 const ChannelConfig& value); |
165 | 161 |
166 std::vector<ChannelConfig> control_configs_; | 162 std::vector<ChannelConfig> control_configs_; |
167 std::vector<ChannelConfig> event_configs_; | 163 std::vector<ChannelConfig> event_configs_; |
168 std::vector<ChannelConfig> video_configs_; | 164 std::vector<ChannelConfig> video_configs_; |
169 | 165 |
170 ScreenResolution initial_resolution_; | 166 ScreenResolution initial_resolution_; |
171 }; | 167 }; |
172 | 168 |
173 } // namespace protocol | 169 } // namespace protocol |
174 } // namespace remoting | 170 } // namespace remoting |
175 | 171 |
176 #endif // REMOTING_PROTOCOL_SESSION_CONFIG_H_ | 172 #endif // REMOTING_PROTOCOL_SESSION_CONFIG_H_ |
OLD | NEW |