Moving ConfigureEncoderTask to the calling scope.
This CL replaces ConfigureEncoderTask with a slightly simpler struct that is defined within the scope of the function using it. This makes it more clear that it is only used once and slightly reduces the amount of code. Bug: None Change-Id: I181a3da90540aa514048ff77fc9a9e9cf19d8f34 Reviewed-on: https://webrtc-review.googlesource.com/63026 Reviewed-by: Erik Språng <sprang@webrtc.org> Commit-Queue: Sebastian Jansson <srte@webrtc.org> Cr-Commit-Position: refs/heads/master@{#22514}
This commit is contained in:

committed by
Commit Bot

parent
68a716878b
commit
3dc0125cf7
@ -96,30 +96,6 @@ bool IsFramerateScalingEnabled(
|
|||||||
|
|
||||||
} // namespace
|
} // namespace
|
||||||
|
|
||||||
class VideoStreamEncoder::ConfigureEncoderTask : public rtc::QueuedTask {
|
|
||||||
public:
|
|
||||||
ConfigureEncoderTask(VideoStreamEncoder* video_stream_encoder,
|
|
||||||
VideoEncoderConfig config,
|
|
||||||
size_t max_data_payload_length,
|
|
||||||
bool nack_enabled)
|
|
||||||
: video_stream_encoder_(video_stream_encoder),
|
|
||||||
config_(std::move(config)),
|
|
||||||
max_data_payload_length_(max_data_payload_length),
|
|
||||||
nack_enabled_(nack_enabled) {}
|
|
||||||
|
|
||||||
private:
|
|
||||||
bool Run() override {
|
|
||||||
video_stream_encoder_->ConfigureEncoderOnTaskQueue(
|
|
||||||
std::move(config_), max_data_payload_length_, nack_enabled_);
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
VideoStreamEncoder* const video_stream_encoder_;
|
|
||||||
VideoEncoderConfig config_;
|
|
||||||
size_t max_data_payload_length_;
|
|
||||||
bool nack_enabled_;
|
|
||||||
};
|
|
||||||
|
|
||||||
class VideoStreamEncoder::EncodeTask : public rtc::QueuedTask {
|
class VideoStreamEncoder::EncodeTask : public rtc::QueuedTask {
|
||||||
public:
|
public:
|
||||||
EncodeTask(const VideoFrame& frame,
|
EncodeTask(const VideoFrame& frame,
|
||||||
@ -510,9 +486,20 @@ void VideoStreamEncoder::SetStartBitrate(int start_bitrate_bps) {
|
|||||||
void VideoStreamEncoder::ConfigureEncoder(VideoEncoderConfig config,
|
void VideoStreamEncoder::ConfigureEncoder(VideoEncoderConfig config,
|
||||||
size_t max_data_payload_length,
|
size_t max_data_payload_length,
|
||||||
bool nack_enabled) {
|
bool nack_enabled) {
|
||||||
encoder_queue_.PostTask(
|
// TODO(srte): This struct should be replaced by a lambda with move capture
|
||||||
std::unique_ptr<rtc::QueuedTask>(new ConfigureEncoderTask(
|
// when C++14 lambda is allowed.
|
||||||
this, std::move(config), max_data_payload_length, nack_enabled)));
|
struct ConfigureEncoderTask {
|
||||||
|
void operator()() {
|
||||||
|
encoder->ConfigureEncoderOnTaskQueue(
|
||||||
|
std::move(config), max_data_payload_length, nack_enabled);
|
||||||
|
}
|
||||||
|
VideoStreamEncoder* encoder;
|
||||||
|
VideoEncoderConfig config;
|
||||||
|
size_t max_data_payload_length;
|
||||||
|
bool nack_enabled;
|
||||||
|
};
|
||||||
|
encoder_queue_.PostTask(ConfigureEncoderTask{
|
||||||
|
this, std::move(config), max_data_payload_length, nack_enabled});
|
||||||
}
|
}
|
||||||
|
|
||||||
void VideoStreamEncoder::ConfigureEncoderOnTaskQueue(
|
void VideoStreamEncoder::ConfigureEncoderOnTaskQueue(
|
||||||
|
@ -117,7 +117,6 @@ class VideoStreamEncoder : public rtc::VideoSinkInterface<VideoFrame>,
|
|||||||
void AdaptDown(AdaptReason reason) override;
|
void AdaptDown(AdaptReason reason) override;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
class ConfigureEncoderTask;
|
|
||||||
class EncodeTask;
|
class EncodeTask;
|
||||||
class VideoSourceProxy;
|
class VideoSourceProxy;
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user