diff options
author | jiesun@google.com <jiesun@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-10-13 20:13:33 +0000 |
---|---|---|
committer | jiesun@google.com <jiesun@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-10-13 20:13:33 +0000 |
commit | f57c6416bb8ef6adc12b081b44ba5a83eae3c5ba (patch) | |
tree | 1ea83a39abaed84d6708e17821681c7f49931e0a | |
parent | 68f1df43323a3a81cd14ed0061e7c3578394d8fd (diff) | |
download | chromium_src-f57c6416bb8ef6adc12b081b44ba5a83eae3c5ba.zip chromium_src-f57c6416bb8ef6adc12b081b44ba5a83eae3c5ba.tar.gz chromium_src-f57c6416bb8ef6adc12b081b44ba5a83eae3c5ba.tar.bz2 |
[media] inject VDC to decoder.
which VDC to be used should be determined by something outside instead of inside video decoder.
1. whether hardware composition is used( probably always true).
2. whether hardware composition is disabled.(if not, why we keep the skbitmap path).
3. whether a opengl or a opengles VDC is needed, probably only apply to player_x11.
4. the video decoder context are sharing a lot of states with "painter/compositor" (e.g. graphic context). and if we create VDC inside decoder, and there is no current code path to inject this to Renderer, there are also complication of the factories and creating orders. even we add that path, it maybe too late for renderer.
while we need to refactor ipc_video_decoder later.
BUG=None
TEST=Bots
Review URL: http://codereview.chromium.org/3534015
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@62443 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r-- | media/filters/ffmpeg_video_decoder.cc | 18 | ||||
-rw-r--r-- | media/filters/ffmpeg_video_decoder.h | 6 | ||||
-rw-r--r-- | media/filters/ffmpeg_video_decoder_unittest.cc | 9 | ||||
-rw-r--r-- | media/filters/omx_video_decoder.cc | 37 | ||||
-rw-r--r-- | media/filters/omx_video_decoder.h | 9 | ||||
-rw-r--r-- | media/tools/player_wtl/movie.cc | 2 | ||||
-rw-r--r-- | media/tools/player_x11/player_x11.cc | 13 | ||||
-rw-r--r-- | webkit/glue/webmediaplayer_impl.cc | 2 |
8 files changed, 64 insertions, 32 deletions
diff --git a/media/filters/ffmpeg_video_decoder.cc b/media/filters/ffmpeg_video_decoder.cc index c79f679..4fe638f 100644 --- a/media/filters/ffmpeg_video_decoder.cc +++ b/media/filters/ffmpeg_video_decoder.cc @@ -17,16 +17,19 @@ #include "media/ffmpeg/ffmpeg_util.h" #include "media/filters/ffmpeg_interfaces.h" #include "media/video/ffmpeg_video_decode_engine.h" +#include "media/video/video_decode_context.h" #include "media/video/video_decode_engine.h" namespace media { -FFmpegVideoDecoder::FFmpegVideoDecoder(VideoDecodeEngine* engine) +FFmpegVideoDecoder::FFmpegVideoDecoder(VideoDecodeEngine* decode_engine, + VideoDecodeContext* decode_context) : width_(0), height_(0), time_base_(new AVRational()), state_(kUnInitialized), - decode_engine_(engine) { + decode_engine_(decode_engine), + decode_context_(decode_context) { memset(&info_, 0, sizeof(info_)); } @@ -146,6 +149,8 @@ void FFmpegVideoDecoder::OnUninitializeComplete() { AutoCallbackRunner done_runner(uninitialize_callback_.release()); state_ = kStopped; + + // TODO(jiesun): Destroy the decoder context. } void FFmpegVideoDecoder::Pause(FilterCallback* callback) { @@ -435,9 +440,12 @@ void FFmpegVideoDecoder::SetVideoDecodeEngineForTest( } // static -FilterFactory* FFmpegVideoDecoder::CreateFactory() { - return new FilterFactoryImpl1<FFmpegVideoDecoder, FFmpegVideoDecodeEngine*>( - new FFmpegVideoDecodeEngine()); +FilterFactory* FFmpegVideoDecoder::CreateFactory( + VideoDecodeContext* decode_context) { + return new FilterFactoryImpl2<FFmpegVideoDecoder, + VideoDecodeEngine*, + VideoDecodeContext*>( + new FFmpegVideoDecodeEngine(), decode_context); } // static diff --git a/media/filters/ffmpeg_video_decoder.h b/media/filters/ffmpeg_video_decoder.h index d099892..150a0e1 100644 --- a/media/filters/ffmpeg_video_decoder.h +++ b/media/filters/ffmpeg_video_decoder.h @@ -26,10 +26,11 @@ class VideoDecodeEngine; class FFmpegVideoDecoder : public VideoDecoder, public VideoDecodeEngine::EventHandler { public: - explicit FFmpegVideoDecoder(VideoDecodeEngine* engine); + FFmpegVideoDecoder(VideoDecodeEngine* decode_engine, + VideoDecodeContext* decode_context); virtual ~FFmpegVideoDecoder(); - static FilterFactory* CreateFactory(); + static FilterFactory* CreateFactory(VideoDecodeContext* decode_context); static bool IsMediaFormatSupported(const MediaFormat& media_format); // MediaFilter implementation. @@ -122,6 +123,7 @@ class FFmpegVideoDecoder : public VideoDecoder, scoped_ptr<AVRational> time_base_; // Pointer to avoid needing full type. DecoderState state_; scoped_ptr<VideoDecodeEngine> decode_engine_; + scoped_ptr<VideoDecodeContext> decode_context_; scoped_ptr<FilterCallback> initialize_callback_; scoped_ptr<FilterCallback> uninitialize_callback_; diff --git a/media/filters/ffmpeg_video_decoder_unittest.cc b/media/filters/ffmpeg_video_decoder_unittest.cc index 6ed176f..a81125d 100644 --- a/media/filters/ffmpeg_video_decoder_unittest.cc +++ b/media/filters/ffmpeg_video_decoder_unittest.cc @@ -71,8 +71,8 @@ class MockVideoDecodeEngine : public VideoDecodeEngine { // Class that just mocks the private functions. class DecoderPrivateMock : public FFmpegVideoDecoder { public: - DecoderPrivateMock(VideoDecodeEngine* engine) - : FFmpegVideoDecoder(engine) { + DecoderPrivateMock(VideoDecodeEngine* engine, VideoDecodeContext* context) + : FFmpegVideoDecoder(engine, context) { } // change access qualifier for test: used in actions. @@ -125,7 +125,7 @@ class FFmpegVideoDecoderTest : public testing::Test { // Create an FFmpegVideoDecoder, and MockVideoDecodeEngine. // // TODO(ajwong): Break the test's dependency on FFmpegVideoDecoder. - factory_ = FFmpegVideoDecoder::CreateFactory(); + factory_ = FFmpegVideoDecoder::CreateFactory(NULL); decoder_ = factory_->Create<DecoderPrivateMock>(media_format); renderer_ = new MockVideoRenderer(); engine_ = new StrictMock<MockVideoDecodeEngine>(); @@ -231,7 +231,8 @@ const FFmpegVideoDecoder::TimeTuple FFmpegVideoDecoderTest::kTestPts3 = TEST(FFmpegVideoDecoderFactoryTest, Create) { // Should only accept video/x-ffmpeg mime type. - scoped_refptr<FilterFactory> factory = FFmpegVideoDecoder::CreateFactory(); + scoped_refptr<FilterFactory> factory = + FFmpegVideoDecoder::CreateFactory(NULL); MediaFormat media_format; media_format.SetAsString(MediaFormat::kMimeType, "foo/x-bar"); scoped_refptr<VideoDecoder> decoder = diff --git a/media/filters/omx_video_decoder.cc b/media/filters/omx_video_decoder.cc index 82793de..c3e4e14 100644 --- a/media/filters/omx_video_decoder.cc +++ b/media/filters/omx_video_decoder.cc @@ -16,9 +16,12 @@ namespace media { // static -FilterFactory* OmxVideoDecoder::CreateFactory() { - return new FilterFactoryImpl1<OmxVideoDecoder, VideoDecodeEngine*>( - new OmxVideoDecodeEngine()); +FilterFactory* OmxVideoDecoder::CreateFactory( + VideoDecodeContext* decode_context) { + return new FilterFactoryImpl2<OmxVideoDecoder, + VideoDecodeEngine*, + VideoDecodeContext*>( + new OmxVideoDecodeEngine(), decode_context); } // static @@ -40,9 +43,13 @@ bool OmxVideoDecoder::IsMediaFormatSupported(const MediaFormat& format) { return false; } -OmxVideoDecoder::OmxVideoDecoder(VideoDecodeEngine* engine) - : omx_engine_(engine), width_(0), height_(0) { - DCHECK(omx_engine_.get()); +OmxVideoDecoder::OmxVideoDecoder( + VideoDecodeEngine* engine, + VideoDecodeContext* context) + : decode_engine_(engine), + decode_context_(context), + width_(0), height_(0) { + DCHECK(decode_engine_.get()); memset(&info_, 0, sizeof(info_)); } @@ -110,7 +117,7 @@ void OmxVideoDecoder::Initialize(DemuxerStream* demuxer_stream, config.opaque_context = NULL; config.width = width_; config.height = height_; - omx_engine_->Initialize(message_loop(), this, NULL, config); + decode_engine_->Initialize(message_loop(), this, NULL, config); } void OmxVideoDecoder::OnInitializeComplete(const VideoCodecInfo& info) { @@ -149,7 +156,7 @@ void OmxVideoDecoder::Stop(FilterCallback* callback) { DCHECK(!uninitialize_callback_.get()); uninitialize_callback_.reset(callback); - omx_engine_->Uninitialize(); + decode_engine_->Uninitialize(); } void OmxVideoDecoder::OnUninitializeComplete() { @@ -157,6 +164,8 @@ void OmxVideoDecoder::OnUninitializeComplete() { DCHECK(uninitialize_callback_.get()); AutoCallbackRunner done_runner(uninitialize_callback_.release()); + + // TODO(jiesun): Destroy the decoder context. } void OmxVideoDecoder::Flush(FilterCallback* callback) { @@ -173,7 +182,7 @@ void OmxVideoDecoder::Flush(FilterCallback* callback) { flush_callback_.reset(callback); - omx_engine_->Flush(); + decode_engine_->Flush(); } @@ -198,7 +207,7 @@ void OmxVideoDecoder::Seek(base::TimeDelta time, DCHECK(!seek_callback_.get()); seek_callback_.reset(callback); - omx_engine_->Seek(); + decode_engine_->Seek(); } void OmxVideoDecoder::OnSeekComplete() { @@ -228,10 +237,10 @@ void OmxVideoDecoder::ConsumeVideoFrame(scoped_refptr<VideoFrame> frame) { } void OmxVideoDecoder::ProduceVideoFrame(scoped_refptr<VideoFrame> frame) { - DCHECK(omx_engine_.get()); + DCHECK(decode_engine_.get()); message_loop()->PostTask( FROM_HERE, - NewRunnableMethod(omx_engine_.get(), + NewRunnableMethod(decode_engine_.get(), &VideoDecodeEngine::ProduceVideoFrame, frame)); } @@ -243,10 +252,10 @@ bool OmxVideoDecoder::ProvidesBuffer() { void OmxVideoDecoder::DemuxCompleteTask(Buffer* buffer) { // We simply delicate the buffer to the right message loop. scoped_refptr<Buffer> ref_buffer = buffer; - DCHECK(omx_engine_.get()); + DCHECK(decode_engine_.get()); message_loop()->PostTask( FROM_HERE, - NewRunnableMethod(omx_engine_.get(), + NewRunnableMethod(decode_engine_.get(), &VideoDecodeEngine::ConsumeVideoSample, ref_buffer)); } diff --git a/media/filters/omx_video_decoder.h b/media/filters/omx_video_decoder.h index 2a4f63c..f025554 100644 --- a/media/filters/omx_video_decoder.h +++ b/media/filters/omx_video_decoder.h @@ -10,6 +10,7 @@ #include "media/base/factory.h" #include "media/base/filters.h" #include "media/base/media_format.h" +#include "media/video/video_decode_context.h" #include "media/video/video_decode_engine.h" class MessageLoop; @@ -23,10 +24,11 @@ class VideoFrame; class OmxVideoDecoder : public VideoDecoder, public VideoDecodeEngine::EventHandler { public: - static FilterFactory* CreateFactory(); + static FilterFactory* CreateFactory(VideoDecodeContext* decode_context); static bool IsMediaFormatSupported(const MediaFormat& media_format); - OmxVideoDecoder(VideoDecodeEngine* engine); + OmxVideoDecoder(VideoDecodeEngine* decode_engine, + VideoDecodeContext* decode_context); virtual ~OmxVideoDecoder(); virtual void Initialize(DemuxerStream* stream, FilterCallback* callback); @@ -54,7 +56,8 @@ class OmxVideoDecoder : public VideoDecoder, // Pointer to the demuxer stream that will feed us compressed buffers. scoped_refptr<DemuxerStream> demuxer_stream_; - scoped_ptr<VideoDecodeEngine> omx_engine_; + scoped_ptr<VideoDecodeEngine> decode_engine_; + scoped_ptr<VideoDecodeContext> decode_context_; MediaFormat media_format_; size_t width_; size_t height_; diff --git a/media/tools/player_wtl/movie.cc b/media/tools/player_wtl/movie.cc index 7070138..be97097 100644 --- a/media/tools/player_wtl/movie.cc +++ b/media/tools/player_wtl/movie.cc @@ -59,7 +59,7 @@ bool Movie::Open(const wchar_t* url, WtlVideoRenderer* video_renderer) { factories->AddFactory(FileDataSource::CreateFactory()); factories->AddFactory(FFmpegAudioDecoder::CreateFactory()); factories->AddFactory(FFmpegDemuxer::CreateFilterFactory()); - factories->AddFactory(FFmpegVideoDecoder::CreateFactory()); + factories->AddFactory(FFmpegVideoDecoder::CreateFactory(NULL)); if (enable_audio_) { factories->AddFactory(AudioRendererImpl::CreateFilterFactory()); diff --git a/media/tools/player_x11/player_x11.cc b/media/tools/player_x11/player_x11.cc index a361368..11b8b5f 100644 --- a/media/tools/player_x11/player_x11.cc +++ b/media/tools/player_x11/player_x11.cc @@ -24,6 +24,14 @@ #include "media/filters/null_audio_renderer.h" #include "media/filters/omx_video_decoder.h" +// TODO(jiesun): implement different video decode contexts according to +// these flags. e.g. +// 1. system memory video decode context for x11 +// 2. gl texture video decode context for OpenGL. +// 3. gles texture video decode context for OpenGLES. +// TODO(jiesun): add an uniform video renderer which take the video +// decode context object and delegate renderer request to these +// objects. i.e. Seperate "painter" and "pts scheduler". #if defined(RENDERER_GL) #include "media/tools/player_x11/gl_video_renderer.h" typedef GlVideoRenderer Renderer; @@ -96,9 +104,10 @@ bool InitPipeline(MessageLoop* message_loop, factories->AddFactory(media::FFmpegDemuxer::CreateFilterFactory()); if (CommandLine::ForCurrentProcess()->HasSwitch( switches::kEnableOpenMax)) { - factories->AddFactory(media::OmxVideoDecoder::CreateFactory()); + factories->AddFactory(media::OmxVideoDecoder::CreateFactory(NULL)); + } else { + factories->AddFactory(media::FFmpegVideoDecoder::CreateFactory(NULL)); } - factories->AddFactory(media::FFmpegVideoDecoder::CreateFactory()); factories->AddFactory(Renderer::CreateFactory(g_display, g_window, paint_message_loop)); diff --git a/webkit/glue/webmediaplayer_impl.cc b/webkit/glue/webmediaplayer_impl.cc index d5c667d..e4aca5a 100644 --- a/webkit/glue/webmediaplayer_impl.cc +++ b/webkit/glue/webmediaplayer_impl.cc @@ -244,7 +244,7 @@ WebMediaPlayerImpl::WebMediaPlayerImpl(WebKit::WebMediaPlayerClient* client, // Add in the default filter factories. filter_factory_->AddFactory(media::FFmpegDemuxer::CreateFilterFactory()); filter_factory_->AddFactory(media::FFmpegAudioDecoder::CreateFactory()); - filter_factory_->AddFactory(media::FFmpegVideoDecoder::CreateFactory()); + filter_factory_->AddFactory(media::FFmpegVideoDecoder::CreateFactory(NULL)); filter_factory_->AddFactory(media::NullAudioRenderer::CreateFilterFactory()); filter_factory_->AddFactory(video_renderer_factory->CreateFactory(proxy_)); } |