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

Unified Diff: media/filters/ffmpeg_glue.cc

Issue 14495010: Add UMA stats for audio/video containers. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 7 years, 7 months 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
Index: media/filters/ffmpeg_glue.cc
diff --git a/media/filters/ffmpeg_glue.cc b/media/filters/ffmpeg_glue.cc
index e3b227b2ac5140f74f9057090d0bafdb26429961..c86eb76d5988ab348629759c2d8bd12247c55bc6 100644
--- a/media/filters/ffmpeg_glue.cc
+++ b/media/filters/ffmpeg_glue.cc
@@ -6,7 +6,9 @@
#include "base/lazy_instance.h"
#include "base/logging.h"
+#include "base/metrics/sparse_histogram.h"
#include "base/synchronization/lock.h"
+#include "media/base/container_names.h"
#include "media/ffmpeg/ffmpeg_common.h"
namespace media {
@@ -155,6 +157,22 @@ bool FFmpegGlue::OpenContext() {
// destruction path to avoid double frees.
open_called_ = true;
+ // Attempt to recognize the container by looking at the first few bytes of the
+ // stream. The stream position is left unchanged.
+ scoped_ptr<uint8[]> buffer(new uint8[8192]);
acolwell GONE FROM CHROMIUM 2013/05/22 21:03:14 nit: Could std::vector<uint8> work here? If so the
jrummell 2013/05/22 23:59:46 Done.
+
+ int64 pos = AVIOSeekOperation(avio_context_.get()->opaque, 0, SEEK_CUR);
+ AVIOSeekOperation(avio_context_.get()->opaque, 0, SEEK_SET);
+ int numRead =
+ AVIOReadOperation(avio_context_.get()->opaque, buffer.get(), 8192);
+ AVIOSeekOperation(avio_context_.get()->opaque, pos, SEEK_SET);
+ if (numRead > 0) {
+ // < 0 means Read failed
+ container_names::MediaContainerName container =
+ container_names::DetermineContainer(buffer.get(), numRead);
+ UMA_HISTOGRAM_SPARSE_SLOWLY("Media.DetectedContainer", container);
+ }
+
// By passing NULL for the filename (second parameter) we are telling FFmpeg
// to use the AVIO context we setup from the AVFormatContext structure.
return avformat_open_input(&format_context_, NULL, NULL, NULL) == 0;

Powered by Google App Engine
This is Rietveld 408576698