/* * Copyright (c) 2022 The WebRTC project authors. All Rights Reserved. * * Use of this source code is governed by a BSD-style license * that can be found in the LICENSE file in the root of the source * tree. An additional intellectual property rights grant can be found * in the file PATENTS. All contributing project authors may * be found in the AUTHORS file in the root of the source tree.
*/
void DecodeSynchronizer::ScheduledFrame::RunFrameReleaseCallback() && { // Inspiration from Chromium base::OnceCallback. Move `*this` to a local // before execution to ensure internal state is cleared after callback // execution. auto sf = std::move(*this);
std::move(sf.callback_)(sf.rtp_timestamp_, sf.schedule_.render_time);
}
std::unique_ptr<FrameDecodeScheduler>
DecodeSynchronizer::CreateSynchronizedFrameScheduler() {
TRACE_EVENT0("webrtc", __func__);
RTC_DCHECK_RUN_ON(worker_queue_); auto scheduler = std::make_unique<SynchronizedFrameDecodeScheduler>(this); auto [it, inserted] = schedulers_.emplace(scheduler.get()); // If this is the first `scheduler` added, start listening to the metronome. if (inserted && schedulers_.size() == 1) {
RTC_DLOG(LS_VERBOSE) << "Listening to metronome";
ScheduleNextTick();
}
Timestamp now = clock_->CurrentTime();
Timestamp next_tick = expected_next_tick_; // If no tick has registered yet assume it will occur in the tick period. if (next_tick.IsInfinite()) {
next_tick = now + metronome_->TickPeriod();
}
// Release the frame right away if the decode time is too soon. Otherwise // the stream may fall behind too much. bool decode_before_next_tick =
scheduler->LatestDecodeTime() <
(next_tick - FrameDecodeTiming::kMaxAllowedFrameDelay); // Decode immediately if the decode time is in the past. bool decode_time_in_past = scheduler->LatestDecodeTime() < now;
void DecodeSynchronizer::RemoveFrameScheduler(
SynchronizedFrameDecodeScheduler* scheduler) {
TRACE_EVENT0("webrtc", __func__);
RTC_DCHECK_RUN_ON(worker_queue_);
RTC_DCHECK(scheduler); auto it = schedulers_.find(scheduler); if (it == schedulers_.end()) { return;
}
schedulers_.erase(it); // If there are no more schedulers active, stop listening for metronome ticks. if (schedulers_.empty()) {
expected_next_tick_ = Timestamp::PlusInfinity();
}
}
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.