| 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 "base/logging.h" | 7 #include "base/logging.h" |
| 8 #include "base/metrics/histogram_macros.h" | 8 #include "base/metrics/histogram_macros.h" |
| 9 #include "media/base/audio_buffer.h" | 9 #include "media/base/audio_buffer.h" |
| 10 #include "media/base/audio_decoder.h" | 10 #include "media/base/audio_decoder.h" |
| (...skipping 10 matching lines...) Expand all Loading... |
| 21 return "audio"; | 21 return "audio"; |
| 22 } | 22 } |
| 23 | 23 |
| 24 // static | 24 // static |
| 25 bool DecoderStreamTraits<DemuxerStream::AUDIO>::NeedsBitstreamConversion( | 25 bool DecoderStreamTraits<DemuxerStream::AUDIO>::NeedsBitstreamConversion( |
| 26 DecoderType* decoder) { | 26 DecoderType* decoder) { |
| 27 return decoder->NeedsBitstreamConversion(); | 27 return decoder->NeedsBitstreamConversion(); |
| 28 } | 28 } |
| 29 | 29 |
| 30 // static | 30 // static |
| 31 void DecoderStreamTraits<DemuxerStream::AUDIO>::ReportStatistics( | |
| 32 const StatisticsCB& statistics_cb, | |
| 33 int bytes_decoded) { | |
| 34 PipelineStatistics statistics; | |
| 35 statistics.audio_bytes_decoded = bytes_decoded; | |
| 36 statistics_cb.Run(statistics); | |
| 37 } | |
| 38 | |
| 39 // static | |
| 40 scoped_refptr<DecoderStreamTraits<DemuxerStream::AUDIO>::OutputType> | 31 scoped_refptr<DecoderStreamTraits<DemuxerStream::AUDIO>::OutputType> |
| 41 DecoderStreamTraits<DemuxerStream::AUDIO>::CreateEOSOutput() { | 32 DecoderStreamTraits<DemuxerStream::AUDIO>::CreateEOSOutput() { |
| 42 return OutputType::CreateEOSBuffer(); | 33 return OutputType::CreateEOSBuffer(); |
| 43 } | 34 } |
| 44 | 35 |
| 45 DecoderStreamTraits<DemuxerStream::AUDIO>::DecoderStreamTraits( | 36 DecoderStreamTraits<DemuxerStream::AUDIO>::DecoderStreamTraits( |
| 46 const scoped_refptr<MediaLog>& media_log) | 37 const scoped_refptr<MediaLog>& media_log) |
| 47 : media_log_(media_log) {} | 38 : media_log_(media_log) {} |
| 48 | 39 |
| 40 void DecoderStreamTraits<DemuxerStream::AUDIO>::ReportStatistics( |
| 41 const StatisticsCB& statistics_cb, |
| 42 int bytes_decoded) { |
| 43 PipelineStatistics statistics; |
| 44 statistics.audio_bytes_decoded = bytes_decoded; |
| 45 statistics_cb.Run(statistics); |
| 46 } |
| 47 |
| 49 void DecoderStreamTraits<DemuxerStream::AUDIO>::InitializeDecoder( | 48 void DecoderStreamTraits<DemuxerStream::AUDIO>::InitializeDecoder( |
| 50 DecoderType* decoder, | 49 DecoderType* decoder, |
| 51 DemuxerStream* stream, | 50 DemuxerStream* stream, |
| 52 CdmContext* cdm_context, | 51 CdmContext* cdm_context, |
| 53 const InitCB& init_cb, | 52 const InitCB& init_cb, |
| 54 const OutputCB& output_cb) { | 53 const OutputCB& output_cb) { |
| 55 DCHECK(stream->audio_decoder_config().IsValidConfig()); | 54 DCHECK(stream->audio_decoder_config().IsValidConfig()); |
| 56 decoder->Initialize(stream->audio_decoder_config(), cdm_context, init_cb, | 55 decoder->Initialize(stream->audio_decoder_config(), cdm_context, init_cb, |
| 57 output_cb); | 56 output_cb); |
| 58 } | 57 } |
| (...skipping 24 matching lines...) Expand all Loading... |
| 83 return "video"; | 82 return "video"; |
| 84 } | 83 } |
| 85 | 84 |
| 86 // static | 85 // static |
| 87 bool DecoderStreamTraits<DemuxerStream::VIDEO>::NeedsBitstreamConversion( | 86 bool DecoderStreamTraits<DemuxerStream::VIDEO>::NeedsBitstreamConversion( |
| 88 DecoderType* decoder) { | 87 DecoderType* decoder) { |
| 89 return decoder->NeedsBitstreamConversion(); | 88 return decoder->NeedsBitstreamConversion(); |
| 90 } | 89 } |
| 91 | 90 |
| 92 // static | 91 // static |
| 92 scoped_refptr<DecoderStreamTraits<DemuxerStream::VIDEO>::OutputType> |
| 93 DecoderStreamTraits<DemuxerStream::VIDEO>::CreateEOSOutput() { |
| 94 return OutputType::CreateEOSFrame(); |
| 95 } |
| 96 |
| 97 DecoderStreamTraits<DemuxerStream::VIDEO>::DecoderStreamTraits( |
| 98 const scoped_refptr<MediaLog>& media_log) |
| 99 // Randomly selected number of samples to keep. |
| 100 : keyframe_distance_average_(16) {} |
| 101 |
| 93 void DecoderStreamTraits<DemuxerStream::VIDEO>::ReportStatistics( | 102 void DecoderStreamTraits<DemuxerStream::VIDEO>::ReportStatistics( |
| 94 const StatisticsCB& statistics_cb, | 103 const StatisticsCB& statistics_cb, |
| 95 int bytes_decoded) { | 104 int bytes_decoded) { |
| 96 PipelineStatistics statistics; | 105 PipelineStatistics statistics; |
| 97 statistics.video_bytes_decoded = bytes_decoded; | 106 statistics.video_bytes_decoded = bytes_decoded; |
| 107 statistics.video_keyframe_distance_average_ms = |
| 108 keyframe_distance_average_.Average().InMilliseconds(); |
| 98 statistics_cb.Run(statistics); | 109 statistics_cb.Run(statistics); |
| 99 } | 110 } |
| 100 | 111 |
| 101 // static | |
| 102 scoped_refptr<DecoderStreamTraits<DemuxerStream::VIDEO>::OutputType> | |
| 103 DecoderStreamTraits<DemuxerStream::VIDEO>::CreateEOSOutput() { | |
| 104 return OutputType::CreateEOSFrame(); | |
| 105 } | |
| 106 | |
| 107 void DecoderStreamTraits<DemuxerStream::VIDEO>::InitializeDecoder( | 112 void DecoderStreamTraits<DemuxerStream::VIDEO>::InitializeDecoder( |
| 108 DecoderType* decoder, | 113 DecoderType* decoder, |
| 109 DemuxerStream* stream, | 114 DemuxerStream* stream, |
| 110 CdmContext* cdm_context, | 115 CdmContext* cdm_context, |
| 111 const InitCB& init_cb, | 116 const InitCB& init_cb, |
| 112 const OutputCB& output_cb) { | 117 const OutputCB& output_cb) { |
| 113 DCHECK(stream->video_decoder_config().IsValidConfig()); | 118 DCHECK(stream->video_decoder_config().IsValidConfig()); |
| 114 decoder->Initialize(stream->video_decoder_config(), | 119 decoder->Initialize(stream->video_decoder_config(), |
| 115 stream->liveness() == DemuxerStream::LIVENESS_LIVE, | 120 stream->liveness() == DemuxerStream::LIVENESS_LIVE, |
| 116 cdm_context, init_cb, output_cb); | 121 cdm_context, init_cb, output_cb); |
| (...skipping 17 matching lines...) Expand all Loading... |
| 134 | 139 |
| 135 if (!buffer->is_key_frame()) | 140 if (!buffer->is_key_frame()) |
| 136 return; | 141 return; |
| 137 | 142 |
| 138 base::TimeDelta current_frame_timestamp = buffer->timestamp(); | 143 base::TimeDelta current_frame_timestamp = buffer->timestamp(); |
| 139 if (last_keyframe_timestamp_.is_zero()) { | 144 if (last_keyframe_timestamp_.is_zero()) { |
| 140 last_keyframe_timestamp_ = current_frame_timestamp; | 145 last_keyframe_timestamp_ = current_frame_timestamp; |
| 141 return; | 146 return; |
| 142 } | 147 } |
| 143 | 148 |
| 144 UMA_HISTOGRAM_MEDIUM_TIMES( | 149 base::TimeDelta frame_distance = |
| 145 "Media.Video.KeyFrameDistance", | 150 current_frame_timestamp - last_keyframe_timestamp_; |
| 146 current_frame_timestamp - last_keyframe_timestamp_); | 151 UMA_HISTOGRAM_MEDIUM_TIMES("Media.Video.KeyFrameDistance", frame_distance); |
| 147 last_keyframe_timestamp_ = current_frame_timestamp; | 152 last_keyframe_timestamp_ = current_frame_timestamp; |
| 153 keyframe_distance_average_.AddSample(frame_distance); |
| 148 } | 154 } |
| 149 | 155 |
| 150 } // namespace media | 156 } // namespace media |
| OLD | NEW |