#include "media/renderers/video_renderer_impl.h"
#include <algorithm>
#include <memory>
#include <utility>
#include "base/feature_list.h"
#include "base/functional/bind.h"
#include "base/functional/callback.h"
#include "base/functional/callback_helpers.h"
#include "base/location.h"
#include "base/metrics/histogram_macros.h"
#include "base/numerics/safe_conversions.h"
#include "base/strings/string_util.h"
#include "base/task/bind_post_task.h"
#include "base/task/sequenced_task_runner.h"
#include "base/task/single_thread_task_runner.h"
#include "base/time/default_tick_clock.h"
#include "base/trace_event/trace_event.h"
#include "media/base/media_log.h"
#include "media/base/media_switches.h"
#include "media/base/pipeline_status.h"
#include "media/base/renderer_client.h"
#include "media/base/video_frame.h"
namespace media {
namespace {
constexpr int kAbsoluteMaxFrames = …;
bool ShouldUseLowDelayMode(DemuxerStream* stream) { … }
}
VideoRendererImpl::VideoRendererImpl(
const scoped_refptr<base::SequencedTaskRunner>& media_task_runner,
VideoRendererSink* sink,
const CreateVideoDecodersCB& create_video_decoders_cb,
bool drop_frames,
MediaLog* media_log,
std::unique_ptr<GpuMemoryBufferVideoFramePool> gmb_pool,
MediaPlayerLoggingID media_player_id)
: … { … }
VideoRendererImpl::~VideoRendererImpl() { … }
void VideoRendererImpl::Flush(base::OnceClosure callback) { … }
void VideoRendererImpl::StartPlayingFrom(base::TimeDelta timestamp) { … }
void VideoRendererImpl::Initialize(
DemuxerStream* stream,
CdmContext* cdm_context,
RendererClient* client,
const TimeSource::WallClockTimeCB& wall_clock_time_cb,
PipelineStatusCallback init_cb) { … }
scoped_refptr<VideoFrame> VideoRendererImpl::Render(
base::TimeTicks deadline_min,
base::TimeTicks deadline_max,
RenderingMode rendering_mode) { … }
void VideoRendererImpl::OnFrameDropped() { … }
base::TimeDelta VideoRendererImpl::GetPreferredRenderInterval() { … }
void VideoRendererImpl::OnVideoDecoderStreamInitialized(bool success) { … }
void VideoRendererImpl::FinishInitialization(PipelineStatus status) { … }
void VideoRendererImpl::FinishFlush() { … }
void VideoRendererImpl::OnPlaybackError(PipelineStatus error) { … }
void VideoRendererImpl::OnPlaybackEnded() { … }
void VideoRendererImpl::OnStatisticsUpdate(const PipelineStatistics& stats) { … }
void VideoRendererImpl::OnBufferingStateChange(BufferingState buffering_state) { … }
void VideoRendererImpl::OnWaiting(WaitingReason reason) { … }
void VideoRendererImpl::OnConfigChange(const VideoDecoderConfig& config) { … }
void VideoRendererImpl::OnFallback(PipelineStatus status) { … }
void VideoRendererImpl::SetTickClockForTesting(
const base::TickClock* tick_clock) { … }
void VideoRendererImpl::OnTimeProgressing() { … }
void VideoRendererImpl::OnTimeStopped() { … }
void VideoRendererImpl::SetLatencyHint(
std::optional<base::TimeDelta> latency_hint) { … }
void VideoRendererImpl::UpdateLatencyHintBufferingCaps_Locked(
base::TimeDelta average_frame_duration) { … }
void VideoRendererImpl::FrameReady(VideoDecoderStream::ReadResult result) { … }
bool VideoRendererImpl::HaveEnoughData_Locked() const { … }
void VideoRendererImpl::TransitionToHaveEnough_Locked() { … }
void VideoRendererImpl::TransitionToHaveNothing() { … }
void VideoRendererImpl::TransitionToHaveNothing_Locked() { … }
void VideoRendererImpl::AddReadyFrame_Locked(scoped_refptr<VideoFrame> frame) { … }
void VideoRendererImpl::AttemptRead_Locked() { … }
void VideoRendererImpl::OnVideoDecoderStreamResetDone() { … }
void VideoRendererImpl::UpdateStats_Locked(bool force_update) { … }
void VideoRendererImpl::ReportFrameRateIfNeeded_Locked() { … }
bool VideoRendererImpl::HaveReachedBufferingCap(size_t buffering_cap) const { … }
void VideoRendererImpl::StartSink() { … }
void VideoRendererImpl::StopSink() { … }
void VideoRendererImpl::MaybeFireEndedCallback_Locked(bool time_progressing) { … }
base::TimeTicks VideoRendererImpl::ConvertMediaTimestamp(
base::TimeDelta media_time) { … }
base::TimeTicks VideoRendererImpl::GetCurrentMediaTimeAsWallClockTime() { … }
bool VideoRendererImpl::IsBeforeStartTime(const VideoFrame& frame) { … }
bool VideoRendererImpl::HasBestFirstFrame(const VideoFrame& frame) { … }
void VideoRendererImpl::RemoveFramesForUnderflowOrBackgroundRendering() { … }
void VideoRendererImpl::CheckForMetadataChanges(VideoPixelFormat pixel_format,
const gfx::Size& natural_size) { … }
void VideoRendererImpl::AttemptReadAndCheckForMetadataChanges(
VideoPixelFormat pixel_format,
const gfx::Size& natural_size) { … }
void VideoRendererImpl::PaintFirstFrame() { … }
void VideoRendererImpl::PaintFirstFrame_Locked() { … }
}