Index: remoting/protocol/session_config.cc |
diff --git a/remoting/protocol/session_config.cc b/remoting/protocol/session_config.cc |
index 6fef6045eb1c2ae3ec21a6c562dd6ec1cdfd5963..c2b54e442056b4933794975bca0240a14268f63f 100644 |
--- a/remoting/protocol/session_config.cc |
+++ b/remoting/protocol/session_config.cc |
@@ -5,6 +5,7 @@ |
#include "remoting/protocol/session_config.h" |
#include <algorithm> |
+#include <vector> |
#include "base/logging.h" |
@@ -33,6 +34,19 @@ bool SelectCommonChannelConfig(const std::list<ChannelConfig>& host_configs, |
return false; |
} |
+void UpdateConfigListToPreferTransport(std::list<ChannelConfig>* configs, |
+ ChannelConfig::TransportType transport) { |
+ std::vector<ChannelConfig> sorted(configs->begin(), configs->end()); |
+ std::stable_sort(sorted.begin(), sorted.end(), |
+ [transport](const ChannelConfig& a, const ChannelConfig& b) { |
+ // |a| must precede |b| if |a| uses preferred transport and |
+ // |b| doesn't. |
+ return a.transport == transport && |
+ b.transport != transport; |
+ }); |
+ configs->assign(sorted.begin(), sorted.end()); |
+} |
+ |
} // namespace |
const int kDefaultStreamVersion = 2; |
@@ -122,13 +136,13 @@ scoped_ptr<SessionConfig> SessionConfig::GetFinalConfig( |
// static |
scoped_ptr<SessionConfig> SessionConfig::ForTest() { |
scoped_ptr<SessionConfig> result(new SessionConfig()); |
- result->control_config_ = ChannelConfig(ChannelConfig::TRANSPORT_MUX_STREAM, |
+ result->control_config_ = ChannelConfig(ChannelConfig::TRANSPORT_QUIC_STREAM, |
kControlStreamVersion, |
ChannelConfig::CODEC_UNDEFINED); |
- result->event_config_ = ChannelConfig(ChannelConfig::TRANSPORT_MUX_STREAM, |
+ result->event_config_ = ChannelConfig(ChannelConfig::TRANSPORT_QUIC_STREAM, |
kDefaultStreamVersion, |
ChannelConfig::CODEC_UNDEFINED); |
- result->video_config_ = ChannelConfig(ChannelConfig::TRANSPORT_STREAM, |
+ result->video_config_ = ChannelConfig(ChannelConfig::TRANSPORT_QUIC_STREAM, |
kDefaultStreamVersion, |
ChannelConfig::CODEC_VP8); |
result->audio_config_ = ChannelConfig(ChannelConfig::TRANSPORT_NONE, |
@@ -182,12 +196,20 @@ scoped_ptr<CandidateSessionConfig> CandidateSessionConfig::CreateDefault() { |
ChannelConfig(ChannelConfig::TRANSPORT_MUX_STREAM, |
kControlStreamVersion, |
ChannelConfig::CODEC_UNDEFINED)); |
+ result->mutable_control_configs()->push_back( |
+ ChannelConfig(ChannelConfig::TRANSPORT_QUIC_STREAM, |
+ kControlStreamVersion, |
+ ChannelConfig::CODEC_UNDEFINED)); |
// Event channel. |
result->mutable_event_configs()->push_back( |
ChannelConfig(ChannelConfig::TRANSPORT_MUX_STREAM, |
kDefaultStreamVersion, |
ChannelConfig::CODEC_UNDEFINED)); |
+ result->mutable_event_configs()->push_back( |
+ ChannelConfig(ChannelConfig::TRANSPORT_QUIC_STREAM, |
+ kDefaultStreamVersion, |
+ ChannelConfig::CODEC_UNDEFINED)); |
// Video channel. |
result->mutable_video_configs()->push_back( |
@@ -198,12 +220,24 @@ scoped_ptr<CandidateSessionConfig> CandidateSessionConfig::CreateDefault() { |
ChannelConfig(ChannelConfig::TRANSPORT_STREAM, |
kDefaultStreamVersion, |
ChannelConfig::CODEC_VP8)); |
+ result->mutable_video_configs()->push_back( |
+ ChannelConfig(ChannelConfig::TRANSPORT_QUIC_STREAM, |
+ kDefaultStreamVersion, |
+ ChannelConfig::CODEC_VP9)); |
+ result->mutable_video_configs()->push_back( |
+ ChannelConfig(ChannelConfig::TRANSPORT_QUIC_STREAM, |
+ kDefaultStreamVersion, |
+ ChannelConfig::CODEC_VP8)); |
// Audio channel. |
result->mutable_audio_configs()->push_back( |
ChannelConfig(ChannelConfig::TRANSPORT_MUX_STREAM, |
kDefaultStreamVersion, |
ChannelConfig::CODEC_OPUS)); |
+ result->mutable_audio_configs()->push_back( |
+ ChannelConfig(ChannelConfig::TRANSPORT_QUIC_STREAM, |
+ kDefaultStreamVersion, |
+ ChannelConfig::CODEC_OPUS)); |
result->mutable_audio_configs()->push_back(ChannelConfig::None()); |
return result.Pass(); |
@@ -214,5 +248,13 @@ void CandidateSessionConfig::DisableAudioChannel() { |
mutable_audio_configs()->push_back(ChannelConfig()); |
} |
+void CandidateSessionConfig::PreferTransport( |
+ ChannelConfig::TransportType transport) { |
+ UpdateConfigListToPreferTransport(&control_configs_, transport); |
+ UpdateConfigListToPreferTransport(&event_configs_, transport); |
+ UpdateConfigListToPreferTransport(&video_configs_, transport); |
+ UpdateConfigListToPreferTransport(&audio_configs_, transport); |
+} |
+ |
} // namespace protocol |
} // namespace remoting |