Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(91)

Side by Side Diff: webrtc/media/base/codec.cc

Issue 2483173002: Negotiate H264 profiles in SDP (Closed)
Patch Set: Extract IsSameH264Profile and don't check payload type in FindMatchingCodec Created 4 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « webrtc/media/base/codec.h ('k') | webrtc/media/engine/fakewebrtcvideoengine.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 static bool IsSameH264Profile(const CodecParameterMap& params1,
25 const CodecParameterMap& params2) {
26 const rtc::Optional<webrtc::H264::ProfileLevelId> profile_level_id =
27 webrtc::H264::ParseSdpProfileLevelId(params1);
28 const rtc::Optional<webrtc::H264::ProfileLevelId> other_profile_level_id =
29 webrtc::H264::ParseSdpProfileLevelId(params2);
30 // Compare H264 profiles, but not levels.
31 return profile_level_id && other_profile_level_id &&
32 profile_level_id->profile == other_profile_level_id->profile;
33 }
24 34
25 bool FeedbackParam::operator==(const FeedbackParam& other) const { 35 bool FeedbackParam::operator==(const FeedbackParam& other) const {
26 return _stricmp(other.id().c_str(), id().c_str()) == 0 && 36 return _stricmp(other.id().c_str(), id().c_str()) == 0 &&
27 _stricmp(other.param().c_str(), param().c_str()) == 0; 37 _stricmp(other.param().c_str(), param().c_str()) == 0;
28 } 38 }
29 39
30 bool FeedbackParams::operator==(const FeedbackParams& other) const { 40 bool FeedbackParams::operator==(const FeedbackParams& other) const {
31 return params_ == other.params_; 41 return params_ == other.params_;
32 } 42 }
33 43
(...skipping 177 matching lines...) Expand 10 before | Expand all | Expand 10 after
211 221
212 VideoCodec::VideoCodec(const VideoCodec& c) = default; 222 VideoCodec::VideoCodec(const VideoCodec& c) = default;
213 VideoCodec::VideoCodec(VideoCodec&& c) = default; 223 VideoCodec::VideoCodec(VideoCodec&& c) = default;
214 VideoCodec& VideoCodec::operator=(const VideoCodec& c) = default; 224 VideoCodec& VideoCodec::operator=(const VideoCodec& c) = default;
215 VideoCodec& VideoCodec::operator=(VideoCodec&& c) = default; 225 VideoCodec& VideoCodec::operator=(VideoCodec&& c) = default;
216 226
217 bool VideoCodec::operator==(const VideoCodec& c) const { 227 bool VideoCodec::operator==(const VideoCodec& c) const {
218 return Codec::operator==(c); 228 return Codec::operator==(c);
219 } 229 }
220 230
231 bool VideoCodec::Matches(const VideoCodec& other) const {
232 if (!Codec::Matches(other))
233 return false;
234 if (CodecNamesEq(name.c_str(), kH264CodecName))
235 return IsSameH264Profile(params, other.params);
236 return true;
237 }
238
221 VideoCodec VideoCodec::CreateRtxCodec(int rtx_payload_type, 239 VideoCodec VideoCodec::CreateRtxCodec(int rtx_payload_type,
222 int associated_payload_type) { 240 int associated_payload_type) {
223 VideoCodec rtx_codec(rtx_payload_type, kRtxCodecName); 241 VideoCodec rtx_codec(rtx_payload_type, kRtxCodecName);
224 rtx_codec.SetParam(kCodecParamAssociatedPayloadType, associated_payload_type); 242 rtx_codec.SetParam(kCodecParamAssociatedPayloadType, associated_payload_type);
225 return rtx_codec; 243 return rtx_codec;
226 } 244 }
227 245
228 VideoCodec::CodecType VideoCodec::GetCodecType() const { 246 VideoCodec::CodecType VideoCodec::GetCodecType() const {
229 const char* payload_name = name.c_str(); 247 const char* payload_name = name.c_str();
230 if (_stricmp(payload_name, kRedCodecName) == 0) { 248 if (_stricmp(payload_name, kRedCodecName) == 0) {
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after
310 if (CodecNamesEq(name.c_str(), kVp8CodecName)) { 328 if (CodecNamesEq(name.c_str(), kVp8CodecName)) {
311 return webrtc::kVideoCodecVP8; 329 return webrtc::kVideoCodecVP8;
312 } else if (CodecNamesEq(name.c_str(), kVp9CodecName)) { 330 } else if (CodecNamesEq(name.c_str(), kVp9CodecName)) {
313 return webrtc::kVideoCodecVP9; 331 return webrtc::kVideoCodecVP9;
314 } else if (CodecNamesEq(name.c_str(), kH264CodecName)) { 332 } else if (CodecNamesEq(name.c_str(), kH264CodecName)) {
315 return webrtc::kVideoCodecH264; 333 return webrtc::kVideoCodecH264;
316 } 334 }
317 return webrtc::kVideoCodecUnknown; 335 return webrtc::kVideoCodecUnknown;
318 } 336 }
319 337
320 bool IsCodecSupported(const std::vector<VideoCodec>& supported_codecs, 338 const VideoCodec* FindMatchingCodec(
321 const VideoCodec& codec) { 339 const std::vector<VideoCodec>& supported_codecs,
322 return std::any_of(supported_codecs.begin(), supported_codecs.end(), 340 const VideoCodec& codec) {
323 [&codec](const VideoCodec& supported_codec) -> bool { 341 for (const VideoCodec& supported_codec : supported_codecs) {
324 return CodecNamesEq(codec.name, supported_codec.name); 342 if (!CodecNamesEq(codec.name, supported_codec.name))
325 }); 343 continue;
344 if (CodecNamesEq(codec.name.c_str(), kH264CodecName) &&
345 !IsSameH264Profile(codec.params, supported_codec.params)) {
346 continue;
347 }
348 return &supported_codec;
349 }
350 return nullptr;
326 } 351 }
327 352
328 } // namespace cricket 353 } // namespace cricket
OLDNEW
« no previous file with comments | « webrtc/media/base/codec.h ('k') | webrtc/media/engine/fakewebrtcvideoengine.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698