summaryrefslogtreecommitdiffstats
path: root/content
diff options
context:
space:
mode:
authorfischman@chromium.org <fischman@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-05-25 20:25:03 +0000
committerfischman@chromium.org <fischman@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-05-25 20:25:03 +0000
commitee2a19b11962637b36171fef40eb85ab93958036 (patch)
treed934cc904a4515b9358efff92eae33bd0b29cef1 /content
parent76420799ecf0dae804bd267d8336e96c031752ce (diff)
downloadchromium_src-ee2a19b11962637b36171fef40eb85ab93958036.zip
chromium_src-ee2a19b11962637b36171fef40eb85ab93958036.tar.gz
chromium_src-ee2a19b11962637b36171fef40eb85ab93958036.tar.bz2
Revert 86681 - Updated OMX decoder for recent PPAPI changes, and added to the build.
Had to move from content/gpu to content/common/gpu to allow gpu_video_service.cc to depend on the decoder. Removed some dead code and did some random cleanup while I was in there. BUG=none TEST=chrome compiles on cros/arm! Review URL: http://codereview.chromium.org/7057027 TBR=fischman@chromium.org Review URL: http://codereview.chromium.org/6979017 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@86687 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'content')
-rw-r--r--content/common/gpu/DEPS1
-rw-r--r--content/common/gpu/gpu_video_decode_accelerator.cc10
-rw-r--r--content/common/gpu/gpu_video_decode_accelerator.h5
-rw-r--r--content/common/gpu/gpu_video_service.cc8
-rw-r--r--content/content_common.gypi17
-rw-r--r--content/gpu/DEPS1
-rw-r--r--content/gpu/gles2_texture_to_egl_image_translator.cc (renamed from content/common/gpu/gles2_texture_to_egl_image_translator.cc)6
-rw-r--r--content/gpu/gles2_texture_to_egl_image_translator.h (renamed from content/common/gpu/gles2_texture_to_egl_image_translator.h)8
-rw-r--r--content/gpu/omx_video_decode_accelerator.cc (renamed from content/common/gpu/omx_video_decode_accelerator.cc)196
-rw-r--r--content/gpu/omx_video_decode_accelerator.h (renamed from content/common/gpu/omx_video_decode_accelerator.h)48
-rw-r--r--content/renderer/gpu_video_decode_accelerator_host.cc11
-rw-r--r--content/renderer/pepper_platform_video_decoder_impl.cc1
12 files changed, 148 insertions, 164 deletions
diff --git a/content/common/gpu/DEPS b/content/common/gpu/DEPS
index ee929c1..274c1ef 100644
--- a/content/common/gpu/DEPS
+++ b/content/common/gpu/DEPS
@@ -6,5 +6,4 @@ include_rules = [
"+media/base",
"+media/video",
"+skia",
- "+third_party/openmax",
]
diff --git a/content/common/gpu/gpu_video_decode_accelerator.cc b/content/common/gpu/gpu_video_decode_accelerator.cc
index 5b4723a..e962968 100644
--- a/content/common/gpu/gpu_video_decode_accelerator.cc
+++ b/content/common/gpu/gpu_video_decode_accelerator.cc
@@ -108,7 +108,7 @@ void GpuVideoDecodeAccelerator::OnGetConfigs(
void GpuVideoDecodeAccelerator::OnInitialize(
const std::vector<uint32>& configs) {
- if (!video_decode_accelerator_.get())
+ if (!video_decode_accelerator_)
return;
video_decode_accelerator_->Initialize(configs);
@@ -117,7 +117,7 @@ void GpuVideoDecodeAccelerator::OnInitialize(
void GpuVideoDecodeAccelerator::OnDecode(int32 id,
base::SharedMemoryHandle handle,
int32 size) {
- if (!video_decode_accelerator_.get())
+ if (!video_decode_accelerator_)
return;
video_decode_accelerator_->Decode(media::BitstreamBuffer(id, handle, size));
}
@@ -140,14 +140,14 @@ void GpuVideoDecodeAccelerator::OnAssignSysmemBuffers(
}
void GpuVideoDecodeAccelerator::OnReusePictureBuffer(int32 picture_buffer_id) {
- if (!video_decode_accelerator_.get())
+ if (!video_decode_accelerator_)
return;
video_decode_accelerator_->ReusePictureBuffer(picture_buffer_id);
}
void GpuVideoDecodeAccelerator::OnFlush() {
- if (!video_decode_accelerator_.get())
+ if (!video_decode_accelerator_)
return;
if (!video_decode_accelerator_->Flush()) {
@@ -157,7 +157,7 @@ void GpuVideoDecodeAccelerator::OnFlush() {
}
void GpuVideoDecodeAccelerator::OnAbort() {
- if (!video_decode_accelerator_.get())
+ if (!video_decode_accelerator_)
return;
video_decode_accelerator_->Abort();
diff --git a/content/common/gpu/gpu_video_decode_accelerator.h b/content/common/gpu/gpu_video_decode_accelerator.h
index 318dabc..584e3de 100644
--- a/content/common/gpu/gpu_video_decode_accelerator.h
+++ b/content/common/gpu/gpu_video_decode_accelerator.h
@@ -45,8 +45,7 @@ class GpuVideoDecodeAccelerator
void set_video_decode_accelerator(
media::VideoDecodeAccelerator* accelerator) {
- DCHECK(!video_decode_accelerator_.get());
- video_decode_accelerator_.reset(accelerator);
+ video_decode_accelerator_ = accelerator;
}
private:
@@ -73,7 +72,7 @@ class GpuVideoDecodeAccelerator
int32 route_id_;
// Pointer to the underlying VideoDecodeAccelerator.
- scoped_ptr<media::VideoDecodeAccelerator> video_decode_accelerator_;
+ media::VideoDecodeAccelerator* video_decode_accelerator_;
DISALLOW_IMPLICIT_CONSTRUCTORS(GpuVideoDecodeAccelerator);
};
diff --git a/content/common/gpu/gpu_video_service.cc b/content/common/gpu/gpu_video_service.cc
index 26814f5..095ef23 100644
--- a/content/common/gpu/gpu_video_service.cc
+++ b/content/common/gpu/gpu_video_service.cc
@@ -8,10 +8,6 @@
#include "content/common/gpu/gpu_messages.h"
#include "content/common/gpu/gpu_video_decode_accelerator.h"
-#if defined(OS_CHROMEOS) && defined(ARCH_CPU_ARMEL)
-#include "content/common/gpu/omx_video_decode_accelerator.h"
-#endif // defined(OS_CHROMEOS) && defined(ARCH_CPU_ARMEL)
-
GpuVideoService::GpuVideoService() {
// TODO(jiesun): move this time consuming stuff out of here.
IntializeGpuVideoService();
@@ -61,10 +57,6 @@ bool GpuVideoService::CreateVideoDecoder(
// Create GpuVideoDecodeAccelerator and add to map.
scoped_refptr<GpuVideoDecodeAccelerator> decoder =
new GpuVideoDecodeAccelerator(channel, decoder_host_id);
-#if defined(OS_CHROMEOS) && defined(ARCH_CPU_ARMEL)
- decoder->set_video_decode_accelerator(
- new OmxVideoDecodeAccelerator(decoder, MessageLoop::current()));
-#endif // defined(OS_CHROMEOS) && defined(ARCH_CPU_ARMEL)
bool result = decoder_map_.insert(std::make_pair(decoder_id, decoder)).second;
diff --git a/content/content_common.gypi b/content/content_common.gypi
index 27d0aa8..24d9bee 100644
--- a/content/content_common.gypi
+++ b/content/content_common.gypi
@@ -289,23 +289,6 @@
'../gpu/gpu.gyp:command_buffer_service',
],
}],
- ['target_arch=="arm"', {
- 'sources': [
- 'common/gpu/gles2_texture_to_egl_image_translator.cc',
- 'common/gpu/gles2_texture_to_egl_image_translator.h',
- 'common/gpu/omx_video_decode_accelerator.cc',
- 'common/gpu/omx_video_decode_accelerator.h',
- ],
- 'include_dirs': [
- '<(DEPTH)/third_party/openmax/il',
- ],
- 'link_settings': {
- 'libraries': [
- '-lEGL',
- '-lGLESv2',
- ],
- },
- }],
],
},
],
diff --git a/content/gpu/DEPS b/content/gpu/DEPS
index 11b3d3d..15603d8 100644
--- a/content/gpu/DEPS
+++ b/content/gpu/DEPS
@@ -8,4 +8,5 @@ include_rules = [
"+media/video",
"+sandbox",
"+skia",
+ "+third_party/openmax",
]
diff --git a/content/common/gpu/gles2_texture_to_egl_image_translator.cc b/content/gpu/gles2_texture_to_egl_image_translator.cc
index 487dd0b..ed30368 100644
--- a/content/common/gpu/gles2_texture_to_egl_image_translator.cc
+++ b/content/gpu/gles2_texture_to_egl_image_translator.cc
@@ -2,9 +2,7 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#include "content/common/gpu/gles2_texture_to_egl_image_translator.h"
-
-#include "base/logging.h"
+#include "content/gpu/gles2_texture_to_egl_image_translator.h"
// Get EGL extension functions.
static PFNEGLCREATEIMAGEKHRPROC egl_create_image_khr =
@@ -71,3 +69,5 @@ void Gles2TextureToEglImageTranslator::DestroyEglImage(EGLImageKHR egl_image) {
}
egl_destroy_image_khr(egl_display_, egl_image);
}
+
+
diff --git a/content/common/gpu/gles2_texture_to_egl_image_translator.h b/content/gpu/gles2_texture_to_egl_image_translator.h
index 173c63f..547ce27 100644
--- a/content/common/gpu/gles2_texture_to_egl_image_translator.h
+++ b/content/gpu/gles2_texture_to_egl_image_translator.h
@@ -2,8 +2,8 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#ifndef CONTENT_COMMON_GPU_GLES2_TEXTURE_TO_EGL_IMAGE_TRANSLATOR_H_
-#define CONTENT_COMMON_GPU_GLES2_TEXTURE_TO_EGL_IMAGE_TRANSLATOR_H_
+#ifndef CONTENT_GPU_GLES2_TEXTURE_TO_EGL_IMAGE_TRANSLATOR_H_
+#define CONTENT_GPU_GLES2_TEXTURE_TO_EGL_IMAGE_TRANSLATOR_H_
#include <EGL/egl.h>
#include <EGL/eglext.h>
@@ -36,4 +36,6 @@ class Gles2TextureToEglImageTranslator {
DISALLOW_IMPLICIT_CONSTRUCTORS(Gles2TextureToEglImageTranslator);
};
-#endif // CONTENT_COMMON_GPU_GLES2_TEXTURE_TO_EGL_IMAGE_TRANSLATOR_H_
+#endif // CONTENT_GPU_GLES2_TEXTURE_TO_EGL_IMAGE_TRANSLATOR_H_
+
+
diff --git a/content/common/gpu/omx_video_decode_accelerator.cc b/content/gpu/omx_video_decode_accelerator.cc
index fcdef2d..3367cd9 100644
--- a/content/common/gpu/omx_video_decode_accelerator.cc
+++ b/content/gpu/omx_video_decode_accelerator.cc
@@ -2,15 +2,17 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#include "content/common/gpu/omx_video_decode_accelerator.h"
+#include "content/gpu/omx_video_decode_accelerator.h"
-#include "base/stl_util-inl.h"
-#include "base/string_util.h"
-#include "content/common/gpu/gles2_texture_to_egl_image_translator.h"
#include "content/common/gpu/gpu_channel.h"
+#include "content/common/gpu_messages.h"
+#include "content/gpu/gles2_texture_to_egl_image_translator.h"
#include "media/base/bitstream_buffer.h"
+#include "media/base/data_buffer.h"
#include "media/video/picture.h"
+static Gles2TextureToEglImageTranslator* texture2eglImage_translator(
+ new Gles2TextureToEglImageTranslator(NULL, 0));
enum { kNumPictureBuffers = 4 };
// Open the libnvomx here for now.
@@ -24,6 +26,7 @@ typedef OMX_ERRORTYPE (*OMXFreeHandle)(OMX_HANDLETYPE);
typedef OMX_ERRORTYPE (*OMXDeinit)();
OMXInit omx_init = reinterpret_cast<OMXInit>(dlsym(omx_handle, "OMX_Init"));
+
OMXGetHandle omx_gethandle =
reinterpret_cast<OMXGetHandle>(dlsym(omx_handle, "OMX_GetHandle"));
OMXGetComponentsOfRole omx_get_components_of_role =
@@ -55,7 +58,8 @@ OmxVideoDecodeAccelerator::OmxVideoDecodeAccelerator(
output_port_(0),
output_buffers_at_component_(0),
uses_egl_image_(false),
- client_(client) {
+ client_(client),
+ egl_image_(NULL) {
if (!AreOMXFunctionPointersInitialized()) {
LOG(ERROR) << "Failed to load openmax library";
return;
@@ -72,11 +76,11 @@ OmxVideoDecodeAccelerator::~OmxVideoDecodeAccelerator() {
DCHECK(output_pictures_.empty());
}
-void OmxVideoDecodeAccelerator::GetConfigs(
- const std::vector<uint32>& requested_configs,
- std::vector<uint32>* matched_configs) {
+const std::vector<uint32>& OmxVideoDecodeAccelerator::GetConfig(
+ const std::vector<uint32>& prototype_config) {
// TODO(vhiremath@nvidia.com) use this properly
NOTIMPLEMENTED();
+ return component_config_;
}
// This is to initialize the OMX data structures to default values.
@@ -88,7 +92,7 @@ static void InitParam(const OmxVideoDecodeAccelerator& dec, T* param) {
}
bool OmxVideoDecodeAccelerator::Initialize(const std::vector<uint32>& config) {
- // TODO(vhiremath@nvidia.com) get these actual values from config
+ // TODO(vhiremath@nvidia.com) get these acutal values from config
// Assume qvga for now
width_ = 320;
height_ = 240;
@@ -118,17 +122,12 @@ bool OmxVideoDecodeAccelerator::Initialize(const std::vector<uint32>& config) {
// - SharedMemHandle in case of decoding to system memory.
// - Textures in case of decoding to egl-images.
- // Output buffers will be eventually handed to us via
- // Assign{GLES,Sysmem}Buffers().
+ // Output buffers will be eventually allocated in AssignPictureBuffer().
+
+ // TODO(vhiremath@nvidia.com) fill buffer_properties
+ std::vector<uint32> buffer_properties;
output_buffer_count_ = kNumPictureBuffers;
- client_->ProvidePictureBuffers(
- output_buffer_count_, gfx::Size(width_, height_),
- PICTUREBUFFER_MEMORYTYPE_GL_TEXTURE);
- // TODO(fischman): we always ask for GLES buffers above. So why maintain the
- // !uses_egl_image_ path in this class at all? Theoretically it could be
- // useful for testing, but today there's no such testing. Consider ripping it
- // out of this class and replacing AssignSysmemBuffers() with
- // NOTIMPLEMENTED().
+ client_->ProvidePictureBuffers(output_buffer_count_, buffer_properties);
return true;
}
@@ -249,8 +248,10 @@ bool OmxVideoDecodeAccelerator::CreateComponent() {
}
bool OmxVideoDecodeAccelerator::Decode(
- const media::BitstreamBuffer& bitstream_buffer) {
+ const media::BitstreamBuffer& bitstream_buffer,
+ const media::VideoDecodeAcceleratorCallback& callback) {
DCHECK(!free_input_buffers_.empty());
+ DCHECK(bitstream_buffer);
if (!CanAcceptInput()) {
return false;
@@ -267,7 +268,7 @@ bool OmxVideoDecodeAccelerator::Decode(
return false;
}
omx_buffer->pBuffer = static_cast<OMX_U8*>(shm->memory());
- omx_buffer->nFilledLen = bitstream_buffer.size();
+ omx_buffer->nFilledLen = bitstream_buffer->size();
omx_buffer->nAllocLen = omx_buffer->nFilledLen;
omx_buffer->nFlags &= ~OMX_BUFFERFLAG_EOS;
@@ -284,35 +285,25 @@ bool OmxVideoDecodeAccelerator::Decode(
input_buffers_at_component_++;
// OMX_EmptyThisBuffer is a non blocking call and should
// not make any assumptions about its completion.
- omx_buff_ids_.insert(std::make_pair(
- omx_buffer, std::make_pair(shm.release(), bitstream_buffer.id())));
+ omx_buff_cb_.insert(std::make_pair(
+ omx_buffer, make_pair(shm.release(), callback)));
return true;
}
-// NOTE: this is only partially-implemented as never unsets uses_egl_image_ once
-// set.
-void OmxVideoDecodeAccelerator::AssignGLESBuffers(
- const std::vector<media::GLESBuffer>& buffers) {
- uses_egl_image_ = true;
- std::vector<media::BaseBuffer*> base_buffers(buffers.size());
- for (size_t i = 0; i < buffers.size(); ++i)
- base_buffers[i] = new media::GLESBuffer(buffers[i]);
- AssignBuffersHelper(base_buffers);
-}
-
-void OmxVideoDecodeAccelerator::AssignSysmemBuffers(
- const std::vector<media::SysmemBuffer>& buffers) {
- DCHECK(!uses_egl_image_);
- std::vector<media::BaseBuffer*> base_buffers(buffers.size());
- for (size_t i = 0; i < buffers.size(); ++i)
- base_buffers[i] = new media::SysmemBuffer(buffers[i]);
- AssignBuffersHelper(base_buffers);
-}
+void OmxVideoDecodeAccelerator::AssignPictureBuffer(
+ std::vector<PictureBuffer*> picture_buffers) {
+ // NOTE: this is only partially-implemented as it only inspects the first
+ // picture buffer passed in each AssignPictureBuffer call, and never unsets
+ // uses_egl_image_ once set.
+ if (PictureBuffer::PICTUREBUFFER_MEMORYTYPE_GL_TEXTURE ==
+ picture_buffers[0]->GetMemoryType()) {
+ uses_egl_image_ = true;
+ }
-void OmxVideoDecodeAccelerator::AssignBuffersHelper(
- const std::vector<media::BaseBuffer*>& buffers) {
assigned_picture_buffers_.insert(
- assigned_picture_buffers_.end(), buffers.begin(), buffers.end());
+ assigned_picture_buffers_.end(),
+ picture_buffers.begin(),
+ picture_buffers.end());
if (assigned_picture_buffers_.size() < kNumPictureBuffers)
return; // get all the buffers first.
@@ -365,7 +356,7 @@ void OmxVideoDecodeAccelerator::ReusePictureBuffer(int32 picture_buffer_id) {
return;
for (int i = 0; i < output_buffer_count_; ++i) {
- if (picture_buffer_id != assigned_picture_buffers_[i]->id())
+ if (picture_buffer_id != assigned_picture_buffers_[i]->GetId())
continue;
output_buffers_at_component_++;
OMX_ERRORTYPE result =
@@ -399,15 +390,17 @@ void OmxVideoDecodeAccelerator::InitialFillBuffer() {
}
}
-bool OmxVideoDecodeAccelerator::Flush() {
+bool OmxVideoDecodeAccelerator::Flush(
+ const media::VideoDecodeAcceleratorCallback& callback) {
OMX_STATETYPE il_state;
OMX_GetState(component_handle_, &il_state);
DCHECK_EQ(il_state, OMX_StateExecuting);
if (il_state != OMX_StateExecuting) {
- client_->NotifyFlushDone();
+ callback.Run();
return false;
}
on_buffer_flag_event_func_ = &OmxVideoDecodeAccelerator::FlushBegin;
+ flush_done_callback_ = callback;
OMX_BUFFERHEADERTYPE* omx_buffer = free_input_buffers_.front();
free_input_buffers_.pop();
@@ -485,12 +478,13 @@ void OmxVideoDecodeAccelerator::PortFlushDone(int port) {
OnPortCommandFlush(OMX_StateExecuting);
}
-bool OmxVideoDecodeAccelerator::Abort() {
+bool OmxVideoDecodeAccelerator::Abort(
+ const media::VideoDecodeAcceleratorCallback& callback) {
// TODO(vhiremath@nvidia.com)
// Need more thinking on this to handle w.r.t OMX.
// There is no explicit UnInitialize call for this.
// Also review again for trick modes.
- client_->NotifyAbortDone();
+ callback.Run();
return true;
}
@@ -515,6 +509,7 @@ void OmxVideoDecodeAccelerator::OnStateChangeIdleToExecuting(
client_state_ = OMX_StateExecuting;
on_state_event_func_ = NULL;
// This will kickoff the actual decoding
+ client_->NotifyResourcesAcquired();
InitialFillBuffer();
}
@@ -542,7 +537,6 @@ void OmxVideoDecodeAccelerator::OnPortCommandFlush(OMX_STATETYPE state) {
OutputPicture output_picture = output_pictures_[i];
client_->DismissPictureBuffer(output_picture.first);
}
- STLDeleteElements(&assigned_picture_buffers_);
}
void OmxVideoDecodeAccelerator::OnStateChangeExecutingToIdle(
@@ -575,7 +569,7 @@ void OmxVideoDecodeAccelerator::OnStateChangeIdleToLoaded(OMX_STATETYPE state) {
client_state_ = OMX_StateLoaded;
(*omx_deinit)();
VLOG(1) << "OMX Deinit Clean exit done";
- client_->NotifyFlushDone();
+ flush_done_callback_.Run();
}
void OmxVideoDecodeAccelerator::StopOnError() {
@@ -617,49 +611,62 @@ bool OmxVideoDecodeAccelerator::AllocateInputBuffers() {
}
bool OmxVideoDecodeAccelerator::AllocateOutputBuffers() {
- static Gles2TextureToEglImageTranslator* texture2eglImage_translator(
- new Gles2TextureToEglImageTranslator(NULL, 0));
-
+ OMX_BUFFERHEADERTYPE* buffer;
+ Picture* picture;
+ OMX_ERRORTYPE result;
gfx::Size decoded_pixel_size(width_, height_);
gfx::Size visible_pixel_size(width_, height_);
- // TODO(fischman): remove garbage bitstream buffer id's below (42 and 24) when
- // the bitstream_buffer_id field is removed from Picture.
+
if (uses_egl_image_) {
+ media::VideoDecodeAccelerator::PictureBuffer::DataPlaneHandle egl_ids;
+ std::vector<PictureBuffer::DataPlaneHandle> planes;
+ uint32 texture;
+
for (uint32 i = 0; i < assigned_picture_buffers_.size(); i++) {
- media::GLESBuffer* gles_buffer =
- reinterpret_cast<media::GLESBuffer*>(assigned_picture_buffers_[i]);
- OMX_BUFFERHEADERTYPE* omx_buffer;
- void* egl = texture2eglImage_translator->TranslateToEglImage(
- gles_buffer->texture_id());
- OMX_ERRORTYPE result = OMX_UseEGLImage(
- component_handle_, &omx_buffer, output_port_, gles_buffer, egl);
+ picture = new media::Picture(
+ reinterpret_cast<media::PictureBuffer*>(assigned_picture_buffers_[i]),
+ decoded_pixel_size, visible_pixel_size,
+ static_cast<void*>(component_handle_));
+
+ planes = assigned_picture_buffers_[i]->GetPlaneHandles();
+ egl_ids = planes[i];
+ texture = egl_ids.texture_id;
+ egl_image_ = texture2eglImage_translator->TranslateToEglImage(texture);
+ result = OMX_UseEGLImage(
+ component_handle_,
+ &buffer,
+ output_port_,
+ reinterpret_cast<media::PictureBuffer*>(assigned_picture_buffers_[i]),
+ egl_image_);
+
if (result != OMX_ErrorNone) {
LOG(ERROR) << "OMX_UseEGLImage failed";
return false;
}
- omx_buffer->pAppPrivate =
- new media::Picture(gles_buffer->id(),
- 42 /* garbage bitstreambuffer id */,
- decoded_pixel_size, visible_pixel_size);
output_pictures_.push_back(
- std::make_pair(assigned_picture_buffers_[i]->id(), omx_buffer));
+ std::make_pair(
+ reinterpret_cast<media::PictureBuffer*>(
+ assigned_picture_buffers_[i]),
+ buffer));
+ buffer->pAppPrivate = picture;
}
} else {
for (uint32 i = 0; i < assigned_picture_buffers_.size(); i++) {
- media::SysmemBuffer* sysmem_buffer =
- reinterpret_cast<media::SysmemBuffer*>(assigned_picture_buffers_[i]);
- OMX_BUFFERHEADERTYPE* omx_buffer;
- OMX_ERRORTYPE result = OMX_AllocateBuffer(
- component_handle_, &omx_buffer, output_port_, NULL,
- output_buffer_size_);
+ picture = new media::Picture(
+ reinterpret_cast<media::PictureBuffer*>(assigned_picture_buffers_[i]),
+ decoded_pixel_size, visible_pixel_size,
+ static_cast<void*>(component_handle_));
+
+ result = OMX_AllocateBuffer(component_handle_, &buffer, output_port_,
+ NULL, output_buffer_size_);
if (result != OMX_ErrorNone)
return false;
- omx_buffer->pAppPrivate = new media::Picture(
- sysmem_buffer->id(),
- 24 /* garbage bitstreambuffer id */,
- decoded_pixel_size, visible_pixel_size);
output_pictures_.push_back(
- std::make_pair(sysmem_buffer->id(), omx_buffer));
+ std::make_pair(
+ reinterpret_cast<media::PictureBuffer*>(
+ assigned_picture_buffers_[i]),
+ buffer));
+ buffer->pAppPrivate = picture;
}
}
return true;
@@ -687,7 +694,6 @@ void OmxVideoDecodeAccelerator::FreeOutputBuffers() {
for (size_t i = 0; i < output_pictures_.size(); ++i) {
OMX_BUFFERHEADERTYPE* omx_buffer = output_pictures_[i].second;
CHECK(omx_buffer);
- delete reinterpret_cast<media::Picture*>(omx_buffer->pAppPrivate);
result = OMX_FreeBuffer(component_handle_, output_port_, omx_buffer);
if (result != OMX_ErrorNone) {
LOG(ERROR) << "SendCommand(OMX_CommandPortDisable) failed";
@@ -713,8 +719,7 @@ void OmxVideoDecodeAccelerator::FillBufferDoneTask(
OMX_BUFFERHEADERTYPE* buffer) {
DCHECK_GT(output_buffers_at_component_, 0);
output_buffers_at_component_--;
- client_->PictureReady(*reinterpret_cast<media::Picture*>(
- buffer->pAppPrivate));
+ client_->PictureReady(reinterpret_cast<Picture*>(buffer->pAppPrivate));
}
void OmxVideoDecodeAccelerator::EmptyBufferDoneTask(
@@ -724,17 +729,16 @@ void OmxVideoDecodeAccelerator::EmptyBufferDoneTask(
input_buffers_at_component_--;
if (buffer->nFlags & OMX_BUFFERFLAG_EOS)
return;
- // Retrieve the corresponding BitstreamBuffer's id and notify the client of
- // its completion.
- OMXBufferIdMap::iterator it = omx_buff_ids_.find(buffer);
- if (it == omx_buff_ids_.end()) {
- LOG(ERROR) << "Unexpectedly failed to find a buffer id.";
+ // Retrieve the corresponding callback and run it.
+ OMXBufferCallbackMap::iterator it = omx_buff_cb_.find(buffer);
+ if (it == omx_buff_cb_.end()) {
+ LOG(ERROR) << "Unexpectedly failed to find a buffer callback.";
StopOnError();
return;
}
delete it->second.first;
- client_->NotifyEndOfBitstreamBuffer(it->second.second);
- omx_buff_ids_.erase(it);
+ it->second.second.Run();
+ omx_buff_cb_.erase(it);
}
void OmxVideoDecodeAccelerator::EventHandlerCompleteTask(OMX_EVENTTYPE event,
@@ -806,11 +810,10 @@ OMX_ERRORTYPE OmxVideoDecodeAccelerator::EventHandler(OMX_HANDLETYPE component,
static_cast<OmxVideoDecodeAccelerator*>(priv_data);
DCHECK_EQ(component, decoder->component_handle_);
- decoder->message_loop_->PostTask(
- FROM_HERE,
- NewRunnableMethod(decoder,
- &OmxVideoDecodeAccelerator::EventHandlerCompleteTask,
- event, data1, data2));
+ decoder->message_loop_->PostTask(FROM_HERE,
+ NewRunnableMethod(decoder,
+ &OmxVideoDecodeAccelerator::EventHandlerCompleteTask,
+ event, data1, data2));
return OMX_ErrorNone;
}
@@ -841,8 +844,7 @@ OMX_ERRORTYPE OmxVideoDecodeAccelerator::FillBufferCallback(
static_cast<OmxVideoDecodeAccelerator*>(priv_data);
DCHECK_EQ(component, decoder->component_handle_);
- decoder->message_loop_->PostTask(
- FROM_HERE,
+ decoder->message_loop_->PostTask(FROM_HERE,
NewRunnableMethod(
decoder,
&OmxVideoDecodeAccelerator::FillBufferDoneTask, buffer));
diff --git a/content/common/gpu/omx_video_decode_accelerator.h b/content/gpu/omx_video_decode_accelerator.h
index 5f8e324..ea4e6c2 100644
--- a/content/common/gpu/omx_video_decode_accelerator.h
+++ b/content/gpu/omx_video_decode_accelerator.h
@@ -2,8 +2,8 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#ifndef CONTENT_COMMON_GPU_OMX_VIDEO_DECODE_ACCELERATOR_H_
-#define CONTENT_COMMON_GPU_OMX_VIDEO_DECODE_ACCELERATOR_H_
+#ifndef CONTENT_GPU_OMX_VIDEO_DECODE_ACCELERATOR_H_
+#define CONTENT_GPU_OMX_VIDEO_DECODE_ACCELERATOR_H_
#include <dlfcn.h>
#include <map>
@@ -30,25 +30,20 @@ class OmxVideoDecodeAccelerator : public media::VideoDecodeAccelerator {
virtual ~OmxVideoDecodeAccelerator();
// media::VideoDecodeAccelerator implementation.
- void GetConfigs(const std::vector<uint32>& requested_configs,
- std::vector<uint32>* matched_configs) OVERRIDE;
- bool Initialize(const std::vector<uint32>& config) OVERRIDE;
- bool Decode(const media::BitstreamBuffer& bitstream_buffer) OVERRIDE;
- virtual void AssignGLESBuffers(
- const std::vector<media::GLESBuffer>& buffers) OVERRIDE;
- virtual void AssignSysmemBuffers(
- const std::vector<media::SysmemBuffer>& buffers) OVERRIDE;
- void ReusePictureBuffer(int32 picture_buffer_id) OVERRIDE;
- bool Flush() OVERRIDE;
- bool Abort() OVERRIDE;
+ const std::vector<uint32>& GetConfig(
+ const std::vector<uint32>& prototype_config);
+ bool Initialize(const std::vector<uint32>& config);
+ bool Decode(const media::BitstreamBuffer& bitstream_buffer,
+ const media::VideoDecodeAcceleratorCallback& callback);
+ void AssignPictureBuffer(std::vector<PictureBuffer*> picture_buffers);
+ void ReusePictureBuffer(int32 picture_buffer_id);
+ bool Flush(const media::VideoDecodeAcceleratorCallback& callback);
+ bool Abort(const media::VideoDecodeAcceleratorCallback& callback);
private:
MessageLoop* message_loop_;
OMX_HANDLETYPE component_handle_;
- // Common initialization code for Assign{GLES,Sysmem}Buffers.
- void AssignBuffersHelper(const std::vector<media::BaseBuffer*>& buffers);
-
// Create the Component for OMX. Handles all OMX initialization.
bool CreateComponent();
// Buffer allocation/free methods for input and output buffers.
@@ -107,13 +102,18 @@ class OmxVideoDecodeAccelerator : public media::VideoDecodeAccelerator {
std::queue<OMX_BUFFERHEADERTYPE*> free_input_buffers_;
// For output buffer recycling cases.
- std::vector<media::BaseBuffer*> assigned_picture_buffers_;
- typedef std::pair<int32, OMX_BUFFERHEADERTYPE*> OutputPicture;
+ std::vector<media::VideoDecodeAccelerator::PictureBuffer*>
+ assigned_picture_buffers_;
+ typedef std::pair<PictureBuffer*,
+ OMX_BUFFERHEADERTYPE*> OutputPicture;
std::vector<OutputPicture> output_pictures_;
// To expose client callbacks from VideoDecodeAccelerator.
Client* client_;
+ media::VideoDecodeAcceleratorCallback flush_done_callback_;
+ media::VideoDecodeAcceleratorCallback abort_done_callback_;
+
std::vector<uint32> texture_ids_;
std::vector<uint32> context_ids_;
// Method to handle events
@@ -127,10 +127,14 @@ class OmxVideoDecodeAccelerator : public media::VideoDecodeAccelerator {
// Method to receive buffers from component's output port
void FillBufferDoneTask(OMX_BUFFERHEADERTYPE* buffer);
typedef std::pair<OMX_BUFFERHEADERTYPE*, uint32> OMXbufferTexture;
+ // void pointer to hold EGLImage handle.
+ void* egl_image_;
- typedef std::map<OMX_BUFFERHEADERTYPE*,
- std::pair<base::SharedMemory*, int32> > OMXBufferIdMap;
- OMXBufferIdMap omx_buff_ids_;
+ typedef std::map<
+ OMX_BUFFERHEADERTYPE*,
+ std::pair<base::SharedMemory*,
+ media::VideoDecodeAcceleratorCallback> > OMXBufferCallbackMap;
+ OMXBufferCallbackMap omx_buff_cb_;
// Method used the change the state of the port.
void ChangePort(OMX_COMMANDTYPE cmd, int port_index);
@@ -158,4 +162,4 @@ class OmxVideoDecodeAccelerator : public media::VideoDecodeAccelerator {
OMX_BUFFERHEADERTYPE* buffer);
};
-#endif // CONTENT_COMMON_GPU_OMX_VIDEO_DECODE_ACCELERATOR_H_
+#endif // CONTENT_GPU_OMX_VIDEO_DECODE_ACCELERATOR_H_
diff --git a/content/renderer/gpu_video_decode_accelerator_host.cc b/content/renderer/gpu_video_decode_accelerator_host.cc
index ef9ef7f..2b2d027 100644
--- a/content/renderer/gpu_video_decode_accelerator_host.cc
+++ b/content/renderer/gpu_video_decode_accelerator_host.cc
@@ -14,6 +14,7 @@
#include "ipc/ipc_message_utils.h"
using media::VideoDecodeAccelerator;
+using media::VideoDecodeAcceleratorCallback;
GpuVideoDecodeAcceleratorHost::GpuVideoDecodeAcceleratorHost(
MessageRouter* router,
@@ -104,11 +105,11 @@ void GpuVideoDecodeAcceleratorHost::AssignGLESBuffers(
std::vector<uint32> context_ids;
std::vector<gfx::Size> sizes;
for (uint32 i = 0; i < buffers.size(); i++) {
- const media::GLESBuffer& buffer = buffers[i];
- texture_ids.push_back(buffer.texture_id());
- context_ids.push_back(buffer.context_id());
- buffer_ids.push_back(buffer.id());
- sizes.push_back(buffer.size());
+ const media::BufferInfo& info = buffers[i].buffer_info();
+ texture_ids.push_back(buffers[i].texture_id());
+ context_ids.push_back(buffers[i].context_id());
+ buffer_ids.push_back(info.id());
+ sizes.push_back(info.size());
}
if (!ipc_sender_->Send(new AcceleratedVideoDecoderMsg_AssignGLESBuffers(
decoder_id_, buffer_ids, texture_ids, context_ids, sizes))) {
diff --git a/content/renderer/pepper_platform_video_decoder_impl.cc b/content/renderer/pepper_platform_video_decoder_impl.cc
index 88ccb3a..7d46cf4 100644
--- a/content/renderer/pepper_platform_video_decoder_impl.cc
+++ b/content/renderer/pepper_platform_video_decoder_impl.cc
@@ -15,6 +15,7 @@
#include "content/renderer/render_thread.h"
using media::BitstreamBuffer;
+using media::VideoDecodeAcceleratorCallback;
PlatformVideoDecoderImpl::PlatformVideoDecoderImpl(
VideoDecodeAccelerator::Client* client)