| 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 200 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 211 | 211 |
| 212 std::string AudioCodec::ToString() const { | 212 std::string AudioCodec::ToString() const { |
| 213 std::ostringstream os; | 213 std::ostringstream os; |
| 214 os << "AudioCodec[" << id << ":" << name << ":" << clockrate << ":" << bitrate | 214 os << "AudioCodec[" << id << ":" << name << ":" << clockrate << ":" << bitrate |
| 215 << ":" << channels << "]"; | 215 << ":" << channels << "]"; |
| 216 return os.str(); | 216 return os.str(); |
| 217 } | 217 } |
| 218 | 218 |
| 219 std::string VideoCodec::ToString() const { | 219 std::string VideoCodec::ToString() const { |
| 220 std::ostringstream os; | 220 std::ostringstream os; |
| 221 os << "VideoCodec[" << id << ":" << name << ":" << width << ":" << height | 221 os << "VideoCodec[" << id << ":" << name << "]"; |
| 222 << ":" << framerate << "]"; | |
| 223 return os.str(); | 222 return os.str(); |
| 224 } | 223 } |
| 225 | 224 |
| 226 VideoCodec::VideoCodec(int id, | 225 VideoCodec::VideoCodec(int id, const std::string& name) |
| 227 const std::string& name, | 226 : Codec(id, name, kVideoCodecClockrate) {} |
| 228 int width, | |
| 229 int height, | |
| 230 int framerate) | |
| 231 : Codec(id, name, kVideoCodecClockrate), | |
| 232 width(width), | |
| 233 height(height), | |
| 234 framerate(framerate) {} | |
| 235 | 227 |
| 236 VideoCodec::VideoCodec(int id, const std::string& name) | 228 VideoCodec::VideoCodec() : Codec() { |
| 237 : Codec(id, name, kVideoCodecClockrate), | |
| 238 width(0), | |
| 239 height(0), | |
| 240 framerate(0) {} | |
| 241 | |
| 242 VideoCodec::VideoCodec() : Codec(), width(0), height(0), framerate(0) { | |
| 243 clockrate = kVideoCodecClockrate; | 229 clockrate = kVideoCodecClockrate; |
| 244 } | 230 } |
| 245 | 231 |
| 246 VideoCodec::VideoCodec(const VideoCodec& c) = default; | 232 VideoCodec::VideoCodec(const VideoCodec& c) = default; |
| 247 | 233 |
| 248 VideoCodec& VideoCodec::operator=(const VideoCodec& c) { | 234 VideoCodec& VideoCodec::operator=(const VideoCodec& c) { |
| 249 Codec::operator=(c); | 235 Codec::operator=(c); |
| 250 width = c.width; | |
| 251 height = c.height; | |
| 252 framerate = c.framerate; | |
| 253 return *this; | 236 return *this; |
| 254 } | 237 } |
| 255 | 238 |
| 256 bool VideoCodec::operator==(const VideoCodec& c) const { | 239 bool VideoCodec::operator==(const VideoCodec& c) const { |
| 257 return width == c.width && height == c.height && framerate == c.framerate && | 240 return Codec::operator==(c); |
| 258 Codec::operator==(c); | |
| 259 } | 241 } |
| 260 | 242 |
| 261 bool VideoCodec::Matches(const VideoCodec& codec) const { | 243 bool VideoCodec::Matches(const VideoCodec& codec) const { |
| 262 if (!Codec::Matches(codec)) | 244 if (!Codec::Matches(codec)) |
| 263 return false; | 245 return false; |
| 264 // TODO(magjed): It would be better to have this logic in a H264 subclass. See | 246 // TODO(magjed): It would be better to have this logic in a H264 subclass. See |
| 265 // http://crbug/webrtc/6385 for more info. | 247 // http://crbug/webrtc/6385 for more info. |
| 266 if (!CodecNamesEq(name, kH264CodecName)) | 248 if (!CodecNamesEq(name, kH264CodecName)) |
| 267 return true; | 249 return true; |
| 268 // H264 codecs need to have matching profile-level-id. | 250 // H264 codecs need to have matching profile-level-id. |
| 269 const std::string our_profile_level_id = GetParamOrDefault( | 251 const std::string our_profile_level_id = GetParamOrDefault( |
| 270 *this, kH264FmtpProfileLevelId, kH264FmtpDefaultProfileLevelId); | 252 *this, kH264FmtpProfileLevelId, kH264FmtpDefaultProfileLevelId); |
| 271 const std::string their_profile_level_id = GetParamOrDefault( | 253 const std::string their_profile_level_id = GetParamOrDefault( |
| 272 codec, kH264FmtpProfileLevelId, kH264FmtpDefaultProfileLevelId); | 254 codec, kH264FmtpProfileLevelId, kH264FmtpDefaultProfileLevelId); |
| 273 if (our_profile_level_id == their_profile_level_id) | 255 if (our_profile_level_id == their_profile_level_id) |
| 274 return true; | 256 return true; |
| 275 // At this point, profile-level-id is not an exact match, but that is still ok | 257 // At this point, profile-level-id is not an exact match, but that is still ok |
| 276 // if only level_idc differs and level asymmetry is allowed. | 258 // if only level_idc differs and level asymmetry is allowed. |
| 277 const bool level_asymmetry_allowed = | 259 const bool level_asymmetry_allowed = |
| 278 GetParamOrDefault(*this, kH264FmtpLevelAsymmetryAllowed, "0") == "1" && | 260 GetParamOrDefault(*this, kH264FmtpLevelAsymmetryAllowed, "0") == "1" && |
| 279 GetParamOrDefault(codec, kH264FmtpLevelAsymmetryAllowed, "0") == "1"; | 261 GetParamOrDefault(codec, kH264FmtpLevelAsymmetryAllowed, "0") == "1"; |
| 280 // Ignore level_idc and compare only profile_idc and profile_iop. | 262 // Ignore level_idc and compare only profile_idc and profile_iop. |
| 281 const bool is_profile_match = (our_profile_level_id.substr(0, 4) == | 263 const bool is_profile_match = (our_profile_level_id.substr(0, 4) == |
| 282 their_profile_level_id.substr(0, 4)); | 264 their_profile_level_id.substr(0, 4)); |
| 283 return level_asymmetry_allowed && is_profile_match; | 265 return level_asymmetry_allowed && is_profile_match; |
| 284 } | 266 } |
| 285 | 267 |
| 286 VideoCodec VideoCodec::CreateRtxCodec(int rtx_payload_type, | 268 VideoCodec VideoCodec::CreateRtxCodec(int rtx_payload_type, |
| 287 int associated_payload_type) { | 269 int associated_payload_type) { |
| 288 VideoCodec rtx_codec(rtx_payload_type, kRtxCodecName, 0, 0, 0); | 270 VideoCodec rtx_codec(rtx_payload_type, kRtxCodecName); |
| 289 rtx_codec.SetParam(kCodecParamAssociatedPayloadType, associated_payload_type); | 271 rtx_codec.SetParam(kCodecParamAssociatedPayloadType, associated_payload_type); |
| 290 return rtx_codec; | 272 return rtx_codec; |
| 291 } | 273 } |
| 292 | 274 |
| 293 VideoCodec::CodecType VideoCodec::GetCodecType() const { | 275 VideoCodec::CodecType VideoCodec::GetCodecType() const { |
| 294 const char* payload_name = name.c_str(); | 276 const char* payload_name = name.c_str(); |
| 295 if (_stricmp(payload_name, kRedCodecName) == 0) { | 277 if (_stricmp(payload_name, kRedCodecName) == 0) { |
| 296 return CODEC_RED; | 278 return CODEC_RED; |
| 297 } | 279 } |
| 298 if (_stricmp(payload_name, kUlpfecCodecName) == 0) { | 280 if (_stricmp(payload_name, kUlpfecCodecName) == 0) { |
| (...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 357 bool HasTransportCc(const Codec& codec) { | 339 bool HasTransportCc(const Codec& codec) { |
| 358 return codec.HasFeedbackParam( | 340 return codec.HasFeedbackParam( |
| 359 FeedbackParam(kRtcpFbParamTransportCc, kParamValueEmpty)); | 341 FeedbackParam(kRtcpFbParamTransportCc, kParamValueEmpty)); |
| 360 } | 342 } |
| 361 | 343 |
| 362 bool CodecNamesEq(const std::string& name1, const std::string& name2) { | 344 bool CodecNamesEq(const std::string& name1, const std::string& name2) { |
| 363 return _stricmp(name1.c_str(), name2.c_str()) == 0; | 345 return _stricmp(name1.c_str(), name2.c_str()) == 0; |
| 364 } | 346 } |
| 365 | 347 |
| 366 } // namespace cricket | 348 } // namespace cricket |
| OLD | NEW |