| 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 #ifndef MEDIA_FILTERS_DECODER_STREAM_TRAITS_H_ | 5 #ifndef MEDIA_FILTERS_DECODER_STREAM_TRAITS_H_ |
| 6 #define MEDIA_FILTERS_DECODER_STREAM_TRAITS_H_ | 6 #define MEDIA_FILTERS_DECODER_STREAM_TRAITS_H_ |
| 7 | 7 |
| 8 #include "base/time/time.h" | 8 #include "base/time/time.h" |
| 9 #include "media/base/cdm_context.h" | 9 #include "media/base/cdm_context.h" |
| 10 #include "media/base/demuxer_stream.h" | 10 #include "media/base/demuxer_stream.h" |
| (...skipping 26 matching lines...) Expand all Loading... |
| 37 typedef AudioDecoderConfig DecoderConfigType; | 37 typedef AudioDecoderConfig DecoderConfigType; |
| 38 typedef DecryptingAudioDecoder DecryptingDecoderType; | 38 typedef DecryptingAudioDecoder DecryptingDecoderType; |
| 39 typedef base::Callback<void(bool success)> InitCB; | 39 typedef base::Callback<void(bool success)> InitCB; |
| 40 typedef base::Callback<void(const scoped_refptr<OutputType>&)> OutputCB; | 40 typedef base::Callback<void(const scoped_refptr<OutputType>&)> OutputCB; |
| 41 | 41 |
| 42 static std::string ToString(); | 42 static std::string ToString(); |
| 43 static bool NeedsBitstreamConversion(DecoderType* decoder); | 43 static bool NeedsBitstreamConversion(DecoderType* decoder); |
| 44 static scoped_refptr<OutputType> CreateEOSOutput(); | 44 static scoped_refptr<OutputType> CreateEOSOutput(); |
| 45 static DecoderConfigType GetDecoderConfig(DemuxerStream* stream); | 45 static DecoderConfigType GetDecoderConfig(DemuxerStream* stream); |
| 46 | 46 |
| 47 explicit DecoderStreamTraits(const scoped_refptr<MediaLog>& media_log); | 47 explicit DecoderStreamTraits(MediaLog* media_log); |
| 48 | 48 |
| 49 void ReportStatistics(const StatisticsCB& statistics_cb, int bytes_decoded); | 49 void ReportStatistics(const StatisticsCB& statistics_cb, int bytes_decoded); |
| 50 void InitializeDecoder(DecoderType* decoder, | 50 void InitializeDecoder(DecoderType* decoder, |
| 51 const DecoderConfigType& config, | 51 const DecoderConfigType& config, |
| 52 bool low_delay, | 52 bool low_delay, |
| 53 CdmContext* cdm_context, | 53 CdmContext* cdm_context, |
| 54 const InitCB& init_cb, | 54 const InitCB& init_cb, |
| 55 const OutputCB& output_cb); | 55 const OutputCB& output_cb); |
| 56 void OnDecode(const scoped_refptr<DecoderBuffer>& buffer); | 56 void OnDecode(const scoped_refptr<DecoderBuffer>& buffer); |
| 57 void OnDecodeDone(const scoped_refptr<OutputType>& buffer); | 57 void OnDecodeDone(const scoped_refptr<OutputType>& buffer); |
| 58 void OnStreamReset(DemuxerStream* stream); | 58 void OnStreamReset(DemuxerStream* stream); |
| 59 | 59 |
| 60 private: | 60 private: |
| 61 // Validates encoded timestamps match decoded output duration. MEDIA_LOG warns | 61 // Validates encoded timestamps match decoded output duration. MEDIA_LOG warns |
| 62 // if timestamp gaps are detected. Sufficiently large gaps can lead to AV sync | 62 // if timestamp gaps are detected. Sufficiently large gaps can lead to AV sync |
| 63 // drift. | 63 // drift. |
| 64 std::unique_ptr<AudioTimestampValidator> audio_ts_validator_; | 64 std::unique_ptr<AudioTimestampValidator> audio_ts_validator_; |
| 65 | 65 |
| 66 scoped_refptr<MediaLog> media_log_; | 66 MediaLog* media_log_; |
| 67 }; | 67 }; |
| 68 | 68 |
| 69 template <> | 69 template <> |
| 70 class MEDIA_EXPORT DecoderStreamTraits<DemuxerStream::VIDEO> { | 70 class MEDIA_EXPORT DecoderStreamTraits<DemuxerStream::VIDEO> { |
| 71 public: | 71 public: |
| 72 typedef VideoFrame OutputType; | 72 typedef VideoFrame OutputType; |
| 73 typedef VideoDecoder DecoderType; | 73 typedef VideoDecoder DecoderType; |
| 74 typedef VideoDecoderConfig DecoderConfigType; | 74 typedef VideoDecoderConfig DecoderConfigType; |
| 75 typedef DecryptingVideoDecoder DecryptingDecoderType; | 75 typedef DecryptingVideoDecoder DecryptingDecoderType; |
| 76 typedef base::Callback<void(bool success)> InitCB; | 76 typedef base::Callback<void(bool success)> InitCB; |
| 77 typedef base::Callback<void(const scoped_refptr<OutputType>&)> OutputCB; | 77 typedef base::Callback<void(const scoped_refptr<OutputType>&)> OutputCB; |
| 78 | 78 |
| 79 static std::string ToString(); | 79 static std::string ToString(); |
| 80 static bool NeedsBitstreamConversion(DecoderType* decoder); | 80 static bool NeedsBitstreamConversion(DecoderType* decoder); |
| 81 static scoped_refptr<OutputType> CreateEOSOutput(); | 81 static scoped_refptr<OutputType> CreateEOSOutput(); |
| 82 static DecoderConfigType GetDecoderConfig(DemuxerStream* stream); | 82 static DecoderConfigType GetDecoderConfig(DemuxerStream* stream); |
| 83 | 83 |
| 84 explicit DecoderStreamTraits(const scoped_refptr<MediaLog>& media_log); | 84 explicit DecoderStreamTraits(MediaLog* media_log); |
| 85 | 85 |
| 86 void ReportStatistics(const StatisticsCB& statistics_cb, int bytes_decoded); | 86 void ReportStatistics(const StatisticsCB& statistics_cb, int bytes_decoded); |
| 87 void InitializeDecoder(DecoderType* decoder, | 87 void InitializeDecoder(DecoderType* decoder, |
| 88 const DecoderConfigType& config, | 88 const DecoderConfigType& config, |
| 89 bool low_delay, | 89 bool low_delay, |
| 90 CdmContext* cdm_context, | 90 CdmContext* cdm_context, |
| 91 const InitCB& init_cb, | 91 const InitCB& init_cb, |
| 92 const OutputCB& output_cb); | 92 const OutputCB& output_cb); |
| 93 void OnDecode(const scoped_refptr<DecoderBuffer>& buffer); | 93 void OnDecode(const scoped_refptr<DecoderBuffer>& buffer); |
| 94 void OnDecodeDone(const scoped_refptr<OutputType>& buffer) {} | 94 void OnDecodeDone(const scoped_refptr<OutputType>& buffer) {} |
| 95 void OnStreamReset(DemuxerStream* stream); | 95 void OnStreamReset(DemuxerStream* stream); |
| 96 | 96 |
| 97 private: | 97 private: |
| 98 base::TimeDelta last_keyframe_timestamp_; | 98 base::TimeDelta last_keyframe_timestamp_; |
| 99 MovingAverage keyframe_distance_average_; | 99 MovingAverage keyframe_distance_average_; |
| 100 }; | 100 }; |
| 101 | 101 |
| 102 } // namespace media | 102 } // namespace media |
| 103 | 103 |
| 104 #endif // MEDIA_FILTERS_DECODER_STREAM_TRAITS_H_ | 104 #endif // MEDIA_FILTERS_DECODER_STREAM_TRAITS_H_ |
| OLD | NEW |