OLD | NEW |
1 /* | 1 /* |
2 * Copyright (c) 2004 The WebRTC project authors. All Rights Reserved. | 2 * Copyright (c) 2004 The WebRTC project authors. All Rights Reserved. |
3 * | 3 * |
4 * Use of this source code is governed by a BSD-style license | 4 * Use of this source code is governed by a BSD-style license |
5 * that can be found in the LICENSE file in the root of the source | 5 * that can be found in the LICENSE file in the root of the source |
6 * tree. An additional intellectual property rights grant can be found | 6 * tree. An additional intellectual property rights grant can be found |
7 * in the file PATENTS. All contributing project authors may | 7 * in the file PATENTS. All contributing project authors may |
8 * be found in the AUTHORS file in the root of the source tree. | 8 * be found in the AUTHORS file in the root of the source tree. |
9 */ | 9 */ |
10 | 10 |
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
70 } | 70 } |
71 return false; | 71 return false; |
72 } | 72 } |
73 | 73 |
74 Codec::Codec(int id, const std::string& name, int clockrate) | 74 Codec::Codec(int id, const std::string& name, int clockrate) |
75 : id(id), name(name), clockrate(clockrate) {} | 75 : id(id), name(name), clockrate(clockrate) {} |
76 | 76 |
77 Codec::Codec() : id(0), clockrate(0) {} | 77 Codec::Codec() : id(0), clockrate(0) {} |
78 | 78 |
79 Codec::Codec(const Codec& c) = default; | 79 Codec::Codec(const Codec& c) = default; |
80 | 80 Codec::Codec(Codec&& c) = default; |
81 Codec::~Codec() = default; | 81 Codec::~Codec() = default; |
82 | 82 Codec& Codec::operator=(const Codec& c) = default; |
83 Codec& Codec::operator=(const Codec& c) { | 83 Codec& Codec::operator=(Codec&& c) = default; |
84 this->id = c.id; // id is reserved in objective-c | |
85 name = c.name; | |
86 clockrate = c.clockrate; | |
87 params = c.params; | |
88 feedback_params = c.feedback_params; | |
89 return *this; | |
90 } | |
91 | 84 |
92 bool Codec::operator==(const Codec& c) const { | 85 bool Codec::operator==(const Codec& c) const { |
93 return this->id == c.id && // id is reserved in objective-c | 86 return this->id == c.id && // id is reserved in objective-c |
94 name == c.name && clockrate == c.clockrate && params == c.params && | 87 name == c.name && clockrate == c.clockrate && params == c.params && |
95 feedback_params == c.feedback_params; | 88 feedback_params == c.feedback_params; |
96 } | 89 } |
97 | 90 |
98 bool Codec::Matches(const Codec& codec) const { | 91 bool Codec::Matches(const Codec& codec) const { |
99 // Match the codec id/name based on the typical static/dynamic name rules. | 92 // Match the codec id/name based on the typical static/dynamic name rules. |
100 // Matching is case-insensitive. | 93 // Matching is case-insensitive. |
101 const int kMaxStaticPayloadId = 95; | 94 const int kMaxStaticPayloadId = 95; |
102 return (codec.id <= kMaxStaticPayloadId) ? | 95 return (id <= kMaxStaticPayloadId || codec.id <= kMaxStaticPayloadId) |
103 (id == codec.id) : (_stricmp(name.c_str(), codec.name.c_str()) == 0); | 96 ? (id == codec.id) |
| 97 : (_stricmp(name.c_str(), codec.name.c_str()) == 0); |
104 } | 98 } |
105 | 99 |
106 bool Codec::GetParam(const std::string& name, std::string* out) const { | 100 bool Codec::GetParam(const std::string& name, std::string* out) const { |
107 CodecParameterMap::const_iterator iter = params.find(name); | 101 CodecParameterMap::const_iterator iter = params.find(name); |
108 if (iter == params.end()) | 102 if (iter == params.end()) |
109 return false; | 103 return false; |
110 *out = iter->second; | 104 *out = iter->second; |
111 return true; | 105 return true; |
112 } | 106 } |
113 | 107 |
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
154 const std::string& name, | 148 const std::string& name, |
155 int clockrate, | 149 int clockrate, |
156 int bitrate, | 150 int bitrate, |
157 size_t channels) | 151 size_t channels) |
158 : Codec(id, name, clockrate), bitrate(bitrate), channels(channels) {} | 152 : Codec(id, name, clockrate), bitrate(bitrate), channels(channels) {} |
159 | 153 |
160 AudioCodec::AudioCodec() : Codec(), bitrate(0), channels(0) { | 154 AudioCodec::AudioCodec() : Codec(), bitrate(0), channels(0) { |
161 } | 155 } |
162 | 156 |
163 AudioCodec::AudioCodec(const AudioCodec& c) = default; | 157 AudioCodec::AudioCodec(const AudioCodec& c) = default; |
164 | 158 AudioCodec::AudioCodec(AudioCodec&& c) = default; |
165 AudioCodec& AudioCodec::operator=(const AudioCodec& c) { | 159 AudioCodec& AudioCodec::operator=(const AudioCodec& c) = default; |
166 Codec::operator=(c); | 160 AudioCodec& AudioCodec::operator=(AudioCodec&& c) = default; |
167 bitrate = c.bitrate; | |
168 channels = c.channels; | |
169 return *this; | |
170 } | |
171 | 161 |
172 bool AudioCodec::operator==(const AudioCodec& c) const { | 162 bool AudioCodec::operator==(const AudioCodec& c) const { |
173 return bitrate == c.bitrate && channels == c.channels && Codec::operator==(c); | 163 return bitrate == c.bitrate && channels == c.channels && Codec::operator==(c); |
174 } | 164 } |
175 | 165 |
176 bool AudioCodec::Matches(const AudioCodec& codec) const { | 166 bool AudioCodec::Matches(const AudioCodec& codec) const { |
177 // If a nonzero clockrate is specified, it must match the actual clockrate. | 167 // If a nonzero clockrate is specified, it must match the actual clockrate. |
178 // If a nonzero bitrate is specified, it must match the actual bitrate, | 168 // If a nonzero bitrate is specified, it must match the actual bitrate, |
179 // unless the codec is VBR (0), where we just force the supplied value. | 169 // unless the codec is VBR (0), where we just force the supplied value. |
180 // The number of channels must match exactly, with the exception | 170 // The number of channels must match exactly, with the exception |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
213 : Codec(id, name, kVideoCodecClockrate) {} | 203 : Codec(id, name, kVideoCodecClockrate) {} |
214 | 204 |
215 VideoCodec::VideoCodec(const std::string& name) | 205 VideoCodec::VideoCodec(const std::string& name) |
216 : VideoCodec(0 /* id */, name) {} | 206 : VideoCodec(0 /* id */, name) {} |
217 | 207 |
218 VideoCodec::VideoCodec() : Codec() { | 208 VideoCodec::VideoCodec() : Codec() { |
219 clockrate = kVideoCodecClockrate; | 209 clockrate = kVideoCodecClockrate; |
220 } | 210 } |
221 | 211 |
222 VideoCodec::VideoCodec(const VideoCodec& c) = default; | 212 VideoCodec::VideoCodec(const VideoCodec& c) = default; |
223 | 213 VideoCodec::VideoCodec(VideoCodec&& c) = default; |
224 VideoCodec& VideoCodec::operator=(const VideoCodec& c) { | 214 VideoCodec& VideoCodec::operator=(const VideoCodec& c) = default; |
225 Codec::operator=(c); | 215 VideoCodec& VideoCodec::operator=(VideoCodec&& c) = default; |
226 return *this; | |
227 } | |
228 | 216 |
229 bool VideoCodec::operator==(const VideoCodec& c) const { | 217 bool VideoCodec::operator==(const VideoCodec& c) const { |
230 return Codec::operator==(c); | 218 return Codec::operator==(c); |
231 } | 219 } |
232 | 220 |
233 VideoCodec VideoCodec::CreateRtxCodec(int rtx_payload_type, | 221 VideoCodec VideoCodec::CreateRtxCodec(int rtx_payload_type, |
234 int associated_payload_type) { | 222 int associated_payload_type) { |
235 VideoCodec rtx_codec(rtx_payload_type, kRtxCodecName); | 223 VideoCodec rtx_codec(rtx_payload_type, kRtxCodecName); |
236 rtx_codec.SetParam(kCodecParamAssociatedPayloadType, associated_payload_type); | 224 rtx_codec.SetParam(kCodecParamAssociatedPayloadType, associated_payload_type); |
237 return rtx_codec; | 225 return rtx_codec; |
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
275 } | 263 } |
276 | 264 |
277 DataCodec::DataCodec(int id, const std::string& name) | 265 DataCodec::DataCodec(int id, const std::string& name) |
278 : Codec(id, name, kDataCodecClockrate) {} | 266 : Codec(id, name, kDataCodecClockrate) {} |
279 | 267 |
280 DataCodec::DataCodec() : Codec() { | 268 DataCodec::DataCodec() : Codec() { |
281 clockrate = kDataCodecClockrate; | 269 clockrate = kDataCodecClockrate; |
282 } | 270 } |
283 | 271 |
284 DataCodec::DataCodec(const DataCodec& c) = default; | 272 DataCodec::DataCodec(const DataCodec& c) = default; |
285 | 273 DataCodec::DataCodec(DataCodec&& c) = default; |
286 DataCodec& DataCodec::operator=(const DataCodec& c) = default; | 274 DataCodec& DataCodec::operator=(const DataCodec& c) = default; |
| 275 DataCodec& DataCodec::operator=(DataCodec&& c) = default; |
287 | 276 |
288 std::string DataCodec::ToString() const { | 277 std::string DataCodec::ToString() const { |
289 std::ostringstream os; | 278 std::ostringstream os; |
290 os << "DataCodec[" << id << ":" << name << "]"; | 279 os << "DataCodec[" << id << ":" << name << "]"; |
291 return os.str(); | 280 return os.str(); |
292 } | 281 } |
293 | 282 |
294 bool HasNack(const Codec& codec) { | 283 bool HasNack(const Codec& codec) { |
295 return codec.HasFeedbackParam( | 284 return codec.HasFeedbackParam( |
296 FeedbackParam(kRtcpFbParamNack, kParamValueEmpty)); | 285 FeedbackParam(kRtcpFbParamNack, kParamValueEmpty)); |
(...skipping 30 matching lines...) Expand all Loading... |
327 | 316 |
328 bool IsCodecSupported(const std::vector<VideoCodec>& supported_codecs, | 317 bool IsCodecSupported(const std::vector<VideoCodec>& supported_codecs, |
329 const VideoCodec& codec) { | 318 const VideoCodec& codec) { |
330 return std::any_of(supported_codecs.begin(), supported_codecs.end(), | 319 return std::any_of(supported_codecs.begin(), supported_codecs.end(), |
331 [&codec](const VideoCodec& supported_codec) -> bool { | 320 [&codec](const VideoCodec& supported_codec) -> bool { |
332 return CodecNamesEq(codec.name, supported_codec.name); | 321 return CodecNamesEq(codec.name, supported_codec.name); |
333 }); | 322 }); |
334 } | 323 } |
335 | 324 |
336 } // namespace cricket | 325 } // namespace cricket |
OLD | NEW |