Metronome: complete API migration.
This CL finalizes the Metronome refactor undertaken in crbug.com/1381982 and enables it again in call.cc. Fixed: chromium:1381982 Change-Id: I1642103e9c8a3f2a1f12d7635a1b27310802c1c3 Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/282920 Commit-Queue: Markus Handell <handellm@webrtc.org> Reviewed-by: Evan Shrubsole <eshr@webrtc.org> Reviewed-by: Erik Språng <sprang@webrtc.org> Reviewed-by: Per Kjellander <perkj@webrtc.org> Cr-Commit-Position: refs/heads/main@{#38605}
This commit is contained in:
committed by
WebRTC LUCI CQ
parent
123a0ed604
commit
15a82c93d0
@ -10,10 +10,7 @@ import("../../webrtc.gni")
|
|||||||
|
|
||||||
rtc_source_set("metronome") {
|
rtc_source_set("metronome") {
|
||||||
visibility = [ "*" ]
|
visibility = [ "*" ]
|
||||||
sources = [
|
sources = [ "metronome.h" ]
|
||||||
"metronome.cc",
|
|
||||||
"metronome.h",
|
|
||||||
]
|
|
||||||
deps = [
|
deps = [
|
||||||
"../../rtc_base/system:rtc_export",
|
"../../rtc_base/system:rtc_export",
|
||||||
"../task_queue",
|
"../task_queue",
|
||||||
|
|||||||
@ -30,22 +30,8 @@ namespace webrtc {
|
|||||||
// Metronome implementations must be thread-compatible.
|
// Metronome implementations must be thread-compatible.
|
||||||
class RTC_EXPORT Metronome {
|
class RTC_EXPORT Metronome {
|
||||||
public:
|
public:
|
||||||
// TODO(crbug.com/1381982): remove stale classes and methods once downstream
|
|
||||||
// dependencies adapts.
|
|
||||||
class RTC_EXPORT TickListener {
|
|
||||||
public:
|
|
||||||
virtual ~TickListener() = default;
|
|
||||||
virtual void OnTick() = 0;
|
|
||||||
virtual TaskQueueBase* OnTickTaskQueue() = 0;
|
|
||||||
};
|
|
||||||
|
|
||||||
virtual ~Metronome() = default;
|
virtual ~Metronome() = default;
|
||||||
|
|
||||||
// TODO(crbug.com/1381982): remove stale classes and methods once downstream
|
|
||||||
// dependencies adapts.
|
|
||||||
virtual void AddListener(TickListener* listener);
|
|
||||||
virtual void RemoveListener(TickListener* listener);
|
|
||||||
|
|
||||||
// Requests a call to `callback` on the next tick. Scheduled callbacks are
|
// Requests a call to `callback` on the next tick. Scheduled callbacks are
|
||||||
// executed on the same sequence as they were requested on. There are no
|
// executed on the same sequence as they were requested on. There are no
|
||||||
// features for cancellation. When that's needed, use e.g. ScopedTaskSafety
|
// features for cancellation. When that's needed, use e.g. ScopedTaskSafety
|
||||||
|
|||||||
@ -1043,7 +1043,7 @@ webrtc::VideoReceiveStreamInterface* Call::CreateVideoReceiveStream(
|
|||||||
task_queue_factory_, this, num_cpu_cores_,
|
task_queue_factory_, this, num_cpu_cores_,
|
||||||
transport_send_->packet_router(), std::move(configuration),
|
transport_send_->packet_router(), std::move(configuration),
|
||||||
call_stats_.get(), clock_, std::make_unique<VCMTiming>(clock_, trials()),
|
call_stats_.get(), clock_, std::make_unique<VCMTiming>(clock_, trials()),
|
||||||
&nack_periodic_processor_, /*decode_sync=*/nullptr, event_log_);
|
&nack_periodic_processor_, decode_sync_.get(), event_log_);
|
||||||
// TODO(bugs.webrtc.org/11993): Set this up asynchronously on the network
|
// TODO(bugs.webrtc.org/11993): Set this up asynchronously on the network
|
||||||
// thread.
|
// thread.
|
||||||
receive_stream->RegisterWithTransport(&video_receiver_controller_);
|
receive_stream->RegisterWithTransport(&video_receiver_controller_);
|
||||||
|
|||||||
@ -110,8 +110,10 @@ PeerConnectionFactory::PeerConnectionFactory(
|
|||||||
|
|
||||||
PeerConnectionFactory::~PeerConnectionFactory() {
|
PeerConnectionFactory::~PeerConnectionFactory() {
|
||||||
RTC_DCHECK_RUN_ON(signaling_thread());
|
RTC_DCHECK_RUN_ON(signaling_thread());
|
||||||
// Ensures the metronome is destroyed on the worker thread.
|
worker_thread()->BlockingCall([this] {
|
||||||
worker_thread()->BlockingCall([metronome = std::move(metronome_)] {});
|
RTC_DCHECK_RUN_ON(worker_thread());
|
||||||
|
metronome_ = nullptr;
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
void PeerConnectionFactory::SetOptions(const Options& options) {
|
void PeerConnectionFactory::SetOptions(const Options& options) {
|
||||||
|
|||||||
@ -57,27 +57,36 @@ int FindFirstMediaStatsIndexByKind(
|
|||||||
}
|
}
|
||||||
|
|
||||||
TaskQueueMetronome::TaskQueueMetronome(TimeDelta tick_period)
|
TaskQueueMetronome::TaskQueueMetronome(TimeDelta tick_period)
|
||||||
: tick_period_(tick_period) {}
|
: tick_period_(tick_period) {
|
||||||
|
sequence_checker_.Detach();
|
||||||
|
}
|
||||||
|
|
||||||
|
TaskQueueMetronome::~TaskQueueMetronome() {
|
||||||
|
RTC_DCHECK_RUN_ON(&sequence_checker_);
|
||||||
|
}
|
||||||
void TaskQueueMetronome::RequestCallOnNextTick(
|
void TaskQueueMetronome::RequestCallOnNextTick(
|
||||||
absl::AnyInvocable<void() &&> callback) {
|
absl::AnyInvocable<void() &&> callback) {
|
||||||
|
RTC_DCHECK_RUN_ON(&sequence_checker_);
|
||||||
callbacks_.push_back(std::move(callback));
|
callbacks_.push_back(std::move(callback));
|
||||||
// Only schedule a tick callback for the first `callback` addition.
|
// Only schedule a tick callback for the first `callback` addition.
|
||||||
// Schedule on the current task queue to comply with RequestCallOnNextTick
|
// Schedule on the current task queue to comply with RequestCallOnNextTick
|
||||||
// requirements.
|
// requirements.
|
||||||
if (callbacks_.size() == 1) {
|
if (callbacks_.size() == 1) {
|
||||||
TaskQueueBase::Current()->PostDelayedTask(
|
TaskQueueBase::Current()->PostDelayedTask(
|
||||||
[this] {
|
SafeTask(safety_.flag(),
|
||||||
std::vector<absl::AnyInvocable<void() &&>> callbacks;
|
[this] {
|
||||||
callbacks_.swap(callbacks);
|
RTC_DCHECK_RUN_ON(&sequence_checker_);
|
||||||
for (auto& callback : callbacks)
|
std::vector<absl::AnyInvocable<void() &&>> callbacks;
|
||||||
std::move(callback)();
|
callbacks_.swap(callbacks);
|
||||||
},
|
for (auto& callback : callbacks)
|
||||||
|
std::move(callback)();
|
||||||
|
}),
|
||||||
tick_period_);
|
tick_period_);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
TimeDelta TaskQueueMetronome::TickPeriod() const {
|
TimeDelta TaskQueueMetronome::TickPeriod() const {
|
||||||
|
RTC_DCHECK_RUN_ON(&sequence_checker_);
|
||||||
return tick_period_;
|
return tick_period_;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -181,6 +181,7 @@ int FindFirstMediaStatsIndexByKind(
|
|||||||
class TaskQueueMetronome : public webrtc::Metronome {
|
class TaskQueueMetronome : public webrtc::Metronome {
|
||||||
public:
|
public:
|
||||||
explicit TaskQueueMetronome(TimeDelta tick_period);
|
explicit TaskQueueMetronome(TimeDelta tick_period);
|
||||||
|
~TaskQueueMetronome() override;
|
||||||
|
|
||||||
// webrtc::Metronome implementation.
|
// webrtc::Metronome implementation.
|
||||||
void RequestCallOnNextTick(absl::AnyInvocable<void() &&> callback) override;
|
void RequestCallOnNextTick(absl::AnyInvocable<void() &&> callback) override;
|
||||||
@ -188,7 +189,9 @@ class TaskQueueMetronome : public webrtc::Metronome {
|
|||||||
|
|
||||||
private:
|
private:
|
||||||
const TimeDelta tick_period_;
|
const TimeDelta tick_period_;
|
||||||
|
SequenceChecker sequence_checker_;
|
||||||
std::vector<absl::AnyInvocable<void() &&>> callbacks_;
|
std::vector<absl::AnyInvocable<void() &&>> callbacks_;
|
||||||
|
ScopedTaskSafetyDetached safety_;
|
||||||
};
|
};
|
||||||
|
|
||||||
class SignalingMessageReceiver {
|
class SignalingMessageReceiver {
|
||||||
|
|||||||
Reference in New Issue
Block a user