Migrate rtp_rtcp to absl::AnyInvocable based TaskQueueBase interface

Bug: webrtc:14245
Change-Id: I037f964130648caf0bd1de86611f8681d475b078
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/268146
Reviewed-by: Erik Språng <sprang@webrtc.org>
Commit-Queue: Danil Chapovalov <danilchap@webrtc.org>
Cr-Commit-Position: refs/heads/main@{#37481}
This commit is contained in:
Danil Chapovalov
2022-07-07 13:34:25 +02:00
committed by WebRTC LUCI CQ
parent c52e627c83
commit 677c1ddde5
10 changed files with 78 additions and 97 deletions

View File

@ -22,7 +22,6 @@
#include "absl/strings/string_view.h"
#include "absl/types/optional.h"
#include "api/sequence_checker.h"
#include "api/task_queue/to_queued_task.h"
#include "api/transport/field_trial_based_config.h"
#include "api/units/time_delta.h"
#include "api/units/timestamp.h"
@ -52,13 +51,6 @@ RTCPSender::Configuration AddRtcpSendEvaluationCallback(
return config;
}
int DelayMillisForDuration(TimeDelta duration) {
// TimeDelta::ms() rounds downwards sometimes which leads to too little time
// slept. Account for this, unless `duration` is exactly representable in
// millisecs.
return (duration.us() + rtc::kNumMillisecsPerSec - 1) /
rtc::kNumMicrosecsPerMillisec;
}
} // namespace
ModuleRtpRtcpImpl2::RtpSenderContext::RtpSenderContext(
@ -805,7 +797,7 @@ void ModuleRtpRtcpImpl2::ScheduleRtcpSendEvaluation(TimeDelta duration) {
// than the worker queue on which it's created on implies that external
// synchronization is present and removes this activity before destruction.
if (duration.IsZero()) {
worker_queue_->PostTask(ToQueuedTask(task_safety_, [this] {
worker_queue_->PostTask(SafeTask(task_safety_.flag(), [this] {
RTC_DCHECK_RUN_ON(worker_queue_);
MaybeSendRtcp();
}));
@ -823,12 +815,12 @@ void ModuleRtpRtcpImpl2::ScheduleMaybeSendRtcpAtOrAfterTimestamp(
// See note in ScheduleRtcpSendEvaluation about why `worker_queue_` can be
// accessed.
worker_queue_->PostDelayedTask(
ToQueuedTask(task_safety_,
[this, execution_time] {
RTC_DCHECK_RUN_ON(worker_queue_);
MaybeSendRtcpAtOrAfterTimestamp(execution_time);
}),
DelayMillisForDuration(duration));
SafeTask(task_safety_.flag(),
[this, execution_time] {
RTC_DCHECK_RUN_ON(worker_queue_);
MaybeSendRtcpAtOrAfterTimestamp(execution_time);
}),
duration.RoundUpTo(TimeDelta::Millis(1)));
}
} // namespace webrtc