summaryrefslogtreecommitdiffstats
path: root/media/video
diff options
context:
space:
mode:
authorscherkus@chromium.org <scherkus@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-10-01 00:49:07 +0000
committerscherkus@chromium.org <scherkus@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-10-01 00:49:07 +0000
commit3360355599b28cc4874db9b51ce5a2146d779aa6 (patch)
tree86b40540df09e85972036773b6dbedd61e5c25f7 /media/video
parentf28dd7b26f0ec615bb56ab393429466757f4c93f (diff)
downloadchromium_src-3360355599b28cc4874db9b51ce5a2146d779aa6.zip
chromium_src-3360355599b28cc4874db9b51ce5a2146d779aa6.tar.gz
chromium_src-3360355599b28cc4874db9b51ce5a2146d779aa6.tar.bz2
Clean up VideoDecoderConfig and replace VideoCodecInfo with a bool.
Similar to AudioDecoderConfig that was introduced in r102183, add Initialize() and IsValidConfig() to VideoDecoderConfig and update documentation. This helps pave the way to remove DemuxerStream::GetAVStream(). Since natural_size isn't used by neither VideoDecoderConfig nor VideoDecodeEngines, remove it from both and replace VideoCodecInfo with a bool. Review URL: http://codereview.chromium.org/8084021 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@103603 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'media/video')
-rw-r--r--media/video/ffmpeg_video_decode_engine.cc17
-rw-r--r--media/video/ffmpeg_video_decode_engine_unittest.cc30
-rw-r--r--media/video/video_decode_engine.h10
3 files changed, 16 insertions, 41 deletions
diff --git a/media/video/ffmpeg_video_decode_engine.cc b/media/video/ffmpeg_video_decode_engine.cc
index 9a89262..8d547b9 100644
--- a/media/video/ffmpeg_video_decode_engine.cc
+++ b/media/video/ffmpeg_video_decode_engine.cc
@@ -92,18 +92,17 @@ void FFmpegVideoDecodeEngine::Initialize(
const CommandLine* cmd_line = CommandLine::ForCurrentProcess();
std::string threads(cmd_line->GetSwitchValueASCII(switches::kVideoThreads));
if ((!threads.empty() &&
- !base::StringToInt(threads, &decode_threads)) ||
+ !base::StringToInt(threads, &decode_threads)) ||
decode_threads < 0 || decode_threads > kMaxDecodeThreads) {
decode_threads = kDecodeThreads;
}
+ codec_context_->thread_count = decode_threads;
+
// We don't allocate AVFrame on the stack since different versions of FFmpeg
// may change the size of AVFrame, causing stack corruption. The solution is
// to let FFmpeg allocate the structure via avcodec_alloc_frame().
av_frame_.reset(avcodec_alloc_frame());
- VideoCodecInfo info;
- info.success = false;
- info.natural_size = config.natural_size();
// If we do not have enough buffers, we will report error too.
frame_queue_available_.clear();
@@ -119,14 +118,10 @@ void FFmpegVideoDecodeEngine::Initialize(
frame_queue_available_.push_back(video_frame);
}
- codec_context_->thread_count = decode_threads;
- if (codec &&
- avcodec_open(codec_context_, codec) >= 0 &&
- av_frame_.get()) {
- info.success = true;
- }
+ // Open the codec!
+ bool success = codec && avcodec_open(codec_context_, codec) >= 0;
event_handler_ = event_handler;
- event_handler_->OnInitializeComplete(info);
+ event_handler_->OnInitializeComplete(success);
}
void FFmpegVideoDecodeEngine::ConsumeVideoSample(
diff --git a/media/video/ffmpeg_video_decode_engine_unittest.cc b/media/video/ffmpeg_video_decode_engine_unittest.cc
index 2ab4b3f..581fb3d 100644
--- a/media/video/ffmpeg_video_decode_engine_unittest.cc
+++ b/media/video/ffmpeg_video_decode_engine_unittest.cc
@@ -36,7 +36,7 @@ class FFmpegVideoDecodeEngineTest
public VideoDecodeEngine::EventHandler {
public:
FFmpegVideoDecodeEngineTest()
- : config_(kCodecVP8, kCodedSize, kVisibleRect, kNaturalSize,
+ : config_(kCodecVP8, kCodedSize, kVisibleRect,
kFrameRate.num, kFrameRate.den, NULL, 0) {
CHECK(FFmpegGlue::GetInstance());
@@ -56,11 +56,8 @@ class FFmpegVideoDecodeEngineTest
}
void Initialize() {
- VideoCodecInfo info;
- EXPECT_CALL(*this, OnInitializeComplete(_))
- .WillOnce(SaveArg<0>(&info));
+ EXPECT_CALL(*this, OnInitializeComplete(true));
test_engine_->Initialize(MessageLoop::current(), this, NULL, config_);
- EXPECT_TRUE(info.success);
}
// Decodes the single compressed frame in |buffer| and writes the
@@ -114,12 +111,9 @@ class FFmpegVideoDecodeEngineTest
// VideoDecodeEngine::EventHandler implementation.
MOCK_METHOD2(ConsumeVideoFrame,
- void(scoped_refptr<VideoFrame> video_frame,
- const PipelineStatistics& statistics));
- MOCK_METHOD1(ProduceVideoSample,
- void(scoped_refptr<Buffer> buffer));
- MOCK_METHOD1(OnInitializeComplete,
- void(const VideoCodecInfo& info));
+ void(scoped_refptr<VideoFrame>, const PipelineStatistics&));
+ MOCK_METHOD1(ProduceVideoSample, void(scoped_refptr<Buffer>));
+ MOCK_METHOD1(OnInitializeComplete, void(bool));
MOCK_METHOD0(OnUninitializeComplete, void());
MOCK_METHOD0(OnFlushComplete, void());
MOCK_METHOD0(OnSeekComplete, void());
@@ -149,27 +143,21 @@ TEST_F(FFmpegVideoDecodeEngineTest, Initialize_Normal) {
TEST_F(FFmpegVideoDecodeEngineTest, Initialize_FindDecoderFails) {
VideoDecoderConfig config(kUnknownVideoCodec, kCodedSize, kVisibleRect,
- kNaturalSize, kFrameRate.num, kFrameRate.den,
+ kFrameRate.num, kFrameRate.den,
NULL, 0);
// Test avcodec_find_decoder() returning NULL.
- VideoCodecInfo info;
- EXPECT_CALL(*this, OnInitializeComplete(_))
- .WillOnce(SaveArg<0>(&info));
+ EXPECT_CALL(*this, OnInitializeComplete(false));
test_engine_->Initialize(MessageLoop::current(), this, NULL, config);
- EXPECT_FALSE(info.success);
}
TEST_F(FFmpegVideoDecodeEngineTest, Initialize_OpenDecoderFails) {
// Specify Theora w/o extra data so that avcodec_open() fails.
VideoDecoderConfig config(kCodecTheora, kCodedSize, kVisibleRect,
- kNaturalSize, kFrameRate.num, kFrameRate.den,
+ kFrameRate.num, kFrameRate.den,
NULL, 0);
- VideoCodecInfo info;
- EXPECT_CALL(*this, OnInitializeComplete(_))
- .WillOnce(SaveArg<0>(&info));
+ EXPECT_CALL(*this, OnInitializeComplete(false));
test_engine_->Initialize(MessageLoop::current(), this, NULL, config);
- EXPECT_FALSE(info.success);
}
TEST_F(FFmpegVideoDecodeEngineTest, DecodeFrame_Normal) {
diff --git a/media/video/video_decode_engine.h b/media/video/video_decode_engine.h
index 4ec7cf5..cd1f986 100644
--- a/media/video/video_decode_engine.h
+++ b/media/video/video_decode_engine.h
@@ -21,20 +21,12 @@ class VideoDecodeContext;
struct PipelineStatistics;
-struct VideoCodecInfo {
- // Other parameter is only meaningful when this is true.
- bool success;
-
- // Natural dimensions of video. May be different from coded and visible sizes.
- gfx::Size natural_size;
-};
-
class MEDIA_EXPORT VideoDecodeEngine {
public:
struct MEDIA_EXPORT EventHandler {
public:
virtual ~EventHandler() {}
- virtual void OnInitializeComplete(const VideoCodecInfo& info) = 0;
+ virtual void OnInitializeComplete(bool success) = 0;
virtual void OnUninitializeComplete() = 0;
virtual void OnFlushComplete() = 0;
virtual void OnSeekComplete() = 0;