Remove VideoProcessor interface.
BUG=webrtc:6634 Review-Url: https://codereview.webrtc.org/2994613002 Cr-Commit-Position: refs/heads/master@{#19256}
This commit is contained in:
@ -105,16 +105,16 @@ const char* ExcludeFrameTypesToStr(ExcludeFrameTypes e) {
|
||||
}
|
||||
}
|
||||
|
||||
VideoProcessorImpl::VideoProcessorImpl(webrtc::VideoEncoder* encoder,
|
||||
webrtc::VideoDecoder* decoder,
|
||||
FrameReader* analysis_frame_reader,
|
||||
FrameWriter* analysis_frame_writer,
|
||||
PacketManipulator* packet_manipulator,
|
||||
const TestConfig& config,
|
||||
Stats* stats,
|
||||
FrameWriter* source_frame_writer,
|
||||
IvfFileWriter* encoded_frame_writer,
|
||||
FrameWriter* decoded_frame_writer)
|
||||
VideoProcessor::VideoProcessor(webrtc::VideoEncoder* encoder,
|
||||
webrtc::VideoDecoder* decoder,
|
||||
FrameReader* analysis_frame_reader,
|
||||
FrameWriter* analysis_frame_writer,
|
||||
PacketManipulator* packet_manipulator,
|
||||
const TestConfig& config,
|
||||
Stats* stats,
|
||||
FrameWriter* source_frame_writer,
|
||||
IvfFileWriter* encoded_frame_writer,
|
||||
FrameWriter* decoded_frame_writer)
|
||||
: encoder_(encoder),
|
||||
decoder_(decoder),
|
||||
bitrate_allocator_(CreateBitrateAllocator(config)),
|
||||
@ -144,12 +144,12 @@ VideoProcessorImpl::VideoProcessorImpl(webrtc::VideoEncoder* encoder,
|
||||
frame_infos_.reserve(analysis_frame_reader->NumberOfFrames());
|
||||
}
|
||||
|
||||
VideoProcessorImpl::~VideoProcessorImpl() {
|
||||
VideoProcessor::~VideoProcessor() {
|
||||
encoder_->RegisterEncodeCompleteCallback(nullptr);
|
||||
decoder_->RegisterDecodeCompleteCallback(nullptr);
|
||||
}
|
||||
|
||||
void VideoProcessorImpl::Init() {
|
||||
void VideoProcessor::Init() {
|
||||
RTC_DCHECK(!initialized_) << "VideoProcessor already initialized.";
|
||||
RTC_DCHECK(config_.codec_settings) << "No codec settings supplied.";
|
||||
initialized_ = true;
|
||||
@ -196,7 +196,7 @@ void VideoProcessorImpl::Init() {
|
||||
}
|
||||
}
|
||||
|
||||
bool VideoProcessorImpl::ProcessFrame(int frame_number) {
|
||||
bool VideoProcessor::ProcessFrame(int frame_number) {
|
||||
RTC_DCHECK_GE(frame_number, 0);
|
||||
RTC_DCHECK_LE(frame_number, frame_infos_.size())
|
||||
<< "Must process frames without gaps.";
|
||||
@ -253,7 +253,7 @@ bool VideoProcessorImpl::ProcessFrame(int frame_number) {
|
||||
return true;
|
||||
}
|
||||
|
||||
void VideoProcessorImpl::SetRates(int bit_rate, int frame_rate) {
|
||||
void VideoProcessor::SetRates(int bit_rate, int frame_rate) {
|
||||
config_.codec_settings->maxFramerate = frame_rate;
|
||||
int set_rates_result = encoder_->SetRateAllocation(
|
||||
bitrate_allocator_->GetAllocation(bit_rate * 1000, frame_rate),
|
||||
@ -264,35 +264,35 @@ void VideoProcessorImpl::SetRates(int bit_rate, int frame_rate) {
|
||||
num_spatial_resizes_ = 0;
|
||||
}
|
||||
|
||||
size_t VideoProcessorImpl::EncodedFrameSize(int frame_number) {
|
||||
size_t VideoProcessor::EncodedFrameSize(int frame_number) {
|
||||
RTC_DCHECK_LT(frame_number, frame_infos_.size());
|
||||
return frame_infos_[frame_number].encoded_frame_size;
|
||||
}
|
||||
|
||||
FrameType VideoProcessorImpl::EncodedFrameType(int frame_number) {
|
||||
FrameType VideoProcessor::EncodedFrameType(int frame_number) {
|
||||
RTC_DCHECK_LT(frame_number, frame_infos_.size());
|
||||
return frame_infos_[frame_number].encoded_frame_type;
|
||||
}
|
||||
|
||||
int VideoProcessorImpl::GetQpFromEncoder(int frame_number) {
|
||||
int VideoProcessor::GetQpFromEncoder(int frame_number) {
|
||||
RTC_DCHECK_LT(frame_number, frame_infos_.size());
|
||||
return frame_infos_[frame_number].qp_encoder;
|
||||
}
|
||||
|
||||
int VideoProcessorImpl::GetQpFromBitstream(int frame_number) {
|
||||
int VideoProcessor::GetQpFromBitstream(int frame_number) {
|
||||
RTC_DCHECK_LT(frame_number, frame_infos_.size());
|
||||
return frame_infos_[frame_number].qp_bitstream;
|
||||
}
|
||||
|
||||
int VideoProcessorImpl::NumberDroppedFrames() {
|
||||
int VideoProcessor::NumberDroppedFrames() {
|
||||
return num_dropped_frames_;
|
||||
}
|
||||
|
||||
int VideoProcessorImpl::NumberSpatialResizes() {
|
||||
int VideoProcessor::NumberSpatialResizes() {
|
||||
return num_spatial_resizes_;
|
||||
}
|
||||
|
||||
void VideoProcessorImpl::FrameEncoded(
|
||||
void VideoProcessor::FrameEncoded(
|
||||
webrtc::VideoCodecType codec,
|
||||
const EncodedImage& encoded_image,
|
||||
const webrtc::RTPFragmentationHeader* fragmentation) {
|
||||
@ -428,7 +428,7 @@ void VideoProcessorImpl::FrameEncoded(
|
||||
}
|
||||
}
|
||||
|
||||
void VideoProcessorImpl::FrameDecoded(const VideoFrame& image) {
|
||||
void VideoProcessor::FrameDecoded(const VideoFrame& image) {
|
||||
// For the highest measurement accuracy of the decode time, the start/stop
|
||||
// time recordings should wrap the Decode call as tightly as possible.
|
||||
int64_t decode_stop_ns = rtc::TimeNanos();
|
||||
@ -496,14 +496,14 @@ void VideoProcessorImpl::FrameDecoded(const VideoFrame& image) {
|
||||
last_decoded_frame_buffer_ = std::move(extracted_buffer);
|
||||
}
|
||||
|
||||
uint32_t VideoProcessorImpl::FrameNumberToTimestamp(int frame_number) {
|
||||
uint32_t VideoProcessor::FrameNumberToTimestamp(int frame_number) {
|
||||
RTC_DCHECK_GE(frame_number, 0);
|
||||
const int ticks_per_frame =
|
||||
kRtpClockRateHz / config_.codec_settings->maxFramerate;
|
||||
return (frame_number + 1) * ticks_per_frame;
|
||||
}
|
||||
|
||||
int VideoProcessorImpl::TimestampToFrameNumber(uint32_t timestamp) {
|
||||
int VideoProcessor::TimestampToFrameNumber(uint32_t timestamp) {
|
||||
RTC_DCHECK_GT(timestamp, 0);
|
||||
const int ticks_per_frame =
|
||||
kRtpClockRateHz / config_.codec_settings->maxFramerate;
|
||||
|
||||
@ -136,67 +136,49 @@ struct TestConfig {
|
||||
//
|
||||
// Note this class is not thread safe in any way and is meant for simple testing
|
||||
// purposes.
|
||||
//
|
||||
// TODO(brandtr): Remove this interface.
|
||||
class VideoProcessor {
|
||||
public:
|
||||
virtual ~VideoProcessor() {}
|
||||
VideoProcessor(webrtc::VideoEncoder* encoder,
|
||||
webrtc::VideoDecoder* decoder,
|
||||
FrameReader* analysis_frame_reader,
|
||||
FrameWriter* analysis_frame_writer,
|
||||
PacketManipulator* packet_manipulator,
|
||||
const TestConfig& config,
|
||||
Stats* stats,
|
||||
FrameWriter* source_frame_writer,
|
||||
IvfFileWriter* encoded_frame_writer,
|
||||
FrameWriter* decoded_frame_writer);
|
||||
~VideoProcessor();
|
||||
|
||||
// Sets up callbacks and initializes the encoder and decoder.
|
||||
virtual void Init() = 0;
|
||||
void Init();
|
||||
|
||||
// Processes a single frame. Returns true as long as there's more frames
|
||||
// available in the source clip.
|
||||
// |frame_number| must be an integer >= 0.
|
||||
virtual bool ProcessFrame(int frame_number) = 0;
|
||||
bool ProcessFrame(int frame_number);
|
||||
|
||||
// Updates the encoder with the target |bit_rate| and the |frame_rate|.
|
||||
virtual void SetRates(int bit_rate, int frame_rate) = 0;
|
||||
void SetRates(int bit_rate, int frame_rate);
|
||||
|
||||
// Return the size of the encoded frame in bytes. Dropped frames by the
|
||||
// encoder are regarded as zero size.
|
||||
virtual size_t EncodedFrameSize(int frame_number) = 0;
|
||||
size_t EncodedFrameSize(int frame_number);
|
||||
|
||||
// Return the encoded frame type (key or delta).
|
||||
virtual FrameType EncodedFrameType(int frame_number) = 0;
|
||||
FrameType EncodedFrameType(int frame_number);
|
||||
|
||||
// Return the qp used by encoder.
|
||||
virtual int GetQpFromEncoder(int frame_number) = 0;
|
||||
int GetQpFromEncoder(int frame_number);
|
||||
|
||||
// Return the qp from the qp parser.
|
||||
virtual int GetQpFromBitstream(int frame_number) = 0;
|
||||
int GetQpFromBitstream(int frame_number);
|
||||
|
||||
// Return the number of dropped frames.
|
||||
virtual int NumberDroppedFrames() = 0;
|
||||
int NumberDroppedFrames();
|
||||
|
||||
// Return the number of spatial resizes.
|
||||
virtual int NumberSpatialResizes() = 0;
|
||||
};
|
||||
|
||||
class VideoProcessorImpl : public VideoProcessor {
|
||||
public:
|
||||
VideoProcessorImpl(webrtc::VideoEncoder* encoder,
|
||||
webrtc::VideoDecoder* decoder,
|
||||
FrameReader* analysis_frame_reader,
|
||||
FrameWriter* analysis_frame_writer,
|
||||
PacketManipulator* packet_manipulator,
|
||||
const TestConfig& config,
|
||||
Stats* stats,
|
||||
FrameWriter* source_frame_writer,
|
||||
IvfFileWriter* encoded_frame_writer,
|
||||
FrameWriter* decoded_frame_writer);
|
||||
~VideoProcessorImpl() override;
|
||||
|
||||
// Implements VideoProcessor.
|
||||
void Init() override;
|
||||
bool ProcessFrame(int frame_number) override;
|
||||
void SetRates(int bit_rate, int frame_rate) override;
|
||||
size_t EncodedFrameSize(int frame_number) override;
|
||||
FrameType EncodedFrameType(int frame_number) override;
|
||||
int GetQpFromEncoder(int frame_number) override;
|
||||
int GetQpFromBitstream(int frame_number) override;
|
||||
int NumberDroppedFrames() override;
|
||||
int NumberSpatialResizes() override;
|
||||
int NumberSpatialResizes();
|
||||
|
||||
private:
|
||||
// Container that holds per-frame information that needs to be stored between
|
||||
@ -231,8 +213,9 @@ class VideoProcessorImpl : public VideoProcessor {
|
||||
class VideoProcessorEncodeCompleteCallback
|
||||
: public webrtc::EncodedImageCallback {
|
||||
public:
|
||||
explicit VideoProcessorEncodeCompleteCallback(VideoProcessorImpl* vp)
|
||||
: video_processor_(vp) {}
|
||||
explicit VideoProcessorEncodeCompleteCallback(
|
||||
VideoProcessor* video_processor)
|
||||
: video_processor_(video_processor) {}
|
||||
Result OnEncodedImage(
|
||||
const webrtc::EncodedImage& encoded_image,
|
||||
const webrtc::CodecSpecificInfo* codec_specific_info,
|
||||
@ -245,15 +228,16 @@ class VideoProcessorImpl : public VideoProcessor {
|
||||
}
|
||||
|
||||
private:
|
||||
VideoProcessorImpl* const video_processor_;
|
||||
VideoProcessor* const video_processor_;
|
||||
};
|
||||
|
||||
// Callback class required to implement according to the VideoDecoder API.
|
||||
class VideoProcessorDecodeCompleteCallback
|
||||
: public webrtc::DecodedImageCallback {
|
||||
public:
|
||||
explicit VideoProcessorDecodeCompleteCallback(VideoProcessorImpl* vp)
|
||||
: video_processor_(vp) {}
|
||||
explicit VideoProcessorDecodeCompleteCallback(
|
||||
VideoProcessor* video_processor)
|
||||
: video_processor_(video_processor) {}
|
||||
int32_t Decoded(webrtc::VideoFrame& image) override {
|
||||
// Forward to parent class.
|
||||
video_processor_->FrameDecoded(image);
|
||||
@ -270,7 +254,7 @@ class VideoProcessorImpl : public VideoProcessor {
|
||||
}
|
||||
|
||||
private:
|
||||
VideoProcessorImpl* const video_processor_;
|
||||
VideoProcessor* const video_processor_;
|
||||
};
|
||||
|
||||
// Invoked by the callback when a frame has completed encoding.
|
||||
|
||||
@ -40,6 +40,7 @@
|
||||
#include "webrtc/rtc_base/checks.h"
|
||||
#include "webrtc/rtc_base/file.h"
|
||||
#include "webrtc/rtc_base/logging.h"
|
||||
#include "webrtc/rtc_base/ptr_util.h"
|
||||
#include "webrtc/test/gtest.h"
|
||||
#include "webrtc/test/testsupport/fileutils.h"
|
||||
#include "webrtc/test/testsupport/frame_reader.h"
|
||||
@ -260,11 +261,11 @@ class VideoProcessorIntegrationTest : public testing::Test {
|
||||
|
||||
packet_manipulator_.reset(new test::PacketManipulatorImpl(
|
||||
&packet_reader_, config_.networking_config, config_.verbose));
|
||||
processor_.reset(new test::VideoProcessorImpl(
|
||||
processor_ = rtc::MakeUnique<VideoProcessor>(
|
||||
encoder_.get(), decoder_.get(), analysis_frame_reader_.get(),
|
||||
analysis_frame_writer_.get(), packet_manipulator_.get(), config_,
|
||||
&stats_, source_frame_writer_.get(), encoded_frame_writer_.get(),
|
||||
decoded_frame_writer_.get()));
|
||||
decoded_frame_writer_.get());
|
||||
processor_->Init();
|
||||
}
|
||||
|
||||
|
||||
@ -56,7 +56,7 @@ class VideoProcessorTest : public testing::Test {
|
||||
.WillRepeatedly(Return(kNumFrames));
|
||||
EXPECT_CALL(frame_reader_mock_, FrameLength())
|
||||
.WillRepeatedly(Return(kFrameSize));
|
||||
video_processor_ = rtc::MakeUnique<VideoProcessorImpl>(
|
||||
video_processor_ = rtc::MakeUnique<VideoProcessor>(
|
||||
&encoder_mock_, &decoder_mock_, &frame_reader_mock_,
|
||||
&frame_writer_mock_, &packet_manipulator_mock_, config_, &stats_,
|
||||
nullptr /* source_frame_writer */, nullptr /* encoded_frame_writer */,
|
||||
@ -80,7 +80,7 @@ class VideoProcessorTest : public testing::Test {
|
||||
VideoCodec codec_settings_;
|
||||
TestConfig config_;
|
||||
Stats stats_;
|
||||
std::unique_ptr<VideoProcessorImpl> video_processor_;
|
||||
std::unique_ptr<VideoProcessor> video_processor_;
|
||||
};
|
||||
|
||||
TEST_F(VideoProcessorTest, Init) {
|
||||
|
||||
@ -506,12 +506,10 @@ int main(int argc, char* argv[]) {
|
||||
if (FLAGS_disable_fixed_random_seed) {
|
||||
packet_manipulator.InitializeRandomSeed(time(NULL));
|
||||
}
|
||||
webrtc::test::VideoProcessor* processor =
|
||||
new webrtc::test::VideoProcessorImpl(
|
||||
encoder, decoder, &frame_reader, &frame_writer, &packet_manipulator,
|
||||
config, &stats, nullptr /* source_frame_writer */,
|
||||
nullptr /* encoded_frame_writer */,
|
||||
nullptr /* decoded_frame_writer */);
|
||||
webrtc::test::VideoProcessor* processor = new webrtc::test::VideoProcessor(
|
||||
encoder, decoder, &frame_reader, &frame_writer, &packet_manipulator,
|
||||
config, &stats, nullptr /* source_frame_writer */,
|
||||
nullptr /* encoded_frame_writer */, nullptr /* decoded_frame_writer */);
|
||||
processor->Init();
|
||||
|
||||
int frame_number = 0;
|
||||
|
||||
Reference in New Issue
Block a user