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 25 matching lines...) Expand all Loading... | |
| 36 SessionConfig result; | 36 SessionConfig result; |
| 37 result.set_control_config(ChannelConfig(ChannelConfig::TRANSPORT_STREAM, | 37 result.set_control_config(ChannelConfig(ChannelConfig::TRANSPORT_STREAM, |
| 38 kDefaultStreamVersion, | 38 kDefaultStreamVersion, |
| 39 ChannelConfig::CODEC_UNDEFINED)); | 39 ChannelConfig::CODEC_UNDEFINED)); |
| 40 result.set_event_config(ChannelConfig(ChannelConfig::TRANSPORT_STREAM, | 40 result.set_event_config(ChannelConfig(ChannelConfig::TRANSPORT_STREAM, |
| 41 kDefaultStreamVersion, | 41 kDefaultStreamVersion, |
| 42 ChannelConfig::CODEC_UNDEFINED)); | 42 ChannelConfig::CODEC_UNDEFINED)); |
| 43 result.set_video_config(ChannelConfig(ChannelConfig::TRANSPORT_STREAM, | 43 result.set_video_config(ChannelConfig(ChannelConfig::TRANSPORT_STREAM, |
| 44 kDefaultStreamVersion, | 44 kDefaultStreamVersion, |
| 45 ChannelConfig::CODEC_VP8)); | 45 ChannelConfig::CODEC_VP8)); |
| 46 result.set_audio_config(ChannelConfig(ChannelConfig::TRANSPORT_STREAM, | |
| 47 kDefaultStreamVersion, | |
| 48 ChannelConfig::CODEC_UNDEFINED)); | |
| 46 return result; | 49 return result; |
| 47 } | 50 } |
| 48 | 51 |
| 49 CandidateSessionConfig::CandidateSessionConfig() { } | 52 CandidateSessionConfig::CandidateSessionConfig() { } |
| 50 | 53 |
| 51 CandidateSessionConfig::CandidateSessionConfig( | 54 CandidateSessionConfig::CandidateSessionConfig( |
| 52 const CandidateSessionConfig& config) | 55 const CandidateSessionConfig& config) |
| 53 : control_configs_(config.control_configs_), | 56 : control_configs_(config.control_configs_), |
| 54 event_configs_(config.event_configs_), | 57 event_configs_(config.event_configs_), |
| 55 video_configs_(config.video_configs_) { | 58 video_configs_(config.video_configs_), |
| 59 audio_configs_(config.audio_configs_) { | |
| 56 } | 60 } |
| 57 | 61 |
| 58 CandidateSessionConfig::~CandidateSessionConfig() { } | 62 CandidateSessionConfig::~CandidateSessionConfig() { } |
| 59 | 63 |
| 60 bool CandidateSessionConfig::Select( | 64 bool CandidateSessionConfig::Select( |
| 61 const CandidateSessionConfig* client_config, | 65 const CandidateSessionConfig* client_config, |
| 62 SessionConfig* result) { | 66 SessionConfig* result) { |
| 63 ChannelConfig control_config; | 67 ChannelConfig control_config; |
| 64 ChannelConfig event_config; | 68 ChannelConfig event_config; |
| 65 ChannelConfig video_config; | 69 ChannelConfig video_config; |
| 70 ChannelConfig audio_config; | |
| 66 | 71 |
| 67 if (!SelectCommonChannelConfig( | 72 if (!SelectCommonChannelConfig( |
| 68 control_configs_, client_config->control_configs_, &control_config) || | 73 control_configs_, client_config->control_configs_, &control_config) || |
| 69 !SelectCommonChannelConfig( | 74 !SelectCommonChannelConfig( |
| 70 event_configs_, client_config->event_configs_, &event_config) || | 75 event_configs_, client_config->event_configs_, &event_config) || |
| 71 !SelectCommonChannelConfig( | 76 !SelectCommonChannelConfig( |
| 72 video_configs_, client_config->video_configs_, &video_config)) { | 77 video_configs_, client_config->video_configs_, &video_config) || |
| 78 !SelectCommonChannelConfig( | |
| 79 audio_configs_, client_config->audio_configs_, &audio_config)) { | |
| 73 return false; | 80 return false; |
| 74 } | 81 } |
| 75 | 82 |
| 76 result->set_control_config(control_config); | 83 result->set_control_config(control_config); |
| 77 result->set_event_config(event_config); | 84 result->set_event_config(event_config); |
| 78 result->set_video_config(video_config); | 85 result->set_video_config(video_config); |
| 86 result->set_audio_config(audio_config); | |
| 79 | 87 |
| 80 return true; | 88 return true; |
| 81 } | 89 } |
| 82 | 90 |
| 83 bool CandidateSessionConfig::IsSupported( | 91 bool CandidateSessionConfig::IsSupported( |
| 84 const SessionConfig& config) const { | 92 const SessionConfig& config) const { |
| 85 return | 93 return |
| 86 IsChannelConfigSupported(control_configs_, config.control_config()) && | 94 IsChannelConfigSupported(control_configs_, config.control_config()) && |
| 87 IsChannelConfigSupported(event_configs_, config.event_config()) && | 95 IsChannelConfigSupported(event_configs_, config.event_config()) && |
| 88 IsChannelConfigSupported(video_configs_, config.video_config()); | 96 IsChannelConfigSupported(video_configs_, config.video_config()) && |
| 97 IsChannelConfigSupported(audio_configs_, config.audio_config()); | |
| 89 } | 98 } |
| 90 | 99 |
| 91 bool CandidateSessionConfig::GetFinalConfig(SessionConfig* result) const { | 100 bool CandidateSessionConfig::GetFinalConfig(SessionConfig* result) const { |
| 92 if (control_configs_.size() != 1 || | 101 if (control_configs_.size() != 1 || |
| 93 event_configs_.size() != 1 || | 102 event_configs_.size() != 1 || |
| 94 video_configs_.size() != 1) { | 103 video_configs_.size() != 1 || |
| 104 audio_configs_.size() != 1) { | |
| 95 return false; | 105 return false; |
| 96 } | 106 } |
| 97 | 107 |
| 98 result->set_control_config(control_configs_.front()); | 108 result->set_control_config(control_configs_.front()); |
| 99 result->set_event_config(event_configs_.front()); | 109 result->set_event_config(event_configs_.front()); |
| 100 result->set_video_config(video_configs_.front()); | 110 result->set_video_config(video_configs_.front()); |
| 111 result->set_audio_config(audio_configs_.front()); | |
| 101 | 112 |
| 102 return true; | 113 return true; |
| 103 } | 114 } |
| 104 | 115 |
| 105 // static | 116 // static |
| 106 bool CandidateSessionConfig::SelectCommonChannelConfig( | 117 bool CandidateSessionConfig::SelectCommonChannelConfig( |
| 107 const std::vector<ChannelConfig>& host_configs, | 118 const std::vector<ChannelConfig>& host_configs, |
| 108 const std::vector<ChannelConfig>& client_configs, | 119 const std::vector<ChannelConfig>& client_configs, |
| 109 ChannelConfig* config) { | 120 ChannelConfig* config) { |
| 110 // Usually each of these vectors will contain just several elements, | 121 // Usually each of these vectors will contain just several elements, |
| (...skipping 24 matching lines...) Expand all Loading... | |
| 135 return scoped_ptr<CandidateSessionConfig>(new CandidateSessionConfig()); | 146 return scoped_ptr<CandidateSessionConfig>(new CandidateSessionConfig()); |
| 136 } | 147 } |
| 137 | 148 |
| 138 // static | 149 // static |
| 139 scoped_ptr<CandidateSessionConfig> CandidateSessionConfig::CreateFrom( | 150 scoped_ptr<CandidateSessionConfig> CandidateSessionConfig::CreateFrom( |
| 140 const SessionConfig& config) { | 151 const SessionConfig& config) { |
| 141 scoped_ptr<CandidateSessionConfig> result = CreateEmpty(); | 152 scoped_ptr<CandidateSessionConfig> result = CreateEmpty(); |
| 142 result->mutable_control_configs()->push_back(config.control_config()); | 153 result->mutable_control_configs()->push_back(config.control_config()); |
| 143 result->mutable_event_configs()->push_back(config.event_config()); | 154 result->mutable_event_configs()->push_back(config.event_config()); |
| 144 result->mutable_video_configs()->push_back(config.video_config()); | 155 result->mutable_video_configs()->push_back(config.video_config()); |
| 156 result->mutable_audio_configs()->push_back(config.audio_config()); | |
| 145 return result.Pass(); | 157 return result.Pass(); |
| 146 } | 158 } |
| 147 | 159 |
| 148 // static | 160 // static |
| 149 scoped_ptr<CandidateSessionConfig> CandidateSessionConfig::CreateDefault() { | 161 scoped_ptr<CandidateSessionConfig> CandidateSessionConfig::CreateDefault() { |
| 150 scoped_ptr<CandidateSessionConfig> result = CreateEmpty(); | 162 scoped_ptr<CandidateSessionConfig> result = CreateEmpty(); |
| 151 result->mutable_control_configs()->push_back( | 163 result->mutable_control_configs()->push_back( |
| 152 ChannelConfig(ChannelConfig::TRANSPORT_STREAM, | 164 ChannelConfig(ChannelConfig::TRANSPORT_STREAM, |
| 153 kDefaultStreamVersion, | 165 kDefaultStreamVersion, |
| 154 ChannelConfig::CODEC_UNDEFINED)); | 166 ChannelConfig::CODEC_UNDEFINED)); |
| 155 result->mutable_event_configs()->push_back( | 167 result->mutable_event_configs()->push_back( |
| 156 ChannelConfig(ChannelConfig::TRANSPORT_STREAM, | 168 ChannelConfig(ChannelConfig::TRANSPORT_STREAM, |
| 157 kDefaultStreamVersion, | 169 kDefaultStreamVersion, |
| 158 ChannelConfig::CODEC_UNDEFINED)); | 170 ChannelConfig::CODEC_UNDEFINED)); |
| 159 result->mutable_video_configs()->push_back( | 171 result->mutable_video_configs()->push_back( |
| 160 ChannelConfig(ChannelConfig::TRANSPORT_STREAM, | 172 ChannelConfig(ChannelConfig::TRANSPORT_STREAM, |
| 161 kDefaultStreamVersion, | 173 kDefaultStreamVersion, |
| 162 ChannelConfig::CODEC_VP8)); | 174 ChannelConfig::CODEC_VP8)); |
| 175 result->mutable_audio_configs()->push_back( | |
| 176 ChannelConfig(ChannelConfig::TRANSPORT_NONE, | |
| 177 kDefaultStreamVersion, | |
| 178 ChannelConfig::CODEC_UNDEFINED)); | |
| 179 result->mutable_audio_configs()->push_back( | |
| 180 ChannelConfig(ChannelConfig::TRANSPORT_STREAM, | |
| 181 kDefaultStreamVersion, | |
| 182 ChannelConfig::CODEC_UNDEFINED)); | |
|
Sergey Ulanov
2012/06/21 18:36:04
Also need to define codec? CODEC_VERBATIM for raw
kxing
2012/06/21 18:53:28
Done.
| |
| 163 return result.Pass(); | 183 return result.Pass(); |
| 164 } | 184 } |
| 165 | 185 |
| 166 } // namespace protocol | 186 } // namespace protocol |
| 167 } // namespace remoting | 187 } // namespace remoting |
| OLD | NEW |