#include "media/filters/decoder_selector.h"
#include <algorithm>
#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/metrics/histogram_functions.h"
#include "base/strings/stringprintf.h"
#include "base/task/sequenced_task_runner.h"
#include "base/trace_event/trace_event.h"
#include "build/build_config.h"
#include "build/chromeos_buildflags.h"
#include "media/base/audio_decoder.h"
#include "media/base/cdm_context.h"
#include "media/base/demuxer_stream.h"
#include "media/base/media_log.h"
#include "media/base/media_switches.h"
#include "media/base/video_decoder.h"
#include "media/filters/decoder_stream_traits.h"
#include "media/filters/decrypting_demuxer_stream.h"
namespace media {
namespace {
const char kSelectDecoderTrace[] = …;
bool SkipDecoderForRTC(const AudioDecoderConfig& ,
const AudioDecoder& ) { … }
bool SkipDecoderForRTC(const VideoDecoderConfig& config,
const VideoDecoder& decoder) { … }
template <typename ConfigT, typename DecoderT>
DecoderPriority NormalDecoderPriority(const ConfigT& config,
const DecoderT& decoder) { … }
DecoderPriority ResolutionBasedDecoderPriority(const VideoDecoderConfig& config,
const VideoDecoder& decoder) { … }
DecoderPriority PreferNonPlatformDecoders(const VideoDecoderConfig& config,
const VideoDecoder& decoder) { … }
DecoderPriority UnifiedDecoderPriority(const VideoDecoderConfig& config,
const VideoDecoder& decoder) { … }
template <typename ConfigT, typename DecoderT>
DecoderPriority SkipNonPlatformDecoders(const ConfigT& config,
const DecoderT& decoder) { … }
void SetDefaultDecoderPriorityCB(
VideoDecoderSelector::DecoderPriorityCB* out,
const DecoderStreamTraits<DemuxerStream::VIDEO>* traits) { … }
void SetDefaultDecoderPriorityCB(
AudioDecoderSelector::DecoderPriorityCB* out,
const DecoderStreamTraits<DemuxerStream::AUDIO>*) { … }
}
template <DemuxerStream::Type StreamType>
DecoderSelector<StreamType>::DecoderSelector(
scoped_refptr<base::SequencedTaskRunner> task_runner,
CreateDecodersCB create_decoders_cb,
MediaLog* media_log)
: … { … }
template <DemuxerStream::Type StreamType>
DecoderSelector<StreamType>::~DecoderSelector() { … }
template <DemuxerStream::Type StreamType>
void DecoderSelector<StreamType>::Initialize(StreamTraits* traits,
DemuxerStream* stream,
CdmContext* cdm_context,
WaitingCB waiting_cb) { … }
template <DemuxerStream::Type StreamType>
void DecoderSelector<StreamType>::SelectDecoderInternal(
SelectDecoderCB select_decoder_cb,
typename Decoder::OutputCB output_cb,
bool needs_new_decoders) { … }
template <DemuxerStream::Type StreamType>
void DecoderSelector<StreamType>::BeginDecoderSelection(
SelectDecoderCB select_decoder_cb,
typename Decoder::OutputCB output_cb) { … }
template <DemuxerStream::Type StreamType>
void DecoderSelector<StreamType>::ResumeDecoderSelection(
SelectDecoderCB select_decoder_cb,
typename Decoder::OutputCB output_cb,
DecoderStatus&& reinit_cause) { … }
template <DemuxerStream::Type StreamType>
void DecoderSelector<StreamType>::FinalizeDecoderSelection() { … }
template <DemuxerStream::Type StreamType>
void DecoderSelector<StreamType>::PrependDecoder(
std::unique_ptr<Decoder> decoder) { … }
template <DemuxerStream::Type StreamType>
void DecoderSelector<StreamType>::OverrideDecoderPriorityCBForTesting(
DecoderPriorityCB decoder_priority_cb) { … }
template <DemuxerStream::Type StreamType>
void DecoderSelector<StreamType>::CreateDecoders() { … }
template <DemuxerStream::Type StreamType>
void DecoderSelector<StreamType>::GetAndInitializeNextDecoder() { … }
template <DemuxerStream::Type StreamType>
void DecoderSelector<StreamType>::OnDecoderInitializeDone(
DecoderStatus status) { … }
template <DemuxerStream::Type StreamType>
void DecoderSelector<StreamType>::ReturnSelectionError(DecoderStatus error) { … }
template <DemuxerStream::Type StreamType>
void DecoderSelector<StreamType>::InitializeDecryptingDemuxerStream() { … }
template <DemuxerStream::Type StreamType>
void DecoderSelector<StreamType>::OnDecryptingDemuxerStreamInitializeDone(
PipelineStatus status) { … }
template <DemuxerStream::Type StreamType>
void DecoderSelector<StreamType>::RunSelectDecoderCB(
DecoderOrError decoder_or_error) { … }
template <DemuxerStream::Type StreamType>
void DecoderSelector<StreamType>::FilterAndSortAvailableDecoders() { … }
template class DecoderSelector<DemuxerStream::AUDIO>;
template class DecoderSelector<DemuxerStream::VIDEO>;
}