Chromium Code Reviews| 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 |
| 11 #include "webrtc/media/base/codec.h" | 11 #include "webrtc/media/base/codec.h" |
| 12 | 12 |
| 13 #include <algorithm> | 13 #include <algorithm> |
| 14 #include <sstream> | 14 #include <sstream> |
| 15 | 15 |
| 16 #include "webrtc/base/common.h" | 16 #include "webrtc/base/common.h" |
| 17 #include "webrtc/base/logging.h" | 17 #include "webrtc/base/logging.h" |
| 18 #include "webrtc/base/stringencode.h" | 18 #include "webrtc/base/stringencode.h" |
| 19 #include "webrtc/base/stringutils.h" | 19 #include "webrtc/base/stringutils.h" |
| 20 #include "webrtc/common_video/h264/profile_level_id.h" | |
| 20 | 21 |
| 21 namespace cricket { | 22 namespace cricket { |
| 22 | 23 |
| 23 const int kMaxPayloadId = 127; | 24 const int kMaxPayloadId = 127; |
| 24 | 25 |
| 25 bool FeedbackParam::operator==(const FeedbackParam& other) const { | 26 bool FeedbackParam::operator==(const FeedbackParam& other) const { |
| 26 return _stricmp(other.id().c_str(), id().c_str()) == 0 && | 27 return _stricmp(other.id().c_str(), id().c_str()) == 0 && |
| 27 _stricmp(other.param().c_str(), param().c_str()) == 0; | 28 _stricmp(other.param().c_str(), param().c_str()) == 0; |
| 28 } | 29 } |
| 29 | 30 |
| (...skipping 181 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 211 | 212 |
| 212 VideoCodec::VideoCodec(const VideoCodec& c) = default; | 213 VideoCodec::VideoCodec(const VideoCodec& c) = default; |
| 213 VideoCodec::VideoCodec(VideoCodec&& c) = default; | 214 VideoCodec::VideoCodec(VideoCodec&& c) = default; |
| 214 VideoCodec& VideoCodec::operator=(const VideoCodec& c) = default; | 215 VideoCodec& VideoCodec::operator=(const VideoCodec& c) = default; |
| 215 VideoCodec& VideoCodec::operator=(VideoCodec&& c) = default; | 216 VideoCodec& VideoCodec::operator=(VideoCodec&& c) = default; |
| 216 | 217 |
| 217 bool VideoCodec::operator==(const VideoCodec& c) const { | 218 bool VideoCodec::operator==(const VideoCodec& c) const { |
| 218 return Codec::operator==(c); | 219 return Codec::operator==(c); |
| 219 } | 220 } |
| 220 | 221 |
| 222 bool VideoCodec::Matches(const VideoCodec& other) const { | |
| 223 if (!Codec::Matches(other)) | |
| 224 return false; | |
| 225 if (!CodecNamesEq(name.c_str(), kH264CodecName)) | |
| 226 return true; | |
| 227 const rtc::Optional<webrtc::H264::ProfileLevelId> profile_level_id = | |
| 228 webrtc::H264::ParseSdpProfileLevelId(params); | |
| 229 const rtc::Optional<webrtc::H264::ProfileLevelId> other_profile_level_id = | |
| 230 webrtc::H264::ParseSdpProfileLevelId(other.params); | |
| 231 // Compare H264 profiles, but not levels. | |
| 232 return profile_level_id && other_profile_level_id && | |
| 233 profile_level_id->profile == other_profile_level_id->profile; | |
|
hta-webrtc
2016/11/08 13:59:53
See comment about matching. This says whether they
magjed_webrtc
2016/11/08 16:18:26
Yes, this function compares whether the codecs are
| |
| 234 } | |
| 235 | |
| 221 VideoCodec VideoCodec::CreateRtxCodec(int rtx_payload_type, | 236 VideoCodec VideoCodec::CreateRtxCodec(int rtx_payload_type, |
| 222 int associated_payload_type) { | 237 int associated_payload_type) { |
| 223 VideoCodec rtx_codec(rtx_payload_type, kRtxCodecName); | 238 VideoCodec rtx_codec(rtx_payload_type, kRtxCodecName); |
| 224 rtx_codec.SetParam(kCodecParamAssociatedPayloadType, associated_payload_type); | 239 rtx_codec.SetParam(kCodecParamAssociatedPayloadType, associated_payload_type); |
| 225 return rtx_codec; | 240 return rtx_codec; |
| 226 } | 241 } |
| 227 | 242 |
| 228 VideoCodec::CodecType VideoCodec::GetCodecType() const { | 243 VideoCodec::CodecType VideoCodec::GetCodecType() const { |
| 229 const char* payload_name = name.c_str(); | 244 const char* payload_name = name.c_str(); |
| 230 if (_stricmp(payload_name, kRedCodecName) == 0) { | 245 if (_stricmp(payload_name, kRedCodecName) == 0) { |
| (...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 314 } else if (CodecNamesEq(name.c_str(), kH264CodecName)) { | 329 } else if (CodecNamesEq(name.c_str(), kH264CodecName)) { |
| 315 return webrtc::kVideoCodecH264; | 330 return webrtc::kVideoCodecH264; |
| 316 } | 331 } |
| 317 return webrtc::kVideoCodecUnknown; | 332 return webrtc::kVideoCodecUnknown; |
| 318 } | 333 } |
| 319 | 334 |
| 320 bool IsCodecSupported(const std::vector<VideoCodec>& supported_codecs, | 335 bool IsCodecSupported(const std::vector<VideoCodec>& supported_codecs, |
| 321 const VideoCodec& codec) { | 336 const VideoCodec& codec) { |
| 322 return std::any_of(supported_codecs.begin(), supported_codecs.end(), | 337 return std::any_of(supported_codecs.begin(), supported_codecs.end(), |
| 323 [&codec](const VideoCodec& supported_codec) -> bool { | 338 [&codec](const VideoCodec& supported_codec) -> bool { |
| 324 return CodecNamesEq(codec.name, supported_codec.name); | 339 return codec.Matches(supported_codec); |
| 325 }); | 340 }); |
| 326 } | 341 } |
| 327 | 342 |
| 328 } // namespace cricket | 343 } // namespace cricket |
| OLD | NEW |