summaryrefslogtreecommitdiffstats
path: root/chrome/gpu
diff options
context:
space:
mode:
authorhclam@chromium.org <hclam@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-10-07 18:59:36 +0000
committerhclam@chromium.org <hclam@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-10-07 18:59:36 +0000
commit3b098bbef42fa93a2c17c96c888a65564191f767 (patch)
tree0509385a390e0ff9b348e96382c10074127319f6 /chrome/gpu
parentc7b7800afbf7aadb5c9f99c95209237cdf869678 (diff)
downloadchromium_src-3b098bbef42fa93a2c17c96c888a65564191f767.zip
chromium_src-3b098bbef42fa93a2c17c96c888a65564191f767.tar.gz
chromium_src-3b098bbef42fa93a2c17c96c888a65564191f767.tar.bz2
Implement GpuVideoDecoderHost and unit tests
Add the following feature to GpuVideoDecoderHost: 1. Video frame allocation / release. 2. ProduceVideoFrame / ConsumeVideoFrame using frames allocated. 3. Change GpuVideoDecoder creation to asynchronous. BUG=53714 TEST=unit_tests --gtest_filter=GpuVideoDecoder* Review URL: http://codereview.chromium.org/3397027 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@61824 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/gpu')
-rw-r--r--chrome/gpu/gpu_channel.cc20
-rw-r--r--chrome/gpu/gpu_channel.h3
-rw-r--r--chrome/gpu/gpu_video_decoder.cc23
-rw-r--r--chrome/gpu/gpu_video_decoder.h7
-rw-r--r--chrome/gpu/gpu_video_decoder_unittest.cc8
-rw-r--r--chrome/gpu/gpu_video_service.cc31
-rw-r--r--chrome/gpu/gpu_video_service.h12
7 files changed, 52 insertions, 52 deletions
diff --git a/chrome/gpu/gpu_channel.cc b/chrome/gpu/gpu_channel.cc
index c5c5025..9b8095f 100644
--- a/chrome/gpu/gpu_channel.cc
+++ b/chrome/gpu/gpu_channel.cc
@@ -206,24 +206,26 @@ void GpuChannel::OnGetVideoService(GpuVideoServiceInfoParam* info) {
#endif
}
-void GpuChannel::OnCreateVideoDecoder(GpuVideoDecoderInfoParam* info) {
+void GpuChannel::OnCreateVideoDecoder(int32 context_route_id,
+ int32 decoder_host_id) {
#if defined(ENABLE_GPU)
LOG(INFO) << "GpuChannel::OnCreateVideoDecoder";
- info->decoder_id = -1;
GpuVideoService* service = GpuVideoService::get();
- if (service == NULL)
+ if (service == NULL) {
+ // TODO(hclam): Need to send a failure message.
return;
+ }
// The context ID corresponds to the command buffer used.
- GpuCommandBufferStub* stub = stubs_.Lookup(info->context_id);
-
- info->decoder_host_route_id = GenerateRouteID();
- info->decoder_route_id = GenerateRouteID();
+ GpuCommandBufferStub* stub = stubs_.Lookup(context_route_id);
+ int32 decoder_id = GenerateRouteID();
// TODO(hclam): Need to be careful about the lifetime of the command buffer
// decoder.
- service->CreateVideoDecoder(this, &router_, info,
- stub->processor()->decoder());
+ bool ret = service->CreateVideoDecoder(
+ this, &router_, decoder_host_id, decoder_id,
+ stub->processor()->decoder());
+ DCHECK(ret) << "Failed to create a GpuVideoDecoder";
#endif
}
diff --git a/chrome/gpu/gpu_channel.h b/chrome/gpu/gpu_channel.h
index 13994c3..73fce43 100644
--- a/chrome/gpu/gpu_channel.h
+++ b/chrome/gpu/gpu_channel.h
@@ -76,7 +76,8 @@ class GpuChannel : public IPC::Channel::Listener,
void OnDestroyCommandBuffer(int32 route_id);
void OnGetVideoService(GpuVideoServiceInfoParam* info);
- void OnCreateVideoDecoder(GpuVideoDecoderInfoParam* info);
+ void OnCreateVideoDecoder(int32 context_route_id,
+ int32 decoder_host_id);
void OnDestroyVideoDecoder(int32 decoder_id);
scoped_ptr<IPC::SyncChannel> channel_;
diff --git a/chrome/gpu/gpu_video_decoder.cc b/chrome/gpu/gpu_video_decoder.cc
index a7877a0..b316253 100644
--- a/chrome/gpu/gpu_video_decoder.cc
+++ b/chrome/gpu/gpu_video_decoder.cc
@@ -209,12 +209,12 @@ void GpuVideoDecoder::SetGpuVideoDevice(GpuVideoDevice* device) {
GpuVideoDecoder::GpuVideoDecoder(
MessageLoop* message_loop,
- const GpuVideoDecoderInfoParam* param,
+ int32 decoder_host_id,
IPC::Message::Sender* sender,
base::ProcessHandle handle,
gpu::gles2::GLES2Decoder* decoder)
: message_loop_(message_loop),
- decoder_host_route_id_(param->decoder_host_route_id),
+ decoder_host_id_(decoder_host_id),
sender_(sender),
renderer_handle_(handle),
gles2_decoder_(decoder) {
@@ -310,33 +310,34 @@ void GpuVideoDecoder::OnVideoFrameAllocated(int32 frame_id,
void GpuVideoDecoder::SendInitializeDone(
const GpuVideoDecoderInitDoneParam& param) {
if (!sender_->Send(
- new GpuVideoDecoderHostMsg_InitializeACK(route_id(), param))) {
+ new GpuVideoDecoderHostMsg_InitializeACK(decoder_host_id(), param))) {
LOG(ERROR) << "GpuVideoDecoderMsg_InitializeACK failed";
}
}
void GpuVideoDecoder::SendUninitializeDone() {
- if (!sender_->Send(new GpuVideoDecoderHostMsg_DestroyACK(route_id()))) {
+ if (!sender_->Send(
+ new GpuVideoDecoderHostMsg_DestroyACK(decoder_host_id()))) {
LOG(ERROR) << "GpuVideoDecoderMsg_DestroyACK failed";
}
}
void GpuVideoDecoder::SendFlushDone() {
- if (!sender_->Send(new GpuVideoDecoderHostMsg_FlushACK(route_id()))) {
+ if (!sender_->Send(new GpuVideoDecoderHostMsg_FlushACK(decoder_host_id()))) {
LOG(ERROR) << "GpuVideoDecoderMsg_FlushACK failed";
}
}
void GpuVideoDecoder::SendEmptyBufferDone() {
if (!sender_->Send(
- new GpuVideoDecoderHostMsg_EmptyThisBufferDone(route_id()))) {
+ new GpuVideoDecoderHostMsg_EmptyThisBufferDone(decoder_host_id()))) {
LOG(ERROR) << "GpuVideoDecoderMsg_EmptyThisBufferDone failed";
}
}
void GpuVideoDecoder::SendEmptyBufferACK() {
if (!sender_->Send(
- new GpuVideoDecoderHostMsg_EmptyThisBufferACK(route_id()))) {
+ new GpuVideoDecoderHostMsg_EmptyThisBufferACK(decoder_host_id()))) {
LOG(ERROR) << "GpuVideoDecoderMsg_EmptyThisBufferACK failed";
}
}
@@ -345,7 +346,7 @@ void GpuVideoDecoder::SendConsumeVideoFrame(
int32 frame_id, int64 timestamp, int64 duration, int32 flags) {
if (!sender_->Send(
new GpuVideoDecoderHostMsg_ConsumeVideoFrame(
- route_id(), frame_id, timestamp, duration, flags))) {
+ decoder_host_id(), frame_id, timestamp, duration, flags))) {
LOG(ERROR) << "GpuVideoDecodeHostMsg_ConsumeVideoFrame failed.";
}
}
@@ -354,14 +355,16 @@ void GpuVideoDecoder::SendAllocateVideoFrames(
int n, size_t width, size_t height, media::VideoFrame::Format format) {
if (!sender_->Send(
new GpuVideoDecoderHostMsg_AllocateVideoFrames(
- route_id(), n, width, height, static_cast<int32>(format)))) {
+ decoder_host_id(), n, width, height,
+ static_cast<int32>(format)))) {
LOG(ERROR) << "GpuVideoDecoderMsg_AllocateVideoFrames failed";
}
}
void GpuVideoDecoder::SendReleaseAllVideoFrames() {
if (!sender_->Send(
- new GpuVideoDecoderHostMsg_ReleaseAllVideoFrames(route_id()))) {
+ new GpuVideoDecoderHostMsg_ReleaseAllVideoFrames(
+ decoder_host_id()))) {
LOG(ERROR) << "GpuVideoDecoderMsg_ReleaseAllVideoFrames failed";
}
}
diff --git a/chrome/gpu/gpu_video_decoder.h b/chrome/gpu/gpu_video_decoder.h
index f975eb8..786e0de 100644
--- a/chrome/gpu/gpu_video_decoder.h
+++ b/chrome/gpu/gpu_video_decoder.h
@@ -93,7 +93,7 @@ class GpuVideoDecoder
public:
// Constructor and destructor.
GpuVideoDecoder(MessageLoop* message_loop,
- const GpuVideoDecoderInfoParam* param,
+ int32 decoder_host_id,
IPC::Message::Sender* sender,
base::ProcessHandle handle,
gpu::gles2::GLES2Decoder* decoder);
@@ -139,7 +139,7 @@ class GpuVideoDecoder
Task* task;
};
- int32 route_id() { return decoder_host_route_id_; }
+ int32 decoder_host_id() { return decoder_host_id_; }
bool CreateInputTransferBuffer(uint32 size,
base::SharedMemoryHandle* handle);
@@ -168,7 +168,8 @@ class GpuVideoDecoder
// The message loop that this object should run on.
MessageLoop* message_loop_;
- int32 decoder_host_route_id_;
+ // 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_;
diff --git a/chrome/gpu/gpu_video_decoder_unittest.cc b/chrome/gpu/gpu_video_decoder_unittest.cc
index 4548807..948e30b 100644
--- a/chrome/gpu/gpu_video_decoder_unittest.cc
+++ b/chrome/gpu/gpu_video_decoder_unittest.cc
@@ -18,6 +18,7 @@ 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;
@@ -71,11 +72,8 @@ class GpuVideoDecoderTest : public testing::Test,
// Create the mock objects.
gles2_decoder_.reset(new gpu::gles2::MockGLES2Decoder(&group_));
- // Initialize GpuVideoDecoder with the default params.
- GpuVideoDecoderInfoParam param;
- memset(&param, 0, sizeof(param));
gpu_video_decoder_ = new GpuVideoDecoder(
- &message_loop_, &param, this, base::kNullProcessHandle,
+ &message_loop_, kDecoderHostId, this, base::kNullProcessHandle,
gles2_decoder_.get());
// Create the mock objects.
@@ -95,7 +93,7 @@ class GpuVideoDecoderTest : public testing::Test,
&device_frame_);
}
- ~GpuVideoDecoderTest() {
+ virtual ~GpuVideoDecoderTest() {
gpu_video_decoder_->SetVideoDecodeEngine(NULL);
gpu_video_decoder_->SetGpuVideoDevice(NULL);
}
diff --git a/chrome/gpu/gpu_video_service.cc b/chrome/gpu/gpu_video_service.cc
index 6ff2e81..2ef32e8 100644
--- a/chrome/gpu/gpu_video_service.cc
+++ b/chrome/gpu/gpu_video_service.cc
@@ -7,7 +7,7 @@
#include "chrome/gpu/gpu_video_decoder.h"
#include "chrome/gpu/gpu_video_service.h"
-GpuVideoService::GpuVideoService() : next_available_decoder_id_(0) {
+GpuVideoService::GpuVideoService() {
// TODO(jiesun): move this time consuming stuff out of here.
IntializeGpuVideoService();
}
@@ -43,30 +43,27 @@ bool GpuVideoService::UnintializeGpuVideoService() {
bool GpuVideoService::CreateVideoDecoder(
GpuChannel* channel,
MessageRouter* router,
- GpuVideoDecoderInfoParam* param,
+ int32 decoder_host_id,
+ int32 decoder_id,
gpu::gles2::GLES2Decoder* gles2_decoder) {
GpuVideoDecoderInfo decoder_info;
- int32 decoder_id = GetNextAvailableDecoderID();
- param->decoder_id = decoder_id;
- base::ProcessHandle handle = channel->renderer_handle();
- decoder_info.decoder_ = new GpuVideoDecoder(MessageLoop::current(),
- param, channel, handle,
- gles2_decoder);
- decoder_info.channel_ = channel;
- decoder_info.param = *param;
+ decoder_info.decoder = new GpuVideoDecoder(MessageLoop::current(),
+ decoder_host_id,
+ channel,
+ channel->renderer_handle(),
+ gles2_decoder);
+ decoder_info.channel = channel;
decoder_map_[decoder_id] = decoder_info;
- router->AddRoute(param->decoder_route_id, decoder_info.decoder_);
+ router->AddRoute(decoder_id, decoder_info.decoder);
+
+ channel->Send(new GpuVideoDecoderHostMsg_CreateVideoDecoderDone(
+ decoder_host_id, decoder_id));
return true;
}
void GpuVideoService::DestroyVideoDecoder(
MessageRouter* router,
int32 decoder_id) {
- int32 route_id = decoder_map_[decoder_id].param.decoder_route_id;
- router->RemoveRoute(route_id);
+ router->RemoveRoute(decoder_id);
decoder_map_.erase(decoder_id);
}
-
-int32 GpuVideoService::GetNextAvailableDecoderID() {
- return ++next_available_decoder_id_;
-}
diff --git a/chrome/gpu/gpu_video_service.h b/chrome/gpu/gpu_video_service.h
index 0b446bb..a2c090e 100644
--- a/chrome/gpu/gpu_video_service.h
+++ b/chrome/gpu/gpu_video_service.h
@@ -22,32 +22,30 @@ class GpuVideoService : public IPC::Channel::Listener,
virtual void OnChannelError();
virtual void OnMessageReceived(const IPC::Message& message);
+ // TODO(hclam): Remove return value.
bool CreateVideoDecoder(GpuChannel* channel,
MessageRouter* router,
- GpuVideoDecoderInfoParam* param,
+ int32 decoder_host_id,
+ int32 decoder_id,
gpu::gles2::GLES2Decoder* gles2_decoder);
void DestroyVideoDecoder(MessageRouter* router,
int32 decoder_id);
private:
struct GpuVideoDecoderInfo {
- scoped_refptr<GpuVideoDecoder> decoder_;
- GpuChannel* channel_;
- GpuVideoDecoderInfoParam param;
+ scoped_refptr<GpuVideoDecoder> decoder;
+ GpuChannel* channel;
};
GpuVideoService();
virtual ~GpuVideoService();
std::map<int32, GpuVideoDecoderInfo> decoder_map_;
- int32 next_available_decoder_id_;
// Specialize video service on different platform will override.
virtual bool IntializeGpuVideoService();
virtual bool UnintializeGpuVideoService();
- int32 GetNextAvailableDecoderID();
-
friend struct DefaultSingletonTraits<GpuVideoService>;
DISALLOW_COPY_AND_ASSIGN(GpuVideoService);
};