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

Unified 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « webrtc/media/base/codec.h ('k') | webrtc/media/engine/fakewebrtcvideoengine.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: webrtc/media/base/codec.cc
diff --git a/webrtc/media/base/codec.cc b/webrtc/media/base/codec.cc
index 66bc9ff7d9d0a44f5129707c2cea06172cfe79f8..0320e58c722a9245661c257af27de37159318044 100644
--- a/webrtc/media/base/codec.cc
+++ b/webrtc/media/base/codec.cc
@@ -17,10 +17,20 @@
#include "webrtc/base/logging.h"
#include "webrtc/base/stringencode.h"
#include "webrtc/base/stringutils.h"
+#include "webrtc/common_video/h264/profile_level_id.h"
namespace cricket {
-const int kMaxPayloadId = 127;
+static bool IsSameH264Profile(const CodecParameterMap& params1,
+ const CodecParameterMap& params2) {
+ const rtc::Optional<webrtc::H264::ProfileLevelId> profile_level_id =
+ webrtc::H264::ParseSdpProfileLevelId(params1);
+ const rtc::Optional<webrtc::H264::ProfileLevelId> other_profile_level_id =
+ webrtc::H264::ParseSdpProfileLevelId(params2);
+ // Compare H264 profiles, but not levels.
+ return profile_level_id && other_profile_level_id &&
+ profile_level_id->profile == other_profile_level_id->profile;
+}
bool FeedbackParam::operator==(const FeedbackParam& other) const {
return _stricmp(other.id().c_str(), id().c_str()) == 0 &&
@@ -218,6 +228,14 @@ bool VideoCodec::operator==(const VideoCodec& c) const {
return Codec::operator==(c);
}
+bool VideoCodec::Matches(const VideoCodec& other) const {
+ if (!Codec::Matches(other))
+ return false;
+ if (CodecNamesEq(name.c_str(), kH264CodecName))
+ return IsSameH264Profile(params, other.params);
+ return true;
+}
+
VideoCodec VideoCodec::CreateRtxCodec(int rtx_payload_type,
int associated_payload_type) {
VideoCodec rtx_codec(rtx_payload_type, kRtxCodecName);
@@ -317,12 +335,19 @@ webrtc::VideoCodecType CodecTypeFromName(const std::string& name) {
return webrtc::kVideoCodecUnknown;
}
-bool IsCodecSupported(const std::vector<VideoCodec>& supported_codecs,
- const VideoCodec& codec) {
- return std::any_of(supported_codecs.begin(), supported_codecs.end(),
- [&codec](const VideoCodec& supported_codec) -> bool {
- return CodecNamesEq(codec.name, supported_codec.name);
- });
+const VideoCodec* FindMatchingCodec(
+ const std::vector<VideoCodec>& supported_codecs,
+ const VideoCodec& codec) {
+ for (const VideoCodec& supported_codec : supported_codecs) {
+ if (!CodecNamesEq(codec.name, supported_codec.name))
+ continue;
+ if (CodecNamesEq(codec.name.c_str(), kH264CodecName) &&
+ !IsSameH264Profile(codec.params, supported_codec.params)) {
+ continue;
+ }
+ return &supported_codec;
+ }
+ return nullptr;
}
} // namespace cricket
« 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