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

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, 8 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..597cff0e288140e9db982c9269e679995a63bbf9 100644
--- a/media/filters/ffmpeg_glue.cc
+++ b/media/filters/ffmpeg_glue.cc
@@ -7,6 +7,7 @@
#include "base/lazy_instance.h"
#include "base/logging.h"
#include "base/synchronization/lock.h"
+#include "media/base/container_names.h"
#include "media/ffmpeg/ffmpeg_common.h"
namespace media {
@@ -123,7 +124,8 @@ void FFmpegGlue::InitializeFFmpeg() {
}
FFmpegGlue::FFmpegGlue(FFmpegURLProtocol* protocol)
- : open_called_(false) {
+ : open_called_(false),
+ protocol_(protocol) {
InitializeFFmpeg();
// Initialize an AVIOContext using our custom read and seek operations. Don't
@@ -157,7 +159,26 @@ bool FFmpegGlue::OpenContext() {
// 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;
+ int result = avformat_open_input(&format_context_, NULL, NULL, NULL);
+ if (result == 0) {
+ // FFmpeg decoded the container, so report what it found
+ ContainerNames::LogContainer(format_context_->iformat->name);
+ return true;
+ }
+
+ // Stream was not recognized by FFmpeg. Re-read part of the stream and see if
+ // the stream can be recognized. Unfortunately FFmpeg has released the buffer
+ // where it read the header, so we need to read it again. We leave the stream
+ // position unchanged.
+ int64 pos;
+ scoped_ptr<uint8[]> buffer(new uint8[8192]);
+
+ protocol_->GetPosition(&pos);
+ protocol_->SetPosition(0);
+ int numRead = protocol_->Read(8192, buffer.get());
+ protocol_->SetPosition(pos);
+ ContainerNames::LogContainer(buffer.get(), numRead);
+ return false;
}
FFmpegGlue::~FFmpegGlue() {

Powered by Google App Engine
This is Rietveld 408576698