summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorscherkus@chromium.org <scherkus@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-06-03 20:06:02 +0000
committerscherkus@chromium.org <scherkus@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-06-03 20:06:02 +0000
commitd0cef8b4da166d1835f7e4caf6021cce978e2ddd (patch)
treec26c6b2d093e580f536029163cf6956f97efc541
parentf2fcf4df7b83cba250b64877116038eb0d285c0a (diff)
downloadchromium_src-d0cef8b4da166d1835f7e4caf6021cce978e2ddd.zip
chromium_src-d0cef8b4da166d1835f7e4caf6021cce978e2ddd.tar.gz
chromium_src-d0cef8b4da166d1835f7e4caf6021cce978e2ddd.tar.bz2
Removing defunct GpuVideoDecoder and IpcVideoDecoder.
These haven't been used in quite some time and have been replaced by the newer VideoDecoderAccelerator set of classes. BUG=none TEST=the world still compiles Review URL: http://codereview.chromium.org/6993016 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@87841 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r--content/browser/gpu/gpu_process_host.cc1
-rw-r--r--content/browser/renderer_host/browser_render_process_host.cc1
-rw-r--r--content/common/gpu/gpu_messages.h126
-rw-r--r--content/common/gpu/gpu_video_decoder.cc431
-rw-r--r--content/common/gpu/gpu_video_decoder.h209
-rw-r--r--content/common/gpu/gpu_video_decoder_unittest.cc264
-rw-r--r--content/common/gpu/media/fake_gl_video_decode_engine.cc132
-rw-r--r--content/common/gpu/media/fake_gl_video_decode_engine.h68
-rw-r--r--content/common/gpu/media/fake_gl_video_device.cc58
-rw-r--r--content/common/gpu/media/fake_gl_video_device.h27
-rw-r--r--content/common/gpu/media/gpu_video_device.h56
-rw-r--r--content/content_common.gypi5
-rw-r--r--content/content_renderer.gypi4
-rw-r--r--content/renderer/gpu/gpu_video_decoder_host.cc401
-rw-r--r--content/renderer/gpu/gpu_video_decoder_host.h165
-rw-r--r--content/renderer/gpu/gpu_video_service_host.cc6
-rw-r--r--content/renderer/gpu/gpu_video_service_host.h16
-rw-r--r--content/renderer/gpu/renderer_gl_context.cc11
-rw-r--r--content/renderer/gpu/renderer_gl_context.h19
-rw-r--r--content/renderer/gpu/transport_texture_service.h1
-rw-r--r--content/renderer/media/gles2_video_decode_context.cc122
-rw-r--r--content/renderer/media/gles2_video_decode_context.h112
-rw-r--r--content/renderer/media/ipc_video_decoder.cc207
-rw-r--r--content/renderer/media/ipc_video_decoder.h89
-rw-r--r--content/renderer/render_view.cc18
-rw-r--r--media/base/media_switches.cc3
-rw-r--r--media/base/media_switches.h1
27 files changed, 1 insertions, 2552 deletions
diff --git a/content/browser/gpu/gpu_process_host.cc b/content/browser/gpu/gpu_process_host.cc
index 6778095..e307964 100644
--- a/content/browser/gpu/gpu_process_host.cc
+++ b/content/browser/gpu/gpu_process_host.cc
@@ -548,7 +548,6 @@ bool GpuProcessHost::LaunchGpuProcess() {
switches::kDisableGpuVsync,
switches::kDisableGpuWatchdog,
switches::kDisableLogging,
- switches::kEnableAcceleratedDecoding,
switches::kEnableLogging,
#if defined(OS_MACOSX)
switches::kEnableSandboxLogging,
diff --git a/content/browser/renderer_host/browser_render_process_host.cc b/content/browser/renderer_host/browser_render_process_host.cc
index a2f246f..a05160b 100644
--- a/content/browser/renderer_host/browser_render_process_host.cc
+++ b/content/browser/renderer_host/browser_render_process_host.cc
@@ -558,7 +558,6 @@ void BrowserRenderProcessHost::PropagateBrowserCommandLineToRenderer(
switches::kDisableWebSockets,
switches::kDomAutomationController,
switches::kDumpHistogramsOnExit,
- switches::kEnableAcceleratedDecoding,
switches::kEnableAdaptive,
switches::kEnableBenchmarking,
switches::kEnableClickToPlay,
diff --git a/content/common/gpu/gpu_messages.h b/content/common/gpu/gpu_messages.h
index 017c876..161e4eb 100644
--- a/content/common/gpu/gpu_messages.h
+++ b/content/common/gpu/gpu_messages.h
@@ -20,51 +20,12 @@
#define IPC_MESSAGE_START GpuMsgStart
-// Flag assigned to a video buffer for both input and output.
-#define kGpuVideoEndOfStream (1 << 0)
-
IPC_STRUCT_BEGIN(GPUCreateCommandBufferConfig)
IPC_STRUCT_MEMBER(std::string, allowed_extensions)
IPC_STRUCT_MEMBER(std::vector<int>, attribs)
IPC_STRUCT_MEMBER(GURL, active_url)
IPC_STRUCT_END()
-IPC_STRUCT_BEGIN(GpuVideoDecoderInitParam)
- IPC_STRUCT_MEMBER(int32, codec_id)
- IPC_STRUCT_MEMBER(int32, width)
- IPC_STRUCT_MEMBER(int32, height)
- IPC_STRUCT_MEMBER(int32, profile)
- IPC_STRUCT_MEMBER(int32, level)
- IPC_STRUCT_MEMBER(int32, frame_rate_den)
- IPC_STRUCT_MEMBER(int32, frame_rate_num)
- IPC_STRUCT_MEMBER(int32, aspect_ratio_den)
- IPC_STRUCT_MEMBER(int32, aspect_ratio_num)
-IPC_STRUCT_END()
-
-IPC_STRUCT_BEGIN(GpuVideoDecoderInitDoneParam)
- // other parameter is only meaningful when this is true.
- IPC_STRUCT_MEMBER(int32, success)
- IPC_STRUCT_MEMBER(int32, input_buffer_size)
- IPC_STRUCT_MEMBER(base::SharedMemoryHandle, input_buffer_handle)
-IPC_STRUCT_END()
-
-IPC_STRUCT_BEGIN(GpuVideoDecoderInputBufferParam)
- IPC_STRUCT_MEMBER(int64, timestamp) // In unit of microseconds.
- IPC_STRUCT_MEMBER(int32, offset)
- IPC_STRUCT_MEMBER(int32, size)
- IPC_STRUCT_MEMBER(int32, flags) // Miscellaneous flag bit mask.
-IPC_STRUCT_END()
-
-IPC_STRUCT_BEGIN(GpuVideoDecoderErrorInfoParam)
- IPC_STRUCT_MEMBER(int32, error_id) // TODO(jiesun): define enum.
-IPC_STRUCT_END()
-
-// TODO(jiesun): define this.
-IPC_STRUCT_BEGIN(GpuVideoDecoderFormatChangeParam)
- IPC_STRUCT_MEMBER(int32, input_buffer_size)
- IPC_STRUCT_MEMBER(base::SharedMemoryHandle, input_buffer_handle)
-IPC_STRUCT_END()
-
#if defined(OS_MACOSX)
IPC_STRUCT_BEGIN(GpuHostMsg_AcceleratedSurfaceSetIOSurface_Params)
IPC_STRUCT_MEMBER(int32, renderer_id)
@@ -418,93 +379,8 @@ IPC_MESSAGE_ROUTED1(GpuCommandBufferMsg_SetWindowSize,
gfx::Size /* size */)
#endif
-//------------------------------------------------------------------------------
-// GPU Video Decoder Messages
-// These messages are sent from Renderer process to GPU process.
-// Initialize and configure GpuVideoDecoder asynchronously.
-IPC_MESSAGE_ROUTED1(GpuVideoDecoderMsg_Initialize,
- GpuVideoDecoderInitParam)
-
-// Destroy and release GpuVideoDecoder asynchronously.
-IPC_MESSAGE_ROUTED0(GpuVideoDecoderMsg_Destroy)
-
-// Start decoder flushing operation.
-IPC_MESSAGE_ROUTED0(GpuVideoDecoderMsg_Flush)
-
-// Tell the decoder to start prerolling.
-IPC_MESSAGE_ROUTED0(GpuVideoDecoderMsg_Preroll)
-
-// Send input buffer to GpuVideoDecoder.
-IPC_MESSAGE_ROUTED1(GpuVideoDecoderMsg_EmptyThisBuffer,
- GpuVideoDecoderInputBufferParam)
-
-// Ask the GPU process to produce a video frame with the ID.
-IPC_MESSAGE_ROUTED1(GpuVideoDecoderMsg_ProduceVideoFrame,
- int32) /* Video Frame ID */
-
-// Sent from Renderer process to the GPU process to notify that textures are
-// generated for a video frame.
-IPC_MESSAGE_ROUTED2(GpuVideoDecoderMsg_VideoFrameAllocated,
- int32, /* Video Frame ID */
- std::vector<uint32>) /* Textures for video frame */
-
-//------------------------------------------------------------------------------
-// GPU Video Decoder Host Messages
-// These messages are sent from GPU process to Renderer process.
-// Inform GpuVideoDecoderHost that a GpuVideoDecoder is created.
-IPC_MESSAGE_ROUTED1(GpuVideoDecoderHostMsg_CreateVideoDecoderDone,
- int32) /* decoder_id */
-
-// Confirm GpuVideoDecoder had been initialized or failed to initialize.
-// TODO(hclam): Change this to Done instead of ACK.
-IPC_MESSAGE_ROUTED1(GpuVideoDecoderHostMsg_InitializeACK,
- GpuVideoDecoderInitDoneParam)
-
-// Confrim GpuVideoDecoder had been destroyed properly.
-// TODO(hclam): Change this to Done instead of ACK.
-IPC_MESSAGE_ROUTED0(GpuVideoDecoderHostMsg_DestroyACK)
-
-// Confirm decoder had been flushed.
-// TODO(hclam): Change this to Done instead of ACK.
-IPC_MESSAGE_ROUTED0(GpuVideoDecoderHostMsg_FlushACK)
-
-// Confirm preroll operation is done.
-IPC_MESSAGE_ROUTED0(GpuVideoDecoderHostMsg_PrerollDone)
-
-// GpuVideoDecoder has consumed input buffer from transfer buffer.
-// TODO(hclam): Change this to Done instead of ACK.
-IPC_MESSAGE_ROUTED0(GpuVideoDecoderHostMsg_EmptyThisBufferACK)
-
-// GpuVideoDecoder require new input buffer.
-IPC_MESSAGE_ROUTED0(GpuVideoDecoderHostMsg_EmptyThisBufferDone)
-
-// GpuVideoDecoder reports that a video frame is ready to be consumed.
-IPC_MESSAGE_ROUTED4(GpuVideoDecoderHostMsg_ConsumeVideoFrame,
- int32, /* Video Frame ID */
- int64, /* Timestamp in microseconds */
- int64, /* Duration in microseconds */
- int32) /* Flags */
-
-// Allocate video frames for output of the hardware video decoder.
-IPC_MESSAGE_ROUTED4(GpuVideoDecoderHostMsg_AllocateVideoFrames,
- int32, /* Number of video frames to generate */
- uint32, /* Width of the video frame */
- uint32, /* Height of the video frame */
- int32 /* Format of the video frame */)
-
-// Release all video frames allocated for a hardware video decoder.
-IPC_MESSAGE_ROUTED0(GpuVideoDecoderHostMsg_ReleaseAllVideoFrames)
-
-// GpuVideoDecoder report output format change.
-IPC_MESSAGE_ROUTED1(GpuVideoDecoderHostMsg_MediaFormatChange,
- GpuVideoDecoderFormatChangeParam)
-
-// GpuVideoDecoder report error.
-IPC_MESSAGE_ROUTED1(GpuVideoDecoderHostMsg_ErrorNotification,
- GpuVideoDecoderErrorInfoParam)
-
// --------------------------------------------------------------------------
-// TranspotTexture messages
+// TransportTexture messages
//
// These are messages sent from renderer process to the GPU proess.
diff --git a/content/common/gpu/gpu_video_decoder.cc b/content/common/gpu/gpu_video_decoder.cc
deleted file mode 100644
index 651d34d..0000000
--- a/content/common/gpu/gpu_video_decoder.cc
+++ /dev/null
@@ -1,431 +0,0 @@
-// Copyright (c) 2011 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 "content/common/gpu/gpu_video_decoder.h"
-
-#include "base/command_line.h"
-#include "content/common/child_thread.h"
-#include "content/common/gpu/gpu_channel.h"
-#include "content/common/gpu/gpu_messages.h"
-#include "content/common/gpu/media/fake_gl_video_device.h"
-#include "content/common/gpu/media/fake_gl_video_decode_engine.h"
-#include "media/base/data_buffer.h"
-#include "media/base/media_switches.h"
-#include "media/base/video_frame.h"
-
-#if defined(OS_WIN)
-#include "content/common/gpu/media/mft_angle_video_device.h"
-#include "media/video/mft_h264_decode_engine.h"
-#include <d3d9.h>
-#endif
-
-struct GpuVideoDecoder::PendingAllocation {
- size_t n;
- size_t width;
- size_t height;
- media::VideoFrame::Format format;
- std::vector<scoped_refptr<media::VideoFrame> >* frames;
- Task* task;
-};
-
-void GpuVideoDecoder::OnChannelConnected(int32 peer_pid) {
-}
-
-void GpuVideoDecoder::OnChannelError() {
-}
-
-bool GpuVideoDecoder::OnMessageReceived(const IPC::Message& msg) {
- bool handled = true;
- IPC_BEGIN_MESSAGE_MAP(GpuVideoDecoder, msg)
- IPC_MESSAGE_HANDLER(GpuVideoDecoderMsg_Initialize,
- OnInitialize)
- IPC_MESSAGE_HANDLER(GpuVideoDecoderMsg_Destroy,
- OnUninitialize)
- IPC_MESSAGE_HANDLER(GpuVideoDecoderMsg_Flush,
- OnFlush)
- IPC_MESSAGE_HANDLER(GpuVideoDecoderMsg_Preroll,
- OnPreroll)
- IPC_MESSAGE_HANDLER(GpuVideoDecoderMsg_EmptyThisBuffer,
- OnEmptyThisBuffer)
- IPC_MESSAGE_HANDLER(GpuVideoDecoderMsg_ProduceVideoFrame,
- OnProduceVideoFrame)
- IPC_MESSAGE_HANDLER(GpuVideoDecoderMsg_VideoFrameAllocated,
- OnVideoFrameAllocated)
- IPC_MESSAGE_UNHANDLED(handled = false)
- IPC_END_MESSAGE_MAP()
- DCHECK(handled);
- return handled;
-}
-
-bool GpuVideoDecoder::CreateInputTransferBuffer(
- uint32 size,
- base::SharedMemoryHandle* handle) {
- input_transfer_buffer_.reset(new base::SharedMemory);
- if (!input_transfer_buffer_.get())
- return false;
-
- if (!input_transfer_buffer_->CreateAndMapAnonymous(size))
- return false;
-
- if (!input_transfer_buffer_->ShareToProcess(renderer_handle_, handle))
- return false;
-
- return true;
-}
-
-void GpuVideoDecoder::OnInitializeComplete(const VideoCodecInfo& info) {
- info_ = info;
- GpuVideoDecoderInitDoneParam param;
- param.success = false;
- param.input_buffer_handle = base::SharedMemory::NULLHandle();
-
- if (!info.success) {
- SendInitializeDone(param);
- return;
- }
-
- // TODO(jiesun): Check the assumption of input size < original size.
- param.input_buffer_size =
- info.stream_info.surface_width * info.stream_info.surface_height * 3 / 2;
- if (!CreateInputTransferBuffer(param.input_buffer_size,
- &param.input_buffer_handle)) {
- SendInitializeDone(param);
- return;
- }
-
- param.success = true;
- SendInitializeDone(param);
-}
-
-void GpuVideoDecoder::OnUninitializeComplete() {
- SendUninitializeDone();
-}
-
-void GpuVideoDecoder::OnFlushComplete() {
- SendFlushDone();
-}
-
-void GpuVideoDecoder::OnSeekComplete() {
- SendPrerollDone();
-}
-
-void GpuVideoDecoder::OnError() {
- NOTIMPLEMENTED();
-}
-
-void GpuVideoDecoder::OnFormatChange(VideoStreamInfo stream_info) {
- NOTIMPLEMENTED();
-}
-
-void GpuVideoDecoder::ProduceVideoSample(scoped_refptr<Buffer> buffer) {
- SendEmptyBufferDone();
-}
-
-void GpuVideoDecoder::ConsumeVideoFrame(scoped_refptr<VideoFrame> frame,
- const PipelineStatistics& statistics) {
- // TODO(sjl): Do something with the statistics...
-
- if (frame->IsEndOfStream()) {
- SendConsumeVideoFrame(0, 0, 0, kGpuVideoEndOfStream);
- return;
- }
-
- int32 frame_id = -1;
- for (VideoFrameMap::iterator i = video_frame_map_.begin();
- i != video_frame_map_.end(); ++i) {
- if (i->second == frame) {
- frame_id = i->first;
- break;
- }
- }
-
- if (frame_id == -1) {
- NOTREACHED() << "VideoFrame not recognized";
- return;
- }
-
- SendConsumeVideoFrame(frame_id, frame->GetTimestamp().InMicroseconds(),
- frame->GetDuration().InMicroseconds(), 0);
-}
-
-void* GpuVideoDecoder::GetDevice() {
- bool ret = gles2_decoder_->MakeCurrent();
- DCHECK(ret) << "Failed to switch context";
-
- // Simply delegate the method call to GpuVideoDevice.
- return video_device_->GetDevice();
-}
-
-void GpuVideoDecoder::AllocateVideoFrames(
- int n, size_t width, size_t height, media::VideoFrame::Format format,
- std::vector<scoped_refptr<media::VideoFrame> >* frames, Task* task) {
- // Since the communication between Renderer and GPU process is by GL textures.
- // We need to obtain a set of GL textures by sending IPC commands to the
- // Renderer process. The recipient of these commands will be IpcVideoDecoder.
- //
- // After IpcVideoDecoder replied with a set of textures. We'll assign these
- // textures to GpuVideoDevice. They will be used to generate platform
- // specific VideoFrames objects that are used by VideoDecodeEngine.
- //
- // After GL textures are assigned we'll proceed with allocation the
- // VideoFrames. GpuVideoDevice::CreateVideoFramesFromGlTextures() will be
- // called.
- //
- // When GpuVideoDevice replied with a set of VideoFrames we'll give
- // that to VideoDecodeEngine and the cycle of video frame allocation is done.
- //
- // Note that this method is called when there's no video frames allocated or
- // they were all released.
- DCHECK(video_frame_map_.empty());
-
- // Save the parameters for allocation.
- pending_allocation_.reset(new PendingAllocation());
- pending_allocation_->n = n;
- pending_allocation_->width = width;
- pending_allocation_->height = height;
- pending_allocation_->format = format;
- pending_allocation_->frames = frames;
- pending_allocation_->task = task;
- SendAllocateVideoFrames(n, width, height, format);
-}
-
-void GpuVideoDecoder::ReleaseAllVideoFrames() {
- // This method will first call to GpuVideoDevice to release all the resource
- // associated with a VideoFrame.
- //
- // And then we'll call GpuVideoDevice::ReleaseVideoFrame() to remove the set
- // of Gl textures associated with the context.
- //
- // And finally we'll send IPC commands to IpcVideoDecoder to destroy all
- // GL textures generated.
- bool ret = gles2_decoder_->MakeCurrent();
- DCHECK(ret) << "Failed to switch context";
-
- for (VideoFrameMap::iterator i = video_frame_map_.begin();
- i != video_frame_map_.end(); ++i) {
- video_device_->ReleaseVideoFrame(i->second);
- }
- video_frame_map_.clear();
- SendReleaseAllVideoFrames();
-}
-
-void GpuVideoDecoder::ConvertToVideoFrame(
- void* buffer,
- scoped_refptr<media::VideoFrame> frame,
- Task* task) {
- // This method is called by VideoDecodeEngine to upload a buffer to a
- // VideoFrame. We should just delegate this to GpuVideoDevice which contains
- // the actual implementation.
- bool ret = gles2_decoder_->MakeCurrent();
- DCHECK(ret) << "Failed to switch context";
-
- // Actually doing the upload on the main thread.
- ret = video_device_->ConvertToVideoFrame(buffer, frame);
- DCHECK(ret) << "Failed to upload video content to a VideoFrame.";
- task->Run();
- delete task;
-}
-
-void GpuVideoDecoder::Destroy(Task* task) {
- // TODO(hclam): I still need to think what I should do here.
-}
-
-void GpuVideoDecoder::SetVideoDecodeEngine(media::VideoDecodeEngine* engine) {
- decode_engine_.reset(engine);
-}
-
-void GpuVideoDecoder::SetGpuVideoDevice(GpuVideoDevice* device) {
- video_device_.reset(device);
-}
-
-GpuVideoDecoder::GpuVideoDecoder(
- MessageLoop* message_loop,
- int32 decoder_host_id,
- IPC::Message::Sender* sender,
- base::ProcessHandle handle,
- gpu::gles2::GLES2Decoder* decoder)
- : message_loop_(message_loop),
- decoder_host_id_(decoder_host_id),
- sender_(sender),
- renderer_handle_(handle),
- gles2_decoder_(decoder) {
- memset(&info_, 0, sizeof(info_));
-
- // TODO(jiesun): find a better way to determine which VideoDecodeEngine
- // to return on current platform.
-#if defined(OS_WIN)
- const CommandLine& command_line = *CommandLine::ForCurrentProcess();
- if (command_line.HasSwitch(switches::kEnableAcceleratedDecoding)) {
- // The following code are removed so that we don't link them.
- // TODO(hclam): Enable the code once the crash is solved on XP.
- // decode_engine_.reset(new media::MftH264DecodeEngine(true));
- // video_device_.reset(new MftAngleVideoDevice());
- }
-#else
- decode_engine_.reset(new FakeGlVideoDecodeEngine());
- video_device_.reset(new FakeGlVideoDevice());
-#endif
-}
-
-GpuVideoDecoder::~GpuVideoDecoder() {}
-
-void GpuVideoDecoder::OnInitialize(const GpuVideoDecoderInitParam& param) {
-
- // TODO(jiesun): codec id should come from |param|.
- // TODO(scottfr): surface dimensions should use aspect ratio from |param|.
- media::VideoDecoderConfig config(media::kCodecH264,
- param.width,
- param.height,
- param.width,
- param.height,
- param.frame_rate_num,
- param.frame_rate_den,
- NULL,
- 0);
- decode_engine_->Initialize(message_loop_, this, this, config);
-}
-
-void GpuVideoDecoder::OnUninitialize() {
- decode_engine_->Uninitialize();
-}
-
-void GpuVideoDecoder::OnFlush() {
- decode_engine_->Flush();
-}
-
-void GpuVideoDecoder::OnPreroll() {
- decode_engine_->Seek();
-}
-
-void GpuVideoDecoder::OnEmptyThisBuffer(
- const GpuVideoDecoderInputBufferParam& buffer) {
- DCHECK(input_transfer_buffer_->memory());
-
- uint8* src = static_cast<uint8*>(input_transfer_buffer_->memory());
-
- scoped_refptr<Buffer> input_buffer;
- uint8* dst = buffer.size ? new uint8[buffer.size] : NULL;
- input_buffer = new media::DataBuffer(dst, buffer.size);
- memcpy(dst, src, buffer.size);
- SendEmptyBufferACK();
-
- // Delegate the method call to VideoDecodeEngine.
- decode_engine_->ConsumeVideoSample(input_buffer);
-}
-
-void GpuVideoDecoder::OnProduceVideoFrame(int32 frame_id) {
- VideoFrameMap::iterator i = video_frame_map_.find(frame_id);
- if (i == video_frame_map_.end()) {
- NOTREACHED() << "Received a request of unknown frame ID.";
- }
-
- // Delegate the method call to VideoDecodeEngine.
- decode_engine_->ProduceVideoFrame(i->second);
-}
-
-void GpuVideoDecoder::OnVideoFrameAllocated(int32 frame_id,
- std::vector<uint32> textures) {
- bool ret = gles2_decoder_->MakeCurrent();
- DCHECK(ret) << "Failed to switch context";
-
- // This method is called in response to a video frame allocation request sent
- // to the Renderer process.
- // We should use the textures to generate a VideoFrame by using
- // GpuVideoDevice. The VideoFrame created is added to the internal map.
- // If we have generated enough VideoFrame, we call |allocation_callack_| to
- // complete the allocation process.
- for (size_t i = 0; i < textures.size(); ++i) {
- media::VideoFrame::GlTexture gl_texture;
- // Translate the client texture id to service texture id.
- ret = gles2_decoder_->GetServiceTextureId(textures[i], &gl_texture);
- DCHECK(ret) << "Cannot translate client texture ID to service ID";
- textures[i] = gl_texture;
- }
-
- // Use GpuVideoDevice to allocate VideoFrame objects.
- scoped_refptr<media::VideoFrame> frame;
-
- ret = video_device_->CreateVideoFrameFromGlTextures(
- pending_allocation_->width, pending_allocation_->height,
- pending_allocation_->format, textures, &frame);
-
- DCHECK(ret) << "Failed to allocation VideoFrame from GL textures)";
- pending_allocation_->frames->push_back(frame);
- video_frame_map_.insert(std::make_pair(frame_id, frame));
-
- if (video_frame_map_.size() == pending_allocation_->n) {
- pending_allocation_->task->Run();
- delete pending_allocation_->task;
- pending_allocation_.reset();
- }
-}
-
-void GpuVideoDecoder::SendInitializeDone(
- const GpuVideoDecoderInitDoneParam& param) {
- if (!sender_->Send(
- new GpuVideoDecoderHostMsg_InitializeACK(decoder_host_id(), param))) {
- LOG(ERROR) << "GpuVideoDecoderMsg_InitializeACK failed";
- }
-}
-
-void GpuVideoDecoder::SendUninitializeDone() {
- if (!sender_->Send(
- new GpuVideoDecoderHostMsg_DestroyACK(decoder_host_id()))) {
- LOG(ERROR) << "GpuVideoDecoderMsg_DestroyACK failed";
- }
-}
-
-void GpuVideoDecoder::SendFlushDone() {
- if (!sender_->Send(new GpuVideoDecoderHostMsg_FlushACK(decoder_host_id()))) {
- LOG(ERROR) << "GpuVideoDecoderMsg_FlushACK failed";
- }
-}
-
-void GpuVideoDecoder::SendPrerollDone() {
- if (!sender_->Send(new GpuVideoDecoderHostMsg_PrerollDone(
- decoder_host_id()))) {
- LOG(ERROR) << "GpuVideoDecoderMsg_PrerollDone failed";
- }
-}
-
-void GpuVideoDecoder::SendEmptyBufferDone() {
- if (!sender_->Send(
- new GpuVideoDecoderHostMsg_EmptyThisBufferDone(decoder_host_id()))) {
- LOG(ERROR) << "GpuVideoDecoderMsg_EmptyThisBufferDone failed";
- }
-}
-
-void GpuVideoDecoder::SendEmptyBufferACK() {
- if (!sender_->Send(
- new GpuVideoDecoderHostMsg_EmptyThisBufferACK(decoder_host_id()))) {
- LOG(ERROR) << "GpuVideoDecoderMsg_EmptyThisBufferACK failed";
- }
-}
-
-void GpuVideoDecoder::SendConsumeVideoFrame(
- int32 frame_id, int64 timestamp, int64 duration, int32 flags) {
- if (!sender_->Send(
- new GpuVideoDecoderHostMsg_ConsumeVideoFrame(
- decoder_host_id(), frame_id, timestamp, duration, flags))) {
- LOG(ERROR) << "GpuVideoDecodeHostMsg_ConsumeVideoFrame failed.";
- }
-}
-
-void GpuVideoDecoder::SendAllocateVideoFrames(
- int n, size_t width, size_t height, media::VideoFrame::Format format) {
- if (!sender_->Send(
- new GpuVideoDecoderHostMsg_AllocateVideoFrames(
- decoder_host_id(), n, width, height,
- static_cast<int32>(format)))) {
- LOG(ERROR) << "GpuVideoDecoderMsg_AllocateVideoFrames failed";
- }
-}
-
-void GpuVideoDecoder::SendReleaseAllVideoFrames() {
- if (!sender_->Send(
- new GpuVideoDecoderHostMsg_ReleaseAllVideoFrames(
- decoder_host_id()))) {
- LOG(ERROR) << "GpuVideoDecoderMsg_ReleaseAllVideoFrames failed";
- }
-}
diff --git a/content/common/gpu/gpu_video_decoder.h b/content/common/gpu/gpu_video_decoder.h
deleted file mode 100644
index 1f8ca6e..0000000
--- a/content/common/gpu/gpu_video_decoder.h
+++ /dev/null
@@ -1,209 +0,0 @@
-// Copyright (c) 2011 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 CONTENT_COMMON_GPU_GPU_VIDEO_DECODER_H_
-#define CONTENT_COMMON_GPU_GPU_VIDEO_DECODER_H_
-
-#include <map>
-#include <vector>
-
-#include "base/basictypes.h"
-#include "base/callback.h"
-#include "base/memory/ref_counted.h"
-#include "base/memory/scoped_ptr.h"
-#include "base/process.h"
-#include "base/shared_memory.h"
-#include "content/common/gpu/media/gpu_video_device.h"
-#include "media/video/video_decode_context.h"
-#include "media/video/video_decode_engine.h"
-#include "ipc/ipc_channel.h"
-
-using media::Buffer;
-using media::PipelineStatistics;
-using media::VideoDecoderConfig;
-using media::VideoCodecInfo;
-using media::VideoStreamInfo;
-using media::VideoFrame;
-
-namespace gpu {
-namespace gles2 {
-class GLES2Decoder;
-} // namespace gles2
-} // namespace gpu
-
-class GpuChannel;
-struct GpuVideoDecoderInitDoneParam;
-struct GpuVideoDecoderInitParam;
-struct GpuVideoDecoderInputBufferParam;
-
-// A GpuVideoDecoder is a platform independent video decoder that uses platform
-// specific VideoDecodeEngine and GpuVideoDevice for the actual decoding
-// operations.
-//
-// In addition to delegating video related commamnds to VideoDecodeEngine it
-// has the following important functions:
-//
-// BUFFER ALLOCATION
-//
-// VideoDecodeEngine requires platform specific video frame buffer to operate.
-// In order to abstract the platform specific bits GpuVideoDecoderContext is
-// used to allocate video frames that a VideoDecodeEngine can use.
-//
-// Since all the video frames appear to the Renderer process as textures, the
-// first thing GpuVideoDecoder needs to do is to ask Renderer process to
-// generate and allocate textures. This will establish a texture record in the
-// command buffer decoder. After the texture is allocated, this class will
-// pass the textures meaningful in the local GLES context to
-// GpuVideoDevice for generating VideoFrames that VideoDecodeEngine
-// can actually use.
-//
-// In order to coordinate these operations, GpuVideoDecoder implements
-// VideoDecodeContext and is injected into the VideoDecodeEngine.
-//
-// The sequence of operations is:
-// 1. VideoDecodeEngine requests by call AllocateVideoFrames().
-// 2. GpuVideoDecoder receives AllocateVideoFrames() and then call to the
-// Renderer process to generate textures.
-// 3. Renderer process replied with textures.
-// 4. Textures generated are passed into GpuVideoDevice.
-// 5. GpuVideoDevice::AllocateVideoFrames() is called to generate
-// VideoFrame(s) from the textures.
-// 6. GpuVideoDecoder sends the VideoFrame(s) generated to VideoDecodeEngine.
-//
-// BUFFER UPLOADING
-//
-// A VideoDecodeEngine always produces some device specific buffer. In order to
-// use them in Chrome we always upload them to GL textures. The upload step is
-// different on each platform and each subsystem. We perform these special
-// upload steps by using GpuVideoDevice which are written for each
-// VideoDecodeEngine.
-//
-// BUFFER MAPPING
-//
-// GpuVideoDecoder will be working with VideoDecodeEngine, they exchange
-// buffers that are only meaningful to VideoDecodeEngine. In order to map that
-// to something we can transport in the IPC channel we need a mapping between
-// VideoFrame and buffer ID known between GpuVideoDecoder and
-// GpuVideoDecoderHost in the Renderer process.
-//
-// After texture allocation and VideoFrame allocation are done, GpuVideoDecoder
-// will maintain such mapping.
-//
-class GpuVideoDecoder
- : public base::RefCountedThreadSafe<GpuVideoDecoder>,
- public IPC::Channel::Listener,
- public media::VideoDecodeEngine::EventHandler,
- public media::VideoDecodeContext {
- public:
- // Constructor and destructor.
- GpuVideoDecoder(MessageLoop* message_loop,
- int32 decoder_host_id,
- IPC::Message::Sender* sender,
- base::ProcessHandle handle,
- gpu::gles2::GLES2Decoder* decoder);
- virtual ~GpuVideoDecoder();
-
- // IPC::Channel::Listener implementation.
- virtual void OnChannelConnected(int32 peer_pid);
- virtual void OnChannelError();
- virtual bool OnMessageReceived(const IPC::Message& message);
-
- // VideoDecodeEngine::EventHandler implementation.
- virtual void OnInitializeComplete(const VideoCodecInfo& info);
- virtual void OnUninitializeComplete();
- virtual void OnFlushComplete();
- virtual void OnSeekComplete();
- virtual void OnError();
- virtual void OnFormatChange(VideoStreamInfo stream_info);
- virtual void ProduceVideoSample(scoped_refptr<Buffer> buffer);
- virtual void ConsumeVideoFrame(scoped_refptr<VideoFrame> frame,
- const PipelineStatistics& statistics);
-
- // VideoDecodeContext implementation.
- virtual void* GetDevice();
- virtual void AllocateVideoFrames(
- int n, size_t width, size_t height, media::VideoFrame::Format format,
- std::vector<scoped_refptr<media::VideoFrame> >* frames, Task* task);
- virtual void ReleaseAllVideoFrames();
- virtual void ConvertToVideoFrame(void* buffer,
- scoped_refptr<media::VideoFrame> frame,
- Task* task);
- virtual void Destroy(Task* task);
-
- // These methods are used in unit test only.
- void SetVideoDecodeEngine(media::VideoDecodeEngine* engine);
- void SetGpuVideoDevice(GpuVideoDevice* device);
-
- private:
- struct PendingAllocation;
-
- int32 decoder_host_id() { return decoder_host_id_; }
-
- bool CreateInputTransferBuffer(uint32 size,
- base::SharedMemoryHandle* handle);
-
- // These methods are message handlers for the messages sent from the Renderer
- // process.
- void OnInitialize(const GpuVideoDecoderInitParam& param);
- void OnUninitialize();
- void OnFlush();
- void OnPreroll();
- void OnEmptyThisBuffer(const GpuVideoDecoderInputBufferParam& buffer);
- void OnProduceVideoFrame(int32 frame_id);
- void OnVideoFrameAllocated(int32 frame_id, std::vector<uint32> textures);
-
- // Helper methods for sending messages to the Renderer process.
- void SendInitializeDone(const GpuVideoDecoderInitDoneParam& param);
- void SendUninitializeDone();
- void SendFlushDone();
- void SendPrerollDone();
- void SendEmptyBufferDone();
- void SendEmptyBufferACK();
- void SendConsumeVideoFrame(int32 frame_id, int64 timestamp, int64 duration,
- int32 flags);
- void SendAllocateVideoFrames(
- int n, size_t width, size_t height, media::VideoFrame::Format format);
- void SendReleaseAllVideoFrames();
-
- // The message loop that this object should run on.
- MessageLoop* message_loop_;
-
- // ID of GpuVideoDecoderHost in the Renderer Process.
- int32 decoder_host_id_;
-
- // Used only in system memory path. i.e. Remove this later.
- scoped_refptr<VideoFrame> frame_;
-
- IPC::Message::Sender* sender_;
- base::ProcessHandle renderer_handle_;
-
- // The GLES2 decoder has the context associated with this decoder. This object
- // is used to switch context and translate client texture ID to service ID.
- gpu::gles2::GLES2Decoder* gles2_decoder_;
-
- // Memory for transfering the input data for the hardware video decoder.
- scoped_ptr<base::SharedMemory> input_transfer_buffer_;
-
- // VideoDecodeEngine is used to do the actual video decoding.
- scoped_ptr<media::VideoDecodeEngine> decode_engine_;
-
- // GpuVideoDevice is used to generate VideoFrame(s) from GL textures. The
- // frames generated are understood by the decode engine.
- scoped_ptr<GpuVideoDevice> video_device_;
-
- // Contain information for allocation VideoFrame(s).
- scoped_ptr<PendingAllocation> pending_allocation_;
-
- // Contains the mapping between a |frame_id| and VideoFrame generated by
- // GpuVideoDevice from the associated GL textures.
- // TODO(hclam): Using a faster data structure than map.
- typedef std::map<int32, scoped_refptr<media::VideoFrame> > VideoFrameMap;
- VideoFrameMap video_frame_map_;
-
- media::VideoCodecInfo info_;
-
- DISALLOW_COPY_AND_ASSIGN(GpuVideoDecoder);
-};
-
-#endif // CONTENT_COMMON_GPU_GPU_VIDEO_DECODER_H_
diff --git a/content/common/gpu/gpu_video_decoder_unittest.cc b/content/common/gpu/gpu_video_decoder_unittest.cc
deleted file mode 100644
index 78e46cf..0000000
--- a/content/common/gpu/gpu_video_decoder_unittest.cc
+++ /dev/null
@@ -1,264 +0,0 @@
-// Copyright (c) 2011 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 "base/message_loop.h"
-#include "base/process.h"
-#include "content/common/gpu/gpu_messages.h"
-#include "content/common/gpu/gpu_video_decoder.h"
-#include "gpu/command_buffer/service/gles2_cmd_decoder_mock.h"
-#include "ipc/ipc_message_utils.h"
-#include "media/base/pipeline.h"
-#include "media/video/video_mock_objects.h"
-#include "testing/gtest/include/gtest/gtest.h"
-
-using testing::_;
-using testing::DoAll;
-using testing::NotNull;
-using testing::Return;
-using testing::SetArgumentPointee;
-
-static const int32 kFrameId = 10;
-static const int32 kDecoderHostId = 50;
-static const media::VideoFrame::GlTexture kClientTexture = 101;
-static const media::VideoFrame::GlTexture kServiceTexture = 102;
-static const size_t kWidth = 320;
-static const size_t kHeight = 240;
-
-class MockGpuVideoDevice : public GpuVideoDevice {
- public:
- MockGpuVideoDevice() {}
- virtual ~MockGpuVideoDevice() {}
-
- MOCK_METHOD0(GetDevice, void*());
- MOCK_METHOD5(CreateVideoFrameFromGlTextures,
- bool(size_t, size_t, media::VideoFrame::Format,
- const std::vector<media::VideoFrame::GlTexture>&,
- scoped_refptr<media::VideoFrame>*));
- MOCK_METHOD1(ReleaseVideoFrame,
- void(const scoped_refptr<media::VideoFrame>& frame));
- MOCK_METHOD2(ConvertToVideoFrame,
- bool(void* buffer, scoped_refptr<media::VideoFrame> frame));
-
- private:
- DISALLOW_COPY_AND_ASSIGN(MockGpuVideoDevice);
-};
-
-ACTION_P(InitializationDone, handler) {
- media::VideoCodecInfo info;
- info.success = true;
- info.provides_buffers = false;
- info.stream_info.surface_format = media::VideoFrame::RGBA;
- info.stream_info.surface_type = media::VideoFrame::TYPE_SYSTEM_MEMORY;
- info.stream_info.surface_width = kWidth;
- info.stream_info.surface_height = kHeight;
- handler->OnInitializeComplete(info);
-}
-
-ACTION_P(SendVideoFrameAllocated, handler) {
- std::vector<media::VideoFrame::GlTexture> textures;
- textures.push_back(kClientTexture);
- GpuVideoDecoderMsg_VideoFrameAllocated msg(0, kFrameId, textures);
- handler->OnMessageReceived(msg);
-}
-
-ACTION_P2(SendConsumeVideoFrame, handler, frame) {
- media::PipelineStatistics statistics;
- handler->ConsumeVideoFrame(frame, statistics);
-}
-
-class GpuVideoDecoderTest : public testing::Test,
- public IPC::Message::Sender {
- public:
- GpuVideoDecoderTest() {
- // Create the mock objects.
- gles2_decoder_.reset(new gpu::gles2::MockGLES2Decoder());
-
- gpu_video_decoder_ = new GpuVideoDecoder(
- &message_loop_, kDecoderHostId, this, base::kNullProcessHandle,
- gles2_decoder_.get());
-
- // Create the mock objects.
- mock_engine_ = new media::MockVideoDecodeEngine();
- mock_device_ = new MockGpuVideoDevice();
-
- // Inject the mock objects.
- gpu_video_decoder_->SetVideoDecodeEngine(mock_engine_);
- gpu_video_decoder_->SetGpuVideoDevice(mock_device_);
-
- // VideoFrame for GpuVideoDevice.
- media::VideoFrame::GlTexture textures[] = { kServiceTexture, 0, 0 };
- media::VideoFrame::CreateFrameGlTexture(media::VideoFrame::RGBA,
- kWidth, kHeight, textures,
- &device_frame_);
- }
-
- virtual ~GpuVideoDecoderTest() {
- gpu_video_decoder_->SetVideoDecodeEngine(NULL);
- gpu_video_decoder_->SetGpuVideoDevice(NULL);
- }
-
- // This method is used to dispatch IPC messages to mock methods.
- virtual bool Send(IPC::Message* msg) {
- EXPECT_TRUE(msg);
- if (!msg)
- return false;
-
- bool handled = true;
- IPC_BEGIN_MESSAGE_MAP(GpuVideoDecoderTest, *msg)
- IPC_MESSAGE_HANDLER(GpuVideoDecoderHostMsg_InitializeACK,
- OnInitializeDone)
- IPC_MESSAGE_HANDLER(GpuVideoDecoderHostMsg_DestroyACK,
- OnUninitializeDone)
- IPC_MESSAGE_HANDLER(GpuVideoDecoderHostMsg_FlushACK,
- OnFlushDone)
- IPC_MESSAGE_HANDLER(GpuVideoDecoderHostMsg_EmptyThisBufferACK,
- OnEmptyThisBufferACK)
- IPC_MESSAGE_HANDLER(GpuVideoDecoderHostMsg_EmptyThisBufferDone,
- OnEmptyThisBufferDone)
- IPC_MESSAGE_HANDLER(GpuVideoDecoderHostMsg_AllocateVideoFrames,
- OnAllocateVideoFrames)
- IPC_MESSAGE_HANDLER(GpuVideoDecoderHostMsg_ReleaseAllVideoFrames,
- OnReleaseAllVideoFrames)
- IPC_MESSAGE_HANDLER(GpuVideoDecoderHostMsg_ConsumeVideoFrame,
- OnConsumeVideoFrame)
- IPC_MESSAGE_UNHANDLED_ERROR()
- IPC_END_MESSAGE_MAP()
- EXPECT_TRUE(handled);
- delete msg;
- return true;
- }
-
- // Mock methods for handling output IPC messages.
- MOCK_METHOD1(OnInitializeDone,
- void(const GpuVideoDecoderInitDoneParam& param));
- MOCK_METHOD0(OnUninitializeDone, void());
- MOCK_METHOD0(OnFlushDone, void());
- MOCK_METHOD0(OnEmptyThisBufferDone, void());
- MOCK_METHOD4(OnConsumeVideoFrame, void(int32 device_frame_id, int64 timestamp,
- int64 duration, int32 flags));
- MOCK_METHOD0(OnEmptyThisBufferACK, void());
- MOCK_METHOD4(OnAllocateVideoFrames, void(int32 n, uint32 width,
- uint32 height, int32 format));
- MOCK_METHOD0(OnReleaseAllVideoFrames, void());
-
- // Receive events from GpuVideoDecoder.
- MOCK_METHOD0(VideoFramesAllocated, void());
-
- void Initialize() {
- // VideoDecodeEngine is called.
- EXPECT_CALL(*mock_engine_, Initialize(_, _, _, _))
- .WillOnce(InitializationDone(gpu_video_decoder_));
-
- // Expect that initialization is completed.
- EXPECT_CALL(*this, OnInitializeDone(_));
-
- // Send an initialiaze message to GpuVideoDecoder.
- GpuVideoDecoderInitParam param;
- param.width = kWidth;
- param.height = kHeight;
-
- GpuVideoDecoderMsg_Initialize msg(0, param);
- gpu_video_decoder_->OnMessageReceived(msg);
- }
-
- void AllocateVideoFrames() {
- // Expect that IPC messages are sent. We'll reply with some GL textures.
- EXPECT_CALL(*this, OnAllocateVideoFrames(
- 1, kWidth, kHeight, static_cast<int32>(media::VideoFrame::RGBA)))
- .WillOnce(SendVideoFrameAllocated(gpu_video_decoder_));
-
- // Expect that MakeCurrent() is called.
- EXPECT_CALL(*gles2_decoder_.get(), MakeCurrent())
- .WillOnce(Return(true))
- .RetiresOnSaturation();
-
- // Expect that translate method is called.
- EXPECT_CALL(*gles2_decoder_.get(),
- GetServiceTextureId(kClientTexture, NotNull()))
- .WillOnce(DoAll(SetArgumentPointee<1>(kServiceTexture), Return(true)));
-
- // And then GpuVideoDevice is called to create VideoFrame from GL textures.
- EXPECT_CALL(*mock_device_,
- CreateVideoFrameFromGlTextures(kWidth, kHeight,
- media::VideoFrame::RGBA, _,
- NotNull()))
- .WillOnce(DoAll(SetArgumentPointee<4>(device_frame_), Return(true)));
-
- // Finally the task is called.
- EXPECT_CALL(*this, VideoFramesAllocated());
-
- // Pretend calling GpuVideoDecoder for allocating frames.
- gpu_video_decoder_->AllocateVideoFrames(
- 1, kWidth, kHeight, media::VideoFrame::RGBA, &decoder_frames_,
- NewRunnableMethod(this, &GpuVideoDecoderTest::VideoFramesAllocated));
- }
-
- void ReleaseVideoFrames() {
- // Expect that MakeCurrent() is called.
- EXPECT_CALL(*gles2_decoder_.get(), MakeCurrent())
- .WillOnce(Return(true))
- .RetiresOnSaturation();
-
- // Expect that video frame is released.
- EXPECT_CALL(*mock_device_, ReleaseVideoFrame(device_frame_));
-
- // Expect that IPC message is send to release video frame.
- EXPECT_CALL(*this, OnReleaseAllVideoFrames());
-
- // Call to GpuVideoDecoder to release all video frames.
- gpu_video_decoder_->ReleaseAllVideoFrames();
- }
-
- void BufferExchange() {
- // Expect that we call to produce video frame.
- EXPECT_CALL(*mock_engine_, ProduceVideoFrame(device_frame_))
- .WillOnce(SendConsumeVideoFrame(gpu_video_decoder_, device_frame_))
- .RetiresOnSaturation();
-
- // Expect that consume video frame is called.
- EXPECT_CALL(*this, OnConsumeVideoFrame(kFrameId, 0, 0, 0))
- .RetiresOnSaturation();
-
- // Ask the GpuVideoDecoder to produce a video frame.
- GpuVideoDecoderMsg_ProduceVideoFrame msg(0, kFrameId);
- gpu_video_decoder_->OnMessageReceived(msg);
- }
-
- private:
- scoped_refptr<GpuVideoDecoder> gpu_video_decoder_;
- MockGpuVideoDevice* mock_device_;
- media::MockVideoDecodeEngine* mock_engine_;
- scoped_ptr<gpu::gles2::MockGLES2Decoder> gles2_decoder_;
- std::vector<scoped_refptr<media::VideoFrame> > decoder_frames_;
- scoped_refptr<media::VideoFrame> device_frame_;
-
- MessageLoop message_loop_;
-
- DISALLOW_COPY_AND_ASSIGN(GpuVideoDecoderTest);
-};
-
-TEST_F(GpuVideoDecoderTest, Initialize) {
- Initialize();
-}
-
-TEST_F(GpuVideoDecoderTest, AllocateVideoFrames) {
- Initialize();
- AllocateVideoFrames();
-}
-
-TEST_F(GpuVideoDecoderTest, ReleaseVideoFrames) {
- Initialize();
- AllocateVideoFrames();
- ReleaseVideoFrames();
-}
-
-TEST_F(GpuVideoDecoderTest, BufferExchange) {
- Initialize();
- AllocateVideoFrames();
- BufferExchange();
- BufferExchange();
- ReleaseVideoFrames();
-}
-
-DISABLE_RUNNABLE_METHOD_REFCOUNT(GpuVideoDecoderTest);
diff --git a/content/common/gpu/media/fake_gl_video_decode_engine.cc b/content/common/gpu/media/fake_gl_video_decode_engine.cc
deleted file mode 100644
index 4380c7f..0000000
--- a/content/common/gpu/media/fake_gl_video_decode_engine.cc
+++ /dev/null
@@ -1,132 +0,0 @@
-// Copyright (c) 2011 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 "content/common/gpu/media/fake_gl_video_decode_engine.h"
-
-#include "media/base/limits.h"
-#include "media/base/video_frame.h"
-#include "media/video/video_decode_context.h"
-
-FakeGlVideoDecodeEngine::FakeGlVideoDecodeEngine()
- : width_(0),
- height_(0),
- handler_(NULL),
- context_(NULL) {
-}
-
-FakeGlVideoDecodeEngine::~FakeGlVideoDecodeEngine() {
-}
-
-void FakeGlVideoDecodeEngine::Initialize(
- MessageLoop* message_loop,
- media::VideoDecodeEngine::EventHandler* event_handler,
- media::VideoDecodeContext* context,
- const media::VideoDecoderConfig& 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.
- // TODO(hclam): It is horrible to use constants everywhere in the code!
- // The number of frames come from VideoRendererBase in the renderer, this is
- // horrible!
- context_->AllocateVideoFrames(
- media::Limits::kMaxVideoFrames, width_, height_, media::VideoFrame::RGBA,
- &external_frames_,
- NewRunnableMethod(this,
- &FakeGlVideoDecodeEngine::AllocationCompleteTask));
-}
-
-void FakeGlVideoDecodeEngine::AllocationCompleteTask() {
- DCHECK(media::Limits::kMaxVideoFrames == external_frames_.size());
- DCHECK_EQ(media::VideoFrame::TYPE_GL_TEXTURE, external_frames_[0]->type());
-
- 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_;
- handler_->OnInitializeComplete(info);
-}
-
-void FakeGlVideoDecodeEngine::Uninitialize() {
- handler_->OnUninitializeComplete();
-}
-
-void FakeGlVideoDecodeEngine::Flush() {
- handler_->OnFlushComplete();
-}
-
-void FakeGlVideoDecodeEngine::Seek() {
- // TODO(hclam): This is a big hack to continue playing because we need to
- // *push* decoded frames to downstream. The model used in VideoRendererBase
- // to wait for *push* is flawed.
- for (size_t i = 0; i < external_frames_.size(); ++i)
- handler_->ConsumeVideoFrame(external_frames_[i], dummy_stats_);
- handler_->OnSeekComplete();
-}
-
-void FakeGlVideoDecodeEngine::ConsumeVideoSample(
- scoped_refptr<media::Buffer> sample) {
- DCHECK(!pending_frames_.empty());
- scoped_refptr<media::VideoFrame> frame = pending_frames_.front();
- pending_frames_.pop();
-
- frame->SetDuration(sample->GetDuration());
- frame->SetTimestamp(sample->GetTimestamp());
-
- // Generate a pattern to the internal frame and then uploads it.
- int size = width_ * height_ * 4;
- scoped_array<uint8> buffer(new uint8[size]);
- memset(buffer.get(), 255, size);
-
- uint8* row = internal_frame_->data(media::VideoFrame::kRGBPlane);
- 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 + 1] = seed++;
- seed &= 255;
- }
- row += width_ * 4;
- }
- ++seed;
-
- // After we have filled the content upload the internal frame to the
- // VideoFrame allocated through VideoDecodeContext.
- context_->ConvertToVideoFrame(
- internal_frame_, frame,
- NewRunnableMethod(this, &FakeGlVideoDecodeEngine::UploadCompleteTask,
- frame));
-}
-
-void FakeGlVideoDecodeEngine::ProduceVideoFrame(
- scoped_refptr<media::VideoFrame> frame) {
- // Enqueue the frame to the pending queue.
- pending_frames_.push(frame);
-
- // Fake that we need some buffer.
- handler_->ProduceVideoSample(NULL);
-}
-
-void FakeGlVideoDecodeEngine::UploadCompleteTask(
- scoped_refptr<media::VideoFrame> frame) {
- // |frame| is the upload target. We can immediately send this frame out.
- handler_->ConsumeVideoFrame(frame, dummy_stats_);
-}
-
-DISABLE_RUNNABLE_METHOD_REFCOUNT(FakeGlVideoDecodeEngine);
diff --git a/content/common/gpu/media/fake_gl_video_decode_engine.h b/content/common/gpu/media/fake_gl_video_decode_engine.h
deleted file mode 100644
index e3630fe..0000000
--- a/content/common/gpu/media/fake_gl_video_decode_engine.h
+++ /dev/null
@@ -1,68 +0,0 @@
-// Copyright (c) 2011 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 CONTENT_GPU_MEDIA_FAKE_GL_VIDEO_DECODE_ENGINE_H_
-#define CONTENT_GPU_MEDIA_FAKE_GL_VIDEO_DECODE_ENGINE_H_
-
-#include <queue>
-#include <vector>
-
-#include "base/memory/scoped_ptr.h"
-#include "media/base/pipeline.h"
-#include "media/video/video_decode_engine.h"
-
-namespace media {
-class VideoDecodeContext;
-class VideoFrame;
-} // namespace media
-
-class FakeGlVideoDecodeEngine : public media::VideoDecodeEngine {
- public:
- FakeGlVideoDecodeEngine();
- virtual ~FakeGlVideoDecodeEngine();
-
- virtual void Initialize(
- MessageLoop* message_loop,
- media::VideoDecodeEngine::EventHandler* event_handler,
- media::VideoDecodeContext* context,
- const media::VideoDecoderConfig& 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:
- // 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_;
-
- // These are the video frames that are waiting for input buffer to generate
- // fake pattern in them.
- std::queue<scoped_refptr<media::VideoFrame> > pending_frames_;
-
- // Dummy statistics.
- media::PipelineStatistics dummy_stats_;
-
- DISALLOW_COPY_AND_ASSIGN(FakeGlVideoDecodeEngine);
-};
-
-#endif // CONTENT_GPU_MEDIA_FAKE_GL_VIDEO_DECODE_ENGINE_H_
diff --git a/content/common/gpu/media/fake_gl_video_device.cc b/content/common/gpu/media/fake_gl_video_device.cc
deleted file mode 100644
index 172b701..0000000
--- a/content/common/gpu/media/fake_gl_video_device.cc
+++ /dev/null
@@ -1,58 +0,0 @@
-// Copyright (c) 2011 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 "content/common/gpu/media/fake_gl_video_device.h"
-
-#include "media/base/video_frame.h"
-#include "ui/gfx/gl/gl_bindings.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,
- 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::ConvertToVideoFrame(
- 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/content/common/gpu/media/fake_gl_video_device.h b/content/common/gpu/media/fake_gl_video_device.h
deleted file mode 100644
index 4f5233b..0000000
--- a/content/common/gpu/media/fake_gl_video_device.h
+++ /dev/null
@@ -1,27 +0,0 @@
-// Copyright (c) 2011 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 CONTENT_GPU_MEDIA_FAKE_GL_VIDEO_DEVICE_H_
-#define CONTENT_GPU_MEDIA_FAKE_GL_VIDEO_DEVICE_H_
-
-#include "content/common/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 ConvertToVideoFrame(void* buffer,
- scoped_refptr<media::VideoFrame> frame);
-};
-
-#endif // CONTENT_GPU_MEDIA_FAKE_GL_VIDEO_DEVICE_H_
diff --git a/content/common/gpu/media/gpu_video_device.h b/content/common/gpu/media/gpu_video_device.h
deleted file mode 100644
index dcba5f2..0000000
--- a/content/common/gpu/media/gpu_video_device.h
+++ /dev/null
@@ -1,56 +0,0 @@
-// Copyright (c) 2011 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 CONTENT_GPU_MEDIA_GPU_VIDEO_DEVICE_H_
-#define CONTENT_GPU_MEDIA_GPU_VIDEO_DEVICE_H_
-
-#include <vector>
-
-#include "media/base/video_frame.h"
-#include "media/video/video_decode_context.h"
-
-// A GpuVideoDevice is used by GpuVideoDecoder to allocate video frames
-// meaningful to a corresponding VideoDecodeEngine.
-//
-// GpuVideoDecoder will provide a set of GL textures to this class and then
-// GpuVideoDevice will transform the textures into a set of VideoFrame
-// objects that can be used by VideoDecodeEngine.
-//
-// See text in GpuVideoDecoder for the overall flow for buffer allocation.
-//
-// Since all graphics commands execute on the main thread in the GPU process
-// all the methods provided by this class are synchronous.
-class GpuVideoDevice {
- public:
- virtual ~GpuVideoDevice() {}
-
- // Get the hardware video decoding device handle.
- virtual void* GetDevice() = 0;
-
- // The following method is used by GpuVideoDecoder to create VideoFrame(s)
- // associated with some GL textures.
- //
- // VideoFrame generated is used by VideoDecodeEngine for output buffer.
- //
- // |frame| will contain the VideoFrame 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,
- 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.
- virtual bool ConvertToVideoFrame(void* buffer,
- scoped_refptr<media::VideoFrame> frame) = 0;
-};
-
-#endif // CONTENT_GPU_MEDIA_GPU_VIDEO_DEVICE_H_
diff --git a/content/content_common.gypi b/content/content_common.gypi
index d38eeca..f4da646 100644
--- a/content/content_common.gypi
+++ b/content/content_common.gypi
@@ -130,11 +130,6 @@
'common/gpu/gpu_video_service.cc',
'common/gpu/gpu_video_service.h',
'common/gpu/gpu_watchdog.h',
- 'common/gpu/media/gpu_video_device.h',
- 'common/gpu/media/fake_gl_video_decode_engine.cc',
- 'common/gpu/media/fake_gl_video_decode_engine.h',
- 'common/gpu/media/fake_gl_video_device.cc',
- 'common/gpu/media/fake_gl_video_device.h',
'common/gpu/transport_texture.cc',
'common/gpu/transport_texture.h',
'common/hi_res_timer_manager_posix.cc',
diff --git a/content/content_renderer.gypi b/content/content_renderer.gypi
index ebc1f99..ea36f3e 100644
--- a/content/content_renderer.gypi
+++ b/content/content_renderer.gypi
@@ -66,10 +66,6 @@
'renderer/load_progress_tracker.h',
'renderer/media/audio_renderer_impl.cc',
'renderer/media/audio_renderer_impl.h',
- 'renderer/media/gles2_video_decode_context.cc',
- 'renderer/media/gles2_video_decode_context.h',
- 'renderer/media/ipc_video_decoder.cc',
- 'renderer/media/ipc_video_decoder.h',
'renderer/media/video_capture_impl.cc',
'renderer/media/video_capture_impl.h',
'renderer/media/video_capture_impl_manager.cc',
diff --git a/content/renderer/gpu/gpu_video_decoder_host.cc b/content/renderer/gpu/gpu_video_decoder_host.cc
deleted file mode 100644
index 0451960..0000000
--- a/content/renderer/gpu/gpu_video_decoder_host.cc
+++ /dev/null
@@ -1,401 +0,0 @@
-// Copyright (c) 2011 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 "content/renderer/gpu/gpu_video_decoder_host.h"
-
-#include "content/common/gpu/gpu_messages.h"
-#include "content/common/message_router.h"
-#include "media/base/pipeline.h"
-#include "media/video/video_decode_context.h"
-
-GpuVideoDecoderHost::GpuVideoDecoderHost(MessageRouter* router,
- IPC::Message::Sender* ipc_sender,
- int context_route_id,
- int32 decoder_host_id)
- : router_(router),
- ipc_sender_(ipc_sender),
- context_route_id_(context_route_id),
- message_loop_(NULL),
- event_handler_(NULL),
- context_(NULL),
- width_(0),
- height_(0),
- state_(kStateUninitialized),
- decoder_host_id_(decoder_host_id),
- decoder_id_(0),
- input_buffer_busy_(false),
- current_frame_id_(0) {
-}
-
-GpuVideoDecoderHost::~GpuVideoDecoderHost() {}
-
-void GpuVideoDecoderHost::OnChannelError() {
- ipc_sender_ = NULL;
-}
-
-bool GpuVideoDecoderHost::OnMessageReceived(const IPC::Message& msg) {
- bool handled = true;
- IPC_BEGIN_MESSAGE_MAP(GpuVideoDecoderHost, msg)
- IPC_MESSAGE_HANDLER(GpuVideoDecoderHostMsg_CreateVideoDecoderDone,
- OnCreateVideoDecoderDone)
- IPC_MESSAGE_HANDLER(GpuVideoDecoderHostMsg_InitializeACK,
- OnInitializeDone)
- IPC_MESSAGE_HANDLER(GpuVideoDecoderHostMsg_DestroyACK,
- OnUninitializeDone)
- IPC_MESSAGE_HANDLER(GpuVideoDecoderHostMsg_FlushACK,
- OnFlushDone)
- IPC_MESSAGE_HANDLER(GpuVideoDecoderHostMsg_PrerollDone,
- OnPrerollDone)
- IPC_MESSAGE_HANDLER(GpuVideoDecoderHostMsg_EmptyThisBufferACK,
- OnEmptyThisBufferACK)
- IPC_MESSAGE_HANDLER(GpuVideoDecoderHostMsg_EmptyThisBufferDone,
- OnProduceVideoSample)
- IPC_MESSAGE_HANDLER(GpuVideoDecoderHostMsg_ConsumeVideoFrame,
- OnConsumeVideoFrame)
- IPC_MESSAGE_HANDLER(GpuVideoDecoderHostMsg_AllocateVideoFrames,
- OnAllocateVideoFrames)
- IPC_MESSAGE_HANDLER(GpuVideoDecoderHostMsg_ReleaseAllVideoFrames,
- OnReleaseAllVideoFrames)
- IPC_MESSAGE_UNHANDLED(handled = false)
- IPC_END_MESSAGE_MAP()
- DCHECK(handled);
- return handled;
-}
-
-void GpuVideoDecoderHost::Initialize(
- MessageLoop* message_loop,
- VideoDecodeEngine::EventHandler* event_handler,
- media::VideoDecodeContext* context,
- const media::VideoDecoderConfig& config) {
- DCHECK_EQ(kStateUninitialized, state_);
- DCHECK(!message_loop_);
- message_loop_ = message_loop;
- event_handler_ = event_handler;
- context_ = context;
- width_ = config.width();
- height_ = config.height();
-
- if (MessageLoop::current() != message_loop) {
- message_loop->PostTask(
- FROM_HERE,
- NewRunnableMethod(this, &GpuVideoDecoderHost::CreateVideoDecoder));
- return;
- }
- CreateVideoDecoder();
-}
-
-void GpuVideoDecoderHost::ConsumeVideoSample(scoped_refptr<Buffer> buffer) {
- if (MessageLoop::current() != message_loop_) {
- message_loop_->PostTask(
- FROM_HERE,
- NewRunnableMethod(
- this, &GpuVideoDecoderHost::ConsumeVideoSample, buffer));
- return;
- }
-
- DCHECK_NE(state_, kStateUninitialized);
- DCHECK_NE(state_, kStateFlushing);
-
- // We never own input buffers, therefore when client in flush state, it
- // never call us with EmptyThisBuffer.
- if (state_ != kStateNormal)
- return;
-
- input_buffer_queue_.push_back(buffer);
- SendConsumeVideoSample();
-}
-
-void GpuVideoDecoderHost::ProduceVideoFrame(scoped_refptr<VideoFrame> frame) {
- if (MessageLoop::current() != message_loop_) {
- message_loop_->PostTask(
- FROM_HERE,
- NewRunnableMethod(
- this, &GpuVideoDecoderHost::ProduceVideoFrame, frame));
- return;
- }
-
- DCHECK_NE(state_, kStateUninitialized);
-
- // During flush client of this object will call this method to return all
- // video frames. We should only ignore such method calls if we are in error
- // state.
- if (state_ == kStateError)
- return;
-
- // Check that video frame is valid.
- if (!frame || frame->format() == media::VideoFrame::EMPTY ||
- frame->IsEndOfStream()) {
- return;
- }
-
- SendProduceVideoFrame(frame);
-}
-
-void GpuVideoDecoderHost::Uninitialize() {
- if (MessageLoop::current() != message_loop_) {
- message_loop_->PostTask(
- FROM_HERE,
- NewRunnableMethod(this, &GpuVideoDecoderHost::Uninitialize));
- return;
- }
-
- if (!ipc_sender_->Send(new GpuVideoDecoderMsg_Destroy(decoder_id_))) {
- LOG(ERROR) << "GpuVideoDecoderMsg_Destroy failed";
- event_handler_->OnError();
- }
-}
-
-void GpuVideoDecoderHost::Flush() {
- if (MessageLoop::current() != message_loop_) {
- message_loop_->PostTask(
- FROM_HERE, NewRunnableMethod(this, &GpuVideoDecoderHost::Flush));
- return;
- }
-
- state_ = kStateFlushing;
- if (!ipc_sender_->Send(new GpuVideoDecoderMsg_Flush(decoder_id_))) {
- LOG(ERROR) << "GpuVideoDecoderMsg_Flush failed";
- event_handler_->OnError();
- return;
- }
-
- input_buffer_queue_.clear();
- // TODO(jiesun): because GpuVideoDeocder/GpuVideoDecoder are asynchronously.
- // We need a way to make flush logic more clear. but I think ring buffer
- // should make the busy flag obsolete, therefore I will leave it for now.
- input_buffer_busy_ = false;
-}
-
-void GpuVideoDecoderHost::Seek() {
- if (MessageLoop::current() != message_loop_) {
- message_loop_->PostTask(
- FROM_HERE, NewRunnableMethod(this, &GpuVideoDecoderHost::Seek));
- return;
- }
-
- if (!ipc_sender_->Send(new GpuVideoDecoderMsg_Preroll(decoder_id_))) {
- LOG(ERROR) << "GpuVideoDecoderMsg_Preroll failed";
- event_handler_->OnError();
- return;
- }
-}
-
-void GpuVideoDecoderHost::CreateVideoDecoder() {
- DCHECK_EQ(message_loop_, MessageLoop::current());
-
- // Add the route so we'll receive messages.
- router_->AddRoute(decoder_host_id_, this);
-
- if (!ipc_sender_->Send(
- new GpuChannelMsg_CreateVideoDecoder(context_route_id_,
- decoder_host_id_))) {
- LOG(ERROR) << "GpuChannelMsg_CreateVideoDecoder failed";
- event_handler_->OnError();
- return;
- }
-}
-
-void GpuVideoDecoderHost::OnCreateVideoDecoderDone(int32 decoder_id) {
- DCHECK_EQ(message_loop_, MessageLoop::current());
- decoder_id_ = decoder_id;
-
- // TODO(hclam): Initialize |param| with the right values.
- GpuVideoDecoderInitParam param;
- param.width = width_;
- param.height = height_;
-
- if (!ipc_sender_->Send(
- new GpuVideoDecoderMsg_Initialize(decoder_id, param))) {
- LOG(ERROR) << "GpuVideoDecoderMsg_Initialize failed";
- event_handler_->OnError();
- }
-}
-
-void GpuVideoDecoderHost::OnInitializeDone(
- const GpuVideoDecoderInitDoneParam& param) {
- DCHECK_EQ(message_loop_, MessageLoop::current());
-
- bool success = param.success &&
- base::SharedMemory::IsHandleValid(param.input_buffer_handle);
-
- if (success) {
- input_transfer_buffer_.reset(
- new base::SharedMemory(param.input_buffer_handle, false));
- success = input_transfer_buffer_->Map(param.input_buffer_size);
- }
- state_ = success ? kStateNormal : kStateError;
-
- // TODO(hclam): There's too many unnecessary copies for width and height!
- // Need to clean it up.
- // TODO(hclam): Need to fill in more information.
- media::VideoCodecInfo info;
- info.success = success;
- info.stream_info.surface_width = width_;
- info.stream_info.surface_height = height_;
- event_handler_->OnInitializeComplete(info);
-}
-
-void GpuVideoDecoderHost::OnUninitializeDone() {
- DCHECK_EQ(message_loop_, MessageLoop::current());
-
- input_transfer_buffer_.reset();
- router_->RemoveRoute(decoder_host_id_);
- context_->ReleaseAllVideoFrames();
- event_handler_->OnUninitializeComplete();
-}
-
-void GpuVideoDecoderHost::OnFlushDone() {
- DCHECK_EQ(message_loop_, MessageLoop::current());
-
- state_ = kStateNormal;
- event_handler_->OnFlushComplete();
-}
-
-void GpuVideoDecoderHost::OnPrerollDone() {
- DCHECK_EQ(message_loop_, MessageLoop::current());
-
- state_ = kStateNormal;
- event_handler_->OnSeekComplete();
-}
-
-void GpuVideoDecoderHost::OnEmptyThisBufferACK() {
- DCHECK_EQ(message_loop_, MessageLoop::current());
-
- input_buffer_busy_ = false;
- SendConsumeVideoSample();
-}
-
-void GpuVideoDecoderHost::OnProduceVideoSample() {
- DCHECK_EQ(message_loop_, MessageLoop::current());
- DCHECK_EQ(kStateNormal, state_);
-
- event_handler_->ProduceVideoSample(NULL);
-}
-
-void GpuVideoDecoderHost::OnConsumeVideoFrame(int32 frame_id, int64 timestamp,
- int64 duration, int32 flags) {
- DCHECK_EQ(message_loop_, MessageLoop::current());
-
- scoped_refptr<VideoFrame> frame;
- if (flags & kGpuVideoEndOfStream) {
- VideoFrame::CreateEmptyFrame(&frame);
- } else {
- frame = video_frame_map_[frame_id];
- DCHECK(frame) << "Invalid frame ID received";
-
- frame->SetDuration(base::TimeDelta::FromMicroseconds(duration));
- frame->SetTimestamp(base::TimeDelta::FromMicroseconds(timestamp));
- }
-
- media::PipelineStatistics statistics;
- // TODO(sjl): Fill in statistics.
-
- event_handler_->ConsumeVideoFrame(frame, statistics);
-}
-
-void GpuVideoDecoderHost::OnAllocateVideoFrames(
- int32 n, uint32 width, uint32 height, int32 format) {
- DCHECK_EQ(message_loop_, MessageLoop::current());
- DCHECK_EQ(0u, video_frames_.size());
-
- context_->AllocateVideoFrames(
- n, width, height, static_cast<media::VideoFrame::Format>(format),
- &video_frames_,
- NewRunnableMethod(this,
- &GpuVideoDecoderHost::OnAllocateVideoFramesDone));
-}
-
-void GpuVideoDecoderHost::OnReleaseAllVideoFrames() {
- DCHECK_EQ(message_loop_, MessageLoop::current());
-
- context_->ReleaseAllVideoFrames();
- video_frame_map_.clear();
- video_frames_.clear();
-}
-
-void GpuVideoDecoderHost::OnAllocateVideoFramesDone() {
- if (MessageLoop::current() != message_loop_) {
- message_loop_->PostTask(
- FROM_HERE,
- NewRunnableMethod(
- this, &GpuVideoDecoderHost::OnAllocateVideoFramesDone));
- return;
- }
-
- // After video frame allocation is done we add these frames to a map and
- // send them to the GPU process.
- DCHECK(video_frames_.size()) << "No video frames allocated";
- for (size_t i = 0; i < video_frames_.size(); ++i) {
- DCHECK(video_frames_[i]);
- video_frame_map_.insert(
- std::make_pair(current_frame_id_, video_frames_[i]));
- SendVideoFrameAllocated(current_frame_id_, video_frames_[i]);
- ++current_frame_id_;
- }
-}
-
-void GpuVideoDecoderHost::SendVideoFrameAllocated(
- int32 frame_id, scoped_refptr<media::VideoFrame> frame) {
- DCHECK_EQ(message_loop_, MessageLoop::current());
-
- std::vector<uint32> textures;
- for (size_t i = 0; i < frame->planes(); ++i) {
- textures.push_back(frame->gl_texture(i));
- }
-
- if (!ipc_sender_->Send(new GpuVideoDecoderMsg_VideoFrameAllocated(
- decoder_id_, frame_id, textures))) {
- LOG(ERROR) << "GpuVideoDecoderMsg_EmptyThisBuffer failed";
- }
-}
-
-void GpuVideoDecoderHost::SendConsumeVideoSample() {
- DCHECK_EQ(message_loop_, MessageLoop::current());
-
- if (input_buffer_busy_ || input_buffer_queue_.empty())
- return;
- input_buffer_busy_ = true;
-
- scoped_refptr<Buffer> buffer = input_buffer_queue_.front();
- input_buffer_queue_.pop_front();
-
- // Send input data to GPU process.
- GpuVideoDecoderInputBufferParam param;
- param.offset = 0;
- param.size = buffer->GetDataSize();
- param.timestamp = buffer->GetTimestamp().InMicroseconds();
- memcpy(input_transfer_buffer_->memory(), buffer->GetData(), param.size);
-
- if (!ipc_sender_->Send(
- new GpuVideoDecoderMsg_EmptyThisBuffer(decoder_id_, param))) {
- LOG(ERROR) << "GpuVideoDecoderMsg_EmptyThisBuffer failed";
- }
-}
-
-void GpuVideoDecoderHost::SendProduceVideoFrame(
- scoped_refptr<media::VideoFrame> frame) {
- DCHECK_EQ(message_loop_, MessageLoop::current());
-
- // TODO(hclam): I should mark a frame being used to DCHECK and make sure
- // user doesn't use it the second time.
- // TODO(hclam): Derive a faster way to lookup the frame ID.
- bool found = false;
- int32 frame_id = 0;
- for (VideoFrameMap::iterator i = video_frame_map_.begin();
- i != video_frame_map_.end(); ++i) {
- if (frame == i->second) {
- frame_id = i->first;
- found = true;
- break;
- }
- }
-
- DCHECK(found) << "Invalid video frame received";
- if (found && !ipc_sender_->Send(
- new GpuVideoDecoderMsg_ProduceVideoFrame(decoder_id_, frame_id))) {
- LOG(ERROR) << "GpuVideoDecoderMsg_ProduceVideoFrame failed";
- }
-}
-
-DISABLE_RUNNABLE_METHOD_REFCOUNT(GpuVideoDecoderHost);
diff --git a/content/renderer/gpu/gpu_video_decoder_host.h b/content/renderer/gpu/gpu_video_decoder_host.h
deleted file mode 100644
index cfd42b9..0000000
--- a/content/renderer/gpu/gpu_video_decoder_host.h
+++ /dev/null
@@ -1,165 +0,0 @@
-// Copyright (c) 2011 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 CONTENT_RENDERER_GPU_GPU_VIDEO_DECODER_HOST_H_
-#define CONTENT_RENDERER_GPU_GPU_VIDEO_DECODER_HOST_H_
-
-#include <deque>
-#include <map>
-
-#include "base/memory/singleton.h"
-#include "base/shared_memory.h"
-#include "content/renderer/gpu/gpu_channel_host.h"
-#include "media/base/buffers.h"
-#include "media/base/video_frame.h"
-#include "media/video/video_decode_engine.h"
-
-using media::VideoFrame;
-using media::Buffer;
-
-class MessageRouter;
-struct GpuVideoDecoderInitDoneParam;
-
-// This class is used to talk to GpuVideoDecoder in the GPU process through
-// IPC messages. It implements the interface of VideoDecodeEngine so users
-// view it as a regular video decode engine, the implementation is a portal
-// to the GPU process.
-//
-// THREAD SEMANTICS
-//
-// All methods of this class can be accessed on any thread. A message loop
-// needs to be provided to class through Initialize() for accessing the
-// IPC channel. Event handlers are called on that message loop.
-//
-// Since this class is not refcounted, it is important to delete this
-// object only after OnUninitializeCompelte() is called.
-class GpuVideoDecoderHost : public media::VideoDecodeEngine,
- public IPC::Channel::Listener {
- public:
- // |router| is used to dispatch IPC messages to this object.
- // |ipc_sender| is used to send IPC messages to GPU process.
- // It is important that the above two objects are accessed on the
- // |message_loop_|.
- GpuVideoDecoderHost(MessageRouter* router,
- IPC::Message::Sender* ipc_sender,
- int context_route_id,
- int32 decoder_host_id);
- virtual ~GpuVideoDecoderHost();
-
- // IPC::Channel::Listener.
- virtual void OnChannelConnected(int32 peer_pid) {}
- virtual void OnChannelError();
- virtual bool OnMessageReceived(const IPC::Message& message);
-
- // media::VideoDecodeEngine implementation.
- virtual void Initialize(MessageLoop* message_loop,
- VideoDecodeEngine::EventHandler* event_handler,
- media::VideoDecodeContext* context,
- const media::VideoDecoderConfig& config);
- virtual void ConsumeVideoSample(scoped_refptr<Buffer> buffer);
- virtual void ProduceVideoFrame(scoped_refptr<VideoFrame> frame);
- virtual void Uninitialize();
- virtual void Flush();
- virtual void Seek();
-
- private:
- typedef std::map<int32, scoped_refptr<media::VideoFrame> > VideoFrameMap;
-
- // Internal states.
- enum GpuVideoDecoderHostState {
- kStateUninitialized,
- kStateNormal,
- kStateError,
- kStateFlushing,
- };
-
- // Takes care of sending IPC message to create a video decoder.
- void CreateVideoDecoder();
-
- // Handlers for messages received from the GPU process.
- void OnCreateVideoDecoderDone(int32 decoder_id);
- void OnInitializeDone(const GpuVideoDecoderInitDoneParam& param);
- void OnUninitializeDone();
- void OnFlushDone();
- void OnPrerollDone();
- void OnEmptyThisBufferACK();
- void OnProduceVideoSample();
- void OnConsumeVideoFrame(int32 frame_id, int64 timestamp,
- int64 duration, int32 flags);
- void OnAllocateVideoFrames(int32 n, uint32 width,
- uint32 height, int32 format);
- void OnReleaseAllVideoFrames();
-
- // Handler for VideoDecodeContext. This method is called when video frames
- // allocation is done.
- void OnAllocateVideoFramesDone();
-
- // Send a message to the GPU process to inform that a video frame is
- // allocated.
- void SendVideoFrameAllocated(int32 frame_id,
- scoped_refptr<media::VideoFrame> frame);
-
- // Send a video sample to the GPU process and tell it to use the buffer for
- // video decoding.
- void SendConsumeVideoSample();
-
- // Look up the frame_id for |frame| and send a message to the GPU process
- // to use that video frame to produce an output.
- void SendProduceVideoFrame(scoped_refptr<media::VideoFrame> frame);
-
- // A router used to send us IPC messages.
- MessageRouter* router_;
-
- // Sends IPC messages to the GPU process.
- IPC::Message::Sender* ipc_sender_;
-
- // Route ID of the GLES2 context in the GPU process.
- int context_route_id_;
-
- // Message loop that this object runs on.
- MessageLoop* message_loop_;
-
- // We expect that the client of us will always available during our life span.
- EventHandler* event_handler_;
-
- // A Context for allocating video frame textures.
- media::VideoDecodeContext* context_;
-
- // Dimensions of the video.
- int width_;
- int height_;
-
- // Current state of video decoder.
- GpuVideoDecoderHostState state_;
-
- // ID of this GpuVideoDecoderHost.
- int32 decoder_host_id_;
-
- // ID of GpuVideoDecoder in the GPU process.
- int32 decoder_id_;
-
- // We are not able to push all received buffer to gpu process at once.
- std::deque<scoped_refptr<Buffer> > input_buffer_queue_;
-
- // Currently we do not use ring buffer in input buffer, therefore before
- // GPU process had finished access it, we should not touch it.
- bool input_buffer_busy_;
-
- // Transfer buffers for both input and output.
- // TODO(jiesun): remove output buffer when hardware composition is ready.
- scoped_ptr<base::SharedMemory> input_transfer_buffer_;
-
- // Frame ID for the newly generated video frame.
- int32 current_frame_id_;
-
- // The list of video frames allocated by VideoDecodeContext.
- std::vector<scoped_refptr<media::VideoFrame> > video_frames_;
-
- // The mapping between video frame ID and a video frame.
- VideoFrameMap video_frame_map_;
-
- DISALLOW_COPY_AND_ASSIGN(GpuVideoDecoderHost);
-};
-
-#endif // CONTENT_RENDERER_GPU_GPU_VIDEO_DECODER_HOST_H_
diff --git a/content/renderer/gpu/gpu_video_service_host.cc b/content/renderer/gpu/gpu_video_service_host.cc
index 2e7a39e..0c629f8 100644
--- a/content/renderer/gpu/gpu_video_service_host.cc
+++ b/content/renderer/gpu/gpu_video_service_host.cc
@@ -70,12 +70,6 @@ void GpuVideoServiceHost::SetOnInitialized(
on_initialized.Run();
}
-GpuVideoDecoderHost* GpuVideoServiceHost::CreateVideoDecoder(
- int context_route_id) {
- // TODO(vrk): Delete all references to GpuVideoDecoder (deprecated).
- return NULL;
-}
-
GpuVideoDecodeAcceleratorHost* GpuVideoServiceHost::CreateVideoAccelerator(
media::VideoDecodeAccelerator::Client* client) {
base::AutoLock auto_lock(lock_);
diff --git a/content/renderer/gpu/gpu_video_service_host.h b/content/renderer/gpu/gpu_video_service_host.h
index 7049d1c..be3e44b 100644
--- a/content/renderer/gpu/gpu_video_service_host.h
+++ b/content/renderer/gpu/gpu_video_service_host.h
@@ -7,7 +7,6 @@
#include "base/memory/singleton.h"
#include "content/renderer/gpu/gpu_channel_host.h"
-#include "content/renderer/gpu/gpu_video_decoder_host.h"
#include "ipc/ipc_channel.h"
#include "media/base/buffers.h"
#include "media/base/video_frame.h"
@@ -37,21 +36,6 @@ class GpuVideoServiceHost : public IPC::ChannelProxy::MessageFilter {
// Called on RenderThread to create a hardware accelerated video decoder
// in the GPU process.
- //
- // A routing ID for the GLES2 context needs to be provided when creating a
- // hardware video decoder. This is important because the resources used by
- // the video decoder needs to be shared with the GLES2 context corresponding
- // to the RenderView.
- //
- // This means that a GPU video decoder is tied to a specific RenderView and
- // its GLES2 context in the GPU process.
- //
- // Returns a GpuVideoDecoderHost as a handle to control the video decoder.
- //
- // Note: OnFilterAdded() MUST be called before these methods are called,
- // because they require |channel_| to be non-NULL.
- GpuVideoDecoderHost* CreateVideoDecoder(int context_route_id);
-
GpuVideoDecodeAcceleratorHost* CreateVideoAccelerator(
media::VideoDecodeAccelerator::Client* client);
diff --git a/content/renderer/gpu/renderer_gl_context.cc b/content/renderer/gpu/renderer_gl_context.cc
index 91e4dfc..88d79c2 100644
--- a/content/renderer/gpu/renderer_gl_context.cc
+++ b/content/renderer/gpu/renderer_gl_context.cc
@@ -17,7 +17,6 @@
#include "content/renderer/gpu/gpu_video_service_host.h"
#include "content/renderer/gpu/transport_texture_host.h"
#include "content/renderer/gpu/transport_texture_service.h"
-#include "content/renderer/media/gles2_video_decode_context.h"
#include "content/renderer/render_thread.h"
#include "content/renderer/render_widget.h"
#include "googleurl/src/gurl.h"
@@ -305,16 +304,6 @@ bool RendererGLContext::SwapBuffers() {
return true;
}
-media::VideoDecodeEngine* RendererGLContext::CreateVideoDecodeEngine() {
- return channel_->gpu_video_service_host()->CreateVideoDecoder(
- command_buffer_->route_id());
-}
-
-media::VideoDecodeContext* RendererGLContext::CreateVideoDecodeContext(
- MessageLoop* message_loop, bool hardware_decoder) {
- return new Gles2VideoDecodeContext(message_loop, hardware_decoder, this);
-}
-
scoped_refptr<TransportTextureHost>
RendererGLContext::CreateTransportTextureHost() {
return channel_->transport_texture_service()->CreateTransportTextureHost(
diff --git a/content/renderer/gpu/renderer_gl_context.h b/content/renderer/gpu/renderer_gl_context.h
index 6b255cc..3798892 100644
--- a/content/renderer/gpu/renderer_gl_context.h
+++ b/content/renderer/gpu/renderer_gl_context.h
@@ -31,12 +31,6 @@ class GLES2Implementation;
}
}
-namespace media {
-class VideoDecodeContext;
-class VideoDecodeEngine;
-class VideoDecodeRendererGLContext;
-}
-
class RendererGLContext : public base::SupportsWeakPtr<RendererGLContext> {
public:
// These are the same error codes as used by EGL.
@@ -154,19 +148,6 @@ class RendererGLContext : public base::SupportsWeakPtr<RendererGLContext> {
// by the parent RendererGLContext.
bool SwapBuffers();
- // Create a hardware video decode engine corresponding to the
- // RendererGLContext.
- media::VideoDecodeEngine* CreateVideoDecodeEngine();
-
- // Create a hardware video decode RendererGLContext to pair with the hardware
- // video decode engine. It can also be used with a software decode engine.
- //
- // Set |hardware_decoder| to true if this RendererGLContext is for a hardware
- // video engine. |message_loop| is where the decode RendererGLContext should
- // run on.
- media::VideoDecodeContext* CreateVideoDecodeContext(MessageLoop* message_loop,
- bool hardware_decoder);
-
// Create a TransportTextureHost object associated with the context.
scoped_refptr<TransportTextureHost> CreateTransportTextureHost();
diff --git a/content/renderer/gpu/transport_texture_service.h b/content/renderer/gpu/transport_texture_service.h
index 0822ef1..96f5101 100644
--- a/content/renderer/gpu/transport_texture_service.h
+++ b/content/renderer/gpu/transport_texture_service.h
@@ -10,7 +10,6 @@
#include "base/memory/ref_counted.h"
#include "content/renderer/gpu/gpu_channel_host.h"
-#include "content/renderer/gpu/gpu_video_decoder_host.h"
#include "ipc/ipc_channel.h"
#include "media/base/buffers.h"
#include "media/base/video_frame.h"
diff --git a/content/renderer/media/gles2_video_decode_context.cc b/content/renderer/media/gles2_video_decode_context.cc
deleted file mode 100644
index 8b74e23..0000000
--- a/content/renderer/media/gles2_video_decode_context.cc
+++ /dev/null
@@ -1,122 +0,0 @@
-// Copyright (c) 2011 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 <GLES2/gl2.h>
-
-#include "base/message_loop.h"
-#include "content/renderer/gpu/renderer_gl_context.h"
-#include "content/renderer/media/gles2_video_decode_context.h"
-
-Gles2VideoDecodeContext::Gles2VideoDecodeContext(
- MessageLoop* message_loop, bool memory_mapped, RendererGLContext* context)
- : message_loop_(message_loop),
- memory_mapped_(memory_mapped),
- context_(context) {
-}
-
-Gles2VideoDecodeContext::~Gles2VideoDecodeContext() {
-}
-
-void* Gles2VideoDecodeContext::GetDevice() {
- // This decode context is used inside the renderer and so hardware decoder
- // device handler should not be used.
- return NULL;
-}
-
-void Gles2VideoDecodeContext::AllocateVideoFrames(
- int num_frames, size_t width, size_t height,
- media::VideoFrame::Format format,
- std::vector<scoped_refptr<media::VideoFrame> >* frames_out, Task* task) {
- if (MessageLoop::current() != message_loop_) {
- message_loop_->PostTask(
- FROM_HERE,
- NewRunnableMethod(this, &Gles2VideoDecodeContext::AllocateVideoFrames,
- num_frames, width, height, format, frames_out,
- task));
- return;
- }
-
- // In this method we need to make the context current and then generate
- // textures for each video frame. We also need to allocate memory for each
- // texture generated.
- bool ret = RendererGLContext::MakeCurrent(context_);
- CHECK(ret) << "Failed to switch context";
-
- frames_.resize(num_frames);
- for (int i = 0; i < num_frames; ++i) {
- int planes = media::VideoFrame::GetNumberOfPlanes(format);
- media::VideoFrame::GlTexture textures[media::VideoFrame::kMaxPlanes];
-
- // Set the color format of the textures.
- DCHECK(format == media::VideoFrame::RGBA ||
- format == media::VideoFrame::YV12);
- int gl_format = format == media::VideoFrame::RGBA ? GL_RGBA : GL_LUMINANCE;
-
- glGenTextures(planes, textures);
- for (int j = 0; j < planes; ++j) {
- glBindTexture(GL_TEXTURE_2D, textures[j]);
- glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
- glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
- glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
- glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
- glTexImage2D(GL_TEXTURE_2D, 0, gl_format, width, height, 0, gl_format,
- GL_UNSIGNED_BYTE, NULL);
- }
- glFlush();
-
- scoped_refptr<media::VideoFrame> frame;
- media::VideoFrame::CreateFrameGlTexture(format, width, height, textures,
- &frame);
- frames_[i] = frame;
- }
- *frames_out = frames_;
-
- task->Run();
- delete task;
-}
-
-void Gles2VideoDecodeContext::ReleaseAllVideoFrames() {
- if (MessageLoop::current() != message_loop_) {
- message_loop_->PostTask(
- FROM_HERE,
- NewRunnableMethod(this,
- &Gles2VideoDecodeContext::ReleaseAllVideoFrames));
- return;
- }
-
- // Make the context current and then release the video frames.
- bool ret = RendererGLContext::MakeCurrent(context_);
- CHECK(ret) << "Failed to switch context";
-
- for (size_t i = 0; i < frames_.size(); ++i) {
- for (size_t j = 0; j < frames_[i]->planes(); ++j) {
- media::VideoFrame::GlTexture texture = frames_[i]->gl_texture(j);
- glDeleteTextures(1, &texture);
- }
- }
- frames_.clear();
-}
-
-void Gles2VideoDecodeContext::ConvertToVideoFrame(
- void* buffer, scoped_refptr<media::VideoFrame> frame, Task* task) {
- DCHECK(memory_mapped_);
- // TODO(hclam): Implement.
-}
-
-void Gles2VideoDecodeContext::Destroy(Task* task) {
- if (MessageLoop::current() != message_loop_) {
- message_loop_->PostTask(
- FROM_HERE,
- NewRunnableMethod(this, &Gles2VideoDecodeContext::Destroy, task));
- return;
- }
-
- ReleaseAllVideoFrames();
- DCHECK_EQ(0u, frames_.size());
-
- task->Run();
- delete task;
-}
-
-DISABLE_RUNNABLE_METHOD_REFCOUNT(Gles2VideoDecodeContext);
diff --git a/content/renderer/media/gles2_video_decode_context.h b/content/renderer/media/gles2_video_decode_context.h
deleted file mode 100644
index 70b7f71..0000000
--- a/content/renderer/media/gles2_video_decode_context.h
+++ /dev/null
@@ -1,112 +0,0 @@
-// Copyright (c) 2011 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 CONTENT_RENDERER_MEDIA_GLES2_VIDEO_DECODE_CONTEXT_H_
-#define CONTENT_RENDERER_MEDIA_GLES2_VIDEO_DECODE_CONTEXT_H_
-
-#include <vector>
-
-#include "media/video/video_decode_context.h"
-
-class MessageLoop;
-class RendererGLContext;
-
-// FUNCTIONS
-//
-// This is a class that provides a video decode context using a
-// RendererGLContext backend.
-//
-// It provides resources for a VideoDecodeEngine to store decoded video frames.
-//
-// This class is aware of the command buffer implementation of GLES2 inside the
-// Chrome renderer and keeps a reference of RendererGLContext. It might use
-// GLES2 commands specific to Chrome's renderer process to provide needed
-// resources.
-//
-// There are two different kinds of video frame storage provided by this class:
-// 1. Memory mapped textures (aka software decoding mode).
-// Each texture is memory mapped and appears to the VideoDecodeEngine as
-// system memory.
-//
-// The usage of the textures is that the VideoDecodeEngine is performing
-// software video decoding and use them as if they are allocated in plain
-// system memory (in fact they are allocated in system memory and shared
-// bwith the GPU process). An additional step of uploading the content to
-// video memory is needed. Since VideoDecodeEngine is unaware of the video
-// memory, this upload operation is performed by calling
-// ConvertToVideoFrame().
-//
-// After the content is uploaded to video memory, WebKit will see the video
-// frame as textures and will perform the necessary operations for
-// rendering.
-//
-// 2. Opaque textures (aka hardware decoding mode).
-// In this mode of operation each video frame is backed by some opaque
-// textures. This is used only when hardware video decoding is used. The
-// textures needs to be generated and allocated inside the renderer process
-// first. This will establish a translation between texture ID in the
-// renderer process and the GPU process.
-//
-// The texture ID generated is used by IpcVideoDecodeEngine only to be sent
-// the GPU process. Inside the GPU process the texture ID is translated to
-// a real texture ID inside the actual context. The real texture ID is then
-// assigned to the hardware video decoder for storing the video frame.
-//
-// WebKit will see the video frame as a normal textures and perform
-// necessary render operations.
-//
-// In both operation modes, the objective is to have WebKit see the video frames
-// as regular textures.
-//
-// THREAD SEMANTICS
-//
-// All methods of this class can be called on any thread. GLES2 context and all
-// OpenGL method calls are accessed on the Render Thread. As as result all Tasks
-// given to this object are executed on the Render Thread.
-//
-// Since this class is not refcounted, it is important to destroy objects of
-// this class only when the Task given to Destroy() is called.
-//
-class Gles2VideoDecodeContext : public media::VideoDecodeContext {
- public:
- // |message_loop| is the message of the Render Thread.
- // |memory_mapped| determines if textures allocated are memory mapped.
- // |context| is the graphics context for generating textures.
- Gles2VideoDecodeContext(MessageLoop* message_loop,
- bool memory_mapped,
- RendererGLContext* context);
- virtual ~Gles2VideoDecodeContext();
-
- // media::VideoDecodeContext implementation.
- virtual void* GetDevice();
- virtual void AllocateVideoFrames(
- int frames_num, size_t width, size_t height,
- media::VideoFrame::Format format,
- std::vector<scoped_refptr<media::VideoFrame> >* frames_out, Task* task);
- virtual void ReleaseAllVideoFrames();
- virtual void ConvertToVideoFrame(void* buffer,
- scoped_refptr<media::VideoFrame> frame,
- Task* task);
- virtual void Destroy(Task* task);
-
- // Accessor of the current mode of this decode context.
- bool IsMemoryMapped() const { return memory_mapped_; }
-
- private:
- // Message loop for Render Thread.
- MessageLoop* message_loop_;
-
- // Type of storage provided by this class.
- bool memory_mapped_;
-
- // Pointer to the GLES2 context.
- RendererGLContext* context_;
-
- // VideoFrames allocated.
- std::vector<scoped_refptr<media::VideoFrame> > frames_;
-
- DISALLOW_COPY_AND_ASSIGN(Gles2VideoDecodeContext);
-};
-
-#endif // CONTENT_RENDERER_MEDIA_GLES2_VIDEO_DECODE_CONTEXT_H_
diff --git a/content/renderer/media/ipc_video_decoder.cc b/content/renderer/media/ipc_video_decoder.cc
deleted file mode 100644
index 7f71312..0000000
--- a/content/renderer/media/ipc_video_decoder.cc
+++ /dev/null
@@ -1,207 +0,0 @@
-// Copyright (c) 2011 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 "content/renderer/media/ipc_video_decoder.h"
-
-#include "base/task.h"
-#include "content/common/child_process.h"
-#include "content/renderer/gpu/renderer_gl_context.h"
-#include "media/base/callback.h"
-#include "media/base/filters.h"
-#include "media/base/filter_host.h"
-#include "media/base/limits.h"
-#include "media/base/media_format.h"
-#include "media/base/video_frame.h"
-#include "media/ffmpeg/ffmpeg_common.h"
-#include "media/video/video_decode_engine.h"
-
-IpcVideoDecoder::IpcVideoDecoder(MessageLoop* message_loop,
- RendererGLContext* gl_context)
- : decode_context_message_loop_(message_loop),
- gl_context_(gl_context) {
-}
-
-IpcVideoDecoder::~IpcVideoDecoder() {
-}
-
-void IpcVideoDecoder::Initialize(media::DemuxerStream* demuxer_stream,
- media::FilterCallback* callback,
- media::StatisticsCallback* statsCallback) {
- // It doesn't matter which thread we perform initialization because
- // all this method does is create objects and delegate the initialize
- // messsage.
-
- DCHECK(!demuxer_stream_);
- demuxer_stream_ = demuxer_stream;
- initialize_callback_.reset(callback);
- statistics_callback_.reset(statsCallback);
-
- // We require bit stream converter for hardware decoder.
- demuxer_stream->EnableBitstreamConverter();
-
- AVStream* av_stream = demuxer_stream->GetAVStream();
- if (!av_stream) {
- media::VideoCodecInfo info = {0};
- OnInitializeComplete(info);
- return;
- }
-
- int width = av_stream->codec->coded_width;
- int height = av_stream->codec->coded_height;
-
- int surface_width = media::GetSurfaceWidth(av_stream);
- int surface_height = media::GetSurfaceHeight(av_stream);
-
- if (surface_width > media::Limits::kMaxDimension ||
- surface_height > media::Limits::kMaxDimension ||
- (surface_width * surface_height) > media::Limits::kMaxCanvas) {
- media::VideoCodecInfo info = {0};
- OnInitializeComplete(info);
- return;
- }
-
- // Create a video decode context that assocates with the graphics
- // context.
- decode_context_.reset(
- gl_context_->CreateVideoDecodeContext(
- decode_context_message_loop_, true));
-
- // Create a hardware video decoder handle.
- decode_engine_.reset(gl_context_->CreateVideoDecodeEngine());
-
- media::VideoDecoderConfig config(
- media::CodecIDToVideoCodec(av_stream->codec->codec_id),
- width, height,
- surface_width, surface_height,
- av_stream->r_frame_rate.num,
- av_stream->r_frame_rate.den,
- av_stream->codec->extradata,
- av_stream->codec->extradata_size);
-
- // VideoDecodeEngine will perform initialization on the message loop
- // given to it so it doesn't matter on which thread we are calling this.
- decode_engine_->Initialize(ChildProcess::current()->io_message_loop(), this,
- decode_context_.get(), config);
-}
-
-const media::MediaFormat& IpcVideoDecoder::media_format() {
- return media_format_;
-}
-
-void IpcVideoDecoder::Stop(media::FilterCallback* callback) {
- stop_callback_.reset(callback);
- decode_engine_->Uninitialize();
-}
-
-void IpcVideoDecoder::Pause(media::FilterCallback* callback) {
- // TODO(hclam): It looks like that pause is not necessary so implement this
- // later.
- callback->Run();
- delete callback;
-}
-
-void IpcVideoDecoder::Flush(media::FilterCallback* callback) {
- flush_callback_.reset(callback);
- decode_engine_->Flush();
-}
-
-void IpcVideoDecoder::Seek(base::TimeDelta time,
- const media::FilterStatusCB& cb) {
- seek_cb_ = cb;
- decode_engine_->Seek();
-}
-
-void IpcVideoDecoder::OnInitializeComplete(const media::VideoCodecInfo& info) {
- DCHECK_EQ(ChildProcess::current()->io_message_loop(), MessageLoop::current());
-
- if (info.success) {
- media_format_.SetAsInteger(media::MediaFormat::kSurfaceType,
- media::VideoFrame::TYPE_GL_TEXTURE);
- media_format_.SetAsInteger(media::MediaFormat::kSurfaceFormat,
- info.stream_info.surface_format);
- media_format_.SetAsInteger(media::MediaFormat::kWidth,
- info.stream_info.surface_width);
- media_format_.SetAsInteger(media::MediaFormat::kHeight,
- info.stream_info.surface_height);
- media_format_.SetAsInteger(
- media::MediaFormat::kSurfaceType,
- static_cast<int>(media::VideoFrame::TYPE_GL_TEXTURE));
- } else {
- LOG(ERROR) << "IpcVideoDecoder initialization failed!";
- host()->SetError(media::PIPELINE_ERROR_DECODE);
- }
-
- initialize_callback_->Run();
- initialize_callback_.reset();
-}
-
-void IpcVideoDecoder::OnUninitializeComplete() {
- DCHECK_EQ(ChildProcess::current()->io_message_loop(), MessageLoop::current());
-
- // After the decode engine is uninitialized we are safe to destroy the decode
- // context. The task will add a refcount to this object so don't need to worry
- // about objects lifetime.
- decode_context_->Destroy(
- NewRunnableMethod(this, &IpcVideoDecoder::OnDestroyComplete));
-
- // We don't need to wait for destruction of decode context to complete because
- // it can happen asynchronously. This object and decode context will live
- // until the destruction task is called.
- stop_callback_->Run();
- stop_callback_.reset();
-}
-
-void IpcVideoDecoder::OnFlushComplete() {
- DCHECK_EQ(ChildProcess::current()->io_message_loop(), MessageLoop::current());
- flush_callback_->Run();
- flush_callback_.reset();
-}
-
-void IpcVideoDecoder::OnSeekComplete() {
- DCHECK_EQ(ChildProcess::current()->io_message_loop(), MessageLoop::current());
- ResetAndRunCB(&seek_cb_, media::PIPELINE_OK);
-}
-
-void IpcVideoDecoder::OnError() {
- DCHECK_EQ(ChildProcess::current()->io_message_loop(), MessageLoop::current());
- host()->SetError(media::PIPELINE_ERROR_DECODE);
-}
-
-// This methid is called by Demuxer after a demuxed packet is produced.
-void IpcVideoDecoder::OnReadComplete(media::Buffer* buffer) {
- decode_engine_->ConsumeVideoSample(buffer);
-}
-
-void IpcVideoDecoder::OnDestroyComplete() {
- // We don't need to do anything in this method. Destruction of objects will
- // occur as soon as refcount goes to 0.
-}
-
-// This method is called by VideoRenderer. We delegate the method call to
-// VideoDecodeEngine.
-void IpcVideoDecoder::ProduceVideoFrame(
- scoped_refptr<media::VideoFrame> video_frame) {
- decode_engine_->ProduceVideoFrame(video_frame);
-}
-
-bool IpcVideoDecoder::ProvidesBuffer() {
- return true;
-}
-
-// This method is called by VideoDecodeEngine that a video frame is produced.
-// This is then passed to VideoRenderer.
-void IpcVideoDecoder::ConsumeVideoFrame(
- scoped_refptr<media::VideoFrame> video_frame,
- const media::PipelineStatistics& statistics) {
- DCHECK(video_frame);
- statistics_callback_->Run(statistics);
-
- VideoFrameReady(video_frame);
-}
-
-// This method is called by VideoDecodeEngine to request a video frame. The
-// request is passed to demuxer.
-void IpcVideoDecoder::ProduceVideoSample(scoped_refptr<media::Buffer> buffer) {
- demuxer_stream_->Read(base::Bind(&IpcVideoDecoder::OnReadComplete, this));
-}
diff --git a/content/renderer/media/ipc_video_decoder.h b/content/renderer/media/ipc_video_decoder.h
deleted file mode 100644
index 280014b..0000000
--- a/content/renderer/media/ipc_video_decoder.h
+++ /dev/null
@@ -1,89 +0,0 @@
-// Copyright (c) 2011 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 CONTENT_RENDERER_MEDIA_IPC_VIDEO_DECODER_H_
-#define CONTENT_RENDERER_MEDIA_IPC_VIDEO_DECODER_H_
-
-#include "base/time.h"
-#include "media/base/pts_heap.h"
-#include "media/base/video_frame.h"
-#include "media/filters/decoder_base.h"
-#include "media/video/video_decode_engine.h"
-#include "media/video/video_decode_context.h"
-
-struct AVRational;
-class RendererGLContext;
-
-class IpcVideoDecoder : public media::VideoDecoder,
- public media::VideoDecodeEngine::EventHandler {
- public:
- IpcVideoDecoder(MessageLoop* message_loop, RendererGLContext* gl_context);
- virtual ~IpcVideoDecoder();
-
- // media::Filter implementation.
- virtual void Stop(media::FilterCallback* callback);
- virtual void Seek(base::TimeDelta time, const media::FilterStatusCB& cb);
- virtual void Pause(media::FilterCallback* callback);
- virtual void Flush(media::FilterCallback* callback);
-
- // media::VideoDecoder implementation.
- virtual void Initialize(media::DemuxerStream* demuxer_stream,
- media::FilterCallback* callback,
- media::StatisticsCallback* statsCallback);
- virtual const media::MediaFormat& media_format();
- virtual void ProduceVideoFrame(scoped_refptr<media::VideoFrame> video_frame);
-
- // TODO(hclam): Remove this method.
- virtual bool ProvidesBuffer();
-
- // media::VideoDecodeEngine::EventHandler implementation.
- virtual void OnInitializeComplete(const media::VideoCodecInfo& info);
- virtual void OnUninitializeComplete();
- virtual void OnFlushComplete();
- virtual void OnSeekComplete();
- virtual void OnError();
-
- // TODO(hclam): Remove this method.
- virtual void OnFormatChange(media::VideoStreamInfo stream_info) {}
- virtual void ProduceVideoSample(scoped_refptr<media::Buffer> buffer);
- virtual void ConsumeVideoFrame(scoped_refptr<media::VideoFrame> frame,
- const media::PipelineStatistics& statistics);
-
- private:
- void OnReadComplete(media::Buffer* buffer);
- void OnDestroyComplete();
-
- media::MediaFormat media_format_;
-
- scoped_ptr<media::FilterCallback> flush_callback_;
- media::FilterStatusCB seek_cb_;
- scoped_ptr<media::FilterCallback> initialize_callback_;
- scoped_ptr<media::FilterCallback> stop_callback_;
- scoped_ptr<media::StatisticsCallback> statistics_callback_;
-
- // Pointer to the demuxer stream that will feed us compressed buffers.
- scoped_refptr<media::DemuxerStream> demuxer_stream_;
-
- // This is the message loop that we should assign to VideoDecodeContext.
- MessageLoop* decode_context_message_loop_;
-
- // A context for allocating textures and issuing GLES2 commands.
- // TODO(hclam): A RendererGLContext lives on the Render Thread while this
- // object lives on the Video Decoder Thread, we need to take care of context
- // lost and destruction of the context.
- RendererGLContext* gl_context_;
-
- // This VideoDecodeEngine translate our requests to IPC commands to the
- // GPU process.
- // VideoDecodeEngine should run on IO Thread instead of Render Thread to
- // avoid dead lock during tear down of the media pipeline.
- scoped_ptr<media::VideoDecodeEngine> decode_engine_;
-
- // Decoding context to be used by VideoDecodeEngine.
- scoped_ptr<media::VideoDecodeContext> decode_context_;
-
- DISALLOW_COPY_AND_ASSIGN(IpcVideoDecoder);
-};
-
-#endif // CONTENT_RENDERER_MEDIA_IPC_VIDEO_DECODER_H_
diff --git a/content/renderer/render_view.cc b/content/renderer/render_view.cc
index 96514d4..048da27 100644
--- a/content/renderer/render_view.cc
+++ b/content/renderer/render_view.cc
@@ -47,7 +47,6 @@
#include "content/renderer/gpu/webgraphicscontext3d_command_buffer_impl.h"
#include "content/renderer/load_progress_tracker.h"
#include "content/renderer/media/audio_renderer_impl.h"
-#include "content/renderer/media/ipc_video_decoder.h"
#include "content/renderer/navigation_state.h"
#include "content/renderer/notification_provider.h"
#include "content/renderer/p2p/socket_dispatcher.h"
@@ -1885,23 +1884,6 @@ WebMediaPlayer* RenderView::createMediaPlayer(
collection->AddAudioRenderer(new AudioRendererImpl(audio_message_filter()));
}
- if (cmd_line->HasSwitch(switches::kEnableAcceleratedDecoding) &&
- !cmd_line->HasSwitch(switches::kDisableAcceleratedCompositing)) {
- WebGraphicsContext3DCommandBufferImpl* context =
- static_cast<WebGraphicsContext3DCommandBufferImpl*>(
- frame->view()->graphicsContext3D());
- if (!context)
- return NULL;
-
- // Add the hardware video decoder factory.
- // TODO(hclam): This will cause the renderer process to crash on context
- // lost.
- bool ret = context->makeContextCurrent();
- CHECK(ret) << "Failed to switch context";
- collection->AddVideoDecoder(new IpcVideoDecoder(
- MessageLoop::current(), context->context()));
- }
-
scoped_refptr<webkit_glue::WebVideoRenderer> video_renderer;
bool pts_logging = cmd_line->HasSwitch(switches::kEnableVideoLogging);
scoped_refptr<webkit_glue::VideoRendererImpl> renderer(
diff --git a/media/base/media_switches.cc b/media/base/media_switches.cc
index c93727e..1456482 100644
--- a/media/base/media_switches.cc
+++ b/media/base/media_switches.cc
@@ -13,9 +13,6 @@ const char kAlsaOutputDevice[] = "alsa-output-device";
const char kAlsaInputDevice[] = "alsa-input-device";
#endif
-// Enable hardware decoding through gpu process.
-const char kEnableAcceleratedDecoding[] = "enable-accelerated-decoding";
-
// Enable x-adaptive URL scheme.
const char kEnableAdaptive[] = "enable-adaptive";
diff --git a/media/base/media_switches.h b/media/base/media_switches.h
index 904f9bc..b54ed05 100644
--- a/media/base/media_switches.h
+++ b/media/base/media_switches.h
@@ -16,7 +16,6 @@ extern const char kAlsaOutputDevice[];
extern const char kAlsaInputDevice[];
#endif
-extern const char kEnableAcceleratedDecoding[];
extern const char kEnableAdaptive[];
extern const char kEnableOpenMax[];
extern const char kVideoThreads[];