Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(331)

Unified Diff: media/filters/decoder_stream_traits.cc

Issue 2545523005: [Video] Collect average keyframe distance for video (Closed)
Patch Set: Fixed early exit conditions Created 4 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « media/filters/decoder_stream_traits.h ('k') | tools/metrics/histograms/histograms.xml » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: media/filters/decoder_stream_traits.cc
diff --git a/media/filters/decoder_stream_traits.cc b/media/filters/decoder_stream_traits.cc
index ec6c7993a1464c4c1347ae0af971a8ad288d85e8..645a1de417b6dd9b817e5f27368b797dc408feb6 100644
--- a/media/filters/decoder_stream_traits.cc
+++ b/media/filters/decoder_stream_traits.cc
@@ -5,6 +5,7 @@
#include "media/filters/decoder_stream_traits.h"
#include "base/logging.h"
+#include "base/metrics/histogram_macros.h"
#include "media/base/audio_buffer.h"
#include "media/base/audio_decoder.h"
#include "media/base/audio_decoder_config.h"
@@ -115,4 +116,34 @@ void DecoderStreamTraits<DemuxerStream::VIDEO>::InitializeDecoder(
cdm_context, init_cb, output_cb);
}
+void DecoderStreamTraits<DemuxerStream::VIDEO>::OnStreamReset(
+ DemuxerStream* stream) {
+ DCHECK(stream);
+ last_keyframe_timestamp_ = base::TimeDelta();
+}
+
+void DecoderStreamTraits<DemuxerStream::VIDEO>::OnDecode(
+ const scoped_refptr<DecoderBuffer>& buffer) {
+ if (!buffer)
+ return;
+
+ if (buffer->end_of_stream()) {
+ last_keyframe_timestamp_ = base::TimeDelta();
+ return;
+ }
+
+ if (!buffer->is_key_frame())
+ return;
+
+ base::TimeDelta current_frame_timestamp = buffer->timestamp();
+ if (last_keyframe_timestamp_.is_zero()) {
+ last_keyframe_timestamp_ = current_frame_timestamp;
+ return;
+ }
+
+ UMA_HISTOGRAM_MEDIUM_TIMES(
+ "Media.Video.KeyFrameDistance",
+ current_frame_timestamp - last_keyframe_timestamp_);
+}
+
} // namespace media
« no previous file with comments | « media/filters/decoder_stream_traits.h ('k') | tools/metrics/histograms/histograms.xml » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698