OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "media/filters/decoder_stream_traits.h" | 5 #include "media/filters/decoder_stream_traits.h" |
6 | 6 |
| 7 #include "media/base/audio_decoder.h" |
| 8 #include "media/base/audio_decoder_config.h" |
7 #include "media/base/video_decoder.h" | 9 #include "media/base/video_decoder.h" |
| 10 #include "media/base/video_decoder_config.h" |
8 | 11 |
9 namespace media { | 12 namespace media { |
10 | 13 |
| 14 bool DecoderStreamTraits<DemuxerStream::AUDIO>::FinishInitialization( |
| 15 const StreamInitCB& init_cb, |
| 16 DecoderType* decoder, |
| 17 DemuxerStream* stream) { |
| 18 DCHECK(stream); |
| 19 if (!decoder) { |
| 20 init_cb.Run(false); |
| 21 return false; |
| 22 } |
| 23 init_cb.Run(true); |
| 24 return true; |
| 25 } |
| 26 |
| 27 void DecoderStreamTraits<DemuxerStream::AUDIO>::ReportStatistics( |
| 28 const StatisticsCB& statistics_cb, |
| 29 int bytes_decoded) { |
| 30 PipelineStatistics statistics; |
| 31 statistics.audio_bytes_decoded = bytes_decoded; |
| 32 statistics_cb.Run(statistics); |
| 33 } |
| 34 |
| 35 DecoderStreamTraits<DemuxerStream::AUDIO>::DecoderConfigType |
| 36 DecoderStreamTraits<DemuxerStream::AUDIO>::GetDecoderConfig( |
| 37 DemuxerStream& stream) { |
| 38 return stream.audio_decoder_config(); |
| 39 } |
| 40 |
11 bool DecoderStreamTraits<DemuxerStream::VIDEO>::FinishInitialization( | 41 bool DecoderStreamTraits<DemuxerStream::VIDEO>::FinishInitialization( |
12 const StreamInitCB& init_cb, | 42 const StreamInitCB& init_cb, |
13 DecoderType* decoder, | 43 DecoderType* decoder, |
14 DemuxerStream* stream) { | 44 DemuxerStream* stream) { |
15 DCHECK(stream); | 45 DCHECK(stream); |
16 if (!decoder) { | 46 if (!decoder) { |
17 init_cb.Run(false, false); | 47 init_cb.Run(false, false); |
18 return false; | 48 return false; |
19 } | 49 } |
20 if (decoder->NeedsBitstreamConversion()) | 50 if (decoder->NeedsBitstreamConversion()) |
21 stream->EnableBitstreamConverter(); | 51 stream->EnableBitstreamConverter(); |
22 // TODO(xhwang): We assume |decoder_->HasAlpha()| does not change after | 52 // TODO(xhwang): We assume |decoder_->HasAlpha()| does not change after |
23 // reinitialization. Check this condition. | 53 // reinitialization. Check this condition. |
24 init_cb.Run(true, decoder->HasAlpha()); | 54 init_cb.Run(true, decoder->HasAlpha()); |
25 return true; | 55 return true; |
26 } | 56 } |
27 | 57 |
28 void DecoderStreamTraits<DemuxerStream::VIDEO>::ReportStatistics( | 58 void DecoderStreamTraits<DemuxerStream::VIDEO>::ReportStatistics( |
29 const StatisticsCB& statistics_cb, | 59 const StatisticsCB& statistics_cb, |
30 int bytes_decoded) { | 60 int bytes_decoded) { |
31 PipelineStatistics statistics; | 61 PipelineStatistics statistics; |
32 statistics.video_bytes_decoded = bytes_decoded; | 62 statistics.video_bytes_decoded = bytes_decoded; |
33 statistics_cb.Run(statistics); | 63 statistics_cb.Run(statistics); |
34 } | 64 } |
35 | 65 |
| 66 DecoderStreamTraits<DemuxerStream::VIDEO>::DecoderConfigType |
| 67 DecoderStreamTraits<DemuxerStream::VIDEO>::GetDecoderConfig( |
| 68 DemuxerStream& stream) { |
| 69 return stream.video_decoder_config(); |
| 70 } |
| 71 |
36 } // namespace media | 72 } // namespace media |
OLD | NEW |