Chromium Code Reviews| 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 #include "remoting/protocol/session_config.h" | 5 #include "remoting/protocol/session_config.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 | 8 |
| 9 namespace remoting { | 9 namespace remoting { |
| 10 namespace protocol { | 10 namespace protocol { |
| (...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 122 result->set_control_config(control_configs_.front()); | 122 result->set_control_config(control_configs_.front()); |
| 123 result->set_event_config(event_configs_.front()); | 123 result->set_event_config(event_configs_.front()); |
| 124 result->set_video_config(video_configs_.front()); | 124 result->set_video_config(video_configs_.front()); |
| 125 result->set_audio_config(audio_configs_.front()); | 125 result->set_audio_config(audio_configs_.front()); |
| 126 | 126 |
| 127 return true; | 127 return true; |
| 128 } | 128 } |
| 129 | 129 |
| 130 // static | 130 // static |
| 131 bool CandidateSessionConfig::SelectCommonChannelConfig( | 131 bool CandidateSessionConfig::SelectCommonChannelConfig( |
| 132 const std::vector<ChannelConfig>& host_configs, | 132 const std::list<ChannelConfig>& host_configs, |
| 133 const std::vector<ChannelConfig>& client_configs, | 133 const std::list<ChannelConfig>& client_configs, |
| 134 ChannelConfig* config) { | 134 ChannelConfig* config) { |
| 135 // Usually each of these vectors will contain just several elements, | 135 // Usually each of these vectors will contain just several elements, |
| 136 // so iterating over all of them is not a problem. | 136 // so iterating over all of them is not a problem. |
| 137 std::vector<ChannelConfig>::const_iterator it; | 137 std::list<ChannelConfig>::const_iterator it; |
| 138 for (it = client_configs.begin(); it != client_configs.end(); ++it) { | 138 for (it = client_configs.begin(); it != client_configs.end(); ++it) { |
| 139 if (IsChannelConfigSupported(host_configs, *it)) { | 139 if (IsChannelConfigSupported(host_configs, *it)) { |
| 140 *config = *it; | 140 *config = *it; |
| 141 return true; | 141 return true; |
| 142 } | 142 } |
| 143 } | 143 } |
| 144 return false; | 144 return false; |
| 145 } | 145 } |
| 146 | 146 |
| 147 // static | 147 // static |
| 148 bool CandidateSessionConfig::IsChannelConfigSupported( | 148 bool CandidateSessionConfig::IsChannelConfigSupported( |
| 149 const std::vector<ChannelConfig>& vector, | 149 const std::list<ChannelConfig>& vector, |
| 150 const ChannelConfig& value) { | 150 const ChannelConfig& value) { |
| 151 return std::find(vector.begin(), vector.end(), value) != vector.end(); | 151 return std::find(vector.begin(), vector.end(), value) != vector.end(); |
| 152 } | 152 } |
| 153 | 153 |
| 154 scoped_ptr<CandidateSessionConfig> CandidateSessionConfig::Clone() const { | 154 scoped_ptr<CandidateSessionConfig> CandidateSessionConfig::Clone() const { |
| 155 return scoped_ptr<CandidateSessionConfig>(new CandidateSessionConfig(*this)); | 155 return scoped_ptr<CandidateSessionConfig>(new CandidateSessionConfig(*this)); |
| 156 } | 156 } |
| 157 | 157 |
| 158 // static | 158 // static |
| 159 scoped_ptr<CandidateSessionConfig> CandidateSessionConfig::CreateEmpty() { | 159 scoped_ptr<CandidateSessionConfig> CandidateSessionConfig::CreateEmpty() { |
| (...skipping 28 matching lines...) Expand all Loading... | |
| 188 // Event channel. | 188 // Event channel. |
| 189 result->mutable_event_configs()->push_back( | 189 result->mutable_event_configs()->push_back( |
| 190 ChannelConfig(ChannelConfig::TRANSPORT_MUX_STREAM, | 190 ChannelConfig(ChannelConfig::TRANSPORT_MUX_STREAM, |
| 191 kDefaultStreamVersion, | 191 kDefaultStreamVersion, |
| 192 ChannelConfig::CODEC_UNDEFINED)); | 192 ChannelConfig::CODEC_UNDEFINED)); |
| 193 | 193 |
| 194 // Video channel. | 194 // Video channel. |
| 195 result->mutable_video_configs()->push_back( | 195 result->mutable_video_configs()->push_back( |
| 196 ChannelConfig(ChannelConfig::TRANSPORT_STREAM, | 196 ChannelConfig(ChannelConfig::TRANSPORT_STREAM, |
| 197 kDefaultStreamVersion, | 197 kDefaultStreamVersion, |
| 198 ChannelConfig::CODEC_VP9)); | |
| 199 result->mutable_video_configs()->push_back( | |
| 200 ChannelConfig(ChannelConfig::TRANSPORT_STREAM, | |
| 201 kDefaultStreamVersion, | |
| 202 ChannelConfig::CODEC_VP8)); | 198 ChannelConfig::CODEC_VP8)); |
| 203 | 199 |
| 204 // Audio channel. | 200 // Audio channel. |
| 205 result->mutable_audio_configs()->push_back( | 201 result->mutable_audio_configs()->push_back( |
| 206 ChannelConfig(ChannelConfig::TRANSPORT_MUX_STREAM, | 202 ChannelConfig(ChannelConfig::TRANSPORT_MUX_STREAM, |
| 207 kDefaultStreamVersion, | 203 kDefaultStreamVersion, |
| 208 ChannelConfig::CODEC_OPUS)); | 204 ChannelConfig::CODEC_OPUS)); |
| 209 result->mutable_audio_configs()->push_back(ChannelConfig::None()); | 205 result->mutable_audio_configs()->push_back(ChannelConfig::None()); |
| 210 | 206 |
| 211 return result.Pass(); | 207 return result.Pass(); |
| 212 } | 208 } |
| 213 | 209 |
| 214 // static | 210 void CandidateSessionConfig::DisableAudioChannel() { |
| 215 void CandidateSessionConfig::DisableAudioChannel( | 211 mutable_audio_configs()->clear(); |
| 216 CandidateSessionConfig* config) { | 212 mutable_audio_configs()->push_back(ChannelConfig()); |
| 217 config->mutable_audio_configs()->clear(); | |
| 218 config->mutable_audio_configs()->push_back(ChannelConfig()); | |
| 219 } | 213 } |
| 220 | 214 |
| 221 // static | 215 void CandidateSessionConfig::EnableVideoCodec(ChannelConfig::Codec codec) { |
| 222 void CandidateSessionConfig::DisableVideoCodec( | 216 mutable_video_configs()->push_front( |
| 223 CandidateSessionConfig* config, | 217 ChannelConfig(ChannelConfig::TRANSPORT_STREAM, |
| 224 ChannelConfig::Codec codec) { | 218 kDefaultStreamVersion, |
| 225 std ::vector<ChannelConfig>::iterator i; | 219 ChannelConfig::CODEC_VP9)); |
|
Sergey Ulanov
2014/05/22 18:05:06
I think you want to pass |codec| here instead of C
Wez
2014/05/22 18:17:54
D'oh! Thanks for the catch. :D
| |
| 226 for (i = config->mutable_video_configs()->begin(); | |
| 227 i != config->mutable_video_configs()->end();) { | |
| 228 if (i->codec == codec) { | |
| 229 i = config->mutable_video_configs()->erase(i); | |
| 230 } else { | |
| 231 ++i; | |
| 232 } | |
| 233 } | |
| 234 } | 220 } |
| 235 | 221 |
| 236 } // namespace protocol | 222 } // namespace protocol |
| 237 } // namespace remoting | 223 } // namespace remoting |
| OLD | NEW |