diff options
author | hclam@chromium.org <hclam@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-09-13 15:53:30 +0000 |
---|---|---|
committer | hclam@chromium.org <hclam@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-09-13 15:53:30 +0000 |
commit | 768708171bb6c8dec34509c11460d3bc355a3e81 (patch) | |
tree | 0759c4e4c4fc9bd6d115e5e4ade74f81225756ff /chrome/gpu/media | |
parent | 8f8b6b856f85ec92504ca3e48ea4e0d0886ac7b2 (diff) | |
download | chromium_src-768708171bb6c8dec34509c11460d3bc355a3e81.zip chromium_src-768708171bb6c8dec34509c11460d3bc355a3e81.tar.gz chromium_src-768708171bb6c8dec34509c11460d3bc355a3e81.tar.bz2 |
Added FakeGlVideoDecodeEngine to exercise the IPC protocol for hardware video decoding
There are several things done in this patch:
1. Added FakeGlVideoDecodeEngine
2. Fixed style problem in VideoDecodeEngine and gpu_video_common.h
3. Added route to pass texture from gpu process to WebKit
BUG=53714
TEST=Tree is green
Review URL: http://codereview.chromium.org/3335014
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@59223 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/gpu/media')
-rw-r--r-- | chrome/gpu/media/fake_gl_video_decode_engine.cc | 88 | ||||
-rw-r--r-- | chrome/gpu/media/fake_gl_video_decode_engine.h | 39 |
2 files changed, 127 insertions, 0 deletions
diff --git a/chrome/gpu/media/fake_gl_video_decode_engine.cc b/chrome/gpu/media/fake_gl_video_decode_engine.cc new file mode 100644 index 0000000..52e2dfd --- /dev/null +++ b/chrome/gpu/media/fake_gl_video_decode_engine.cc @@ -0,0 +1,88 @@ +// Copyright (c) 2010 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#include "chrome/gpu/media/fake_gl_video_decode_engine.h" + +#include "app/gfx/gl/gl_bindings.h" + +FakeGlVideoDecodeEngine::FakeGlVideoDecodeEngine() + : width_(0), + height_(0), + handler_(NULL) { +} + +FakeGlVideoDecodeEngine::~FakeGlVideoDecodeEngine() { +} + +void FakeGlVideoDecodeEngine::Initialize( + MessageLoop* message_loop, + media::VideoDecodeEngine::EventHandler* event_handler, + const media::VideoCodecConfig& config) { + handler_ = event_handler; + width_ = config.width; + height_ = config.height; + + media::VideoCodecInfo info; + info.success = true; + info.provides_buffers = true; + info.stream_info.surface_format = media::VideoFrame::RGBA; + info.stream_info.surface_type = media::VideoFrame::TYPE_GL_TEXTURE; + info.stream_info.surface_width = width_; + info.stream_info.surface_height = height_; + + // TODO(hclam): When we have VideoDecodeContext we should use it to allocate + // video frames. + handler_->OnInitializeComplete(info); +} + +void FakeGlVideoDecodeEngine::Uninitialize() { + handler_->OnUninitializeComplete(); +} + +void FakeGlVideoDecodeEngine::Flush() { + handler_->OnFlushComplete(); +} + +void FakeGlVideoDecodeEngine::Seek() { + handler_->OnSeekComplete(); +} + +void FakeGlVideoDecodeEngine::ConsumeVideoSample( + scoped_refptr<media::Buffer> buffer) { + // Don't care. +} + +void FakeGlVideoDecodeEngine::ProduceVideoFrame( + scoped_refptr<media::VideoFrame> frame) { + // Fake that we need some buffer. + handler_->ProduceVideoSample(NULL); + + int size = width_ * height_ * 4; + scoped_array<uint8> buffer(new uint8[size]); + memset(buffer.get(), 0, size); + + uint8* row = buffer.get(); + static int seed = 0; + + for (int y = 0; y < height_; ++y) { + int offset = y % 3; + for (int x = 0; x < width_; ++x) { + row[x * 4 + offset] = seed++; + seed &= 255; + } + row += width_ * 4; + } + ++seed; + + // Assume we are in the right context and then upload the content to the + // texture. + glBindTexture(GL_TEXTURE_2D, + frame->gl_texture(media::VideoFrame::kRGBPlane)); + glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, width_, height_, 0, GL_RGBA, + GL_UNSIGNED_BYTE, buffer.get()); + + // We have done generating data to the frame so give it to the handler. + // TODO(hclam): Advance the timestamp every time we call this method. + handler_->ConsumeVideoFrame(frame); +} diff --git a/chrome/gpu/media/fake_gl_video_decode_engine.h b/chrome/gpu/media/fake_gl_video_decode_engine.h new file mode 100644 index 0000000..c3eeb3e --- /dev/null +++ b/chrome/gpu/media/fake_gl_video_decode_engine.h @@ -0,0 +1,39 @@ +// Copyright (c) 2010 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#ifndef CHROME_GPU_MEDIA_FAKE_GL_VIDEO_DECODE_ENGINE_H_ +#define CHROME_GPU_MEDIA_FAKE_GL_VIDEO_DECODE_ENGINE_H_ + +#include "base/scoped_ptr.h" +#include "media/video/video_decode_engine.h" + +namespace media { +class VideoFrame; +} // namespace media + +class FakeGlVideoDecodeEngine : public media::VideoDecodeEngine { + public: + FakeGlVideoDecodeEngine(); + virtual ~FakeGlVideoDecodeEngine(); + + virtual void Initialize( + MessageLoop* message_loop, + media::VideoDecodeEngine::EventHandler* event_handler, + const media::VideoCodecConfig& config); + + virtual void Uninitialize(); + virtual void Flush(); + virtual void Seek(); + virtual void ConsumeVideoSample(scoped_refptr<media::Buffer> buffer); + virtual void ProduceVideoFrame(scoped_refptr<media::VideoFrame> frame); + + private: + int width_; + int height_; + media::VideoDecodeEngine::EventHandler* handler_; + + DISALLOW_COPY_AND_ASSIGN(FakeGlVideoDecodeEngine); +}; + +#endif // CHROME_GPU_MEDIA_FAKE_GL_VIDEO_DECODE_ENGINE_H_ |