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..a65a914f1eb3b14ed2d092a3080e149119ca0122 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 |
| + container_names::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. |
|
scherkus (not reviewing)
2013/05/07 00:50:20
As mentioned in container_names.cc, let's focus on
jrummell
2013/05/16 23:48:01
Done.
|
| + int64 pos; |
| + scoped_ptr<uint8[]> buffer(new uint8[8192]); |
| + |
| + protocol_->GetPosition(&pos); |
| + protocol_->SetPosition(0); |
| + int numRead = protocol_->Read(8192, buffer.get()); |
|
scherkus (not reviewing)
2013/05/07 00:50:20
it's possible for this to return an error if (for
jrummell
2013/05/16 23:48:01
Done.
|
| + protocol_->SetPosition(pos); |
| + container_names::LogContainer(buffer.get(), numRead); |
| + return false; |
| } |
| FFmpegGlue::~FFmpegGlue() { |