1 // Copyright 2014 The Chromium Authors. All rights reserved. 2 // Use of this source code is governed by a BSD-style license that can be 3 // found in the LICENSE file. 4 5 #ifndef MEDIA_FILTERS_DECODER_STREAM_TRAITS_H_ 6 #define MEDIA_FILTERS_DECODER_STREAM_TRAITS_H_ 7 8 #include "media/base/demuxer_stream.h" 9 #include "media/base/pipeline_status.h" 10 11 namespace media { 12 13 class AudioBuffer; 14 class AudioDecoder; 15 class DecryptingAudioDecoder; 16 class DecryptingVideoDecoder; 17 class DemuxerStream; 18 class VideoDecoder; 19 class VideoFrame; 20 21 template <DemuxerStream::Type StreamType> 22 struct DecoderStreamTraits {}; 23 24 template <> 25 struct DecoderStreamTraits<DemuxerStream::AUDIO> { 26 typedef AudioBuffer OutputType; 27 typedef AudioDecoder DecoderType; 28 typedef AudioDecoderConfig DecoderConfigType; 29 typedef DecryptingAudioDecoder DecryptingDecoderType; 30 typedef base::Callback<void(bool success)> StreamInitCB; 31 typedef base::Callback<void(const scoped_refptr<OutputType>&)> OutputCB; 32 33 static std::string ToString(); 34 static void Initialize(DecoderType* decoder, 35 const DecoderConfigType& config, 36 bool low_delay, 37 const PipelineStatusCB& status_cb, 38 const OutputCB& output_cb); 39 static bool FinishInitialization(const StreamInitCB& init_cb, 40 DecoderType* decoder, 41 DemuxerStream* stream); 42 static void ReportStatistics(const StatisticsCB& statistics_cb, 43 int bytes_decoded); 44 static DecoderConfigType GetDecoderConfig(DemuxerStream& stream); 45 static scoped_refptr<OutputType> CreateEOSOutput(); 46 }; 47 48 template <> 49 struct DecoderStreamTraits<DemuxerStream::VIDEO> { 50 typedef VideoFrame OutputType; 51 typedef VideoDecoder DecoderType; 52 typedef VideoDecoderConfig DecoderConfigType; 53 typedef DecryptingVideoDecoder DecryptingDecoderType; 54 typedef base::Callback<void(bool success)> StreamInitCB; 55 typedef base::Callback<void(const scoped_refptr<OutputType>&)> OutputCB; 56 57 static std::string ToString(); 58 static void Initialize(DecoderType* decoder, 59 const DecoderConfigType& config, 60 bool low_delay, 61 const PipelineStatusCB& status_cb, 62 const OutputCB& output_cb); 63 static bool FinishInitialization(const StreamInitCB& init_cb, 64 DecoderType* decoder, 65 DemuxerStream* stream); 66 static void ReportStatistics(const StatisticsCB& statistics_cb, 67 int bytes_decoded); 68 static DecoderConfigType GetDecoderConfig(DemuxerStream& stream); 69 static scoped_refptr<OutputType> CreateEOSOutput(); 70 }; 71 72 } // namespace media 73 74 #endif // MEDIA_FILTERS_DECODER_STREAM_TRAITS_H_ 75