diff options
author | jiesun@google.com <jiesun@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-08-13 18:56:29 +0000 |
---|---|---|
committer | jiesun@google.com <jiesun@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-08-13 18:56:29 +0000 |
commit | 4cc1caa892d0b0fec6615ec2f7ee5c6f0bcc177f (patch) | |
tree | a7e86efa5a713395d26750097c0dab13bb027b39 /media/tools | |
parent | 35bd7e8e02c470463288874d5794ef3674da787e (diff) | |
download | chromium_src-4cc1caa892d0b0fec6615ec2f7ee5c6f0bcc177f.zip chromium_src-4cc1caa892d0b0fec6615ec2f7ee5c6f0bcc177f.tar.gz chromium_src-4cc1caa892d0b0fec6615ec2f7ee5c6f0bcc177f.tar.bz2 |
media: change engine interface to be suitable for gpu_video_decoder
1. we want the engine interface to be agnostic to ffmpeg.
2. we want use engine interface in both in-process and out-of-process cases.
Review URL: http://codereview.chromium.org/3173013
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@56060 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'media/tools')
-rw-r--r-- | media/tools/omx_test/omx_test.cc | 53 |
1 files changed, 39 insertions, 14 deletions
diff --git a/media/tools/omx_test/omx_test.cc b/media/tools/omx_test/omx_test.cc index 8740f57..efddb14 100644 --- a/media/tools/omx_test/omx_test.cc +++ b/media/tools/omx_test/omx_test.cc @@ -46,7 +46,8 @@ using media::YuvFileReader; // decoder. // TODO(wjia): AVStream should be replaced with a new structure which is // neutral to any video decoder. Also change media.gyp correspondingly. -class TestApp : public base::RefCountedThreadSafe<TestApp> { +class TestApp : public base::RefCountedThreadSafe<TestApp>, + public media::VideoDecodeEngine::EventHandler { public: TestApp(AVStream* av_stream, FileSink* file_sink, @@ -72,10 +73,9 @@ class TestApp : public base::RefCountedThreadSafe<TestApp> { return true; } - void InitializeDoneCallback() { - } + virtual void OnInitializeComplete(const media::VideoCodecInfo& info) {} - void StopCallback() { + virtual void OnUninitializeComplete() { // If this callback is received, mark the |stopped_| flag so that we don't // feed more buffers into the decoder. // We need to exit the current message loop because we have no more work @@ -85,7 +85,7 @@ class TestApp : public base::RefCountedThreadSafe<TestApp> { message_loop_.Quit(); } - void ErrorCallback() { + virtual void OnError() { // In case of error, this method is called. Mark the error flag and // exit the message loop because we have no more work to do. LOG(ERROR) << "Error callback received!"; @@ -93,6 +93,18 @@ class TestApp : public base::RefCountedThreadSafe<TestApp> { message_loop_.Quit(); } + virtual void OnFlushComplete() { + NOTIMPLEMENTED(); + } + + virtual void OnSeekComplete() { + NOTIMPLEMENTED(); + } + + virtual void OnFormatChange(media::VideoStreamInfo stream_info) { + NOTIMPLEMENTED(); + } + void FormatCallback( const OmxConfigurator::MediaFormat& input_format, const OmxConfigurator::MediaFormat& output_format) { @@ -108,7 +120,7 @@ class TestApp : public base::RefCountedThreadSafe<TestApp> { input_format.video_header.height); } - void FeedDoneCallback(scoped_refptr<Buffer> buffer) { + virtual void OnEmptyBufferCallback(scoped_refptr<Buffer> buffer) { // We receive this callback when the decoder has consumed an input buffer. // In this case, delete the previous buffer and enqueue a new one. // There are some conditions we don't want to enqueue, for example when @@ -119,7 +131,7 @@ class TestApp : public base::RefCountedThreadSafe<TestApp> { FeedInputBuffer(); } - void DecodeDoneCallback(scoped_refptr<VideoFrame> frame) { + virtual void OnFillBufferCallback(scoped_refptr<VideoFrame> frame) { // This callback is received when the decoder has completed a decoding // task and given us some output data. The frame is owned by the decoder. if (stopped_ || error_) @@ -130,7 +142,7 @@ class TestApp : public base::RefCountedThreadSafe<TestApp> { // If we are reading to the end, then stop. if (frame->IsEndOfStream()) { - engine_->Stop(NewRunnableMethod(this, &TestApp::StopCallback)); + engine_->Uninitialize(); return; } @@ -158,13 +170,26 @@ class TestApp : public base::RefCountedThreadSafe<TestApp> { // Setup the |engine_| with the message loop of the current thread. Also // setup codec format and callbacks. + media::VideoCodecConfig config; + switch (av_stream_->codec->codec_id) { + case CODEC_ID_VC1: + config.codec_ = media::kCodecVC1; break; + case CODEC_ID_H264: + config.codec_ = media::kCodecH264; break; + case CODEC_ID_THEORA: + config.codec_ = media::kCodecTheora; break; + case CODEC_ID_MPEG2VIDEO: + config.codec_ = media::kCodecMPEG2; break; + case CODEC_ID_MPEG4: + config.codec_ = media::kCodecMPEG4; break; + default: + NOTREACHED(); break; + } + config.opaque_context_ = NULL; + config.width_ = av_stream_->codec->width; + config.height_ = av_stream_->codec->height; engine_ = new OmxVideoDecodeEngine(); - engine_->Initialize(&message_loop_, - av_stream_.get(), - NewCallback(this, &TestApp::FeedDoneCallback), - NewCallback(this, &TestApp::DecodeDoneCallback), - NewRunnableMethod(this, - &TestApp::InitializeDoneCallback)); + engine_->Initialize(&message_loop_, this, config); // Execute the message loop so that we can run tasks on it. This call // will return when we call message_loop_.Quit(). |