#include "media/filters/decoder_stream.h"
#include <utility>
#include "base/feature_list.h"
#include "base/functional/bind.h"
#include "base/functional/callback_helpers.h"
#include "base/location.h"
#include "base/logging.h"
#include "base/numerics/safe_conversions.h"
#include "base/task/bind_post_task.h"
#include "base/task/sequenced_task_runner.h"
#include "base/trace_event/trace_event.h"
#include "base/types/cxx23_to_underlying.h"
#include "media/base/cdm_context.h"
#include "media/base/decoder_buffer.h"
#include "media/base/limits.h"
#include "media/base/media_log.h"
#include "media/base/media_switches.h"
#include "media/base/media_util.h"
#include "media/base/timestamp_constants.h"
#include "media/base/video_decoder.h"
#include "media/base/video_frame.h"
#include "media/filters/decrypting_demuxer_stream.h"
namespace media {
#define FUNCTION_DVLOG(level) …
template <DemuxerStream::Type StreamType>
static const char* GetDecodeTraceString();
template <DemuxerStream::Type StreamType>
static const char* GetReadTraceString();
template <DemuxerStream::Type StreamType>
static const char* GetDemuxerReadTraceString();
template <DemuxerStream::Type StreamType>
static const char* GetPrepareTraceString();
template <>
const char* GetDecodeTraceString<DemuxerStream::VIDEO>() { … }
template <>
const char* GetDecodeTraceString<DemuxerStream::AUDIO>() { … }
template <>
const char* GetReadTraceString<DemuxerStream::VIDEO>() { … }
template <>
const char* GetReadTraceString<DemuxerStream::AUDIO>() { … }
template <>
const char* GetDemuxerReadTraceString<DemuxerStream::VIDEO>() { … }
template <>
const char* GetDemuxerReadTraceString<DemuxerStream::AUDIO>() { … }
template <>
const char* GetPrepareTraceString<DemuxerStream::VIDEO>() { … }
template <>
const char* GetPrepareTraceString<DemuxerStream::AUDIO>() { … }
const char* GetStatusString(const DecoderStatus& status) { … }
template <DemuxerStream::Type StreamType>
DecoderStream<StreamType>::DecoderStream(
std::unique_ptr<DecoderStreamTraits<StreamType>> traits,
scoped_refptr<base::SequencedTaskRunner> task_runner,
CreateDecodersCB create_decoders_cb,
MediaLog* media_log)
: … { … }
template <DemuxerStream::Type StreamType>
DecoderStream<StreamType>::~DecoderStream() { … }
template <DemuxerStream::Type StreamType>
std::string DecoderStream<StreamType>::GetStreamTypeString() { … }
template <DemuxerStream::Type StreamType>
void DecoderStream<StreamType>::Initialize(DemuxerStream* stream,
InitCB init_cb,
CdmContext* cdm_context,
StatisticsCB statistics_cb,
WaitingCB waiting_cb) { … }
template <DemuxerStream::Type StreamType>
void DecoderStream<StreamType>::Read(ReadCB read_cb) { … }
template <DemuxerStream::Type StreamType>
void DecoderStream<StreamType>::Reset(base::OnceClosure closure) { … }
template <DemuxerStream::Type StreamType>
bool DecoderStream<StreamType>::CanReadWithoutStalling() const { … }
template <>
bool DecoderStream<DemuxerStream::AUDIO>::CanReadWithoutStalling() const { … }
template <DemuxerStream::Type StreamType>
int DecoderStream<StreamType>::GetMaxDecodeRequests() const { … }
template <>
int DecoderStream<DemuxerStream::AUDIO>::GetMaxDecodeRequests() const { … }
template <DemuxerStream::Type StreamType>
int DecoderStream<StreamType>::GetMaxReadyOutputs() const { … }
template <>
int DecoderStream<DemuxerStream::AUDIO>::GetMaxReadyOutputs() const { … }
template <DemuxerStream::Type StreamType>
bool DecoderStream<StreamType>::CanDecodeMore() const { … }
template <DemuxerStream::Type StreamType>
base::TimeDelta DecoderStream<StreamType>::AverageDuration() const { … }
template <DemuxerStream::Type StreamType>
void DecoderStream<StreamType>::SetPrepareCB(PrepareCB prepare_cb) { … }
template <DemuxerStream::Type StreamType>
void DecoderStream<StreamType>::SkipPrepareUntil(
base::TimeDelta start_timestamp) { … }
template <DemuxerStream::Type StreamType>
void DecoderStream<StreamType>::BeginDecoderSelection() { … }
template <DemuxerStream::Type StreamType>
void DecoderStream<StreamType>::ResumeDecoderSelection(
DecoderStatus&& reinit_cause) { … }
template <DemuxerStream::Type StreamType>
void DecoderStream<StreamType>::OnDecoderSelected(
DecoderStatus::Or<std::unique_ptr<Decoder>> decoder_or_error,
std::unique_ptr<DecryptingDemuxerStream> decrypting_demuxer_stream) { … }
template <DemuxerStream::Type StreamType>
void DecoderStream<StreamType>::SatisfyRead(ReadResult result) { … }
template <DemuxerStream::Type StreamType>
void DecoderStream<StreamType>::Decode(scoped_refptr<DecoderBuffer> buffer) { … }
template <DemuxerStream::Type StreamType>
void DecoderStream<StreamType>::DecodeInternal(
scoped_refptr<DecoderBuffer> buffer) { … }
template <DemuxerStream::Type StreamType>
void DecoderStream<StreamType>::FlushDecoder() { … }
template <DemuxerStream::Type StreamType>
void DecoderStream<StreamType>::OnDecodeDone(
int buffer_size,
bool end_of_stream,
std::unique_ptr<ScopedDecodeTrace> trace_event,
DecoderStatus status) { … }
template <DemuxerStream::Type StreamType>
void DecoderStream<StreamType>::OnDecodeOutputReady(
scoped_refptr<Output> output) { … }
template <DemuxerStream::Type StreamType>
void DecoderStream<StreamType>::ReadFromDemuxerStream() { … }
template <DemuxerStream::Type StreamType>
void DecoderStream<StreamType>::OnBuffersReady(
DemuxerStream::Status status,
DemuxerStream::DecoderBufferVector buffers) { … }
template <DemuxerStream::Type StreamType>
void DecoderStream<StreamType>::ReinitializeDecoder() { … }
template <DemuxerStream::Type StreamType>
void DecoderStream<StreamType>::CompleteDecoderReinitialization(
DecoderStatus status) { … }
template <DemuxerStream::Type StreamType>
void DecoderStream<StreamType>::ResetDecoder() { … }
template <DemuxerStream::Type StreamType>
void DecoderStream<StreamType>::OnDecoderReset() { … }
template <DemuxerStream::Type StreamType>
void DecoderStream<StreamType>::ClearOutputs() { … }
template <DemuxerStream::Type StreamType>
void DecoderStream<StreamType>::MaybePrepareAnotherOutput() { … }
template <DemuxerStream::Type StreamType>
void DecoderStream<StreamType>::OnPreparedOutputReady(
scoped_refptr<Output> output) { … }
template <DemuxerStream::Type StreamType>
void DecoderStream<StreamType>::CompletePrepare(const Output* output) { … }
template <DemuxerStream::Type StreamType>
void DecoderStream<StreamType>::ReportEncryptionType(
const scoped_refptr<DecoderBuffer>& buffer) { … }
template class DecoderStream<DemuxerStream::VIDEO>;
template class DecoderStream<DemuxerStream::AUDIO>;
}