diff options
author | mlloyd@chromium.org <mlloyd@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-09-17 14:13:05 +0000 |
---|---|---|
committer | mlloyd@chromium.org <mlloyd@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-09-17 14:13:05 +0000 |
commit | 425bbb99f4faa4bdf90d9bca09174baa467aeaae (patch) | |
tree | 381893ee554de8b10f377bdd7bf7a4037f0183f1 /chrome/gpu/media | |
parent | 6d0593200cd191372b5fefe26fedb1dea2b15a64 (diff) | |
download | chromium_src-425bbb99f4faa4bdf90d9bca09174baa467aeaae.zip chromium_src-425bbb99f4faa4bdf90d9bca09174baa467aeaae.tar.gz chromium_src-425bbb99f4faa4bdf90d9bca09174baa467aeaae.tar.bz2 |
Revert 59785 - Implement FakeGlVideoDecodeEngine using FakeGlVideoDecodeContext
Defines UploadToVideoFrame in VideoDecodeContext.
FakeGlVideoDecodeEngine now uses FakeGlVideoDecodeContext to video frame
allocation and uploading.
BUG=53714
TEST=Tree is green
Review URL: http://codereview.chromium.org/3312022
TBR=hclam@chromium.org
Review URL: http://codereview.chromium.org/3436014
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@59789 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/gpu/media')
-rw-r--r-- | chrome/gpu/media/fake_gl_video_decode_engine.cc | 50 | ||||
-rw-r--r-- | chrome/gpu/media/fake_gl_video_decode_engine.h | 20 | ||||
-rw-r--r-- | chrome/gpu/media/fake_gl_video_device.cc | 60 | ||||
-rw-r--r-- | chrome/gpu/media/fake_gl_video_device.h | 27 | ||||
-rw-r--r-- | chrome/gpu/media/gpu_video_device.h | 17 |
5 files changed, 16 insertions, 158 deletions
diff --git a/chrome/gpu/media/fake_gl_video_decode_engine.cc b/chrome/gpu/media/fake_gl_video_decode_engine.cc index b3d093f..52e2dfd 100644 --- a/chrome/gpu/media/fake_gl_video_decode_engine.cc +++ b/chrome/gpu/media/fake_gl_video_decode_engine.cc @@ -4,8 +4,7 @@ #include "chrome/gpu/media/fake_gl_video_decode_engine.h" -#include "media/base/video_frame.h" -#include "media/video/video_decode_context.h" +#include "app/gfx/gl/gl_bindings.h" FakeGlVideoDecodeEngine::FakeGlVideoDecodeEngine() : width_(0), @@ -19,33 +18,11 @@ FakeGlVideoDecodeEngine::~FakeGlVideoDecodeEngine() { void FakeGlVideoDecodeEngine::Initialize( MessageLoop* message_loop, media::VideoDecodeEngine::EventHandler* event_handler, - media::VideoDecodeContext* context, const media::VideoCodecConfig& config) { handler_ = event_handler; - context_ = context; width_ = config.width; height_ = config.height; - // Create an internal VideoFrame that we can write to. This is going to be - // uploaded through VideoDecodeContext. - media::VideoFrame::CreateFrame( - media::VideoFrame::RGBA, width_, height_, base::TimeDelta(), - base::TimeDelta(), &internal_frame_); - memset(internal_frame_->data(media::VideoFrame::kRGBPlane), 0, - height_ * internal_frame_->stride(media::VideoFrame::kRGBPlane)); - - // Use VideoDecodeContext to allocate VideoFrame that can be consumed by - // external body. - context_->AllocateVideoFrames( - 1, width_, height_, media::VideoFrame::RGBA, &external_frames_, - NewRunnableMethod(this, - &FakeGlVideoDecodeEngine::AllocationCompleteTask)); -} - -void FakeGlVideoDecodeEngine::AllocationCompleteTask() { - DCHECK_EQ(1u, external_frames_.size()); - DCHECK_EQ(media::VideoFrame::TYPE_GL_TEXTURE, external_frames_[0]->type()); - media::VideoCodecInfo info; info.success = true; info.provides_buffers = true; @@ -53,6 +30,9 @@ void FakeGlVideoDecodeEngine::AllocationCompleteTask() { 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); } @@ -82,7 +62,7 @@ void FakeGlVideoDecodeEngine::ProduceVideoFrame( scoped_array<uint8> buffer(new uint8[size]); memset(buffer.get(), 0, size); - uint8* row = internal_frame_->data(media::VideoFrame::kRGBPlane); + uint8* row = buffer.get(); static int seed = 0; for (int y = 0; y < height_; ++y) { @@ -95,18 +75,14 @@ void FakeGlVideoDecodeEngine::ProduceVideoFrame( } ++seed; - // After we have filled the content upload the internal frame to the - // VideoFrame allocated through VideoDecodeContext. - context_->UploadToVideoFrame( - internal_frame_, external_frames_[0], - NewRunnableMethod(this, &FakeGlVideoDecodeEngine::UploadCompleteTask, - external_frames_[0])); -} + // 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()); -void FakeGlVideoDecodeEngine::UploadCompleteTask( - scoped_refptr<media::VideoFrame> frame) { - // |frame| is the upload target. We can immediately send this frame out. + // 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); } - -DISABLE_RUNNABLE_METHOD_REFCOUNT(FakeGlVideoDecodeEngine); diff --git a/chrome/gpu/media/fake_gl_video_decode_engine.h b/chrome/gpu/media/fake_gl_video_decode_engine.h index 164c8c4..c3eeb3e 100644 --- a/chrome/gpu/media/fake_gl_video_decode_engine.h +++ b/chrome/gpu/media/fake_gl_video_decode_engine.h @@ -5,13 +5,10 @@ #ifndef CHROME_GPU_MEDIA_FAKE_GL_VIDEO_DECODE_ENGINE_H_ #define CHROME_GPU_MEDIA_FAKE_GL_VIDEO_DECODE_ENGINE_H_ -#include <vector> - #include "base/scoped_ptr.h" #include "media/video/video_decode_engine.h" namespace media { -class VideoDecodeContext; class VideoFrame; } // namespace media @@ -23,7 +20,6 @@ class FakeGlVideoDecodeEngine : public media::VideoDecodeEngine { virtual void Initialize( MessageLoop* message_loop, media::VideoDecodeEngine::EventHandler* event_handler, - media::VideoDecodeContext* context, const media::VideoCodecConfig& config); virtual void Uninitialize(); @@ -33,25 +29,9 @@ class FakeGlVideoDecodeEngine : public media::VideoDecodeEngine { virtual void ProduceVideoFrame(scoped_refptr<media::VideoFrame> frame); private: - // This method is called when video frames allocation is completed by - // VideoDecodeContext. - void AllocationCompleteTask(); - - // This method is called by VideoDecodeContext when uploading to a VideoFrame - // has completed. - void UploadCompleteTask(scoped_refptr<media::VideoFrame> frame); - int width_; int height_; media::VideoDecodeEngine::EventHandler* handler_; - media::VideoDecodeContext* context_; - - // Internal video frame that is to be uploaded through VideoDecodeContext. - scoped_refptr<media::VideoFrame> internal_frame_; - - // VideoFrame(s) allocated through VideoDecodeContext. These frames are - // opaque to us. And we need an extra upload step. - std::vector<scoped_refptr<media::VideoFrame> > external_frames_; DISALLOW_COPY_AND_ASSIGN(FakeGlVideoDecodeEngine); }; diff --git a/chrome/gpu/media/fake_gl_video_device.cc b/chrome/gpu/media/fake_gl_video_device.cc deleted file mode 100644 index df1b5b1..0000000 --- a/chrome/gpu/media/fake_gl_video_device.cc +++ /dev/null @@ -1,60 +0,0 @@ -// 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_device.h" - -#include "app/gfx/gl/gl_bindings.h" -#include "media/base/video_frame.h" - -void* FakeGlVideoDevice::GetDevice() { - // No actual hardware device should be used. - return NULL; -} - -bool FakeGlVideoDevice::CreateVideoFrameFromGlTextures( - size_t width, size_t height, media::VideoFrame::Format format, - const std::vector<media::VideoFrame::GlTexture>& textures, - scoped_refptr<media::VideoFrame>* frame) { - media::VideoFrame::GlTexture texture_array[media::VideoFrame::kMaxPlanes]; - memset(texture_array, 0, sizeof(texture_array)); - - for (size_t i = 0; i < textures.size(); ++i) { - texture_array[i] = textures[i]; - } - - media::VideoFrame::CreateFrameGlTexture(format, - width, - height, - texture_array, - base::TimeDelta(), - base::TimeDelta(), - frame); - return *frame != NULL; -} - -void FakeGlVideoDevice::ReleaseVideoFrame( - const scoped_refptr<media::VideoFrame>& frame) { - // We didn't need to anything here because we didin't allocate any resources - // for the VideoFrame(s) generated. -} - -bool FakeGlVideoDevice::UploadToVideoFrame( - void* buffer, scoped_refptr<media::VideoFrame> frame) { - // 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)); - - // |buffer| is also a VideoFrame. - scoped_refptr<media::VideoFrame> frame_to_upload( - reinterpret_cast<media::VideoFrame*>(buffer)); - DCHECK_EQ(frame->width(), frame_to_upload->width()); - DCHECK_EQ(frame->height(), frame_to_upload->height()); - DCHECK_EQ(frame->format(), frame_to_upload->format()); - glTexImage2D( - GL_TEXTURE_2D, 0, GL_RGBA, frame_to_upload->width(), - frame_to_upload->height(), 0, GL_RGBA, - GL_UNSIGNED_BYTE, frame_to_upload->data(media::VideoFrame::kRGBPlane)); - return true; -} diff --git a/chrome/gpu/media/fake_gl_video_device.h b/chrome/gpu/media/fake_gl_video_device.h deleted file mode 100644 index 711c3ef..0000000 --- a/chrome/gpu/media/fake_gl_video_device.h +++ /dev/null @@ -1,27 +0,0 @@ -// 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_DEVICE_H_ -#define CHROME_GPU_MEDIA_FAKE_GL_VIDEO_DEVICE_H_ - -#include "chrome/gpu/media/gpu_video_device.h" - -// A simple GpuVideoDevice that create VideoFrame with GL textures. -// It uploads frames in RGBA format in system memory to the GL texture. -class FakeGlVideoDevice : public GpuVideoDevice { - public: - virtual ~FakeGlVideoDevice() {} - - virtual void* GetDevice(); - virtual bool CreateVideoFrameFromGlTextures( - size_t width, size_t height, media::VideoFrame::Format format, - const std::vector<media::VideoFrame::GlTexture>& textures, - scoped_refptr<media::VideoFrame>* frame); - virtual void ReleaseVideoFrame( - const scoped_refptr<media::VideoFrame>& frame); - virtual bool UploadToVideoFrame(void* buffer, - scoped_refptr<media::VideoFrame> frame); -}; - -#endif // CHROME_GPU_MEDIA_FAKE_GL_VIDEO_DEVICE_H_ diff --git a/chrome/gpu/media/gpu_video_device.h b/chrome/gpu/media/gpu_video_device.h index 0556903..7998070 100644 --- a/chrome/gpu/media/gpu_video_device.h +++ b/chrome/gpu/media/gpu_video_device.h @@ -5,8 +5,6 @@ #ifndef CHROME_GPU_MEDIA_GPU_VIDEO_DEVICE_H_ #define CHROME_GPU_MEDIA_GPU_VIDEO_DEVICE_H_ -#include <vector> - #include "media/base/video_frame.h" #include "media/video/video_decode_context.h" @@ -33,25 +31,16 @@ class GpuVideoDevice { // // VideoFrame generated is used by VideoDecodeEngine for output buffer. // - // |frame| will contain the VideoFrame generated. + // |frames| will contain the set of VideoFrame(s) generated. // // Return true if the operation was successful. virtual bool CreateVideoFrameFromGlTextures( size_t width, size_t height, media::VideoFrame::Format format, - const std::vector<media::VideoFrame::GlTexture>& textures, + media::VideoFrame::GlTexture const* textures, scoped_refptr<media::VideoFrame>* frame) = 0; // Release VideoFrame generated. - virtual void ReleaseVideoFrame( - const scoped_refptr<media::VideoFrame>& frame) = 0; - - // Upload a device specific buffer to a VideoFrame object that can be used in - // the GPU process. - // - // Return true if successful. - // TODO(hclam): Rename this to ConvertToVideoFrame(). - virtual bool UploadToVideoFrame(void* buffer, - scoped_refptr<media::VideoFrame> frame) = 0; + virtual void ReleaseVideoFrame(scoped_refptr<media::VideoFrame> frame) = 0; }; #endif // CHROME_GPU_MEDIA_GPU_VIDEO_DEVICE_H_ |