diff --git a/pc/test/fake_periodic_video_source.h b/pc/test/fake_periodic_video_source.h index 407811578c..452a8f6c30 100644 --- a/pc/test/fake_periodic_video_source.h +++ b/pc/test/fake_periodic_video_source.h @@ -49,14 +49,15 @@ class FakePeriodicVideoSource final frame_source_.SetRotation(config.rotation); TimeDelta frame_interval = TimeDelta::Millis(config.frame_interval_ms); - RepeatingTaskHandle::Start(task_queue_->Get(), [this, frame_interval] { - if (broadcaster_.wants().rotation_applied) { - broadcaster_.OnFrame(frame_source_.GetFrameRotationApplied()); - } else { - broadcaster_.OnFrame(frame_source_.GetFrame()); - } - return frame_interval; - }); + repeating_task_handle_ = + RepeatingTaskHandle::Start(task_queue_->Get(), [this, frame_interval] { + if (broadcaster_.wants().rotation_applied) { + broadcaster_.OnFrame(frame_source_.GetFrameRotationApplied()); + } else { + broadcaster_.OnFrame(frame_source_.GetFrame()); + } + return frame_interval; + }); } rtc::VideoSinkWants wants() const { @@ -81,6 +82,7 @@ class FakePeriodicVideoSource final void Stop() { RTC_DCHECK(task_queue_); + task_queue_->SendTask([&]() { repeating_task_handle_.Stop(); }); task_queue_.reset(); } @@ -93,6 +95,7 @@ class FakePeriodicVideoSource final rtc::VideoSinkWants wants_ RTC_GUARDED_BY(&mutex_); std::unique_ptr task_queue_; + RepeatingTaskHandle repeating_task_handle_; }; } // namespace webrtc