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

Unified Diff: webrtc/modules/video_coding/codecs/vp8/simulcast_encoder_adapter_unittest.cc

Issue 2008723002: Forward Encode failure codes from sub encoders. (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@master
Patch Set: Test: only set software fallback on 2nd encoder. Created 4 years, 7 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
« no previous file with comments | « webrtc/modules/video_coding/codecs/vp8/simulcast_encoder_adapter.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: webrtc/modules/video_coding/codecs/vp8/simulcast_encoder_adapter_unittest.cc
diff --git a/webrtc/modules/video_coding/codecs/vp8/simulcast_encoder_adapter_unittest.cc b/webrtc/modules/video_coding/codecs/vp8/simulcast_encoder_adapter_unittest.cc
index aafcd797ac50e10ba7ead609ffa3ae516298b96d..89c61cec3af9b84b507c23c27405f96544e420f4 100644
--- a/webrtc/modules/video_coding/codecs/vp8/simulcast_encoder_adapter_unittest.cc
+++ b/webrtc/modules/video_coding/codecs/vp8/simulcast_encoder_adapter_unittest.cc
@@ -121,7 +121,7 @@ class MockVideoEncoder : public VideoEncoder {
int32_t Encode(const VideoFrame& inputImage,
const CodecSpecificInfo* codecSpecificInfo,
const std::vector<FrameType>* frame_types) /* override */ {
- return 0;
+ return encode_return_value_;
}
int32_t RegisterEncodeCompleteCallback(
@@ -160,10 +160,15 @@ class MockVideoEncoder : public VideoEncoder {
supports_native_handle_ = enabled;
}
+ void set_encode_return_value(int value) {
+ encode_return_value_ = value;
+ }
+
MOCK_CONST_METHOD0(ImplementationName, const char*());
private:
bool supports_native_handle_ = false;
+ int encode_return_value_ = WEBRTC_VIDEO_CODEC_OK;
VideoCodec codec_;
EncodedImageCallback* callback_;
};
@@ -171,7 +176,8 @@ class MockVideoEncoder : public VideoEncoder {
class MockVideoEncoderFactory : public VideoEncoderFactory {
public:
VideoEncoder* Create() override {
- MockVideoEncoder* encoder = new MockVideoEncoder();
+ MockVideoEncoder* encoder = new
+ ::testing::NiceMock<MockVideoEncoder>();
const char* encoder_name = encoder_names_.empty()
? "codec_implementation_name"
: encoder_names_[encoders_.size()];
@@ -460,5 +466,33 @@ TEST_F(TestSimulcastEncoderAdapterFake,
EXPECT_FALSE(adapter_->SupportsNativeHandle());
}
+TEST_F(TestSimulcastEncoderAdapterFake, TestFailureReturnCodesFromEncodeCalls) {
+ TestVp8Simulcast::DefaultSettings(
+ &codec_, static_cast<const int*>(kTestTemporalLayerProfile));
+ codec_.numberOfSimulcastStreams = 3;
+ EXPECT_EQ(0, adapter_->InitEncode(&codec_, 1, 1200));
+ adapter_->RegisterEncodeCompleteCallback(this);
+ ASSERT_EQ(3u, helper_->factory()->encoders().size());
+ // Tell the 2nd encoder to request software fallback.
+ helper_->factory()->encoders()[1]->set_encode_return_value(
+ WEBRTC_VIDEO_CODEC_FALLBACK_SOFTWARE);
+
+ // Send a fake frame and assert the return is software fallback.
+ VideoFrame input_frame;
+ int half_width = (kDefaultWidth + 1) / 2;
+ input_frame.CreateEmptyFrame(kDefaultWidth, kDefaultHeight, kDefaultWidth,
+ half_width, half_width);
+ memset(input_frame.video_frame_buffer()->MutableDataY(), 0,
+ input_frame.allocated_size(kYPlane));
+ memset(input_frame.video_frame_buffer()->MutableDataU(), 0,
+ input_frame.allocated_size(kUPlane));
+ memset(input_frame.video_frame_buffer()->MutableDataV(), 0,
+ input_frame.allocated_size(kVPlane));
+
+ std::vector<FrameType> frame_types(3, kVideoFrameKey);
+ EXPECT_EQ(WEBRTC_VIDEO_CODEC_FALLBACK_SOFTWARE,
+ adapter_->Encode(input_frame, nullptr, &frame_types));
+}
+
} // namespace testing
} // namespace webrtc
« no previous file with comments | « webrtc/modules/video_coding/codecs/vp8/simulcast_encoder_adapter.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698