Remove rtc::QueuedTask alias, use webrtc::QueuedTask directly

Use absl::WrapUnique/absl::make_unique to create the queued tasks.

Bug: webrtc:10191
Change-Id: I8f47a60cb326b0fc361c7f0e338b25373d39937c
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/126525
Reviewed-by: Karl Wiberg <kwiberg@webrtc.org>
Commit-Queue: Danil Chapovalov <danilchap@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#27063}
This commit is contained in:
Danil Chapovalov
2019-03-11 14:26:02 +01:00
committed by Commit Bot
parent 125b5d6ffb
commit 471783fc87
20 changed files with 57 additions and 51 deletions

View File

@ -11,6 +11,7 @@
#include "audio/test/audio_bwe_integration_test.h" #include "audio/test/audio_bwe_integration_test.h"
#include "absl/memory/memory.h" #include "absl/memory/memory.h"
#include "api/task_queue/queued_task.h"
#include "api/task_queue/task_queue_base.h" #include "api/task_queue/task_queue_base.h"
#include "call/fake_network_pipe.h" #include "call/fake_network_pipe.h"
#include "call/simulated_network.h" #include "call/simulated_network.h"
@ -81,7 +82,7 @@ void AudioBweTest::PerformTest() {
SleepMs(GetNetworkPipeConfig().queue_delay_ms + kExtraProcessTimeMs); SleepMs(GetNetworkPipeConfig().queue_delay_ms + kExtraProcessTimeMs);
} }
class StatsPollTask : public rtc::QueuedTask { class StatsPollTask : public QueuedTask {
public: public:
explicit StatsPollTask(Call* sender_call) : sender_call_(sender_call) {} explicit StatsPollTask(Call* sender_call) : sender_call_(sender_call) {}
@ -142,7 +143,7 @@ class NoBandwidthDropAfterDtx : public AudioBweTest {
void PerformTest() override { void PerformTest() override {
stats_poller_.PostDelayedTask( stats_poller_.PostDelayedTask(
std::unique_ptr<rtc::QueuedTask>(new StatsPollTask(sender_call_)), 100); absl::make_unique<StatsPollTask>(sender_call_), 100);
sender_call_->OnAudioTransportOverheadChanged(0); sender_call_->OnAudioTransportOverheadChanged(0);
AudioBweTest::PerformTest(); AudioBweTest::PerformTest();
} }

View File

@ -256,6 +256,7 @@ rtc_static_library("rtc_event_log_impl_base") {
":ice_log", ":ice_log",
":rtc_event_log_api", ":rtc_event_log_api",
"../api:libjingle_logging_api", "../api:libjingle_logging_api",
"../api/task_queue",
"../api/task_queue:global_task_queue_factory", "../api/task_queue:global_task_queue_factory",
"../rtc_base:checks", "../rtc_base:checks",
"../rtc_base:rtc_base_approved", "../rtc_base:rtc_base_approved",

View File

@ -21,6 +21,7 @@
#include "absl/types/optional.h" #include "absl/types/optional.h"
#include "api/rtc_event_log_output.h" #include "api/rtc_event_log_output.h"
#include "api/task_queue/global_task_queue_factory.h" #include "api/task_queue/global_task_queue_factory.h"
#include "api/task_queue/queued_task.h"
#include "logging/rtc_event_log/encoder/rtc_event_log_encoder_legacy.h" #include "logging/rtc_event_log/encoder/rtc_event_log_encoder_legacy.h"
#include "logging/rtc_event_log/encoder/rtc_event_log_encoder_new_format.h" #include "logging/rtc_event_log/encoder/rtc_event_log_encoder_new_format.h"
#include "rtc_base/checks.h" #include "rtc_base/checks.h"
@ -48,7 +49,7 @@ constexpr size_t kMaxEventsInConfigHistory = 1000;
// unique_ptr to a lambda (a copy constructor is required). We should get // unique_ptr to a lambda (a copy constructor is required). We should get
// rid of this when we move to C++14. // rid of this when we move to C++14.
template <typename T> template <typename T>
class ResourceOwningTask final : public rtc::QueuedTask { class ResourceOwningTask final : public QueuedTask {
public: public:
ResourceOwningTask(std::unique_ptr<T> resource, ResourceOwningTask(std::unique_ptr<T> resource,
std::function<void(std::unique_ptr<T>)> handler) std::function<void(std::unique_ptr<T>)> handler)

View File

@ -66,6 +66,7 @@ if (rtc_enable_protobuf) {
":aec_dump", ":aec_dump",
"../", "../",
"../../../api/audio:audio_frame_api", "../../../api/audio:audio_frame_api",
"../../../api/task_queue",
"../../../rtc_base:checks", "../../../rtc_base:checks",
"../../../rtc_base:protobuf_utils", "../../../rtc_base:protobuf_utils",
"../../../rtc_base:rtc_base_approved", "../../../rtc_base:rtc_base_approved",

View File

@ -96,7 +96,7 @@ void AecDumpImpl::WriteInitMessage(const ProcessingConfig& api_format,
api_format.reverse_output_stream().num_channels()); api_format.reverse_output_stream().num_channels());
msg->set_timestamp_ms(time_now_ms); msg->set_timestamp_ms(time_now_ms);
worker_queue_->PostTask(std::unique_ptr<rtc::QueuedTask>(std::move(task))); worker_queue_->PostTask(std::move(task));
} }
void AecDumpImpl::AddCaptureStreamInput( void AecDumpImpl::AddCaptureStreamInput(
@ -124,7 +124,7 @@ void AecDumpImpl::AddAudioProcessingState(const AudioProcessingState& state) {
void AecDumpImpl::WriteCaptureStreamMessage() { void AecDumpImpl::WriteCaptureStreamMessage() {
auto task = capture_stream_info_.GetTask(); auto task = capture_stream_info_.GetTask();
RTC_DCHECK(task); RTC_DCHECK(task);
worker_queue_->PostTask(std::unique_ptr<rtc::QueuedTask>(std::move(task))); worker_queue_->PostTask(std::move(task));
capture_stream_info_.SetTask(CreateWriteToFileTask()); capture_stream_info_.SetTask(CreateWriteToFileTask());
} }
@ -138,7 +138,7 @@ void AecDumpImpl::WriteRenderStreamMessage(const AudioFrame& frame) {
sizeof(int16_t) * frame.samples_per_channel_ * frame.num_channels_; sizeof(int16_t) * frame.samples_per_channel_ * frame.num_channels_;
msg->set_data(frame.data(), data_size); msg->set_data(frame.data(), data_size);
worker_queue_->PostTask(std::unique_ptr<rtc::QueuedTask>(std::move(task))); worker_queue_->PostTask(std::move(task));
} }
void AecDumpImpl::WriteRenderStreamMessage( void AecDumpImpl::WriteRenderStreamMessage(
@ -155,7 +155,7 @@ void AecDumpImpl::WriteRenderStreamMessage(
msg->add_channel(channel_view.begin(), sizeof(float) * channel_view.size()); msg->add_channel(channel_view.begin(), sizeof(float) * channel_view.size());
} }
worker_queue_->PostTask(std::unique_ptr<rtc::QueuedTask>(std::move(task))); worker_queue_->PostTask(std::move(task));
} }
void AecDumpImpl::WriteConfig(const InternalAPMConfig& config) { void AecDumpImpl::WriteConfig(const InternalAPMConfig& config) {
@ -164,7 +164,7 @@ void AecDumpImpl::WriteConfig(const InternalAPMConfig& config) {
auto* event = task->GetEvent(); auto* event = task->GetEvent();
event->set_type(audioproc::Event::CONFIG); event->set_type(audioproc::Event::CONFIG);
CopyFromConfigToEvent(config, event->mutable_config()); CopyFromConfigToEvent(config, event->mutable_config());
worker_queue_->PostTask(std::unique_ptr<rtc::QueuedTask>(std::move(task))); worker_queue_->PostTask(std::move(task));
} }
void AecDumpImpl::WriteRuntimeSetting( void AecDumpImpl::WriteRuntimeSetting(
@ -192,7 +192,7 @@ void AecDumpImpl::WriteRuntimeSetting(
RTC_NOTREACHED(); RTC_NOTREACHED();
break; break;
} }
worker_queue_->PostTask(std::unique_ptr<rtc::QueuedTask>(std::move(task))); worker_queue_->PostTask(std::move(task));
} }
std::unique_ptr<WriteToFileTask> AecDumpImpl::CreateWriteToFileTask() { std::unique_ptr<WriteToFileTask> AecDumpImpl::CreateWriteToFileTask() {

View File

@ -15,12 +15,12 @@
#include <string> #include <string>
#include <utility> #include <utility>
#include "api/task_queue/queued_task.h"
#include "rtc_base/checks.h" #include "rtc_base/checks.h"
#include "rtc_base/event.h" #include "rtc_base/event.h"
#include "rtc_base/ignore_wundef.h" #include "rtc_base/ignore_wundef.h"
#include "rtc_base/platform_file.h" #include "rtc_base/platform_file.h"
#include "rtc_base/system/file_wrapper.h" #include "rtc_base/system/file_wrapper.h"
#include "rtc_base/task_queue.h"
// Files generated at build-time by the protobuf compiler. // Files generated at build-time by the protobuf compiler.
RTC_PUSH_IGNORING_WUNDEF() RTC_PUSH_IGNORING_WUNDEF()
@ -33,7 +33,7 @@ RTC_POP_IGNORING_WUNDEF()
namespace webrtc { namespace webrtc {
class WriteToFileTask : public rtc::QueuedTask { class WriteToFileTask : public QueuedTask {
public: public:
WriteToFileTask(webrtc::FileWrapper* debug_file, WriteToFileTask(webrtc::FileWrapper* debug_file,
int64_t* num_bytes_left_for_log); int64_t* num_bytes_left_for_log);

View File

@ -58,8 +58,8 @@ if (rtc_include_tests) {
deps = [ deps = [
":utility", ":utility",
"..:module_api", "..:module_api",
"../../api/task_queue",
"../../rtc_base:rtc_base_approved", "../../rtc_base:rtc_base_approved",
"../../rtc_base:rtc_task_queue",
"../../test:test_support", "../../test:test_support",
] ]
} }

View File

@ -11,10 +11,10 @@
#include <memory> #include <memory>
#include <utility> #include <utility>
#include "api/task_queue/queued_task.h"
#include "modules/include/module.h" #include "modules/include/module.h"
#include "modules/utility/source/process_thread_impl.h" #include "modules/utility/source/process_thread_impl.h"
#include "rtc_base/location.h" #include "rtc_base/location.h"
#include "rtc_base/task_queue.h"
#include "rtc_base/time_utils.h" #include "rtc_base/time_utils.h"
#include "test/gmock.h" #include "test/gmock.h"
#include "test/gtest.h" #include "test/gtest.h"
@ -40,7 +40,7 @@ class MockModule : public Module {
MOCK_METHOD1(ProcessThreadAttached, void(ProcessThread*)); MOCK_METHOD1(ProcessThreadAttached, void(ProcessThread*));
}; };
class RaiseEventTask : public rtc::QueuedTask { class RaiseEventTask : public QueuedTask {
public: public:
RaiseEventTask(rtc::Event* event) : event_(event) {} RaiseEventTask(rtc::Event* event) : event_(event) {}
bool Run() override { bool Run() override {

View File

@ -17,7 +17,9 @@
#include <memory> #include <memory>
#include <vector> #include <vector>
#include "absl/memory/memory.h"
#include "absl/types/optional.h" #include "absl/types/optional.h"
#include "api/task_queue/queued_task.h"
#include "api/task_queue/task_queue_base.h" #include "api/task_queue/task_queue_base.h"
#include "api/test/videocodec_test_fixture.h" #include "api/test/videocodec_test_fixture.h"
#include "api/test/videocodec_test_stats.h" #include "api/test/videocodec_test_stats.h"
@ -35,7 +37,6 @@
#include "rtc_base/checks.h" #include "rtc_base/checks.h"
#include "rtc_base/constructor_magic.h" #include "rtc_base/constructor_magic.h"
#include "rtc_base/sequenced_task_checker.h" #include "rtc_base/sequenced_task_checker.h"
#include "rtc_base/task_queue.h"
#include "rtc_base/thread_annotations.h" #include "rtc_base/thread_annotations.h"
#include "rtc_base/thread_checker.h" #include "rtc_base/thread_checker.h"
#include "test/testsupport/frame_reader.h" #include "test/testsupport/frame_reader.h"
@ -93,9 +94,8 @@ class VideoProcessor {
// Post the callback to the right task queue, if needed. // Post the callback to the right task queue, if needed.
if (!task_queue_->IsCurrent()) { if (!task_queue_->IsCurrent()) {
task_queue_->PostTask( task_queue_->PostTask(absl::make_unique<EncodeCallbackTask>(
std::unique_ptr<rtc::QueuedTask>(new EncodeCallbackTask( video_processor_, encoded_image, codec_specific_info));
video_processor_, encoded_image, codec_specific_info)));
return Result(Result::OK, 0); return Result(Result::OK, 0);
} }
@ -104,7 +104,7 @@ class VideoProcessor {
} }
private: private:
class EncodeCallbackTask : public rtc::QueuedTask { class EncodeCallbackTask : public QueuedTask {
public: public:
EncodeCallbackTask(VideoProcessor* video_processor, EncodeCallbackTask(VideoProcessor* video_processor,
const webrtc::EncodedImage& encoded_image, const webrtc::EncodedImage& encoded_image,

View File

@ -34,11 +34,11 @@ bool TaskQueue::IsCurrent() const {
return impl_->IsCurrent(); return impl_->IsCurrent();
} }
void TaskQueue::PostTask(std::unique_ptr<QueuedTask> task) { void TaskQueue::PostTask(std::unique_ptr<webrtc::QueuedTask> task) {
return impl_->PostTask(std::move(task)); return impl_->PostTask(std::move(task));
} }
void TaskQueue::PostDelayedTask(std::unique_ptr<QueuedTask> task, void TaskQueue::PostDelayedTask(std::unique_ptr<webrtc::QueuedTask> task,
uint32_t milliseconds) { uint32_t milliseconds) {
return impl_->PostDelayedTask(std::move(task), milliseconds); return impl_->PostDelayedTask(std::move(task), milliseconds);
} }

View File

@ -25,11 +25,6 @@
#include "rtc_base/thread_annotations.h" #include "rtc_base/thread_annotations.h"
namespace rtc { namespace rtc {
// TODO(danilchap): Remove the alias when all of webrtc is updated to use
// webrtc::QueuedTask directly.
using ::webrtc::QueuedTask;
// Implements a task queue that asynchronously executes tasks in a way that // Implements a task queue that asynchronously executes tasks in a way that
// guarantees that they're executed in FIFO order and that tasks never overlap. // guarantees that they're executed in FIFO order and that tasks never overlap.
// Tasks may always execute on the same worker thread and they may not. // Tasks may always execute on the same worker thread and they may not.
@ -98,14 +93,15 @@ class RTC_LOCKABLE RTC_EXPORT TaskQueue {
// TODO(tommi): For better debuggability, implement RTC_FROM_HERE. // TODO(tommi): For better debuggability, implement RTC_FROM_HERE.
// Ownership of the task is passed to PostTask. // Ownership of the task is passed to PostTask.
void PostTask(std::unique_ptr<QueuedTask> task); void PostTask(std::unique_ptr<webrtc::QueuedTask> task);
// Schedules a task to execute a specified number of milliseconds from when // Schedules a task to execute a specified number of milliseconds from when
// the call is made. The precision should be considered as "best effort" // the call is made. The precision should be considered as "best effort"
// and in some cases, such as on Windows when all high precision timers have // and in some cases, such as on Windows when all high precision timers have
// been used up, can be off by as much as 15 millseconds (although 8 would be // been used up, can be off by as much as 15 millseconds (although 8 would be
// more likely). This can be mitigated by limiting the use of delayed tasks. // more likely). This can be mitigated by limiting the use of delayed tasks.
void PostDelayedTask(std::unique_ptr<QueuedTask> task, uint32_t milliseconds); void PostDelayedTask(std::unique_ptr<webrtc::QueuedTask> task,
uint32_t milliseconds);
// std::enable_if is used here to make sure that calls to PostTask() with // std::enable_if is used here to make sure that calls to PostTask() with
// std::unique_ptr<SomeClassDerivedFromQueuedTask> would not end up being // std::unique_ptr<SomeClassDerivedFromQueuedTask> would not end up being
@ -113,7 +109,7 @@ class RTC_LOCKABLE RTC_EXPORT TaskQueue {
template <class Closure, template <class Closure,
typename std::enable_if<!std::is_convertible< typename std::enable_if<!std::is_convertible<
Closure, Closure,
std::unique_ptr<QueuedTask>>::value>::type* = nullptr> std::unique_ptr<webrtc::QueuedTask>>::value>::type* = nullptr>
void PostTask(Closure&& closure) { void PostTask(Closure&& closure) {
PostTask(webrtc::ToQueuedTask(std::forward<Closure>(closure))); PostTask(webrtc::ToQueuedTask(std::forward<Closure>(closure)));
} }
@ -122,7 +118,7 @@ class RTC_LOCKABLE RTC_EXPORT TaskQueue {
template <class Closure, template <class Closure,
typename std::enable_if<!std::is_convertible< typename std::enable_if<!std::is_convertible<
Closure, Closure,
std::unique_ptr<QueuedTask>>::value>::type* = nullptr> std::unique_ptr<webrtc::QueuedTask>>::value>::type* = nullptr>
void PostDelayedTask(Closure&& closure, uint32_t milliseconds) { void PostDelayedTask(Closure&& closure, uint32_t milliseconds) {
PostDelayedTask(webrtc::ToQueuedTask(std::forward<Closure>(closure)), PostDelayedTask(webrtc::ToQueuedTask(std::forward<Closure>(closure)),
milliseconds); milliseconds);

View File

@ -37,7 +37,7 @@ class RTC_LOCKABLE TaskQueueForTest : public TaskQueue {
rtc::Event event; rtc::Event event;
PostTask(webrtc::ToQueuedTask( PostTask(webrtc::ToQueuedTask(
[&task]() { [&task]() {
RTC_CHECK_EQ(false, static_cast<QueuedTask*>(task)->Run()); RTC_CHECK_EQ(false, static_cast<webrtc::QueuedTask*>(task)->Run());
}, },
[&event]() { event.Set(); })); [&event]() { event.Set(); }));
event.Wait(rtc::Event::kForever); event.Wait(rtc::Event::kForever);

View File

@ -52,6 +52,7 @@ if (rtc_enable_protobuf) {
"../../rtc_base:rtc_task_queue", "../../rtc_base:rtc_task_queue",
"../../rtc_base:sequenced_task_checker", "../../rtc_base:sequenced_task_checker",
"../../rtc_base/third_party/sigslot:sigslot", "../../rtc_base/third_party/sigslot:sigslot",
"//third_party/abseil-cpp/absl/memory",
"//third_party/abseil-cpp/absl/types:optional", "//third_party/abseil-cpp/absl/types:optional",
] ]
} }

View File

@ -15,7 +15,9 @@
#include <string> #include <string>
#include <utility> #include <utility>
#include "absl/memory/memory.h"
#include "absl/types/optional.h" #include "absl/types/optional.h"
#include "api/task_queue/queued_task.h"
#include "api/task_queue/task_queue_base.h" #include "api/task_queue/task_queue_base.h"
#include "rtc_base/time_utils.h" #include "rtc_base/time_utils.h"
#include "rtc_tools/network_tester/config_reader.h" #include "rtc_tools/network_tester/config_reader.h"
@ -25,7 +27,7 @@ namespace webrtc {
namespace { namespace {
class SendPacketTask : public rtc::QueuedTask { class SendPacketTask : public QueuedTask {
public: public:
explicit SendPacketTask(PacketSender* packet_sender) explicit SendPacketTask(PacketSender* packet_sender)
: target_time_ms_(rtc::TimeMillis()), packet_sender_(packet_sender) {} : target_time_ms_(rtc::TimeMillis()), packet_sender_(packet_sender) {}
@ -48,7 +50,7 @@ class SendPacketTask : public rtc::QueuedTask {
PacketSender* const packet_sender_; PacketSender* const packet_sender_;
}; };
class UpdateTestSettingTask : public rtc::QueuedTask { class UpdateTestSettingTask : public QueuedTask {
public: public:
UpdateTestSettingTask(PacketSender* packet_sender, UpdateTestSettingTask(PacketSender* packet_sender,
std::unique_ptr<ConfigReader> config_reader) std::unique_ptr<ConfigReader> config_reader)
@ -93,12 +95,9 @@ void PacketSender::StartSending() {
RTC_DCHECK_CALLED_SEQUENTIALLY(&worker_queue_checker_); RTC_DCHECK_CALLED_SEQUENTIALLY(&worker_queue_checker_);
sending_ = true; sending_ = true;
}); });
worker_queue_.PostTask( worker_queue_.PostTask(absl::make_unique<UpdateTestSettingTask>(
std::unique_ptr<rtc::QueuedTask>(new UpdateTestSettingTask( this, absl::make_unique<ConfigReader>(config_file_path_)));
this, worker_queue_.PostTask(absl::make_unique<SendPacketTask>(this));
std::unique_ptr<ConfigReader>(new ConfigReader(config_file_path_)))));
worker_queue_.PostTask(
std::unique_ptr<rtc::QueuedTask>(new SendPacketTask(this)));
} }
void PacketSender::StopSending() { void PacketSender::StopSending() {

View File

@ -634,6 +634,7 @@ if (is_android) {
"../../rtc_base:sequenced_task_checker", "../../rtc_base:sequenced_task_checker",
"../../rtc_base:weak_ptr", "../../rtc_base:weak_ptr",
"../../system_wrappers:field_trial", "../../system_wrappers:field_trial",
"//third_party/abseil-cpp/absl/memory:memory",
"//third_party/libyuv", "//third_party/libyuv",
] ]
} }

View File

@ -14,6 +14,8 @@
#include <string> #include <string>
#include <utility> #include <utility>
#include "absl/memory/memory.h"
#include "api/task_queue/queued_task.h"
#include "api/task_queue/task_queue_base.h" #include "api/task_queue/task_queue_base.h"
#include "api/video_codecs/sdp_video_format.h" #include "api/video_codecs/sdp_video_format.h"
#include "api/video_codecs/video_encoder.h" #include "api/video_codecs/video_encoder.h"
@ -32,7 +34,6 @@
#include "rtc_base/checks.h" #include "rtc_base/checks.h"
#include "rtc_base/logging.h" #include "rtc_base/logging.h"
#include "rtc_base/sequenced_task_checker.h" #include "rtc_base/sequenced_task_checker.h"
#include "rtc_base/task_queue.h"
#include "rtc_base/thread.h" #include "rtc_base/thread.h"
#include "rtc_base/time_utils.h" #include "rtc_base/time_utils.h"
#include "rtc_base/weak_ptr.h" #include "rtc_base/weak_ptr.h"
@ -120,7 +121,7 @@ class MediaCodecVideoEncoder : public VideoEncoder {
int stride_v); int stride_v);
private: private:
class EncodeTask : public rtc::QueuedTask { class EncodeTask : public QueuedTask {
public: public:
explicit EncodeTask(rtc::WeakPtr<MediaCodecVideoEncoder> encoder); explicit EncodeTask(rtc::WeakPtr<MediaCodecVideoEncoder> encoder);
bool Run() override; bool Run() override;
@ -223,7 +224,7 @@ class MediaCodecVideoEncoder : public VideoEncoder {
int64_t last_input_timestamp_ms_; // Timestamp of last received yuv frame. int64_t last_input_timestamp_ms_; // Timestamp of last received yuv frame.
int64_t last_output_timestamp_ms_; // Timestamp of last encoded frame. int64_t last_output_timestamp_ms_; // Timestamp of last encoded frame.
// Holds the task while the polling loop is paused. // Holds the task while the polling loop is paused.
std::unique_ptr<rtc::QueuedTask> encode_task_; std::unique_ptr<QueuedTask> encode_task_;
struct InputFrameInfo { struct InputFrameInfo {
InputFrameInfo(int64_t encode_start_time, InputFrameInfo(int64_t encode_start_time,
@ -397,7 +398,7 @@ bool MediaCodecVideoEncoder::EncodeTask::Run() {
ScopedLocalRefFrame local_ref_frame(jni); ScopedLocalRefFrame local_ref_frame(jni);
if (!encoder_->inited_) { if (!encoder_->inited_) {
encoder_->encode_task_ = std::unique_ptr<rtc::QueuedTask>(this); encoder_->encode_task_ = absl::WrapUnique(this);
return false; return false;
} }
@ -417,11 +418,11 @@ bool MediaCodecVideoEncoder::EncodeTask::Run() {
// If there aren't more frames to deliver, we can start polling at lower rate. // If there aren't more frames to deliver, we can start polling at lower rate.
if (encoder_->input_frame_infos_.empty()) { if (encoder_->input_frame_infos_.empty()) {
TaskQueueBase::Current()->PostDelayedTask( TaskQueueBase::Current()->PostDelayedTask(absl::WrapUnique(this),
std::unique_ptr<rtc::QueuedTask>(this), kMediaCodecPollNoFramesMs); kMediaCodecPollNoFramesMs);
} else { } else {
TaskQueueBase::Current()->PostDelayedTask( TaskQueueBase::Current()->PostDelayedTask(absl::WrapUnique(this),
std::unique_ptr<rtc::QueuedTask>(this), kMediaCodecPollMs); kMediaCodecPollMs);
} }
return false; return false;

View File

@ -643,6 +643,7 @@ rtc_source_set("fake_video_codecs") {
deps = [ deps = [
"..:webrtc_common", "..:webrtc_common",
"../api:scoped_refptr", "../api:scoped_refptr",
"../api/task_queue",
"../api/video:encoded_image", "../api/video:encoded_image",
"../api/video:video_bitrate_allocation", "../api/video:video_bitrate_allocation",
"../api/video:video_frame", "../api/video:video_frame",

View File

@ -17,6 +17,7 @@
#include <string> #include <string>
#include "absl/memory/memory.h" #include "absl/memory/memory.h"
#include "api/task_queue/queued_task.h"
#include "api/video/video_content_type.h" #include "api/video/video_content_type.h"
#include "common_types.h" // NOLINT(build/include) #include "common_types.h" // NOLINT(build/include)
#include "modules/video_coding/codecs/h264/include/h264_globals.h" #include "modules/video_coding/codecs/h264/include/h264_globals.h"
@ -383,7 +384,7 @@ int32_t MultithreadedFakeH264Encoder::InitEncode(const VideoCodec* config,
return FakeH264Encoder::InitEncode(config, number_of_cores, max_payload_size); return FakeH264Encoder::InitEncode(config, number_of_cores, max_payload_size);
} }
class MultithreadedFakeH264Encoder::EncodeTask : public rtc::QueuedTask { class MultithreadedFakeH264Encoder::EncodeTask : public QueuedTask {
public: public:
EncodeTask(MultithreadedFakeH264Encoder* encoder, EncodeTask(MultithreadedFakeH264Encoder* encoder,
const VideoFrame& input_image, const VideoFrame& input_image,
@ -415,8 +416,8 @@ int32_t MultithreadedFakeH264Encoder::Encode(
return WEBRTC_VIDEO_CODEC_UNINITIALIZED; return WEBRTC_VIDEO_CODEC_UNINITIALIZED;
} }
queue->PostTask(std::unique_ptr<rtc::QueuedTask>( queue->PostTask(
new EncodeTask(this, input_image, frame_types))); absl::make_unique<EncodeTask>(this, input_image, frame_types));
return WEBRTC_VIDEO_CODEC_OK; return WEBRTC_VIDEO_CODEC_OK;
} }

View File

@ -126,6 +126,7 @@ rtc_source_set("video_stream_decoder_impl") {
] ]
deps = [ deps = [
"../api/task_queue",
"../api/video:encoded_frame", "../api/video:encoded_frame",
"../api/video:video_frame", "../api/video:video_frame",
"../api/video:video_stream_decoder", "../api/video:video_stream_decoder",

View File

@ -11,6 +11,7 @@
#include "video/video_stream_decoder_impl.h" #include "video/video_stream_decoder_impl.h"
#include "absl/memory/memory.h" #include "absl/memory/memory.h"
#include "api/task_queue/queued_task.h"
#include "rtc_base/logging.h" #include "rtc_base/logging.h"
#include "rtc_base/numerics/mod_ops.h" #include "rtc_base/numerics/mod_ops.h"
#include "rtc_base/time_utils.h" #include "rtc_base/time_utils.h"
@ -48,7 +49,7 @@ VideoStreamDecoderImpl::~VideoStreamDecoderImpl() {
void VideoStreamDecoderImpl::OnFrame( void VideoStreamDecoderImpl::OnFrame(
std::unique_ptr<video_coding::EncodedFrame> frame) { std::unique_ptr<video_coding::EncodedFrame> frame) {
if (!bookkeeping_queue_.IsCurrent()) { if (!bookkeeping_queue_.IsCurrent()) {
struct OnFrameTask : rtc::QueuedTask { struct OnFrameTask : QueuedTask {
OnFrameTask(std::unique_ptr<video_coding::EncodedFrame> frame, OnFrameTask(std::unique_ptr<video_coding::EncodedFrame> frame,
VideoStreamDecoderImpl* video_stream_decoder) VideoStreamDecoderImpl* video_stream_decoder)
: frame_(std::move(frame)), : frame_(std::move(frame)),