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
11namespace media {
12
13class AudioBuffer;
14class AudioDecoder;
15class DecryptingAudioDecoder;
16class DecryptingVideoDecoder;
17class DemuxerStream;
18class VideoDecoder;
19class VideoFrame;
20
21template <DemuxerStream::Type StreamType>
22struct DecoderStreamTraits {};
23
24template <>
25struct 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 NeedsBitstreamConversion(DecoderType* decoder) { return false; }
40  static void ReportStatistics(const StatisticsCB& statistics_cb,
41                               int bytes_decoded);
42  static DecoderConfigType GetDecoderConfig(DemuxerStream& stream);
43  static scoped_refptr<OutputType> CreateEOSOutput();
44};
45
46template <>
47struct DecoderStreamTraits<DemuxerStream::VIDEO> {
48  typedef VideoFrame OutputType;
49  typedef VideoDecoder DecoderType;
50  typedef VideoDecoderConfig DecoderConfigType;
51  typedef DecryptingVideoDecoder DecryptingDecoderType;
52  typedef base::Callback<void(bool success)> StreamInitCB;
53  typedef base::Callback<void(const scoped_refptr<OutputType>&)> OutputCB;
54
55  static std::string ToString();
56  static void Initialize(DecoderType* decoder,
57                         const DecoderConfigType& config,
58                         bool low_delay,
59                         const PipelineStatusCB& status_cb,
60                         const OutputCB& output_cb);
61  static bool NeedsBitstreamConversion(DecoderType* decoder);
62  static void ReportStatistics(const StatisticsCB& statistics_cb,
63                               int bytes_decoded);
64  static DecoderConfigType GetDecoderConfig(DemuxerStream& stream);
65  static scoped_refptr<OutputType> CreateEOSOutput();
66};
67
68}  // namespace media
69
70#endif  // MEDIA_FILTERS_DECODER_STREAM_TRAITS_H_
71