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

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
« no previous file with comments | « media/base/container_names_unittest.cc ('k') | media/media.gyp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: media/filters/ffmpeg_glue.cc
diff --git a/media/filters/ffmpeg_glue.cc b/media/filters/ffmpeg_glue.cc
index e3b227b2ac5140f74f9057090d0bafdb26429961..c74b0654e9983525dac71216df568ae0c1327c1e 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<std::vector<uint8> > buffer(new std::vector<uint8>(8192));
+
+ 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()->data(), buffer.get()->size());
+ AVIOSeekOperation(avio_context_.get()->opaque, pos, SEEK_SET);
+ if (numRead > 0) {
+ // < 0 means Read failed
+ container_names::MediaContainerName container =
+ container_names::DetermineContainer(buffer.get()->data(), 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;
« no previous file with comments | « media/base/container_names_unittest.cc ('k') | media/media.gyp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698