// Copyright 2015 The Chromium Authors // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. #ifndef MEDIA_FILTERS_VIDEO_RENDERER_ALGORITHM_H_ #define MEDIA_FILTERS_VIDEO_RENDERER_ALGORITHM_H_ #include <stddef.h> #include <stdint.h> #include "base/containers/circular_deque.h" #include "base/functional/callback.h" #include "base/memory/raw_ptr.h" #include "base/memory/scoped_refptr.h" #include "base/moving_window.h" #include "base/time/time.h" #include "media/base/media_export.h" #include "media/base/video_frame.h" #include "media/base/video_renderer.h" #include "media/filters/video_cadence_estimator.h" namespace media { class MediaLog; // VideoRendererAlgorithm manages a queue of VideoFrames from which it chooses // frames with the goal of providing a smooth playback experience. I.e., the // selection process results in the best possible uniformity for displayed frame // durations over time. // // Clients will provide frames to VRA via EnqueueFrame() and then VRA will yield // one of those frames in response to a future Render() call. Each Render() // call takes a render interval which is used to compute the best frame for // display during that interval. // // Render() calls are expected to happen on a regular basis. Failure to do so // will result in suboptimal rendering experiences. If a client knows that // Render() callbacks are stalled for any reason, it should tell VRA to expire // frames which are unusable via RemoveExpiredFrames(); this prevents useless // accumulation of stale VideoFrame objects (which are frequently quite large). // // The primary means of smooth frame selection is via forced integer cadence, // see VideoCadenceEstimator for details on this process. In cases of non- // integer cadence, the algorithm will fall back to choosing the frame which // covers the most of the current render interval. If no frame covers the // current interval, the least bad frame will be chosen based on its drift from // the start of the interval. // // Combined these three approaches enforce optimal smoothness in many cases. class MEDIA_EXPORT VideoRendererAlgorithm { … }; } // namespace media #endif // MEDIA_FILTERS_VIDEO_RENDERER_ALGORITHM_H_