Chromium Code Reviews| Index: media/filters/ffmpeg_glue.cc |
| diff --git a/media/filters/ffmpeg_glue.cc b/media/filters/ffmpeg_glue.cc |
| index e3b227b2ac5140f74f9057090d0bafdb26429961..b8847220cfdb7b1cb2771c0196756f3a35b39b03 100644 |
| --- a/media/filters/ffmpeg_glue.cc |
| +++ b/media/filters/ffmpeg_glue.cc |
| @@ -3,10 +3,10 @@ |
| // found in the LICENSE file. |
| #include "media/filters/ffmpeg_glue.h" |
| - |
|
xhwang
2013/04/29 21:00:25
keep this empty line: http://google-styleguide.goo
jrummell
2013/04/30 21:36:50
Done.
|
| #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 +123,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 +158,27 @@ 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); |
| + ContainerNames container; |
| + if (result == 0) { |
| + // FFmpeg decoded the container, so report what it found |
| + container.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; |
| + uint8 buf[8192]; |
|
xhwang
2013/04/29 21:00:25
This code path only happens in the failure case. B
jrummell
2013/04/30 21:36:50
Done.
|
| + |
| + protocol_->GetPosition(&pos); |
| + protocol_->SetPosition(0); |
| + int numRead = protocol_->Read(sizeof(buf), buf); |
| + protocol_->SetPosition(pos); |
| + container.LogContainer(buf, numRead); |
| + return false; |
| } |
| FFmpegGlue::~FFmpegGlue() { |