Delete rtc::TaskQueue::Current in favor of webrtc::TaskQueueBase::Current
Bug: webrtc:10191 Change-Id: I506cc50a90c73a6a4f6a3de36de0999cca72f5ba Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/126230 Reviewed-by: Karl Wiberg <kwiberg@webrtc.org> Commit-Queue: Danil Chapovalov <danilchap@webrtc.org> Cr-Commit-Position: refs/heads/master@{#27035}
This commit is contained in:
parent
37d4f91db3
commit
304e9d2df3
@ -15,12 +15,6 @@
|
||||
#include "api/task_queue/queued_task.h"
|
||||
#include "rtc_base/thread_annotations.h"
|
||||
|
||||
// TODO(bugs.webrtc.org/10191): Remove when
|
||||
// rtc::TaskQueue* rtc::TaskQueue::Current() is unused.
|
||||
namespace rtc {
|
||||
class TaskQueue;
|
||||
} // namespace rtc
|
||||
|
||||
namespace webrtc {
|
||||
|
||||
// Asynchronously executes tasks in a way that guarantees that they're executed
|
||||
@ -77,10 +71,6 @@ class RTC_LOCKABLE TaskQueueBase {
|
||||
// Users of the TaskQueue should call Delete instead of directly deleting
|
||||
// this object.
|
||||
virtual ~TaskQueueBase() = default;
|
||||
|
||||
private:
|
||||
friend class rtc::TaskQueue;
|
||||
rtc::TaskQueue* task_queue_ = nullptr;
|
||||
};
|
||||
|
||||
struct TaskQueueDeleter {
|
||||
|
||||
@ -248,6 +248,7 @@ if (rtc_include_tests) {
|
||||
]
|
||||
deps = [
|
||||
"../api:simulated_network_api",
|
||||
"../api/task_queue",
|
||||
"../call:fake_network",
|
||||
"../call:simulated_network",
|
||||
"../common_audio",
|
||||
|
||||
@ -11,6 +11,7 @@
|
||||
#include "audio/test/audio_bwe_integration_test.h"
|
||||
|
||||
#include "absl/memory/memory.h"
|
||||
#include "api/task_queue/task_queue_base.h"
|
||||
#include "call/fake_network_pipe.h"
|
||||
#include "call/simulated_network.h"
|
||||
#include "common_audio/wav_file.h"
|
||||
@ -89,8 +90,8 @@ class StatsPollTask : public rtc::QueuedTask {
|
||||
RTC_CHECK(sender_call_);
|
||||
Call::Stats call_stats = sender_call_->GetStats();
|
||||
EXPECT_GT(call_stats.send_bandwidth_bps, 25000);
|
||||
rtc::TaskQueue::Current()->PostDelayedTask(
|
||||
std::unique_ptr<QueuedTask>(this), 100);
|
||||
TaskQueueBase::Current()->PostDelayedTask(std::unique_ptr<QueuedTask>(this),
|
||||
100);
|
||||
return false;
|
||||
}
|
||||
Call* sender_call_;
|
||||
|
||||
@ -572,6 +572,7 @@ if (rtc_include_tests) {
|
||||
"../..:webrtc_common",
|
||||
"../../api:scoped_refptr",
|
||||
"../../api:videocodec_test_fixture_api",
|
||||
"../../api/task_queue",
|
||||
"../../api/video:builtin_video_bitrate_allocator_factory",
|
||||
"../../api/video:encoded_image",
|
||||
"../../api/video:video_bitrate_allocation",
|
||||
@ -586,6 +587,7 @@ if (rtc_include_tests) {
|
||||
"../../rtc_base:rtc_task_queue",
|
||||
"../../rtc_base:rtc_task_queue_for_test",
|
||||
"../../rtc_base:sequenced_task_checker",
|
||||
"../../rtc_base/task_utils:to_queued_task",
|
||||
"../../test:test_support",
|
||||
"../../test:video_test_common",
|
||||
"../../test:video_test_support",
|
||||
|
||||
@ -31,6 +31,7 @@
|
||||
#include "modules/video_coding/codecs/interface/common_constants.h"
|
||||
#include "modules/video_coding/include/video_error_codes.h"
|
||||
#include "rtc_base/checks.h"
|
||||
#include "rtc_base/task_utils/to_queued_task.h"
|
||||
#include "rtc_base/time_utils.h"
|
||||
#include "test/gtest.h"
|
||||
#include "third_party/libyuv/include/libyuv/compare.h"
|
||||
@ -191,7 +192,7 @@ VideoProcessor::VideoProcessor(webrtc::VideoEncoder* encoder,
|
||||
decoded_frame_buffer_(num_simulcast_or_spatial_layers_),
|
||||
post_encode_time_ns_(0) {
|
||||
// Sanity checks.
|
||||
RTC_CHECK(rtc::TaskQueue::Current())
|
||||
RTC_CHECK(TaskQueueBase::Current())
|
||||
<< "VideoProcessor must be run on a task queue.";
|
||||
RTC_CHECK(encoder);
|
||||
RTC_CHECK(decoders);
|
||||
@ -321,9 +322,9 @@ int32_t VideoProcessor::VideoProcessorDecodeCompleteCallback::Decoded(
|
||||
.build();
|
||||
copy.set_timestamp(image.timestamp());
|
||||
|
||||
task_queue_->PostTask([this, copy]() {
|
||||
task_queue_->PostTask(ToQueuedTask([this, copy]() {
|
||||
video_processor_->FrameDecoded(copy, simulcast_svc_idx_);
|
||||
});
|
||||
}));
|
||||
return 0;
|
||||
}
|
||||
video_processor_->FrameDecoded(image, simulcast_svc_idx_);
|
||||
|
||||
@ -18,6 +18,7 @@
|
||||
#include <vector>
|
||||
|
||||
#include "absl/types/optional.h"
|
||||
#include "api/task_queue/task_queue_base.h"
|
||||
#include "api/test/videocodec_test_fixture.h"
|
||||
#include "api/test/videocodec_test_stats.h"
|
||||
#include "api/video/encoded_image.h"
|
||||
@ -79,7 +80,7 @@ class VideoProcessor {
|
||||
explicit VideoProcessorEncodeCompleteCallback(
|
||||
VideoProcessor* video_processor)
|
||||
: video_processor_(video_processor),
|
||||
task_queue_(rtc::TaskQueue::Current()) {
|
||||
task_queue_(TaskQueueBase::Current()) {
|
||||
RTC_DCHECK(video_processor_);
|
||||
RTC_DCHECK(task_queue_);
|
||||
}
|
||||
@ -126,7 +127,7 @@ class VideoProcessor {
|
||||
};
|
||||
|
||||
VideoProcessor* const video_processor_;
|
||||
rtc::TaskQueue* const task_queue_;
|
||||
TaskQueueBase* const task_queue_;
|
||||
};
|
||||
|
||||
class VideoProcessorDecodeCompleteCallback
|
||||
@ -137,7 +138,7 @@ class VideoProcessor {
|
||||
size_t simulcast_svc_idx)
|
||||
: video_processor_(video_processor),
|
||||
simulcast_svc_idx_(simulcast_svc_idx),
|
||||
task_queue_(rtc::TaskQueue::Current()) {
|
||||
task_queue_(TaskQueueBase::Current()) {
|
||||
RTC_DCHECK(video_processor_);
|
||||
RTC_DCHECK(task_queue_);
|
||||
}
|
||||
@ -158,7 +159,7 @@ class VideoProcessor {
|
||||
private:
|
||||
VideoProcessor* const video_processor_;
|
||||
const size_t simulcast_svc_idx_;
|
||||
rtc::TaskQueue* const task_queue_;
|
||||
TaskQueueBase* const task_queue_;
|
||||
};
|
||||
|
||||
// Invoked by the callback adapter when a frame has completed encoding.
|
||||
|
||||
@ -16,9 +16,7 @@ namespace rtc {
|
||||
|
||||
TaskQueue::TaskQueue(
|
||||
std::unique_ptr<webrtc::TaskQueueBase, webrtc::TaskQueueDeleter> task_queue)
|
||||
: impl_(task_queue.release()) {
|
||||
impl_->task_queue_ = this;
|
||||
}
|
||||
: impl_(task_queue.release()) {}
|
||||
|
||||
TaskQueue::TaskQueue(const char* queue_name, Priority priority)
|
||||
: TaskQueue(webrtc::GlobalTaskQueueFactory().CreateTaskQueue(queue_name,
|
||||
@ -32,17 +30,8 @@ TaskQueue::~TaskQueue() {
|
||||
impl_->Delete();
|
||||
}
|
||||
|
||||
// static
|
||||
TaskQueue* TaskQueue::Current() {
|
||||
webrtc::TaskQueueBase* impl = webrtc::TaskQueueBase::Current();
|
||||
if (impl == nullptr) {
|
||||
return nullptr;
|
||||
}
|
||||
return impl->task_queue_;
|
||||
}
|
||||
|
||||
bool TaskQueue::IsCurrent() const {
|
||||
return Current() == this;
|
||||
return impl_->IsCurrent();
|
||||
}
|
||||
|
||||
void TaskQueue::PostTask(std::unique_ptr<QueuedTask> task) {
|
||||
|
||||
@ -57,8 +57,8 @@ using ::webrtc::QueuedTask;
|
||||
// private:
|
||||
// bool Run() override {
|
||||
// ++count_;
|
||||
// TaskQueue::Current()->PostDelayedTask(
|
||||
// std::unique_ptr<QueuedTask>(this), 1000);
|
||||
// TaskQueueBase::Current()->PostDelayedTask(
|
||||
// absl::WrapUnique(this), 1000);
|
||||
// // Ownership has been transferred to the next occurance,
|
||||
// // so return false to prevent from being deleted now.
|
||||
// return false;
|
||||
@ -66,8 +66,7 @@ using ::webrtc::QueuedTask;
|
||||
// int count_ = 0;
|
||||
// };
|
||||
// ...
|
||||
// queue_.PostDelayedTask(
|
||||
// std::unique_ptr<QueuedTask>(new TimerTask()), 1000);
|
||||
// queue_.PostDelayedTask(absl::make_unique<TimerTask>(), 1000);
|
||||
//
|
||||
// For more examples, see task_queue_unittests.cc.
|
||||
//
|
||||
@ -90,8 +89,6 @@ class RTC_LOCKABLE RTC_EXPORT TaskQueue {
|
||||
Priority priority = Priority::NORMAL);
|
||||
~TaskQueue();
|
||||
|
||||
static TaskQueue* Current();
|
||||
|
||||
// Used for DCHECKing the current queue.
|
||||
bool IsCurrent() const;
|
||||
|
||||
|
||||
@ -43,6 +43,7 @@ if (rtc_enable_protobuf) {
|
||||
deps = [
|
||||
":network_tester_config_proto",
|
||||
":network_tester_packet_proto",
|
||||
"../../api/task_queue",
|
||||
"../../p2p",
|
||||
"../../rtc_base:checks",
|
||||
"../../rtc_base:protobuf_utils",
|
||||
|
||||
@ -16,6 +16,7 @@
|
||||
#include <utility>
|
||||
|
||||
#include "absl/types/optional.h"
|
||||
#include "api/task_queue/task_queue_base.h"
|
||||
#include "rtc_base/time_utils.h"
|
||||
#include "rtc_tools/network_tester/config_reader.h"
|
||||
#include "rtc_tools/network_tester/test_controller.h"
|
||||
@ -36,7 +37,7 @@ class SendPacketTask : public rtc::QueuedTask {
|
||||
target_time_ms_ += packet_sender_->GetSendIntervalMs();
|
||||
int64_t delay_ms = std::max(static_cast<int64_t>(0),
|
||||
target_time_ms_ - rtc::TimeMillis());
|
||||
rtc::TaskQueue::Current()->PostDelayedTask(
|
||||
TaskQueueBase::Current()->PostDelayedTask(
|
||||
std::unique_ptr<QueuedTask>(this), delay_ms);
|
||||
return false;
|
||||
} else {
|
||||
@ -60,7 +61,7 @@ class UpdateTestSettingTask : public rtc::QueuedTask {
|
||||
if (config) {
|
||||
packet_sender_->UpdateTestSetting((*config).packet_size,
|
||||
(*config).packet_send_interval_ms);
|
||||
rtc::TaskQueue::Current()->PostDelayedTask(
|
||||
TaskQueueBase::Current()->PostDelayedTask(
|
||||
std::unique_ptr<QueuedTask>(this), (*config).execution_time_ms);
|
||||
return false;
|
||||
} else {
|
||||
|
||||
@ -621,6 +621,7 @@ if (is_android) {
|
||||
":videoframe_jni",
|
||||
"../..:webrtc_common",
|
||||
"../../api:scoped_refptr",
|
||||
"../../api/task_queue",
|
||||
"../../api/video_codecs:video_codecs_api",
|
||||
"../../common_video:common_video",
|
||||
"../../media:rtc_internal_video_codecs",
|
||||
@ -679,6 +680,7 @@ if (is_android) {
|
||||
":videoframe_jni",
|
||||
"../..:webrtc_common",
|
||||
"../../api:libjingle_peerconnection_api",
|
||||
"../../api/task_queue",
|
||||
"../../api/video:encoded_image",
|
||||
"../../api/video:video_frame",
|
||||
"../../api/video_codecs:rtc_software_fallback_wrappers",
|
||||
@ -691,6 +693,7 @@ if (is_android) {
|
||||
"../../rtc_base:checks",
|
||||
"../../rtc_base:rtc_base",
|
||||
"../../rtc_base:rtc_task_queue",
|
||||
"../../rtc_base/task_utils:to_queued_task",
|
||||
"//third_party/libyuv",
|
||||
]
|
||||
}
|
||||
|
||||
@ -14,6 +14,7 @@
|
||||
#include <string>
|
||||
#include <utility>
|
||||
|
||||
#include "api/task_queue/task_queue_base.h"
|
||||
#include "api/video_codecs/sdp_video_format.h"
|
||||
#include "api/video_codecs/video_encoder.h"
|
||||
#include "common_types.h" // NOLINT(build/include)
|
||||
@ -416,10 +417,10 @@ bool MediaCodecVideoEncoder::EncodeTask::Run() {
|
||||
|
||||
// If there aren't more frames to deliver, we can start polling at lower rate.
|
||||
if (encoder_->input_frame_infos_.empty()) {
|
||||
rtc::TaskQueue::Current()->PostDelayedTask(
|
||||
TaskQueueBase::Current()->PostDelayedTask(
|
||||
std::unique_ptr<rtc::QueuedTask>(this), kMediaCodecPollNoFramesMs);
|
||||
} else {
|
||||
rtc::TaskQueue::Current()->PostDelayedTask(
|
||||
TaskQueueBase::Current()->PostDelayedTask(
|
||||
std::unique_ptr<rtc::QueuedTask>(this), kMediaCodecPollMs);
|
||||
}
|
||||
|
||||
@ -741,8 +742,8 @@ int32_t MediaCodecVideoEncoder::Encode(
|
||||
|
||||
// Start the polling loop if it is not started.
|
||||
if (encode_task_) {
|
||||
rtc::TaskQueue::Current()->PostDelayedTask(std::move(encode_task_),
|
||||
kMediaCodecPollMs);
|
||||
TaskQueueBase::Current()->PostDelayedTask(std::move(encode_task_),
|
||||
kMediaCodecPollMs);
|
||||
}
|
||||
|
||||
if (!DeliverPendingOutputs(jni)) {
|
||||
|
||||
@ -18,6 +18,7 @@
|
||||
#include "modules/video_coding/utility/vp8_header_parser.h"
|
||||
#include "modules/video_coding/utility/vp9_uncompressed_header_parser.h"
|
||||
#include "rtc_base/logging.h"
|
||||
#include "rtc_base/task_utils/to_queued_task.h"
|
||||
#include "rtc_base/time_utils.h"
|
||||
#include "sdk/android/generated_video_jni/jni/VideoEncoderWrapper_jni.h"
|
||||
#include "sdk/android/generated_video_jni/jni/VideoEncoder_jni.h"
|
||||
@ -47,7 +48,7 @@ int32_t VideoEncoderWrapper::InitEncode(const VideoCodec* codec_settings,
|
||||
num_resets_ = 0;
|
||||
{
|
||||
rtc::CritScope lock(&encoder_queue_crit_);
|
||||
encoder_queue_ = rtc::TaskQueue::Current();
|
||||
encoder_queue_ = TaskQueueBase::Current();
|
||||
}
|
||||
|
||||
return InitEncodeInternal(jni);
|
||||
@ -293,10 +294,10 @@ void VideoEncoderWrapper::OnEncodedFrame(JNIEnv* jni,
|
||||
{
|
||||
rtc::CritScope lock(&encoder_queue_crit_);
|
||||
if (encoder_queue_ != nullptr) {
|
||||
encoder_queue_->PostTask(
|
||||
encoder_queue_->PostTask(ToQueuedTask(
|
||||
Lambda{this, std::move(buffer_copy), qp, encoded_width,
|
||||
encoded_height, capture_time_ns, frame_type, rotation,
|
||||
complete_frame, &frame_extra_infos_, callback_});
|
||||
complete_frame, &frame_extra_infos_, callback_}));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -16,10 +16,10 @@
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
#include "api/task_queue/task_queue_base.h"
|
||||
#include "api/video_codecs/video_encoder.h"
|
||||
#include "common_video/h264/h264_bitstream_parser.h"
|
||||
#include "modules/video_coding/codecs/vp9/include/vp9_globals.h"
|
||||
#include "rtc_base/task_queue.h"
|
||||
#include "sdk/android/src/jni/jni_helpers.h"
|
||||
#include "sdk/android/src/jni/video_frame.h"
|
||||
|
||||
@ -92,7 +92,7 @@ class VideoEncoderWrapper : public VideoEncoder {
|
||||
const ScopedJavaGlobalRef<jclass> int_array_class_;
|
||||
|
||||
rtc::CriticalSection encoder_queue_crit_;
|
||||
rtc::TaskQueue* encoder_queue_ RTC_GUARDED_BY(encoder_queue_crit_);
|
||||
TaskQueueBase* encoder_queue_ RTC_GUARDED_BY(encoder_queue_crit_);
|
||||
std::deque<FrameExtraInfo> frame_extra_infos_;
|
||||
EncodedImageCallback* callback_;
|
||||
bool initialized_;
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user