Refactor tests with ConfigurableFrameSizeEncoder

Avoid using post_encode_callback, instead add a new callback function
to ConfigurableFrameSizeEncoder. Intention is to delete
post_encode_callback and the EncodedFrameObserver class in a later cl.

Bug: None
Change-Id: I79c103adf11c8915878b3f7cacf24c9b02dd6373
Reviewed-on: https://webrtc-review.googlesource.com/c/104840
Reviewed-by: Erik Språng <sprang@webrtc.org>
Reviewed-by: Sebastian Jansson <srte@webrtc.org>
Commit-Queue: Niels Moller <nisse@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#25064}
This commit is contained in:
Niels Möller
2018-10-09 14:57:01 +02:00
committed by Commit Bot
parent 040f87f934
commit 759f959984
3 changed files with 16 additions and 6 deletions

View File

@ -54,7 +54,9 @@ int32_t ConfigurableFrameSizeEncoder::Encode(
CodecSpecificInfo specific{};
specific.codecType = codec_type_;
callback_->OnEncodedImage(encodedImage, &specific, fragmentation);
if (post_encode_callback_) {
(*post_encode_callback_)();
}
return WEBRTC_VIDEO_CODEC_OK;
}
@ -89,5 +91,10 @@ void ConfigurableFrameSizeEncoder::SetCodecType(VideoCodecType codec_type) {
codec_type_ = codec_type;
}
void ConfigurableFrameSizeEncoder::RegisterPostEncodeCallback(
std::function<void(void)> post_encode_callback) {
post_encode_callback_ = std::move(post_encode_callback);
}
} // namespace test
} // namespace webrtc

View File

@ -46,8 +46,13 @@ class ConfigurableFrameSizeEncoder : public VideoEncoder {
void SetCodecType(VideoCodecType codec_type_);
void RegisterPostEncodeCallback(
std::function<void(void)> post_encode_callback);
private:
EncodedImageCallback* callback_;
absl::optional<std::function<void(void)>> post_encode_callback_;
const size_t max_frame_size_;
size_t current_frame_size_;
std::unique_ptr<uint8_t[]> buffer_;

View File

@ -17,7 +17,6 @@
#include "call/fake_network_pipe.h"
#include "call/rtp_transport_controller_send.h"
#include "call/simulated_network.h"
#include "common_video/include/frame_callback.h"
#include "modules/rtp_rtcp/include/rtp_header_parser.h"
#include "modules/rtp_rtcp/include/rtp_rtcp.h"
#include "modules/rtp_rtcp/source/rtcp_sender.h"
@ -964,8 +963,7 @@ void VideoSendStreamTest::TestPacketFragmentationSize(VideoFormat format,
// Observer that verifies that the expected number of packets and bytes
// arrive for each frame size, from start_size to stop_size.
class FrameFragmentationTest : public test::SendTest,
public EncodedFrameObserver {
class FrameFragmentationTest : public test::SendTest {
public:
FrameFragmentationTest(size_t max_packet_size,
size_t start_size,
@ -1101,7 +1099,7 @@ void VideoSendStreamTest::TestPacketFragmentationSize(VideoFormat format,
}
}
void EncodedFrameCallback(const EncodedFrame& encoded_frame) override {
void UpdateConfiguration() {
rtc::CritScope lock(&mutex_);
// Increase frame size for next encoded frame, in the context of the
// encoder thread.
@ -1132,7 +1130,7 @@ void VideoSendStreamTest::TestPacketFragmentationSize(VideoFormat format,
send_config->encoder_settings.encoder_factory = &encoder_factory_;
send_config->rtp.max_packet_size = kMaxPacketSize;
send_config->post_encode_callback = this;
encoder_.RegisterPostEncodeCallback([this]() { UpdateConfiguration(); });
// Make sure there is at least one extension header, to make the RTP
// header larger than the base length of 12 bytes.