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

Unified Diff: webrtc/media/engine/webrtcvideoengine2_unittest.cc

Issue 2497773003: Use different RTX payload types for different H264 profiles (Closed)
Patch Set: Fix bug and add test. 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/engine/webrtcvideoengine2.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: webrtc/media/engine/webrtcvideoengine2_unittest.cc
diff --git a/webrtc/media/engine/webrtcvideoengine2_unittest.cc b/webrtc/media/engine/webrtcvideoengine2_unittest.cc
index 7fab75df2943c8fbe95af1d75318dc84b1e7f930..19b7d644cd8942ea702158e08efef53adccf5e3f 100644
--- a/webrtc/media/engine/webrtcvideoengine2_unittest.cc
+++ b/webrtc/media/engine/webrtcvideoengine2_unittest.cc
@@ -16,6 +16,7 @@
#include "webrtc/base/arraysize.h"
#include "webrtc/base/gunit.h"
#include "webrtc/base/stringutils.h"
+#include "webrtc/common_video/h264/profile_level_id.h"
#include "webrtc/logging/rtc_event_log/rtc_event_log.h"
#include "webrtc/media/base/testutils.h"
#include "webrtc/media/base/videoengine_unittest.h"
@@ -61,6 +62,22 @@ void VerifyCodecHasDefaultFeedbackParams(const cricket::VideoCodec& codec) {
cricket::kRtcpFbParamCcm, cricket::kRtcpFbCcmParamFir)));
}
+// Return true if any codec in |codecs| is an RTX codec with associated payload
+// type |payload_type|.
+bool HasRtxCodec(const std::vector<cricket::VideoCodec>& codecs,
+ int payload_type) {
+ for (const cricket::VideoCodec& codec : codecs) {
+ int associated_payload_type;
+ if (cricket::CodecNamesEq(codec.name.c_str(), "rtx") &&
+ codec.GetParam(cricket::kCodecParamAssociatedPayloadType,
+ &associated_payload_type) &&
+ associated_payload_type == payload_type) {
+ return true;
+ }
+ }
+ return false;
+}
+
static rtc::scoped_refptr<webrtc::VideoFrameBuffer> CreateBlackFrameBuffer(
int width,
int height) {
@@ -375,26 +392,38 @@ TEST_F(WebRtcVideoEngine2Test, UseExternalFactoryForVp8WhenSupported) {
// built with no internal H264 support. This test should be updated
// if/when we start adding RTX codecs for unrecognized codec names.
TEST_F(WebRtcVideoEngine2Test, RtxCodecAddedForExternalCodec) {
+ using webrtc::H264::ProfileLevelIdToString;
+ using webrtc::H264::ProfileLevelId;
+ using webrtc::H264::kLevel1;
+ cricket::VideoCodec h264_constrained_baseline("H264");
+ h264_constrained_baseline.params[kH264FmtpProfileLevelId] =
+ *ProfileLevelIdToString(
+ ProfileLevelId(webrtc::H264::kProfileConstrainedBaseline, kLevel1));
+ cricket::VideoCodec h264_constrained_high("H264");
+ h264_constrained_high.params[kH264FmtpProfileLevelId] =
+ *ProfileLevelIdToString(
+ ProfileLevelId(webrtc::H264::kProfileConstrainedHigh, kLevel1));
+ cricket::VideoCodec h264_high("H264");
+ h264_high.params[kH264FmtpProfileLevelId] = *ProfileLevelIdToString(
+ ProfileLevelId(webrtc::H264::kProfileHigh, kLevel1));
+
cricket::FakeWebRtcVideoEncoderFactory encoder_factory;
- encoder_factory.AddSupportedVideoCodecType("H264");
+ encoder_factory.AddSupportedVideoCodec(h264_constrained_baseline);
+ encoder_factory.AddSupportedVideoCodec(h264_constrained_high);
+ encoder_factory.AddSupportedVideoCodec(h264_high);
engine_.SetExternalEncoderFactory(&encoder_factory);
engine_.Init();
- auto codecs = engine_.codecs();
- // First figure out what payload type the test codec got assigned.
- auto test_codec_it =
- std::find_if(codecs.begin(), codecs.end(),
- [](const VideoCodec& c) { return c.name == "H264"; });
- ASSERT_NE(codecs.end(), test_codec_it);
- // Now search for an RTX codec for it.
- EXPECT_TRUE(std::any_of(codecs.begin(), codecs.end(),
- [&test_codec_it](const VideoCodec& c) {
- int associated_payload_type;
- return c.name == "rtx" &&
- c.GetParam(kCodecParamAssociatedPayloadType,
- &associated_payload_type) &&
- associated_payload_type == test_codec_it->id;
- }));
+ // First figure out what payload types the test codecs got assigned.
+ const std::vector<cricket::VideoCodec> codecs = engine_.codecs();
+ // Now search for RTX codecs for them. Expect that Constrained Baseline and
+ // Constrained High got an associated RTX codec, but not High.
+ EXPECT_TRUE(HasRtxCodec(
+ codecs, FindMatchingCodec(codecs, h264_constrained_baseline)->id));
+ EXPECT_TRUE(HasRtxCodec(
+ codecs, FindMatchingCodec(codecs, h264_constrained_high)->id));
+ EXPECT_FALSE(HasRtxCodec(
+ codecs, FindMatchingCodec(codecs, h264_high)->id));
}
void WebRtcVideoEngine2Test::TestExtendedEncoderOveruse(
« no previous file with comments | « webrtc/media/engine/webrtcvideoengine2.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698