OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 <list> |
8 #include <string> | 9 #include <string> |
9 #include <vector> | |
10 | 10 |
11 #include "base/basictypes.h" | 11 #include "base/basictypes.h" |
12 #include "base/memory/scoped_ptr.h" | 12 #include "base/memory/scoped_ptr.h" |
13 | 13 |
14 namespace remoting { | 14 namespace remoting { |
15 namespace protocol { | 15 namespace protocol { |
16 | 16 |
17 extern const int kDefaultStreamVersion; | 17 extern const int kDefaultStreamVersion; |
18 | 18 |
19 // Struct for configuration parameters of a single channel. | 19 // Struct for configuration parameters of a single channel. |
(...skipping 21 matching lines...) Expand all Loading... |
41 // that corresponding channel is disabled. | 41 // that corresponding channel is disabled. |
42 static ChannelConfig None(); | 42 static ChannelConfig None(); |
43 | 43 |
44 // Default constructor. Equivalent to None(). | 44 // Default constructor. Equivalent to None(). |
45 ChannelConfig(); | 45 ChannelConfig(); |
46 | 46 |
47 // Creates a channel config with the specified parameters. | 47 // Creates a channel config with the specified parameters. |
48 ChannelConfig(TransportType transport, int version, Codec codec); | 48 ChannelConfig(TransportType transport, int version, Codec codec); |
49 | 49 |
50 // operator== is overloaded so that std::find() works with | 50 // operator== is overloaded so that std::find() works with |
51 // std::vector<ChannelConfig>. | 51 // std::list<ChannelConfig>. |
52 bool operator==(const ChannelConfig& b) const; | 52 bool operator==(const ChannelConfig& b) const; |
53 | 53 |
54 TransportType transport; | 54 TransportType transport; |
55 int version; | 55 int version; |
56 Codec codec; | 56 Codec codec; |
57 }; | 57 }; |
58 | 58 |
59 // SessionConfig is used by the chromoting Session to store negotiated | 59 // SessionConfig is used by the chromoting Session to store negotiated |
60 // chromotocol configuration. | 60 // chromotocol configuration. |
61 class SessionConfig { | 61 class SessionConfig { |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
94 ChannelConfig event_config_; | 94 ChannelConfig event_config_; |
95 ChannelConfig video_config_; | 95 ChannelConfig video_config_; |
96 ChannelConfig audio_config_; | 96 ChannelConfig audio_config_; |
97 }; | 97 }; |
98 | 98 |
99 // Defines session description that is sent from client to the host in the | 99 // Defines session description that is sent from client to the host in the |
100 // session-initiate message. It is different from the regular Config | 100 // session-initiate message. It is different from the regular Config |
101 // because it allows one to specify multiple configurations for each channel. | 101 // because it allows one to specify multiple configurations for each channel. |
102 class CandidateSessionConfig { | 102 class CandidateSessionConfig { |
103 public: | 103 public: |
| 104 static scoped_ptr<CandidateSessionConfig> CreateEmpty(); |
| 105 static scoped_ptr<CandidateSessionConfig> CreateFrom( |
| 106 const SessionConfig& config); |
| 107 static scoped_ptr<CandidateSessionConfig> CreateDefault(); |
| 108 |
104 ~CandidateSessionConfig(); | 109 ~CandidateSessionConfig(); |
105 | 110 |
106 const std::vector<ChannelConfig>& control_configs() const { | 111 const std::list<ChannelConfig>& control_configs() const { |
107 return control_configs_; | 112 return control_configs_; |
108 } | 113 } |
109 | 114 |
110 std::vector<ChannelConfig>* mutable_control_configs() { | 115 std::list<ChannelConfig>* mutable_control_configs() { |
111 return &control_configs_; | 116 return &control_configs_; |
112 } | 117 } |
113 | 118 |
114 const std::vector<ChannelConfig>& event_configs() const { | 119 const std::list<ChannelConfig>& event_configs() const { |
115 return event_configs_; | 120 return event_configs_; |
116 } | 121 } |
117 | 122 |
118 std::vector<ChannelConfig>* mutable_event_configs() { | 123 std::list<ChannelConfig>* mutable_event_configs() { |
119 return &event_configs_; | 124 return &event_configs_; |
120 } | 125 } |
121 | 126 |
122 const std::vector<ChannelConfig>& video_configs() const { | 127 const std::list<ChannelConfig>& video_configs() const { |
123 return video_configs_; | 128 return video_configs_; |
124 } | 129 } |
125 | 130 |
126 std::vector<ChannelConfig>* mutable_video_configs() { | 131 std::list<ChannelConfig>* mutable_video_configs() { |
127 return &video_configs_; | 132 return &video_configs_; |
128 } | 133 } |
129 | 134 |
130 const std::vector<ChannelConfig>& audio_configs() const { | 135 const std::list<ChannelConfig>& audio_configs() const { |
131 return audio_configs_; | 136 return audio_configs_; |
132 } | 137 } |
133 | 138 |
134 std::vector<ChannelConfig>* mutable_audio_configs() { | 139 std::list<ChannelConfig>* mutable_audio_configs() { |
135 return &audio_configs_; | 140 return &audio_configs_; |
136 } | 141 } |
137 | 142 |
138 // Selects session configuration that is supported by both participants. | 143 // Selects session configuration that is supported by both participants. |
139 // NULL is returned if such configuration doesn't exist. When selecting | 144 // NULL is returned if such configuration doesn't exist. When selecting |
140 // channel configuration priority is given to the configs listed first | 145 // channel configuration priority is given to the configs listed first |
141 // in |client_config|. | 146 // in |client_config|. |
142 bool Select(const CandidateSessionConfig* client_config, | 147 bool Select(const CandidateSessionConfig* client_config, |
143 SessionConfig* result); | 148 SessionConfig* result); |
144 | 149 |
145 // Returns true if |config| is supported. | 150 // Returns true if |config| is supported. |
146 bool IsSupported(const SessionConfig& config) const; | 151 bool IsSupported(const SessionConfig& config) const; |
147 | 152 |
148 // Extracts final protocol configuration. Must be used for the description | 153 // Extracts final protocol configuration. Must be used for the description |
149 // received in the session-accept stanza. If the selection is ambiguous | 154 // received in the session-accept stanza. If the selection is ambiguous |
150 // (e.g. there is more than one configuration for one of the channel) | 155 // (e.g. there is more than one configuration for one of the channel) |
151 // or undefined (e.g. no configurations for a channel) then NULL is returned. | 156 // or undefined (e.g. no configurations for a channel) then NULL is returned. |
152 bool GetFinalConfig(SessionConfig* result) const; | 157 bool GetFinalConfig(SessionConfig* result) const; |
153 | 158 |
154 scoped_ptr<CandidateSessionConfig> Clone() const; | 159 scoped_ptr<CandidateSessionConfig> Clone() const; |
155 | 160 |
156 static scoped_ptr<CandidateSessionConfig> CreateEmpty(); | 161 // Helpers for enabling/disabling specific features. |
157 static scoped_ptr<CandidateSessionConfig> CreateFrom( | 162 void DisableAudioChannel(); |
158 const SessionConfig& config); | 163 void EnableVideoCodec(ChannelConfig::Codec codec); |
159 static scoped_ptr<CandidateSessionConfig> CreateDefault(); | |
160 | |
161 // Modifies |config| to disable specific features. | |
162 static void DisableAudioChannel(CandidateSessionConfig* config); | |
163 static void DisableVideoCodec(CandidateSessionConfig* config, | |
164 ChannelConfig::Codec codec); | |
165 | 164 |
166 private: | 165 private: |
167 CandidateSessionConfig(); | 166 CandidateSessionConfig(); |
168 explicit CandidateSessionConfig(const CandidateSessionConfig& config); | 167 explicit CandidateSessionConfig(const CandidateSessionConfig& config); |
169 CandidateSessionConfig& operator=(const CandidateSessionConfig& b); | 168 CandidateSessionConfig& operator=(const CandidateSessionConfig& b); |
170 | 169 |
171 static bool SelectCommonChannelConfig( | 170 static bool SelectCommonChannelConfig( |
172 const std::vector<ChannelConfig>& host_configs_, | 171 const std::list<ChannelConfig>& host_configs_, |
173 const std::vector<ChannelConfig>& client_configs_, | 172 const std::list<ChannelConfig>& client_configs_, |
174 ChannelConfig* config); | 173 ChannelConfig* config); |
175 static bool IsChannelConfigSupported(const std::vector<ChannelConfig>& vector, | 174 static bool IsChannelConfigSupported(const std::list<ChannelConfig>& list, |
176 const ChannelConfig& value); | 175 const ChannelConfig& value); |
177 | 176 |
178 std::vector<ChannelConfig> control_configs_; | 177 std::list<ChannelConfig> control_configs_; |
179 std::vector<ChannelConfig> event_configs_; | 178 std::list<ChannelConfig> event_configs_; |
180 std::vector<ChannelConfig> video_configs_; | 179 std::list<ChannelConfig> video_configs_; |
181 std::vector<ChannelConfig> audio_configs_; | 180 std::list<ChannelConfig> audio_configs_; |
182 }; | 181 }; |
183 | 182 |
184 } // namespace protocol | 183 } // namespace protocol |
185 } // namespace remoting | 184 } // namespace remoting |
186 | 185 |
187 #endif // REMOTING_PROTOCOL_SESSION_CONFIG_H_ | 186 #endif // REMOTING_PROTOCOL_SESSION_CONFIG_H_ |
OLD | NEW |