Chromium Code Reviews| Index: webrtc/media/base/codec.cc |
| diff --git a/webrtc/media/base/codec.cc b/webrtc/media/base/codec.cc |
| index 01350f7123695276b735166a6517769c69d14a42..a0d9f486a5cbd58f0969e55dbf653b91f9f2bf41 100644 |
| --- a/webrtc/media/base/codec.cc |
| +++ b/webrtc/media/base/codec.cc |
| @@ -118,6 +118,12 @@ bool Codec::GetParam(const std::string& name, int* out) const { |
| return rtc::FromString(iter->second, out); |
| } |
| +std::string Codec::GetParam(const std::string& name, |
| + const std::string& default_value) const { |
| + CodecParameterMap::const_iterator iter = params.find(name); |
| + return (iter == params.end()) ? default_value : iter->second; |
| +} |
| + |
| void Codec::SetParam(const std::string& name, const std::string& value) { |
| params[name] = value; |
| } |
| @@ -245,6 +251,29 @@ bool VideoCodec::operator==(const VideoCodec& c) const { |
| Codec::operator==(c); |
| } |
| +bool VideoCodec::Matches(const VideoCodec& codec) const { |
| + if (!Codec::Matches(codec)) |
| + return false; |
| + if (name != kH264CodecName) |
|
hta-webrtc
2016/09/19 06:38:36
<standard rant>
This is another infection of the
magjed_webrtc
2016/09/19 12:40:30
Yes, I agree this is ugly and that it would be bet
|
| + return true; |
| + // H264 codecs need to have matching profile-level-id. |
| + const std::string our_profile_level_id = |
| + GetParam(kH264FmtpProfileLevelId, kH264FmtpDefaultProfileLevelId); |
| + const std::string their_profile_level_id = |
| + codec.GetParam(kH264FmtpProfileLevelId, kH264FmtpDefaultProfileLevelId); |
| + if (our_profile_level_id == their_profile_level_id) |
| + return true; |
| + // At this point, profile-level-id is not an exact match, but that is still ok |
| + // if only level_idc differs and level asymmetry is allowed. |
| + const bool level_asymmetry_allowed = |
| + GetParam(kH264FmtpLevelAsymmetryAllowed, "0") == "1" && |
| + codec.GetParam(kH264FmtpLevelAsymmetryAllowed, "0") == "1"; |
| + // Ignore level_idc and compare only profile_idc and profile_iop. |
| + const bool is_profile_match = (our_profile_level_id.substr(0, 4) == |
| + their_profile_level_id.substr(0, 4)); |
| + return level_asymmetry_allowed && is_profile_match; |
| +} |
|
hta-webrtc
2016/09/19 06:38:36
Where's the test that we can successfully negotiat
magjed_webrtc
2016/09/19 12:40:30
The tests are in codec_unittest.cc and the specifi
|
| + |
| VideoCodec VideoCodec::CreateRtxCodec(int rtx_payload_type, |
| int associated_payload_type) { |
| VideoCodec rtx_codec(rtx_payload_type, kRtxCodecName, 0, 0, 0); |