diff --git a/media/engine/fake_webrtc_video_engine.cc b/media/engine/fake_webrtc_video_engine.cc index c1fc2e6fa0..35b631589e 100644 --- a/media/engine/fake_webrtc_video_engine.cc +++ b/media/engine/fake_webrtc_video_engine.cc @@ -51,8 +51,8 @@ FakeWebRtcVideoDecoder::~FakeWebRtcVideoDecoder() { } } -int32_t FakeWebRtcVideoDecoder::InitDecode(const webrtc::VideoCodec*, int32_t) { - return WEBRTC_VIDEO_CODEC_OK; +bool FakeWebRtcVideoDecoder::Configure(const Settings& settings) { + return true; } int32_t FakeWebRtcVideoDecoder::Decode(const webrtc::EncodedImage&, diff --git a/media/engine/fake_webrtc_video_engine.h b/media/engine/fake_webrtc_video_engine.h index 9adb5a41ef..831e6169c8 100644 --- a/media/engine/fake_webrtc_video_engine.h +++ b/media/engine/fake_webrtc_video_engine.h @@ -44,7 +44,7 @@ class FakeWebRtcVideoDecoder : public webrtc::VideoDecoder { explicit FakeWebRtcVideoDecoder(FakeWebRtcVideoDecoderFactory* factory); ~FakeWebRtcVideoDecoder(); - int32_t InitDecode(const webrtc::VideoCodec*, int32_t) override; + bool Configure(const Settings& settings) override; int32_t Decode(const webrtc::EncodedImage&, bool, int64_t) override; int32_t RegisterDecodeCompleteCallback( webrtc::DecodedImageCallback*) override; diff --git a/test/fake_decoder.cc b/test/fake_decoder.cc index f164bfbe03..46765d5b31 100644 --- a/test/fake_decoder.cc +++ b/test/fake_decoder.cc @@ -36,9 +36,8 @@ FakeDecoder::FakeDecoder(TaskQueueFactory* task_queue_factory) task_queue_factory_(task_queue_factory), decode_delay_ms_(0) {} -int32_t FakeDecoder::InitDecode(const VideoCodec* config, - int32_t number_of_cores) { - return WEBRTC_VIDEO_CODEC_OK; +bool FakeDecoder::Configure(const Settings& settings) { + return true; } int32_t FakeDecoder::Decode(const EncodedImage& input, diff --git a/test/fake_decoder.h b/test/fake_decoder.h index 6a5d6cb419..33454704e1 100644 --- a/test/fake_decoder.h +++ b/test/fake_decoder.h @@ -15,7 +15,6 @@ #include "api/task_queue/task_queue_factory.h" #include "api/video/encoded_image.h" -#include "api/video_codecs/video_codec.h" #include "api/video_codecs/video_decoder.h" #include "modules/video_coding/include/video_codec_interface.h" #include "rtc_base/task_queue.h" @@ -31,8 +30,7 @@ class FakeDecoder : public VideoDecoder { explicit FakeDecoder(TaskQueueFactory* task_queue_factory); virtual ~FakeDecoder() {} - int32_t InitDecode(const VideoCodec* config, - int32_t number_of_cores) override; + bool Configure(const Settings& settings) override; int32_t Decode(const EncodedImage& input, bool missing_frames, diff --git a/test/fake_vp8_decoder.cc b/test/fake_vp8_decoder.cc index ec636dca11..4c2f55a668 100644 --- a/test/fake_vp8_decoder.cc +++ b/test/fake_vp8_decoder.cc @@ -39,9 +39,8 @@ void ParseFakeVp8(const unsigned char* data, int* width, int* height) { FakeVp8Decoder::FakeVp8Decoder() : callback_(nullptr), width_(0), height_(0) {} -int32_t FakeVp8Decoder::InitDecode(const VideoCodec* config, - int32_t number_of_cores) { - return WEBRTC_VIDEO_CODEC_OK; +bool FakeVp8Decoder::Configure(const Settings& settings) { + return true; } int32_t FakeVp8Decoder::Decode(const EncodedImage& input, diff --git a/test/fake_vp8_decoder.h b/test/fake_vp8_decoder.h index 2e469a17f3..391ee374d4 100644 --- a/test/fake_vp8_decoder.h +++ b/test/fake_vp8_decoder.h @@ -14,7 +14,6 @@ #include #include "api/video/encoded_image.h" -#include "api/video_codecs/video_codec.h" #include "api/video_codecs/video_decoder.h" #include "modules/video_coding/include/video_codec_interface.h" @@ -26,8 +25,7 @@ class FakeVp8Decoder : public VideoDecoder { FakeVp8Decoder(); ~FakeVp8Decoder() override {} - int32_t InitDecode(const VideoCodec* config, - int32_t number_of_cores) override; + bool Configure(const Settings& settings) override; int32_t Decode(const EncodedImage& input, bool missing_frames, diff --git a/test/pc/e2e/analyzer/video/quality_analyzing_video_decoder.cc b/test/pc/e2e/analyzer/video/quality_analyzing_video_decoder.cc index 9fb711637e..deb980aef3 100644 --- a/test/pc/e2e/analyzer/video/quality_analyzing_video_decoder.cc +++ b/test/pc/e2e/analyzer/video/quality_analyzing_video_decoder.cc @@ -40,16 +40,13 @@ QualityAnalyzingVideoDecoder::QualityAnalyzingVideoDecoder( } QualityAnalyzingVideoDecoder::~QualityAnalyzingVideoDecoder() = default; -int32_t QualityAnalyzingVideoDecoder::InitDecode( - const VideoCodec* codec_settings, - int32_t number_of_cores) { +bool QualityAnalyzingVideoDecoder::Configure(const Settings& settings) { { MutexLock lock(&mutex_); - codec_name_ = - std::string(CodecTypeToPayloadString(codec_settings->codecType)) + "_" + - delegate_->GetDecoderInfo().implementation_name; + codec_name_ = std::string(CodecTypeToPayloadString(settings.codec_type())) + + "_" + delegate_->GetDecoderInfo().implementation_name; } - return delegate_->InitDecode(codec_settings, number_of_cores); + return delegate_->Configure(settings); } int32_t QualityAnalyzingVideoDecoder::Decode(const EncodedImage& input_image, diff --git a/test/pc/e2e/analyzer/video/quality_analyzing_video_decoder.h b/test/pc/e2e/analyzer/video/quality_analyzing_video_decoder.h index 9177b961f6..63d7c14373 100644 --- a/test/pc/e2e/analyzer/video/quality_analyzing_video_decoder.h +++ b/test/pc/e2e/analyzer/video/quality_analyzing_video_decoder.h @@ -56,8 +56,7 @@ class QualityAnalyzingVideoDecoder : public VideoDecoder { ~QualityAnalyzingVideoDecoder() override; // Methods of VideoDecoder interface. - int32_t InitDecode(const VideoCodec* codec_settings, - int32_t number_of_cores) override; + bool Configure(const Settings& settings) override; int32_t Decode(const EncodedImage& input_image, bool missing_frames, int64_t render_time_ms) override; diff --git a/test/video_decoder_proxy_factory.h b/test/video_decoder_proxy_factory.h index 303d209dbd..f294f62713 100644 --- a/test/video_decoder_proxy_factory.h +++ b/test/video_decoder_proxy_factory.h @@ -52,9 +52,8 @@ class VideoDecoderProxyFactory final : public VideoDecoderFactory { int64_t render_time_ms) override { return decoder_->Decode(input_image, missing_frames, render_time_ms); } - int32_t InitDecode(const VideoCodec* config, - int32_t number_of_cores) override { - return decoder_->InitDecode(config, number_of_cores); + bool Configure(const Settings& settings) override { + return decoder_->Configure(settings); } int32_t RegisterDecodeCompleteCallback( DecodedImageCallback* callback) override { diff --git a/video/video_receive_stream2_unittest.cc b/video/video_receive_stream2_unittest.cc index cc282d83fb..8004bc375b 100644 --- a/video/video_receive_stream2_unittest.cc +++ b/video/video_receive_stream2_unittest.cc @@ -54,6 +54,7 @@ using ::testing::Invoke; using ::testing::IsEmpty; using ::testing::Property; using ::testing::SizeIs; +using ::testing::WithoutArgs; constexpr int kDefaultTimeOutMs = 50; @@ -137,13 +138,11 @@ TEST_F(VideoReceiveStream2Test, CreateFrameFromH264FmtpSpropAndIdr) { rtppacket.SetPayloadType(99); rtppacket.SetSequenceNumber(1); rtppacket.SetTimestamp(0); - rtc::Event init_decode_event_; - EXPECT_CALL(mock_h264_video_decoder_, InitDecode(_, _)) - .WillOnce(Invoke([&init_decode_event_](const VideoCodec* config, - int32_t number_of_cores) { - init_decode_event_.Set(); - return 0; - })); + rtc::Event init_decode_event; + EXPECT_CALL(mock_h264_video_decoder_, Configure).WillOnce(WithoutArgs([&] { + init_decode_event.Set(); + return true; + })); EXPECT_CALL(mock_h264_video_decoder_, RegisterDecodeCompleteCallback(_)); video_receive_stream_->Start(); EXPECT_CALL(mock_h264_video_decoder_, Decode(_, false, _)); @@ -152,7 +151,7 @@ TEST_F(VideoReceiveStream2Test, CreateFrameFromH264FmtpSpropAndIdr) { rtp_stream_receiver_controller_.OnRtpPacket(parsed_packet); EXPECT_CALL(mock_h264_video_decoder_, Release()); // Make sure the decoder thread had a chance to run. - init_decode_event_.Wait(kDefaultTimeOutMs); + init_decode_event.Wait(kDefaultTimeOutMs); } TEST_F(VideoReceiveStream2Test, PlayoutDelay) { @@ -766,13 +765,11 @@ TEST_F(VideoReceiveStream2TestWithLazyDecoderCreation, LazyDecoderCreation) { &mock_h264_video_decoder_); return h264_decoder_factory.CreateVideoDecoder(format); })); - rtc::Event init_decode_event_; - EXPECT_CALL(mock_h264_video_decoder_, InitDecode(_, _)) - .WillOnce(Invoke([&init_decode_event_](const VideoCodec* config, - int32_t number_of_cores) { - init_decode_event_.Set(); - return 0; - })); + rtc::Event init_decode_event; + EXPECT_CALL(mock_h264_video_decoder_, Configure).WillOnce(WithoutArgs([&] { + init_decode_event.Set(); + return true; + })); EXPECT_CALL(mock_h264_video_decoder_, RegisterDecodeCompleteCallback(_)); EXPECT_CALL(mock_h264_video_decoder_, Decode(_, false, _)); RtpPacketReceived parsed_packet; @@ -781,7 +778,7 @@ TEST_F(VideoReceiveStream2TestWithLazyDecoderCreation, LazyDecoderCreation) { EXPECT_CALL(mock_h264_video_decoder_, Release()); // Make sure the decoder thread had a chance to run. - init_decode_event_.Wait(kDefaultTimeOutMs); + init_decode_event.Wait(kDefaultTimeOutMs); } TEST_F(VideoReceiveStream2TestWithLazyDecoderCreation, diff --git a/video/video_receive_stream_unittest.cc b/video/video_receive_stream_unittest.cc index f3099d8de7..87208c7231 100644 --- a/video/video_receive_stream_unittest.cc +++ b/video/video_receive_stream_unittest.cc @@ -45,6 +45,7 @@ using ::testing::ElementsAreArray; using ::testing::Invoke; using ::testing::IsEmpty; using ::testing::SizeIs; +using ::testing::WithoutArgs; constexpr int kDefaultTimeOutMs = 50; @@ -120,13 +121,11 @@ TEST_F(VideoReceiveStreamTest, CreateFrameFromH264FmtpSpropAndIdr) { rtppacket.SetPayloadType(99); rtppacket.SetSequenceNumber(1); rtppacket.SetTimestamp(0); - rtc::Event init_decode_event_; - EXPECT_CALL(mock_h264_video_decoder_, InitDecode(_, _)) - .WillOnce(Invoke([&init_decode_event_](const VideoCodec* config, - int32_t number_of_cores) { - init_decode_event_.Set(); - return 0; - })); + rtc::Event init_decode_event; + EXPECT_CALL(mock_h264_video_decoder_, Configure).WillOnce(WithoutArgs([&] { + init_decode_event.Set(); + return true; + })); EXPECT_CALL(mock_h264_video_decoder_, RegisterDecodeCompleteCallback(_)); video_receive_stream_->Start(); EXPECT_CALL(mock_h264_video_decoder_, Decode(_, false, _)); @@ -135,7 +134,7 @@ TEST_F(VideoReceiveStreamTest, CreateFrameFromH264FmtpSpropAndIdr) { rtp_stream_receiver_controller_.OnRtpPacket(parsed_packet); EXPECT_CALL(mock_h264_video_decoder_, Release()); // Make sure the decoder thread had a chance to run. - init_decode_event_.Wait(kDefaultTimeOutMs); + init_decode_event.Wait(kDefaultTimeOutMs); } TEST_F(VideoReceiveStreamTest, PlayoutDelay) { diff --git a/video/video_stream_decoder_impl_unittest.cc b/video/video_stream_decoder_impl_unittest.cc index a3e258976a..f3fe3acf41 100644 --- a/video/video_stream_decoder_impl_unittest.cc +++ b/video/video_stream_decoder_impl_unittest.cc @@ -13,6 +13,7 @@ #include #include "api/video/i420_buffer.h" +#include "api/video_codecs/video_decoder.h" #include "test/gmock.h" #include "test/gtest.h" #include "test/time_controller/simulated_time_controller.h" @@ -39,10 +40,9 @@ class MockVideoStreamDecoderCallbacks class StubVideoDecoder : public VideoDecoder { public: - MOCK_METHOD(int32_t, - InitDecode, - (const VideoCodec*, int32_t number_of_cores), - (override)); + StubVideoDecoder() { ON_CALL(*this, Configure).WillByDefault(Return(true)); } + + MOCK_METHOD(bool, Configure, (const Settings&), (override)); int32_t Decode(const EncodedImage& input_image, bool missing_frames, @@ -81,9 +81,8 @@ class WrappedVideoDecoder : public VideoDecoder { public: explicit WrappedVideoDecoder(StubVideoDecoder* decoder) : decoder_(decoder) {} - int32_t InitDecode(const VideoCodec* codec_settings, - int32_t number_of_cores) override { - return decoder_->InitDecode(codec_settings, number_of_cores); + bool Configure(const Settings& settings) override { + return decoder_->Configure(settings); } int32_t Decode(const EncodedImage& input_image, bool missing_frames, @@ -203,8 +202,8 @@ TEST_F(VideoStreamDecoderImplTest, InsertAndDecodeFrameWithKeyframeRequest) { TEST_F(VideoStreamDecoderImplTest, FailToInitDecoder) { video_stream_decoder_.OnFrame(FrameBuilder().WithPayloadType(1).Build()); - ON_CALL(decoder_factory_.Vp8Decoder(), InitDecode) - .WillByDefault(Return(WEBRTC_VIDEO_CODEC_ERROR)); + ON_CALL(decoder_factory_.Vp8Decoder(), Configure) + .WillByDefault(Return(false)); EXPECT_CALL(callbacks_, OnNonDecodableState); time_controller_.AdvanceTime(TimeDelta::Millis(1)); }