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

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

Issue 2521393004: Don't cache video codec list in VideoEngine2. (Closed)
Patch Set: Add more unit tests for codecs() call. 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') | webrtc/pc/channelmanager.cc » ('j') | 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 c473a4099f98d9838a0a9de28857997253f87141..14703ac4bb52e7c994e409fee23f7303ef35009f 100644
--- a/webrtc/media/engine/webrtcvideoengine2_unittest.cc
+++ b/webrtc/media/engine/webrtcvideoengine2_unittest.cc
@@ -12,6 +12,7 @@
#include <list>
#include <map>
#include <memory>
+#include <unordered_set>
#include <vector>
#include "webrtc/base/arraysize.h"
@@ -26,6 +27,8 @@
#include "webrtc/media/engine/simulcast.h"
#include "webrtc/media/engine/webrtcvideoengine2.h"
#include "webrtc/media/engine/webrtcvoiceengine.h"
+#include "webrtc/modules/video_coding/codecs/h264/include/h264.h"
+#include "webrtc/modules/video_coding/codecs/vp9/include/vp9.h"
#include "webrtc/test/field_trial.h"
#include "webrtc/video_encoder.h"
@@ -100,6 +103,14 @@ void VerifySendStreamHasRtxTypes(const webrtc::VideoSendStream::Config& config,
it->second == config.rtp.ulpfec.red_rtx_payload_type);
}
}
+
+std::unordered_set<std::string> GetCodecNames(
+ const cricket::WebRtcVideoEngine2& engine) {
+ std::unordered_set<std::string> codec_names;
+ for (const auto& codec : engine.codecs())
+ codec_names.insert(codec.name);
+ return codec_names;
+}
} // namespace
namespace cricket {
@@ -749,6 +760,42 @@ TEST_F(WebRtcVideoEngine2Test, SimulcastDisabledForH264) {
EXPECT_TRUE(channel->SetVideoSend(ssrcs[0], true, nullptr, nullptr));
}
+// Test that internal codecs are added to the codec list.
+// Update this test if the internal codecs are changed!
+TEST_F(WebRtcVideoEngine2Test, ReportSupportedInternalCodecs) {
perkj_webrtc 2016/11/28 09:20:06 The fix is for different codecs when the engine h
brandtr 2016/11/28 10:40:15 Done. I did not reinitialize the engine in the tes
+ engine_.Init();
+ std::unordered_set<std::string> codec_names = GetCodecNames(engine_);
+
+ size_t expected_num_codecs = 4;
+ EXPECT_NE(codec_names.find("VP8"), codec_names.end());
magjed_webrtc 2016/11/28 10:31:31 nit: I think it would be slightly cleaner to write
brandtr 2016/11/28 10:47:40 Agree. I'm used to the find()/end() style after wo
+ if (webrtc::VP9Encoder::IsSupported()) {
+ EXPECT_NE(codec_names.find("VP9"), codec_names.end());
+ ++expected_num_codecs;
+ }
+ if (webrtc::H264Encoder::IsSupported()) {
+ EXPECT_NE(codec_names.find("H264"), codec_names.end());
+ ++expected_num_codecs;
+ }
+ EXPECT_NE(codec_names.find("rtx"), codec_names.end());
+ EXPECT_NE(codec_names.find("red"), codec_names.end());
+ EXPECT_NE(codec_names.find("ulpfec"), codec_names.end());
+ EXPECT_EQ(expected_num_codecs, codec_names.size());
+}
+
+class WebRtcVideoEngine2FlexfecTest : public WebRtcVideoEngine2Test {
+ public:
+ WebRtcVideoEngine2FlexfecTest()
+ : WebRtcVideoEngine2Test("WebRTC-FlexFEC-03/Enabled/") {}
+};
+
+// TODO(brandtr): Merge with test above, when the FlexFEC field trial is gone.
+TEST_F(WebRtcVideoEngine2FlexfecTest, ReportSupportedInternalCodecs) {
+ engine_.Init();
+ std::unordered_set<std::string> codec_names = GetCodecNames(engine_);
+
+ EXPECT_NE(codec_names.find("flexfec-03"), codec_names.end());
+}
+
// Test that external codecs are added to the end of the supported codec list.
TEST_F(WebRtcVideoEngine2Test, ReportSupportedExternalCodecs) {
cricket::FakeWebRtcVideoEncoderFactory encoder_factory;
@@ -761,7 +808,7 @@ TEST_F(WebRtcVideoEngine2Test, ReportSupportedExternalCodecs) {
cricket::VideoCodec internal_codec = codecs.front();
cricket::VideoCodec external_codec = codecs.back();
- // The external codec will appear at last.
+ // The external codec will appear last in the vector.
EXPECT_EQ("VP8", internal_codec.name);
EXPECT_EQ("FakeExternalCodec", external_codec.name);
}
« no previous file with comments | « webrtc/media/engine/webrtcvideoengine2.cc ('k') | webrtc/pc/channelmanager.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698