summaryrefslogtreecommitdiffstats
path: root/chrome/common
diff options
context:
space:
mode:
Diffstat (limited to 'chrome/common')
-rw-r--r--chrome/common/gpu_messages_internal.h80
-rw-r--r--chrome/common/gpu_video_common.cc211
-rw-r--r--chrome/common/gpu_video_common.h172
3 files changed, 463 insertions, 0 deletions
diff --git a/chrome/common/gpu_messages_internal.h b/chrome/common/gpu_messages_internal.h
index b17135b..543f087 100644
--- a/chrome/common/gpu_messages_internal.h
+++ b/chrome/common/gpu_messages_internal.h
@@ -10,6 +10,7 @@
// from it via utility_messages.h.
#include "base/shared_memory.h"
#include "chrome/common/gpu_info.h"
+#include "chrome/common/gpu_video_common.h"
#include "gfx/size.h"
#include "ipc/ipc_channel_handle.h"
#include "ipc/ipc_message_macros.h"
@@ -155,6 +156,21 @@ IPC_BEGIN_MESSAGES(GpuChannel)
IPC_MESSAGE_CONTROL1(GpuChannelMsg_DestroyCommandBuffer,
int32 /* instance_id */)
+ // Get hardware video service routing id.
+ IPC_SYNC_MESSAGE_CONTROL0_1(GpuChannelMsg_GetVideoService,
+ GpuVideoServiceInfoParam)
+
+ // Create hardware video decoder && associate it with the output |decoder_id|;
+ // We need this to be control message because we had to map the GpuChannel and
+ // |decoder_id|.
+ IPC_SYNC_MESSAGE_CONTROL0_1(GpuChannelMsg_CreateVideoDecoder,
+ GpuVideoDecoderInfoParam)
+
+ // Release all resource of the hardware video decoder which was assocaited
+ // with the input |decoder_id|.
+ IPC_SYNC_MESSAGE_CONTROL1_0(GpuChannelMsg_DestroyVideoDecoder,
+ int32 /* decoder_id */)
+
IPC_END_MESSAGES(GpuChannel)
//------------------------------------------------------------------------------
@@ -241,3 +257,67 @@ IPC_BEGIN_MESSAGES(GpuCommandBuffer)
#endif
IPC_END_MESSAGES(GpuCommandBuffer)
+
+//------------------------------------------------------------------------------
+
+// GpuVideoDecoderMsgs : send from renderer process to gpu process.
+IPC_BEGIN_MESSAGES(GpuVideoDecoder)
+ // 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)
+
+ // Send input buffer to GpuVideoDecoder.
+ IPC_MESSAGE_ROUTED1(GpuVideoDecoderMsg_EmptyThisBuffer,
+ GpuVideoDecoderInputBufferParam)
+
+ // Require output buffer from GpuVideoDecoder.
+ IPC_MESSAGE_ROUTED1(GpuVideoDecoderMsg_FillThisBuffer,
+ GpuVideoDecoderOutputBufferParam)
+
+ // GpuVideoDecoderHost has consumed the output buffer.
+ // NOTE: this may only useful for copy back solution
+ // where output transfer buffer had to be guarded.
+ IPC_MESSAGE_ROUTED0(GpuVideoDecoderMsg_FillThisBufferDoneACK)
+
+IPC_END_MESSAGES(GpuVideoDecoder)
+
+//------------------------------------------------------------------------------
+
+// GpuVideoDecoderMsgs : send from gpu process to renderer process.
+IPC_BEGIN_MESSAGES(GpuVideoDecoderHost)
+ // Confirm GpuVideoDecoder had been initialized or failed to initialize.
+ IPC_MESSAGE_ROUTED1(GpuVideoDecoderHostMsg_InitializeACK,
+ GpuVideoDecoderInitDoneParam)
+
+ // Confrim GpuVideoDecoder had been destroyed properly.
+ IPC_MESSAGE_ROUTED0(GpuVideoDecoderHostMsg_DestroyACK)
+
+ // Confirm decoder had been flushed.
+ IPC_MESSAGE_ROUTED0(GpuVideoDecoderHostMsg_FlushACK)
+
+ // GpuVideoDecoder has consumed input buffer from transfer buffer.
+ IPC_MESSAGE_ROUTED0(GpuVideoDecoderHostMsg_EmptyThisBufferACK)
+
+ // GpuVideoDecoder require new input buffer.
+ IPC_MESSAGE_ROUTED0(GpuVideoDecoderHostMsg_EmptyThisBufferDone)
+
+ // GpuVideoDecoder report output buffer ready.
+ IPC_MESSAGE_ROUTED1(GpuVideoDecoderHostMsg_FillThisBufferDone,
+ GpuVideoDecoderOutputBufferParam)
+
+ // GpuVideoDecoder report output format change.
+ IPC_MESSAGE_ROUTED1(GpuVideoDecoderHostMsg_MediaFormatChange,
+ GpuVideoDecoderFormatChangeParam)
+
+ // GpuVideoDecoder report error.
+ IPC_MESSAGE_ROUTED1(GpuVideoDecoderHostMsg_ErrorNotification,
+ GpuVideoDecoderErrorInfoParam)
+
+IPC_END_MESSAGES(GpuVideoDecoderHost)
+
diff --git a/chrome/common/gpu_video_common.cc b/chrome/common/gpu_video_common.cc
new file mode 100644
index 0000000..06116f9
--- /dev/null
+++ b/chrome/common/gpu_video_common.cc
@@ -0,0 +1,211 @@
+// Copyright (c) 2010 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "chrome/common/gpu_video_common.h"
+
+namespace IPC {
+
+void ParamTraits<GpuVideoServiceInfoParam>::Write(
+ Message* m, const GpuVideoServiceInfoParam& p) {
+ m->WriteInt(p.video_service_route_id_);
+ m->WriteInt(p.video_service_host_route_id_);
+ m->WriteInt(p.service_available_);
+}
+
+bool ParamTraits<GpuVideoServiceInfoParam>::Read(
+ const Message* m, void** iter, GpuVideoServiceInfoParam* r) {
+ if (!m->ReadInt(iter, &r->video_service_route_id_) ||
+ !m->ReadInt(iter, &r->video_service_host_route_id_) ||
+ !m->ReadInt(iter, &r->service_available_))
+ return false;
+ return true;
+}
+
+void ParamTraits<GpuVideoServiceInfoParam>::Log(
+ const GpuVideoServiceInfoParam& p, std::wstring* l) {
+ l->append(StringPrintf(L"(%d, %d, %d)",
+ p.video_service_route_id_,
+ p.video_service_host_route_id_,
+ p.service_available_));
+}
+
+///////////////////////////////////////////////////////////////////////////////
+
+void ParamTraits<GpuVideoDecoderInfoParam>::Write(
+ Message* m, const GpuVideoDecoderInfoParam& p) {
+ m->WriteInt(p.decoder_id_);
+ m->WriteInt(p.decoder_route_id_);
+ m->WriteInt(p.decoder_host_route_id_);
+}
+
+bool ParamTraits<GpuVideoDecoderInfoParam>::Read(
+ const Message* m, void** iter, GpuVideoDecoderInfoParam* r) {
+ if (!m->ReadInt(iter, &r->decoder_id_) ||
+ !m->ReadInt(iter, &r->decoder_route_id_) ||
+ !m->ReadInt(iter, &r->decoder_host_route_id_))
+ return false;
+ return true;
+}
+
+void ParamTraits<GpuVideoDecoderInfoParam>::Log(
+ const GpuVideoDecoderInfoParam& p, std::wstring* l) {
+ l->append(StringPrintf(L"(%d, %d, %d)",
+ p.decoder_id_,
+ p.decoder_route_id_,
+ p.decoder_host_route_id_));
+}
+
+///////////////////////////////////////////////////////////////////////////////
+
+void ParamTraits<GpuVideoDecoderInitParam>::Write(
+ Message* m, const GpuVideoDecoderInitParam& p) {
+ m->WriteInt(p.codec_id_);
+ m->WriteInt(p.width_);
+ m->WriteInt(p.height_);
+}
+
+bool ParamTraits<GpuVideoDecoderInitParam>::Read(
+ const Message* m, void** iter, GpuVideoDecoderInitParam* r) {
+ if (!m->ReadInt(iter, &r->codec_id_) ||
+ !m->ReadInt(iter, &r->width_) ||
+ !m->ReadInt(iter, &r->height_))
+ return false;
+ return true;
+}
+
+void ParamTraits<GpuVideoDecoderInitParam>::Log(
+ const GpuVideoDecoderInitParam& p, std::wstring* l) {
+ l->append(StringPrintf(L"(%d, %d %d)", p.codec_id_, p.width_, p.height_));
+}
+
+///////////////////////////////////////////////////////////////////////////////
+
+void ParamTraits<GpuVideoDecoderInitDoneParam>::Write(
+ Message* m, const GpuVideoDecoderInitDoneParam& p) {
+ m->WriteInt(p.success_);
+ m->WriteInt(p.stride_);
+ m->WriteInt(p.format_);
+ m->WriteInt(p.surface_type_);
+ m->WriteInt(p.input_buffer_size_);
+ m->WriteInt(p.output_buffer_size_);
+ IPC::ParamTraits<base::SharedMemoryHandle>::Write(
+ m, p.input_buffer_handle_);
+ IPC::ParamTraits<base::SharedMemoryHandle>::Write(
+ m, p.output_buffer_handle_);
+}
+
+bool ParamTraits<GpuVideoDecoderInitDoneParam>::Read(
+ const Message* m, void** iter, GpuVideoDecoderInitDoneParam* r) {
+ if (!m->ReadInt(iter, &r->success_) ||
+ !m->ReadInt(iter, &r->stride_) ||
+ !m->ReadInt(iter, &r->format_) ||
+ !m->ReadInt(iter, &r->surface_type_) ||
+ !m->ReadInt(iter, &r->input_buffer_size_) ||
+ !m->ReadInt(iter, &r->output_buffer_size_) ||
+ !IPC::ParamTraits<base::SharedMemoryHandle>::Read(
+ m, iter, &r->input_buffer_handle_) ||
+ !IPC::ParamTraits<base::SharedMemoryHandle>::Read(
+ m, iter, &r->output_buffer_handle_))
+ return false;
+ return true;
+}
+
+void ParamTraits<GpuVideoDecoderInitDoneParam>::Log(
+ const GpuVideoDecoderInitDoneParam& p, std::wstring* l) {
+ l->append(StringPrintf(L"(%d)", p.stride_));
+}
+
+///////////////////////////////////////////////////////////////////////////////
+
+void ParamTraits<GpuVideoDecoderInputBufferParam>::Write(
+ Message* m, const GpuVideoDecoderInputBufferParam& p) {
+ m->WriteInt64(p.timestamp_);
+ m->WriteInt(p.offset_);
+ m->WriteInt(p.size_);
+}
+
+bool ParamTraits<GpuVideoDecoderInputBufferParam>::Read(
+ const Message* m, void** iter, GpuVideoDecoderInputBufferParam* r) {
+ if (!m->ReadInt64(iter, &r->timestamp_) ||
+ !m->ReadInt(iter, &r->offset_) ||
+ !m->ReadInt(iter, &r->size_))
+ return false;
+ return true;
+}
+
+void ParamTraits<GpuVideoDecoderInputBufferParam>::Log(
+ const GpuVideoDecoderInputBufferParam& p, std::wstring* l) {
+ l->append(StringPrintf(L"(%d %d %d)",
+ static_cast<int>(p.timestamp_),
+ p.offset_, p.size_));
+}
+
+///////////////////////////////////////////////////////////////////////////////
+
+void ParamTraits<GpuVideoDecoderOutputBufferParam>::Write(
+ Message* m, const GpuVideoDecoderOutputBufferParam& p) {
+ m->WriteInt64(p.timestamp_);
+ m->WriteInt64(p.duration_);
+ m->WriteInt(p.flags_);
+}
+
+bool ParamTraits<GpuVideoDecoderOutputBufferParam>::Read(
+ const Message* m, void** iter, GpuVideoDecoderOutputBufferParam* r) {
+ if (!m->ReadInt64(iter, &r->timestamp_) ||
+ !m->ReadInt64(iter, &r->duration_) ||
+ !m->ReadInt(iter, &r->flags_))
+ return false;
+ return true;
+}
+
+void ParamTraits<GpuVideoDecoderOutputBufferParam>::Log(
+ const GpuVideoDecoderOutputBufferParam& p, std::wstring* l) {
+ l->append(StringPrintf(L"(%d %d) %x",
+ static_cast<int>(p.timestamp_),
+ static_cast<int>(p.duration_),
+ p.flags_));
+}
+
+///////////////////////////////////////////////////////////////////////////////
+
+void ParamTraits<GpuVideoDecoderErrorInfoParam>::Write(
+ Message* m, const GpuVideoDecoderErrorInfoParam& p) {
+ m->WriteInt(p.error_id);
+}
+
+bool ParamTraits<GpuVideoDecoderErrorInfoParam>::Read(
+ const Message* m, void** iter, GpuVideoDecoderErrorInfoParam* r) {
+ if (!m->ReadInt(iter, &r->error_id))
+ return false;
+ return true;
+}
+
+void ParamTraits<GpuVideoDecoderErrorInfoParam>::Log(
+ const GpuVideoDecoderErrorInfoParam& p, std::wstring* l) {
+ l->append(StringPrintf(L"(%d)", p.error_id));
+}
+
+///////////////////////////////////////////////////////////////////////////////
+
+void ParamTraits<GpuVideoDecoderFormatChangeParam>::Write(
+ Message* m, const GpuVideoDecoderFormatChangeParam& p) {
+ m->WriteInt(p.input_buffer_size_);
+ m->WriteInt(p.output_buffer_size_);
+}
+
+bool ParamTraits<GpuVideoDecoderFormatChangeParam>::Read(
+ const Message* m, void** iter, GpuVideoDecoderFormatChangeParam* r) {
+ if (!m->ReadInt(iter, &r->input_buffer_size_) ||
+ !m->ReadInt(iter, &r->output_buffer_size_))
+ return false;
+ return true;
+}
+
+void ParamTraits<GpuVideoDecoderFormatChangeParam>::Log(
+ const GpuVideoDecoderFormatChangeParam& p, std::wstring* l) {
+ l->append(StringPrintf(L"(%d %d)", p.input_buffer_size_,
+ p.output_buffer_size_));
+}
+};
+
diff --git a/chrome/common/gpu_video_common.h b/chrome/common/gpu_video_common.h
new file mode 100644
index 0000000..34974a6
--- /dev/null
+++ b/chrome/common/gpu_video_common.h
@@ -0,0 +1,172 @@
+// Copyright (c) 2010 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef CHROME_COMMON_GPU_VIDEO_COMMON_H_
+#define CHROME_COMMON_GPU_VIDEO_COMMON_H_
+
+#include "base/basictypes.h"
+#include "base/shared_memory.h"
+#include "chrome/common/common_param_traits.h"
+
+class GpuVideoServiceInfoParam {
+ public:
+ // route id for GpuVideoService on GPU process side for this channel.
+ int32 video_service_route_id_;
+ // route id for GpuVideoServiceHost on Render process side for this channel.
+ int32 video_service_host_route_id_;
+ // TODO(jiesun): define capabilities of video service.
+ int32 service_available_;
+};
+
+class GpuVideoDecoderInfoParam {
+ public:
+ // global decoder id.
+ int32 decoder_id_;
+ // route id for GpuVideoDecoder on GPU process side for this channel.
+ int32 decoder_route_id_;
+ // route id for GpuVideoServiceHost on Render process side for this channel.
+ int32 decoder_host_route_id_;
+};
+
+class GpuVideoDecoderInitParam {
+ public:
+ int32 codec_id_;
+ int32 width_;
+ int32 height_;
+ int32 profile_;
+ int32 level_;
+ int32 frame_rate_den_;
+ int32 frame_rate_num_;
+ int32 aspect_ratio_den_;
+ int32 aspect_ratio_num_;
+};
+
+class GpuVideoDecoderInitDoneParam {
+ public:
+ enum SurfaceType {
+ SurfaceTypeSystemMemory,
+ SurfaceTypeD3D,
+ SurfaceTypeEGLImage,
+ };
+ enum SurfaceFormat {
+ SurfaceFormat_YV12,
+ SurfaceFormat_NV12,
+ SurfaceFormat_XRGB,
+ };
+ int32 success_; // other parameter is only meaningful when this is true.
+ int32 provides_buffer;
+ int32 format_;
+ int32 surface_type_;
+ int32 stride_;
+ int32 input_buffer_size_;
+ int32 output_buffer_size_;
+ base::SharedMemoryHandle input_buffer_handle_;
+ // we do not need this if hardware composition is ready.
+ base::SharedMemoryHandle output_buffer_handle_;
+};
+
+class GpuVideoDecoderInputBufferParam {
+ public:
+ int64 timestamp_; // In unit of microseconds.
+ int32 offset_;
+ int32 size_;
+ int32 flags_; // miscellaneous flag bit mask
+};
+
+class GpuVideoDecoderOutputBufferParam {
+ public:
+ int64 timestamp_; // In unit of microseconds.
+ int64 duration_; // In unit of microseconds.
+ int32 flags_; // miscellaneous flag bit mask
+
+ enum {
+ kFlagsEndOfStream = 0x00000001,
+ kFlagsDiscontinuous = 0x00000002,
+ };
+};
+
+class GpuVideoDecoderErrorInfoParam {
+ public:
+ int32 error_id; // TODO(jiesun): define enum.
+};
+
+// TODO(jiesun): define this.
+class GpuVideoDecoderFormatChangeParam {
+ public:
+ int32 stride_;
+ int32 input_buffer_size_;
+ int32 output_buffer_size_;
+ base::SharedMemoryHandle input_buffer_handle_;
+ base::SharedMemoryHandle output_buffer_handle_;
+};
+
+namespace IPC {
+
+template <>
+struct ParamTraits<GpuVideoServiceInfoParam> {
+ typedef GpuVideoServiceInfoParam param_type;
+ static void Write(Message* m, const param_type& p);
+ static bool Read(const Message* m, void** iter, param_type* r);
+ static void Log(const param_type& p, std::wstring* l);
+};
+
+template <>
+struct ParamTraits<GpuVideoDecoderInfoParam> {
+ typedef GpuVideoDecoderInfoParam param_type;
+ static void Write(Message* m, const param_type& p);
+ static bool Read(const Message* m, void** iter, param_type* r);
+ static void Log(const param_type& p, std::wstring* l);
+};
+
+template <>
+struct ParamTraits<GpuVideoDecoderInitParam> {
+ typedef GpuVideoDecoderInitParam param_type;
+ static void Write(Message* m, const param_type& p);
+ static bool Read(const Message* m, void** iter, param_type* r);
+ static void Log(const param_type& p, std::wstring* l);
+};
+
+template <>
+struct ParamTraits<GpuVideoDecoderInitDoneParam> {
+ typedef GpuVideoDecoderInitDoneParam param_type;
+ static void Write(Message* m, const param_type& p);
+ static bool Read(const Message* m, void** iter, param_type* r);
+ static void Log(const param_type& p, std::wstring* l);
+};
+
+template <>
+struct ParamTraits<GpuVideoDecoderInputBufferParam> {
+ typedef GpuVideoDecoderInputBufferParam param_type;
+ static void Write(Message* m, const param_type& p);
+ static bool Read(const Message* m, void** iter, param_type* r);
+ static void Log(const param_type& p, std::wstring* l);
+};
+
+template <>
+struct ParamTraits<GpuVideoDecoderOutputBufferParam> {
+ typedef GpuVideoDecoderOutputBufferParam param_type;
+ static void Write(Message* m, const param_type& p);
+ static bool Read(const Message* m, void** iter, param_type* r);
+ static void Log(const param_type& p, std::wstring* l);
+};
+
+template <>
+struct ParamTraits<GpuVideoDecoderErrorInfoParam> {
+ typedef GpuVideoDecoderErrorInfoParam param_type;
+ static void Write(Message* m, const param_type& p);
+ static bool Read(const Message* m, void** iter, param_type* r);
+ static void Log(const param_type& p, std::wstring* l);
+};
+
+template <>
+struct ParamTraits<GpuVideoDecoderFormatChangeParam> {
+ typedef GpuVideoDecoderFormatChangeParam param_type;
+ static void Write(Message* m, const param_type& p);
+ static bool Read(const Message* m, void** iter, param_type* r);
+ static void Log(const param_type& p, std::wstring* l);
+};
+};
+
+#endif // CHROME_COMMON_GPU_VIDEO_COMMON_H_
+