diff --git a/call/video_receive_stream.cc b/call/video_receive_stream.cc index b42c9f9dcf..7662afff72 100644 --- a/call/video_receive_stream.cc +++ b/call/video_receive_stream.cc @@ -88,8 +88,6 @@ std::string VideoReceiveStream::Config::ToString() const { ss << ", render_delay_ms: " << render_delay_ms; if (!sync_group.empty()) ss << ", sync_group: " << sync_group; - ss << ", pre_decode_callback: " - << (pre_decode_callback ? "(EncodedFrameObserver)" : "nullptr"); ss << ", target_delay_ms: " << target_delay_ms; ss << '}'; diff --git a/call/video_receive_stream.h b/call/video_receive_stream.h index a6ae8ef3b8..5009ddb43f 100644 --- a/call/video_receive_stream.h +++ b/call/video_receive_stream.h @@ -213,11 +213,6 @@ class VideoReceiveStream { // to one of the audio streams. std::string sync_group; - // Called for each incoming video frame, i.e. in encoded state. E.g. used - // when - // saving the stream to a file. 'nullptr' disables the callback. - EncodedFrameObserver* pre_decode_callback = nullptr; - // Target delay in milliseconds. A positive value indicates this stream is // used for streaming instead of a real-time call. int target_delay_ms = 0; diff --git a/test/fake_decoder.h b/test/fake_decoder.h index 62bfbb83b1..a90c861f1a 100644 --- a/test/fake_decoder.h +++ b/test/fake_decoder.h @@ -57,17 +57,6 @@ class FakeH264Decoder : public FakeDecoder { int64_t render_time_ms) override; }; -class FakeNullDecoder : public FakeDecoder { - public: - virtual ~FakeNullDecoder() {} - - int32_t Decode(const EncodedImage& input, - bool missing_frames, - const CodecSpecificInfo* codec_specific_info, - int64_t render_time_ms) override { - return 0; - } -}; } // namespace test } // namespace webrtc diff --git a/video/end_to_end_tests/call_operation_tests.cc b/video/end_to_end_tests/call_operation_tests.cc index 2c45665535..dad4c426da 100644 --- a/video/end_to_end_tests/call_operation_tests.cc +++ b/video/end_to_end_tests/call_operation_tests.cc @@ -225,15 +225,6 @@ TEST_P(CallOperationEndToEndTest, ObserversEncodedFrames) { bool Wait() { return called_.Wait(kDefaultTimeoutMs); } - void ExpectEqualFrames(const EncodedFrameTestObserver& observer) { - ASSERT_EQ(length_, observer.length_) - << "Observed frames are of different lengths."; - EXPECT_EQ(frame_type_, observer.frame_type_) - << "Observed frames have different frame types."; - EXPECT_EQ(0, memcmp(buffer_.get(), observer.buffer_.get(), length_)) - << "Observed encoded frames have different content."; - } - private: std::unique_ptr buffer_; size_t length_; @@ -242,7 +233,6 @@ TEST_P(CallOperationEndToEndTest, ObserversEncodedFrames) { }; EncodedFrameTestObserver post_encode_observer; - EncodedFrameTestObserver pre_decode_observer; test::FrameForwarder forwarder; std::unique_ptr frame_generator; @@ -262,7 +252,6 @@ TEST_P(CallOperationEndToEndTest, ObserversEncodedFrames) { CreateSendConfig(1, 0, 0, sender_transport.get()); CreateMatchingReceiveConfigs(receiver_transport.get()); video_send_config_.post_encode_callback = &post_encode_observer; - video_receive_configs_[0].pre_decode_callback = &pre_decode_observer; CreateVideoStreams(); Start(); @@ -277,11 +266,6 @@ TEST_P(CallOperationEndToEndTest, ObserversEncodedFrames) { EXPECT_TRUE(post_encode_observer.Wait()) << "Timed out while waiting for send-side encoded-frame callback."; - EXPECT_TRUE(pre_decode_observer.Wait()) - << "Timed out while waiting for pre-decode encoded-frame callback."; - - post_encode_observer.ExpectEqualFrames(pre_decode_observer); - task_queue_.SendTask([this, &sender_transport, &receiver_transport]() { Stop(); DestroyStreams(); diff --git a/video/replay.cc b/video/replay.cc index 8362f59cb4..4667aa20cf 100644 --- a/video/replay.cc +++ b/video/replay.cc @@ -201,7 +201,7 @@ class FileRenderPassthrough : public rtc::VideoSinkInterface { size_t count_; }; -class DecoderBitstreamFileWriter : public EncodedFrameObserver { +class DecoderBitstreamFileWriter : public test::FakeDecoder { public: explicit DecoderBitstreamFileWriter(const char* filename) : file_(fopen(filename, "wb")) { @@ -209,8 +209,16 @@ class DecoderBitstreamFileWriter : public EncodedFrameObserver { } ~DecoderBitstreamFileWriter() { fclose(file_); } - virtual void EncodedFrameCallback(const EncodedFrame& encoded_frame) { - fwrite(encoded_frame.data_, 1, encoded_frame.length_, file_); + int32_t Decode(const EncodedImage& encoded_frame, + bool /* missing_frames */, + const CodecSpecificInfo* /* codec_specific_info */, + int64_t /* render_time_ms */) override { + if (fwrite(encoded_frame._buffer, 1, encoded_frame._length, file_) + < encoded_frame._length) { + RTC_LOG_ERR(LS_ERROR) << "fwrite of encoded frame failed."; + return WEBRTC_VIDEO_CODEC_ERROR; + } + return WEBRTC_VIDEO_CODEC_OK; } private: @@ -252,19 +260,14 @@ void RtpReplay() { receive_config.renderer = &file_passthrough; VideoReceiveStream::Decoder decoder; - std::unique_ptr bitstream_writer; - if (!flags::DecoderBitstreamFilename().empty()) { - bitstream_writer.reset(new DecoderBitstreamFileWriter( - flags::DecoderBitstreamFilename().c_str())); - receive_config.pre_decode_callback = bitstream_writer.get(); - } decoder = test::CreateMatchingDecoder(flags::MediaPayloadType(), flags::Codec()); if (!flags::DecoderBitstreamFilename().empty()) { - // Replace with a null decoder if we're writing the bitstream to a file + // Replace decoder with file writer if we're writing the bitstream to a file // instead. delete decoder.decoder; - decoder.decoder = new test::FakeNullDecoder(); + decoder.decoder = new DecoderBitstreamFileWriter( + flags::DecoderBitstreamFilename().c_str()); } receive_config.decoders.push_back(decoder); diff --git a/video/video_quality_test.cc b/video/video_quality_test.cc index 3dbff9fe6f..c12212e35a 100644 --- a/video/video_quality_test.cc +++ b/video/video_quality_test.cc @@ -97,7 +97,8 @@ namespace webrtc { class VideoAnalyzer : public PacketReceiver, public Transport, - public rtc::VideoSinkInterface { + public rtc::VideoSinkInterface, + public EncodedFrameObserver { public: VideoAnalyzer(test::LayerFilteringTransport* transport, const std::string& test_label, @@ -129,7 +130,6 @@ class VideoAnalyzer : public PacketReceiver, selected_sl_(selected_sl), selected_tl_(selected_tl), pre_encode_proxy_(this), - encode_timing_proxy_(this), last_fec_bytes_(0), frames_to_process_(duration_frames), frames_recorded_(0), @@ -279,7 +279,8 @@ class VideoAnalyzer : public PacketReceiver, } } - void PostEncodeFrameCallback(const EncodedFrame& encoded_frame) { + // EncodedFrameObserver implementation, wired to post_encode_callback. + void EncodedFrameCallback(const EncodedFrame& encoded_frame) override { rtc::CritScope lock(&crit_); if (!first_sent_timestamp_ && encoded_frame.stream_id_ == selected_stream_) { @@ -419,7 +420,6 @@ class VideoAnalyzer : public PacketReceiver, rtc::VideoSinkInterface* pre_encode_proxy() { return &pre_encode_proxy_; } - EncodedFrameObserver* encode_timing_proxy() { return &encode_timing_proxy_; } void StartMeasuringCpuProcessTime() { rtc::CritScope lock(&cpu_measurement_lock_); @@ -529,20 +529,6 @@ class VideoAnalyzer : public PacketReceiver, double ssim; }; - // This class receives the send-side OnEncodeTiming and is provided to not - // conflict with the receiver-side pre_decode_callback. - class OnEncodeTimingProxy : public EncodedFrameObserver { - public: - explicit OnEncodeTimingProxy(VideoAnalyzer* parent) : parent_(parent) {} - - void EncodedFrameCallback(const EncodedFrame& frame) override { - parent_->PostEncodeFrameCallback(frame); - } - - private: - VideoAnalyzer* const parent_; - }; - // This class receives the send-side OnFrame callback and is provided to not // conflict with the receiver-side renderer callback. class PreEncodeProxy : public rtc::VideoSinkInterface { @@ -1000,7 +986,6 @@ class VideoAnalyzer : public PacketReceiver, const int selected_sl_; const int selected_tl_; PreEncodeProxy pre_encode_proxy_; - OnEncodeTimingProxy encode_timing_proxy_; std::vector samples_ RTC_GUARDED_BY(comparison_lock_); test::Statistics sender_time_ RTC_GUARDED_BY(comparison_lock_); test::Statistics receiver_time_ RTC_GUARDED_BY(comparison_lock_); @@ -2007,8 +1992,7 @@ void VideoQualityTest::RunWithAnalyzer(const Params& params) { analyzer.get(); video_send_configs_[0].pre_encode_callback = analyzer->pre_encode_proxy(); RTC_DCHECK(!video_send_configs_[0].post_encode_callback); - video_send_configs_[0].post_encode_callback = - analyzer->encode_timing_proxy(); + video_send_configs_[0].post_encode_callback = analyzer.get(); CreateFlexfecStreams(); CreateVideoStreams(); diff --git a/video/video_receive_stream.cc b/video/video_receive_stream.cc index 3b3d84fda5..3c10c4e7c2 100644 --- a/video/video_receive_stream.cc +++ b/video/video_receive_stream.cc @@ -324,11 +324,6 @@ EncodedImageCallback::Result VideoReceiveStream::OnEncodedImage( if (codec_specific_info->codecType == kVideoCodecVP8) { simulcast_idx = codec_specific_info->codecSpecific.VP8.simulcastIdx; } - if (config_.pre_decode_callback) { - config_.pre_decode_callback->EncodedFrameCallback(EncodedFrame( - encoded_image._buffer, encoded_image._length, encoded_image._frameType, - simulcast_idx, encoded_image._timeStamp)); - } { rtc::CritScope lock(&ivf_writer_lock_); if (ivf_writer_.get()) {