Migrate video/ to absl::AnyInvocable based TaskQueueBase interface
Bug: webrtc:14245
Change-Id: Ibd98d3a0c548443578953ef3e25aee9919eea3d3
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/267980
Commit-Queue: Danil Chapovalov <danilchap@webrtc.org>
Reviewed-by: Erik Språng <sprang@webrtc.org>
Cr-Commit-Position: refs/heads/main@{#37465}
diff --git a/video/receive_statistics_proxy2.cc b/video/receive_statistics_proxy2.cc
index 66dfe9c..5f1f635 100644
--- a/video/receive_statistics_proxy2.cc
+++ b/video/receive_statistics_proxy2.cc
@@ -14,7 +14,6 @@
#include <cmath>
#include <utility>
-#include "api/task_queue/to_queued_task.h"
#include "modules/video_coding/include/video_codec_interface.h"
#include "rtc_base/checks.h"
#include "rtc_base/logging.h"
@@ -642,7 +641,7 @@
void ReceiveStatisticsProxy::OnIncomingPayloadType(int payload_type) {
RTC_DCHECK_RUN_ON(&decode_queue_);
- worker_thread_->PostTask(ToQueuedTask(task_safety_, [payload_type, this]() {
+ worker_thread_->PostTask(SafeTask(task_safety_.flag(), [payload_type, this] {
RTC_DCHECK_RUN_ON(&main_thread_);
stats_.current_payload_type = payload_type;
}));
@@ -651,8 +650,8 @@
void ReceiveStatisticsProxy::OnDecoderImplementationName(
const char* implementation_name) {
RTC_DCHECK_RUN_ON(&decode_queue_);
- worker_thread_->PostTask(ToQueuedTask(
- task_safety_, [name = std::string(implementation_name), this]() {
+ worker_thread_->PostTask(SafeTask(
+ task_safety_.flag(), [name = std::string(implementation_name), this]() {
RTC_DCHECK_RUN_ON(&main_thread_);
stats_.decoder_implementation_name = name;
}));
@@ -668,8 +667,8 @@
// Only called on main_thread_ with FrameBuffer3
if (!worker_thread_->IsCurrent()) {
RTC_DCHECK_RUN_ON(&decode_queue_);
- worker_thread_->PostTask(ToQueuedTask(
- task_safety_,
+ worker_thread_->PostTask(SafeTask(
+ task_safety_.flag(),
[max_decode_ms, current_delay_ms, target_delay_ms, jitter_buffer_ms,
min_playout_delay_ms, render_delay_ms, this]() {
OnFrameBufferTimingsUpdated(max_decode_ms, current_delay_ms,
@@ -704,8 +703,9 @@
// Only called on main_thread_ with FrameBuffer3
if (!worker_thread_->IsCurrent()) {
RTC_DCHECK_RUN_ON(&decode_queue_);
- worker_thread_->PostTask(ToQueuedTask(
- task_safety_, [info, this]() { OnTimingFrameInfoUpdated(info); }));
+ worker_thread_->PostTask(SafeTask(task_safety_.flag(), [info, this]() {
+ OnTimingFrameInfoUpdated(info);
+ }));
return;
}
RTC_DCHECK_RUN_ON(&main_thread_);
@@ -745,7 +745,7 @@
// runs after the `ReceiveStatisticsProxy` has been deleted. In such a
// case the packet_counter update won't be recorded.
worker_thread_->PostTask(
- ToQueuedTask(task_safety_, [ssrc, packet_counter, this]() {
+ SafeTask(task_safety_.flag(), [ssrc, packet_counter, this]() {
RtcpPacketTypesCounterUpdated(ssrc, packet_counter);
}));
return;
@@ -792,8 +792,8 @@
// "com.apple.coremedia.decompressionsession.clientcallback"
VideoFrameMetaData meta(frame, current_time);
worker_thread_->PostTask(
- ToQueuedTask(task_safety_, [meta, qp, decode_time, processing_delay,
- assembly_time, content_type, this]() {
+ SafeTask(task_safety_.flag(), [meta, qp, decode_time, processing_delay,
+ assembly_time, content_type, this]() {
OnDecodedFrame(meta, qp, decode_time, processing_delay, assembly_time,
content_type);
}));
@@ -973,22 +973,24 @@
void ReceiveStatisticsProxy::OnDroppedFrames(uint32_t frames_dropped) {
// Can be called on either the decode queue or the worker thread
// See FrameBuffer2 for more details.
- worker_thread_->PostTask(ToQueuedTask(task_safety_, [frames_dropped, this]() {
- RTC_DCHECK_RUN_ON(&main_thread_);
- stats_.frames_dropped += frames_dropped;
- }));
+ worker_thread_->PostTask(
+ SafeTask(task_safety_.flag(), [frames_dropped, this]() {
+ RTC_DCHECK_RUN_ON(&main_thread_);
+ stats_.frames_dropped += frames_dropped;
+ }));
}
void ReceiveStatisticsProxy::OnPreDecode(VideoCodecType codec_type, int qp) {
RTC_DCHECK_RUN_ON(&decode_queue_);
- worker_thread_->PostTask(ToQueuedTask(task_safety_, [codec_type, qp, this]() {
- RTC_DCHECK_RUN_ON(&main_thread_);
- last_codec_type_ = codec_type;
- if (last_codec_type_ == kVideoCodecVP8 && qp != -1) {
- qp_counters_.vp8.Add(qp);
- qp_sample_.Add(qp);
- }
- }));
+ worker_thread_->PostTask(
+ SafeTask(task_safety_.flag(), [codec_type, qp, this]() {
+ RTC_DCHECK_RUN_ON(&main_thread_);
+ last_codec_type_ = codec_type;
+ if (last_codec_type_ == kVideoCodecVP8 && qp != -1) {
+ qp_counters_.vp8.Add(qp);
+ qp_sample_.Add(qp);
+ }
+ }));
}
void ReceiveStatisticsProxy::OnStreamInactive() {