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 100 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
111 return true; | 111 return true; |
112 } | 112 } |
113 | 113 |
114 bool Codec::GetParam(const std::string& name, int* out) const { | 114 bool Codec::GetParam(const std::string& name, int* out) const { |
115 CodecParameterMap::const_iterator iter = params.find(name); | 115 CodecParameterMap::const_iterator iter = params.find(name); |
116 if (iter == params.end()) | 116 if (iter == params.end()) |
117 return false; | 117 return false; |
118 return rtc::FromString(iter->second, out); | 118 return rtc::FromString(iter->second, out); |
119 } | 119 } |
120 | 120 |
121 std::string Codec::GetParam(const std::string& name, | |
122 const std::string& default_value) const { | |
123 CodecParameterMap::const_iterator iter = params.find(name); | |
124 return (iter == params.end()) ? default_value : iter->second; | |
125 } | |
126 | |
121 void Codec::SetParam(const std::string& name, const std::string& value) { | 127 void Codec::SetParam(const std::string& name, const std::string& value) { |
122 params[name] = value; | 128 params[name] = value; |
123 } | 129 } |
124 | 130 |
125 void Codec::SetParam(const std::string& name, int value) { | 131 void Codec::SetParam(const std::string& name, int value) { |
126 params[name] = rtc::ToString(value); | 132 params[name] = rtc::ToString(value); |
127 } | 133 } |
128 | 134 |
129 bool Codec::RemoveParam(const std::string& name) { | 135 bool Codec::RemoveParam(const std::string& name) { |
130 return params.erase(name) == 1; | 136 return params.erase(name) == 1; |
(...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
238 height = c.height; | 244 height = c.height; |
239 framerate = c.framerate; | 245 framerate = c.framerate; |
240 return *this; | 246 return *this; |
241 } | 247 } |
242 | 248 |
243 bool VideoCodec::operator==(const VideoCodec& c) const { | 249 bool VideoCodec::operator==(const VideoCodec& c) const { |
244 return width == c.width && height == c.height && framerate == c.framerate && | 250 return width == c.width && height == c.height && framerate == c.framerate && |
245 Codec::operator==(c); | 251 Codec::operator==(c); |
246 } | 252 } |
247 | 253 |
254 bool VideoCodec::Matches(const VideoCodec& codec) const { | |
255 if (!Codec::Matches(codec)) | |
256 return false; | |
257 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
| |
258 return true; | |
259 // H264 codecs need to have matching profile-level-id. | |
260 const std::string our_profile_level_id = | |
261 GetParam(kH264FmtpProfileLevelId, kH264FmtpDefaultProfileLevelId); | |
262 const std::string their_profile_level_id = | |
263 codec.GetParam(kH264FmtpProfileLevelId, kH264FmtpDefaultProfileLevelId); | |
264 if (our_profile_level_id == their_profile_level_id) | |
265 return true; | |
266 // At this point, profile-level-id is not an exact match, but that is still ok | |
267 // if only level_idc differs and level asymmetry is allowed. | |
268 const bool level_asymmetry_allowed = | |
269 GetParam(kH264FmtpLevelAsymmetryAllowed, "0") == "1" && | |
270 codec.GetParam(kH264FmtpLevelAsymmetryAllowed, "0") == "1"; | |
271 // Ignore level_idc and compare only profile_idc and profile_iop. | |
272 const bool is_profile_match = (our_profile_level_id.substr(0, 4) == | |
273 their_profile_level_id.substr(0, 4)); | |
274 return level_asymmetry_allowed && is_profile_match; | |
275 } | |
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
| |
276 | |
248 VideoCodec VideoCodec::CreateRtxCodec(int rtx_payload_type, | 277 VideoCodec VideoCodec::CreateRtxCodec(int rtx_payload_type, |
249 int associated_payload_type) { | 278 int associated_payload_type) { |
250 VideoCodec rtx_codec(rtx_payload_type, kRtxCodecName, 0, 0, 0); | 279 VideoCodec rtx_codec(rtx_payload_type, kRtxCodecName, 0, 0, 0); |
251 rtx_codec.SetParam(kCodecParamAssociatedPayloadType, associated_payload_type); | 280 rtx_codec.SetParam(kCodecParamAssociatedPayloadType, associated_payload_type); |
252 return rtx_codec; | 281 return rtx_codec; |
253 } | 282 } |
254 | 283 |
255 VideoCodec::CodecType VideoCodec::GetCodecType() const { | 284 VideoCodec::CodecType VideoCodec::GetCodecType() const { |
256 const char* payload_name = name.c_str(); | 285 const char* payload_name = name.c_str(); |
257 if (_stricmp(payload_name, kRedCodecName) == 0) { | 286 if (_stricmp(payload_name, kRedCodecName) == 0) { |
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
324 bool HasTransportCc(const Codec& codec) { | 353 bool HasTransportCc(const Codec& codec) { |
325 return codec.HasFeedbackParam( | 354 return codec.HasFeedbackParam( |
326 FeedbackParam(kRtcpFbParamTransportCc, kParamValueEmpty)); | 355 FeedbackParam(kRtcpFbParamTransportCc, kParamValueEmpty)); |
327 } | 356 } |
328 | 357 |
329 bool CodecNamesEq(const std::string& name1, const std::string& name2) { | 358 bool CodecNamesEq(const std::string& name1, const std::string& name2) { |
330 return _stricmp(name1.c_str(), name2.c_str()) == 0; | 359 return _stricmp(name1.c_str(), name2.c_str()) == 0; |
331 } | 360 } |
332 | 361 |
333 } // namespace cricket | 362 } // namespace cricket |
OLD | NEW |