#include "media/renderers/renderer_impl.h"
#include <memory>
#include <utility>
#include "base/command_line.h"
#include "base/compiler_specific.h"
#include "base/functional/bind.h"
#include "base/functional/callback.h"
#include "base/functional/callback_helpers.h"
#include "base/location.h"
#include "base/memory/raw_ptr.h"
#include "base/strings/string_number_conversions.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/trace_event/trace_event.h"
#include "media/base/audio_decoder_config.h"
#include "media/base/audio_renderer.h"
#include "media/base/media_log.h"
#include "media/base/media_resource.h"
#include "media/base/media_switches.h"
#include "media/base/renderer_client.h"
#include "media/base/time_source.h"
#include "media/base/video_decoder_config.h"
#include "media/base/video_renderer.h"
#include "media/base/wall_clock_time_source.h"
namespace media {
class RendererImpl::RendererClientInternal final : public RendererClient { … };
RendererImpl::RendererImpl(
const scoped_refptr<base::SequencedTaskRunner>& task_runner,
std::unique_ptr<AudioRenderer> audio_renderer,
std::unique_ptr<VideoRenderer> video_renderer)
: … { … }
RendererImpl::~RendererImpl() { … }
void RendererImpl::Initialize(MediaResource* media_resource,
RendererClient* client,
PipelineStatusCallback init_cb) { … }
void RendererImpl::SetCdm(CdmContext* cdm_context,
CdmAttachedCB cdm_attached_cb) { … }
void RendererImpl::SetLatencyHint(std::optional<base::TimeDelta> latency_hint) { … }
void RendererImpl::SetPreservesPitch(bool preserves_pitch) { … }
void RendererImpl::SetWasPlayedWithUserActivation(
bool was_played_with_user_activation) { … }
void RendererImpl::Flush(base::OnceClosure flush_cb) { … }
void RendererImpl::StartPlayingFrom(base::TimeDelta time) { … }
void RendererImpl::SetPlaybackRate(double playback_rate) { … }
void RendererImpl::SetVolume(float volume) { … }
base::TimeDelta RendererImpl::GetMediaTime() { … }
void RendererImpl::DisableUnderflowForTesting() { … }
void RendererImpl::EnableClocklessVideoPlaybackForTesting() { … }
bool RendererImpl::GetWallClockTimes(
const std::vector<base::TimeDelta>& media_timestamps,
std::vector<base::TimeTicks>* wall_clock_times) { … }
bool RendererImpl::HasEncryptedStream() { … }
void RendererImpl::FinishInitialization(PipelineStatus status) { … }
void RendererImpl::FinishFlush() { … }
void RendererImpl::InitializeAudioRenderer() { … }
void RendererImpl::OnAudioRendererInitializeDone(PipelineStatus status) { … }
void RendererImpl::InitializeVideoRenderer() { … }
void RendererImpl::OnVideoRendererInitializeDone(PipelineStatus status) { … }
void RendererImpl::FlushInternal() { … }
void RendererImpl::FlushAudioRenderer() { … }
void RendererImpl::OnAudioRendererFlushDone() { … }
void RendererImpl::FlushVideoRenderer() { … }
void RendererImpl::OnVideoRendererFlushDone() { … }
void RendererImpl::ReinitializeAudioRenderer(
DemuxerStream* stream,
base::TimeDelta time,
base::OnceClosure reinitialize_completed_cb) { … }
void RendererImpl::OnAudioRendererReinitialized(
DemuxerStream* stream,
base::TimeDelta time,
base::OnceClosure reinitialize_completed_cb,
PipelineStatus status) { … }
void RendererImpl::ReinitializeVideoRenderer(
DemuxerStream* stream,
base::TimeDelta time,
base::OnceClosure reinitialize_completed_cb) { … }
void RendererImpl::OnVideoRendererReinitialized(
DemuxerStream* stream,
base::TimeDelta time,
base::OnceClosure reinitialize_completed_cb,
PipelineStatus status) { … }
void RendererImpl::RestartAudioRenderer(
DemuxerStream* stream,
base::TimeDelta time,
base::OnceClosure restart_completed_cb) { … }
void RendererImpl::RestartVideoRenderer(
DemuxerStream* stream,
base::TimeDelta time,
base::OnceClosure restart_completed_cb) { … }
void RendererImpl::OnStatisticsUpdate(const PipelineStatistics& stats) { … }
void RendererImpl::OnBufferingStateChange(DemuxerStream::Type type,
BufferingState new_buffering_state,
BufferingStateChangeReason reason) { … }
bool RendererImpl::WaitingForEnoughData() const { … }
void RendererImpl::PausePlayback() { … }
void RendererImpl::StartPlayback() { … }
void RendererImpl::OnRendererEnded(DemuxerStream::Type type) { … }
bool RendererImpl::PlaybackHasEnded() const { … }
void RendererImpl::RunEndedCallbackIfNeeded() { … }
void RendererImpl::OnFallback(PipelineStatus fallback) { … }
void RendererImpl::OnError(PipelineStatus error) { … }
void RendererImpl::OnWaiting(WaitingReason reason) { … }
void RendererImpl::OnAudioConfigChange(const AudioDecoderConfig& config) { … }
void RendererImpl::OnVideoConfigChange(const VideoDecoderConfig& config) { … }
void RendererImpl::OnVideoNaturalSizeChange(const gfx::Size& size) { … }
void RendererImpl::OnVideoOpacityChange(bool opaque) { … }
void RendererImpl::OnVideoFrameRateChange(std::optional<int> fps) { … }
void RendererImpl::CleanUpTrackChange(base::OnceClosure on_finished,
bool* ended,
bool* playing) { … }
void RendererImpl::OnSelectedVideoTracksChanged(
const std::vector<DemuxerStream*>& enabled_tracks,
base::OnceClosure change_completed_cb) { … }
void RendererImpl::OnEnabledAudioTracksChanged(
const std::vector<DemuxerStream*>& enabled_tracks,
base::OnceClosure change_completed_cb) { … }
RendererType RendererImpl::GetRendererType() { … }
}