webrtc/video/frame_dumping_decoder.cc
Danil Chapovalov b6f19d7dfd Reland "Update remaining usage of VideoDecoder::InitDecode to Configure"
This reverts commit d6da4c23cc.

Reason for revert: downstream project adjusted

Original change's description:
> Revert "Update remaining usage of VideoDecoder::InitDecode to Configure"
>
> This reverts commit ca0a08ab60.
>
> Reason for revert: Breaks downstream project.
>
> Original change's description:
> > Update remaining usage of VideoDecoder::InitDecode to Configure
> >
> > Bug: webrtc:13045
> > Change-Id: I5253fddfd613cf0228fc3cd861b91e56558dd34a
> > Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/228947
> > Reviewed-by: Erik Språng <sprang@webrtc.org>
> > Commit-Queue: Danil Chapovalov <danilchap@webrtc.org>
> > Cr-Commit-Position: refs/heads/master@{#34777}
>
> TBR=danilchap@webrtc.org,sprang@webrtc.org,webrtc-scoped@luci-project-accounts.iam.gserviceaccount.com
>
> Change-Id: I1868700a43b5aa4b37e9bcba5af233d24526c974
> No-Presubmit: true
> No-Tree-Checks: true
> No-Try: true
> Bug: webrtc:13045
> Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/229024
> Reviewed-by: Mirko Bonadei <mbonadei@webrtc.org>
> Commit-Queue: Mirko Bonadei <mbonadei@webrtc.org>
> Cr-Commit-Position: refs/heads/master@{#34780}

# Not skipping CQ checks because original CL landed > 1 day ago.

Bug: webrtc:13045
Change-Id: I5a44e7126f9f2e405f3be6b84698de53b23203a2
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/229183
Reviewed-by: Danil Chapovalov <danilchap@webrtc.org>
Reviewed-by: Erik Språng <sprang@webrtc.org>
Commit-Queue: Danil Chapovalov <danilchap@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#34795}
2021-08-18 15:58:40 +00:00

91 lines
2.9 KiB
C++

/*
* Copyright (c) 2018 The WebRTC project authors. All Rights Reserved.
*
* Use of this source code is governed by a BSD-style license
* that can be found in the LICENSE file in the root of the source
* tree. An additional intellectual property rights grant can be found
* in the file PATENTS. All contributing project authors may
* be found in the AUTHORS file in the root of the source tree.
*/
#include "video/frame_dumping_decoder.h"
#include <memory>
#include <utility>
#include "modules/video_coding/include/video_codec_interface.h"
#include "modules/video_coding/utility/ivf_file_writer.h"
namespace webrtc {
namespace {
class FrameDumpingDecoder : public VideoDecoder {
public:
FrameDumpingDecoder(std::unique_ptr<VideoDecoder> decoder, FileWrapper file);
~FrameDumpingDecoder() override;
bool Configure(const Settings& settings) override;
int32_t Decode(const EncodedImage& input_image,
bool missing_frames,
int64_t render_time_ms) override;
int32_t RegisterDecodeCompleteCallback(
DecodedImageCallback* callback) override;
int32_t Release() override;
DecoderInfo GetDecoderInfo() const override;
const char* ImplementationName() const override;
private:
std::unique_ptr<VideoDecoder> decoder_;
VideoCodecType codec_type_ = VideoCodecType::kVideoCodecGeneric;
std::unique_ptr<IvfFileWriter> writer_;
};
FrameDumpingDecoder::FrameDumpingDecoder(std::unique_ptr<VideoDecoder> decoder,
FileWrapper file)
: decoder_(std::move(decoder)),
writer_(IvfFileWriter::Wrap(std::move(file),
/* byte_limit= */ 100000000)) {}
FrameDumpingDecoder::~FrameDumpingDecoder() = default;
bool FrameDumpingDecoder::Configure(const Settings& settings) {
codec_type_ = settings.codec_type();
return decoder_->Configure(settings);
}
int32_t FrameDumpingDecoder::Decode(const EncodedImage& input_image,
bool missing_frames,
int64_t render_time_ms) {
int32_t ret = decoder_->Decode(input_image, missing_frames, render_time_ms);
writer_->WriteFrame(input_image, codec_type_);
return ret;
}
int32_t FrameDumpingDecoder::RegisterDecodeCompleteCallback(
DecodedImageCallback* callback) {
return decoder_->RegisterDecodeCompleteCallback(callback);
}
int32_t FrameDumpingDecoder::Release() {
return decoder_->Release();
}
VideoDecoder::DecoderInfo FrameDumpingDecoder::GetDecoderInfo() const {
return decoder_->GetDecoderInfo();
}
const char* FrameDumpingDecoder::ImplementationName() const {
return decoder_->ImplementationName();
}
} // namespace
std::unique_ptr<VideoDecoder> CreateFrameDumpingDecoderWrapper(
std::unique_ptr<VideoDecoder> decoder,
FileWrapper file) {
return std::make_unique<FrameDumpingDecoder>(std::move(decoder),
std::move(file));
}
} // namespace webrtc