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

Unified Diff: webrtc/modules/video_coding/codecs/test/videoprocessor_unittest.cc

Issue 2999113002: Run VideoProcessor on task queue in VideoProcessorIntegrationTest. (Closed)
Patch Set: Created 3 years, 4 months 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
Index: webrtc/modules/video_coding/codecs/test/videoprocessor_unittest.cc
diff --git a/webrtc/modules/video_coding/codecs/test/videoprocessor_unittest.cc b/webrtc/modules/video_coding/codecs/test/videoprocessor_unittest.cc
index 825c076a5033bd68f10b62dba70ee3e5ae1de8e5..7cf867d20512c9e15a50669116dc0d1ae72b92d0 100644
--- a/webrtc/modules/video_coding/codecs/test/videoprocessor_unittest.cc
+++ b/webrtc/modules/video_coding/codecs/test/videoprocessor_unittest.cc
@@ -11,6 +11,7 @@
#include <memory>
#include "webrtc/api/video/i420_buffer.h"
+#include "webrtc/common_types.h"
#include "webrtc/modules/video_coding/codecs/test/mock/mock_packet_manipulator.h"
#include "webrtc/modules/video_coding/codecs/test/videoprocessor.h"
#include "webrtc/modules/video_coding/include/mock/mock_video_codec_interface.h"
@@ -37,7 +38,6 @@ namespace {
const int kWidth = 352;
const int kHeight = 288;
const int kFrameSize = kWidth * kHeight * 3 / 2; // I420.
-const int kFramerate = 30;
const int kNumFrames = 2;
} // namespace
@@ -49,8 +49,9 @@ class VideoProcessorTest : public testing::Test {
webrtc::test::CodecSettings(kVideoCodecVP8, &config_.codec_settings);
config_.codec_settings.width = kWidth;
config_.codec_settings.height = kHeight;
- config_.codec_settings.maxFramerate = kFramerate;
+ }
+ void CreateVideoProcessor() {
EXPECT_CALL(frame_reader_mock_, NumberOfFrames())
.WillRepeatedly(Return(kNumFrames));
EXPECT_CALL(frame_reader_mock_, FrameLength())
@@ -63,11 +64,16 @@ class VideoProcessorTest : public testing::Test {
void ExpectInit() {
EXPECT_CALL(encoder_mock_, InitEncode(_, _, _)).Times(1);
- EXPECT_CALL(encoder_mock_, RegisterEncodeCompleteCallback(_))
- .Times(AtLeast(1));
+ EXPECT_CALL(encoder_mock_, RegisterEncodeCompleteCallback(_)).Times(1);
EXPECT_CALL(decoder_mock_, InitDecode(_, _)).Times(1);
- EXPECT_CALL(decoder_mock_, RegisterDecodeCompleteCallback(_))
- .Times(AtLeast(1));
+ EXPECT_CALL(decoder_mock_, RegisterDecodeCompleteCallback(_)).Times(1);
+ }
+
+ void ExpectRelease() {
+ EXPECT_CALL(encoder_mock_, Release()).Times(1);
+ EXPECT_CALL(encoder_mock_, RegisterEncodeCompleteCallback(_)).Times(1);
+ EXPECT_CALL(decoder_mock_, Release()).Times(1);
+ EXPECT_CALL(decoder_mock_, RegisterDecodeCompleteCallback(_)).Times(1);
}
TestConfig config_;
@@ -81,28 +87,104 @@ class VideoProcessorTest : public testing::Test {
std::unique_ptr<VideoProcessor> video_processor_;
};
-TEST_F(VideoProcessorTest, Init) {
+TEST_F(VideoProcessorTest, InitRelease) {
+ CreateVideoProcessor();
+
+ ExpectInit();
+ video_processor_->Init();
+
+ ExpectRelease();
+ video_processor_->Release();
+}
+
+TEST_F(VideoProcessorTest, ProcessFrames_30fps) {
+ const int kFramerateFps = 30;
+ config_.codec_settings.maxFramerate = kFramerateFps;
+ CreateVideoProcessor();
+
ExpectInit();
video_processor_->Init();
+
+ EXPECT_CALL(frame_reader_mock_, ReadFrame())
+ .WillRepeatedly(Return(I420Buffer::Create(kWidth, kHeight)));
+ EXPECT_CALL(encoder_mock_,
+ Encode(testing::Property(&VideoFrame::timestamp,
+ 1 * 90000 / kFramerateFps),
+ _, _))
+ .Times(1);
+ video_processor_->ProcessFrame(0);
+
+ EXPECT_CALL(encoder_mock_,
+ Encode(testing::Property(&VideoFrame::timestamp,
+ 2 * 90000 / kFramerateFps),
+ _, _))
+ .Times(1);
+ video_processor_->ProcessFrame(1);
+
+ ExpectRelease();
+ video_processor_->Release();
}
-TEST_F(VideoProcessorTest, ProcessFrames) {
+TEST_F(VideoProcessorTest, ProcessFrames_15fps) {
+ const int kFramerateFps = 15;
+ config_.codec_settings.maxFramerate = kFramerateFps;
+ CreateVideoProcessor();
+
ExpectInit();
video_processor_->Init();
EXPECT_CALL(frame_reader_mock_, ReadFrame())
.WillRepeatedly(Return(I420Buffer::Create(kWidth, kHeight)));
- EXPECT_CALL(encoder_mock_, Encode(testing::Property(&VideoFrame::timestamp,
- 1 * 90000 / kFramerate),
- _, _))
+ EXPECT_CALL(encoder_mock_,
+ Encode(testing::Property(&VideoFrame::timestamp,
+ 1 * 90000 / kFramerateFps),
+ _, _))
.Times(1);
video_processor_->ProcessFrame(0);
- EXPECT_CALL(encoder_mock_, Encode(testing::Property(&VideoFrame::timestamp,
- 2 * 90000 / kFramerate),
- _, _))
+ EXPECT_CALL(encoder_mock_,
+ Encode(testing::Property(&VideoFrame::timestamp,
+ 2 * 90000 / kFramerateFps),
+ _, _))
.Times(1);
video_processor_->ProcessFrame(1);
+
+ ExpectRelease();
+ video_processor_->Release();
+}
+
+TEST_F(VideoProcessorTest, SetRates) {
+ CreateVideoProcessor();
+ ExpectInit();
+ video_processor_->Init();
+
+ const int kBitrateKbps = 123;
+ const int kFramerateFps = 17;
+ EXPECT_CALL(
+ encoder_mock_,
+ SetRateAllocation(
+ testing::Property(&BitrateAllocation::get_sum_kbps, kBitrateKbps),
+ kFramerateFps))
+ .Times(1);
+ video_processor_->SetRates(kBitrateKbps, kFramerateFps);
+ ASSERT_EQ(1u, video_processor_->NumberDroppedFramesPerRateUpdate().size());
+ EXPECT_EQ(0, video_processor_->NumberDroppedFramesPerRateUpdate()[0]);
+ ASSERT_EQ(1u, video_processor_->NumberSpatialResizesPerRateUpdate().size());
+ EXPECT_EQ(0, video_processor_->NumberSpatialResizesPerRateUpdate()[0]);
+
+ const int kNewBitrateKbps = 456;
+ const int kNewFramerateFps = 34;
+ EXPECT_CALL(
+ encoder_mock_,
+ SetRateAllocation(
+ testing::Property(&BitrateAllocation::get_sum_kbps, kNewBitrateKbps),
+ kNewFramerateFps))
+ .Times(1);
+ video_processor_->SetRates(kNewBitrateKbps, kNewFramerateFps);
+ ASSERT_EQ(2u, video_processor_->NumberDroppedFramesPerRateUpdate().size());
+ EXPECT_EQ(0, video_processor_->NumberDroppedFramesPerRateUpdate()[0]);
+ ASSERT_EQ(2u, video_processor_->NumberSpatialResizesPerRateUpdate().size());
+ EXPECT_EQ(0, video_processor_->NumberSpatialResizesPerRateUpdate()[0]);
}
} // namespace test

Powered by Google App Engine
This is Rietveld 408576698