| 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() {
|
|
|