Delete pre_decode_callback.

Only user was the replay.cc tool, when dumping frames to a file. It is
changed to instead inject a special decoder.

Bug: None
Change-Id: I521fbba1a0ef440cff7d786f6f4c6397e33f764f
Reviewed-on: https://webrtc-review.googlesource.com/83121
Reviewed-by: Patrik Höglund <phoglund@webrtc.org>
Reviewed-by: Erik Språng <sprang@webrtc.org>
Commit-Queue: Niels Moller <nisse@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#23675}
This commit is contained in:
Niels Möller 2018-06-19 17:05:03 +02:00 committed by Commit Bot
parent 5297bd21b1
commit f88a22cf11
7 changed files with 19 additions and 71 deletions

View File

@ -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 << '}';

View File

@ -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;

View File

@ -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

View File

@ -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<uint8_t[]> 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<test::FrameGenerator> 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();

View File

@ -201,7 +201,7 @@ class FileRenderPassthrough : public rtc::VideoSinkInterface<VideoFrame> {
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<DecoderBitstreamFileWriter> 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);

View File

@ -97,7 +97,8 @@ namespace webrtc {
class VideoAnalyzer : public PacketReceiver,
public Transport,
public rtc::VideoSinkInterface<VideoFrame> {
public rtc::VideoSinkInterface<VideoFrame>,
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<VideoFrame>* 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<VideoFrame> {
@ -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<Sample> 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();

View File

@ -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()) {