| 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 <string> | 8 #include <string> |
| 9 #include <vector> | 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. |
| 20 // Some channels (like video) may have multiple underlying sockets that need | 20 // Some channels (like video) may have multiple underlying sockets that need |
| 21 // to be configured simultaneously. | 21 // to be configured simultaneously. |
| 22 struct ChannelConfig { | 22 struct ChannelConfig { |
| 23 enum TransportType { | 23 enum TransportType { |
| 24 TRANSPORT_STREAM, | 24 TRANSPORT_STREAM, |
| 25 TRANSPORT_DATAGRAM, | 25 TRANSPORT_DATAGRAM, |
| 26 TRANSPORT_NONE, |
| 26 }; | 27 }; |
| 27 | 28 |
| 28 enum Codec { | 29 enum Codec { |
| 29 CODEC_UNDEFINED, // Used for event and control channels. | 30 CODEC_UNDEFINED, // Used for event and control channels. |
| 30 CODEC_VERBATIM, | 31 CODEC_VERBATIM, |
| 31 CODEC_ZIP, | 32 CODEC_ZIP, |
| 32 CODEC_VP8, | 33 CODEC_VP8, |
| 34 CODEC_VORBIS, |
| 33 }; | 35 }; |
| 34 | 36 |
| 35 ChannelConfig(); | 37 ChannelConfig(); |
| 36 ChannelConfig(TransportType transport, int version, Codec codec); | 38 ChannelConfig(TransportType transport, int version, Codec codec); |
| 37 | 39 |
| 38 // operator== is overloaded so that std::find() works with | 40 // operator== is overloaded so that std::find() works with |
| 39 // std::vector<ChannelConfig>. | 41 // std::vector<ChannelConfig>. |
| 40 bool operator==(const ChannelConfig& b) const; | 42 bool operator==(const ChannelConfig& b) const; |
| 41 | 43 |
| 42 void Reset(); | 44 void Reset(); |
| (...skipping 12 matching lines...) Expand all Loading... |
| 55 } | 57 } |
| 56 const ChannelConfig& control_config() const { return control_config_; } | 58 const ChannelConfig& control_config() const { return control_config_; } |
| 57 void set_event_config(const ChannelConfig& event_config) { | 59 void set_event_config(const ChannelConfig& event_config) { |
| 58 event_config_ = event_config; | 60 event_config_ = event_config; |
| 59 } | 61 } |
| 60 const ChannelConfig& event_config() const { return event_config_; } | 62 const ChannelConfig& event_config() const { return event_config_; } |
| 61 void set_video_config(const ChannelConfig& video_config) { | 63 void set_video_config(const ChannelConfig& video_config) { |
| 62 video_config_ = video_config; | 64 video_config_ = video_config; |
| 63 } | 65 } |
| 64 const ChannelConfig& video_config() const { return video_config_; } | 66 const ChannelConfig& video_config() const { return video_config_; } |
| 67 void set_audio_config(const ChannelConfig& audio_config) { |
| 68 audio_config_ = audio_config; |
| 69 } |
| 70 const ChannelConfig& audio_config() const { return audio_config_; } |
| 71 |
| 72 bool is_audio_enabled() const { |
| 73 return audio_config_.transport != ChannelConfig::TRANSPORT_NONE; |
| 74 } |
| 65 | 75 |
| 66 static SessionConfig GetDefault(); | 76 static SessionConfig GetDefault(); |
| 67 | 77 |
| 68 private: | 78 private: |
| 69 ChannelConfig control_config_; | 79 ChannelConfig control_config_; |
| 70 ChannelConfig event_config_; | 80 ChannelConfig event_config_; |
| 71 ChannelConfig video_config_; | 81 ChannelConfig video_config_; |
| 82 ChannelConfig audio_config_; |
| 72 }; | 83 }; |
| 73 | 84 |
| 74 // Defines session description that is sent from client to the host in the | 85 // Defines session description that is sent from client to the host in the |
| 75 // session-initiate message. It is different from the regular Config | 86 // session-initiate message. It is different from the regular Config |
| 76 // because it allows one to specify multiple configurations for each channel. | 87 // because it allows one to specify multiple configurations for each channel. |
| 77 class CandidateSessionConfig { | 88 class CandidateSessionConfig { |
| 78 public: | 89 public: |
| 79 ~CandidateSessionConfig(); | 90 ~CandidateSessionConfig(); |
| 80 | 91 |
| 81 const std::vector<ChannelConfig>& control_configs() const { | 92 const std::vector<ChannelConfig>& control_configs() const { |
| (...skipping 13 matching lines...) Expand all Loading... |
| 95 } | 106 } |
| 96 | 107 |
| 97 const std::vector<ChannelConfig>& video_configs() const { | 108 const std::vector<ChannelConfig>& video_configs() const { |
| 98 return video_configs_; | 109 return video_configs_; |
| 99 } | 110 } |
| 100 | 111 |
| 101 std::vector<ChannelConfig>* mutable_video_configs() { | 112 std::vector<ChannelConfig>* mutable_video_configs() { |
| 102 return &video_configs_; | 113 return &video_configs_; |
| 103 } | 114 } |
| 104 | 115 |
| 116 const std::vector<ChannelConfig>& audio_configs() const { |
| 117 return audio_configs_; |
| 118 } |
| 119 |
| 120 std::vector<ChannelConfig>* mutable_audio_configs() { |
| 121 return &audio_configs_; |
| 122 } |
| 123 |
| 105 // Selects session configuration that is supported by both participants. | 124 // Selects session configuration that is supported by both participants. |
| 106 // NULL is returned if such configuration doesn't exist. When selecting | 125 // NULL is returned if such configuration doesn't exist. When selecting |
| 107 // channel configuration priority is given to the configs listed first | 126 // channel configuration priority is given to the configs listed first |
| 108 // in |client_config|. | 127 // in |client_config|. |
| 109 bool Select(const CandidateSessionConfig* client_config, | 128 bool Select(const CandidateSessionConfig* client_config, |
| 110 SessionConfig* result); | 129 SessionConfig* result); |
| 111 | 130 |
| 112 // Returns true if |config| is supported. | 131 // Returns true if |config| is supported. |
| 113 bool IsSupported(const SessionConfig& config) const; | 132 bool IsSupported(const SessionConfig& config) const; |
| 114 | 133 |
| (...skipping 18 matching lines...) Expand all Loading... |
| 133 static bool SelectCommonChannelConfig( | 152 static bool SelectCommonChannelConfig( |
| 134 const std::vector<ChannelConfig>& host_configs_, | 153 const std::vector<ChannelConfig>& host_configs_, |
| 135 const std::vector<ChannelConfig>& client_configs_, | 154 const std::vector<ChannelConfig>& client_configs_, |
| 136 ChannelConfig* config); | 155 ChannelConfig* config); |
| 137 static bool IsChannelConfigSupported(const std::vector<ChannelConfig>& vector, | 156 static bool IsChannelConfigSupported(const std::vector<ChannelConfig>& vector, |
| 138 const ChannelConfig& value); | 157 const ChannelConfig& value); |
| 139 | 158 |
| 140 std::vector<ChannelConfig> control_configs_; | 159 std::vector<ChannelConfig> control_configs_; |
| 141 std::vector<ChannelConfig> event_configs_; | 160 std::vector<ChannelConfig> event_configs_; |
| 142 std::vector<ChannelConfig> video_configs_; | 161 std::vector<ChannelConfig> video_configs_; |
| 162 std::vector<ChannelConfig> audio_configs_; |
| 143 }; | 163 }; |
| 144 | 164 |
| 145 } // namespace protocol | 165 } // namespace protocol |
| 146 } // namespace remoting | 166 } // namespace remoting |
| 147 | 167 |
| 148 #endif // REMOTING_PROTOCOL_SESSION_CONFIG_H_ | 168 #endif // REMOTING_PROTOCOL_SESSION_CONFIG_H_ |
| OLD | NEW |