summaryrefslogtreecommitdiffstats
path: root/chrome/renderer/gpu_video_decoder_host.h
diff options
context:
space:
mode:
authorjiesun@google.com <jiesun@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2010-08-09 15:59:44 +0000
committerjiesun@google.com <jiesun@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2010-08-09 15:59:44 +0000
commitc9f28a7d16b71b17185b456e3b53e4e638d005d0 (patch)
tree5940cfb4244935b01608e286f84a83413e0329a1 /chrome/renderer/gpu_video_decoder_host.h
parent6b1b2b6bc21270ef1b90a28293a1cb743e933383 (diff)
downloadchromium_src-c9f28a7d16b71b17185b456e3b53e4e638d005d0.zip
chromium_src-c9f28a7d16b71b17185b456e3b53e4e638d005d0.tar.gz
chromium_src-c9f28a7d16b71b17185b456e3b53e4e638d005d0.tar.bz2
Special thanks for in-ming cheng's MFT hardware decodering code.
1. ipc_video_decoder.cc/h is media pipeline filter which use the gpu decoder facilities in video stack. it is only enabled when (a) hardware composition is on (b) hardware decoding command line is on (c) h264 codec is specified. 2. gpu_video_service.cc/h is a singleton in gpu process which provide video services for renderer process, through it we could create decoder. ( in my imagination, in the future, we could create encoder or capturer too) 3. gpu_video_decoder.cc/h. abstract interface for hardware decoder. 4. gpu_video_decoder_mft.cc/h media foundation transform hardware decoder which run on windows 7 only. 5. gpu_video_service_host.cc/h is singleton in renderer process which provide proxy for gpu_video_service. 6. gpu_video_decoder_host.cc/h is proxy for gpu_video_decoder. (1 to 1 map).basically there is one global GpuVideoService in GPU process, one GpuVideoServiceHost in Renderer process. for each renderer process, there are could be multiple renderer view, each could had multiple GpuVideoDecoderHost the connect to GpuVideoDeocder through GPUCHannelHOst/GpuChannel. 7. gpu_video_common.cc/h: IPC message definition and pickle/marshaling support. ISSUES: 1. in media pipeline, we need let decoder to determine if bit stream filter should be used instead of let command line to determine it. 2. stop readback from D3D surface use ANGLE. 3. Flush logic still need fine tuning. 4. CreateThread in GpuVideoDecoder, and post message in message handler, and derived classs handle message loop. ? 5. Error handling. 6. Input ring buffer implementation. Current impl is naive. 7.Add output queue for MFT decoder. 8. Query Capabilities at GetVideoServices()... BUG=None TEST=Windows7 Review URL: http://codereview.chromium.org/2873089 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@55405 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/renderer/gpu_video_decoder_host.h')
-rw-r--r--chrome/renderer/gpu_video_decoder_host.h126
1 files changed, 126 insertions, 0 deletions
diff --git a/chrome/renderer/gpu_video_decoder_host.h b/chrome/renderer/gpu_video_decoder_host.h
new file mode 100644
index 0000000..2bd2f5b
--- /dev/null
+++ b/chrome/renderer/gpu_video_decoder_host.h
@@ -0,0 +1,126 @@
+// 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_RENDERER_GPU_VIDEO_DECODER_HOST_H_
+#define CHROME_RENDERER_GPU_VIDEO_DECODER_HOST_H_
+
+#include <deque>
+
+#include "base/singleton.h"
+#include "chrome/common/gpu_video_common.h"
+#include "chrome/renderer/gpu_channel_host.h"
+#include "ipc/ipc_channel_proxy.h"
+#include "media/base/buffers.h"
+#include "media/base/video_frame.h"
+
+using media::VideoFrame;
+using media::Buffer;
+
+class GpuVideoServiceHost;
+
+class GpuVideoDecoderHost
+ : public base::RefCountedThreadSafe<GpuVideoDecoderHost>,
+ public IPC::Channel::Listener {
+ public:
+ class EventHandler {
+ public:
+ virtual void OnInitializeDone(
+ bool success,
+ const GpuVideoDecoderInitDoneParam& param) = 0;
+ virtual void OnUninitializeDone() = 0;
+ virtual void OnFlushDone() = 0;
+ virtual void OnEmptyBufferDone(scoped_refptr<Buffer> buffer) = 0;
+ virtual void OnFillBufferDone(scoped_refptr<VideoFrame> frame) = 0;
+ virtual void OnDeviceError() = 0;
+ };
+
+ typedef enum {
+ kStateUninitialized,
+ kStateNormal,
+ kStateError,
+ kStateFlushing,
+ } GpuVideoDecoderHostState;
+
+ // IPC::Channel::Listener.
+ virtual void OnChannelConnected(int32 peer_pid) {}
+ virtual void OnChannelError();
+ virtual void OnMessageReceived(const IPC::Message& message);
+
+ bool Initialize(const GpuVideoDecoderInitParam& param);
+ bool Uninitialize();
+ void EmptyThisBuffer(scoped_refptr<Buffer> buffer);
+ void FillThisBuffer(scoped_refptr<VideoFrame> frame);
+ bool Flush();
+
+ int32 decoder_id() { return decoder_info_.decoder_id_; }
+ int32 route_id() { return decoder_info_.decoder_route_id_; }
+ int32 my_route_id() { return decoder_info_.decoder_host_route_id_; }
+
+ virtual ~GpuVideoDecoderHost() {}
+
+ private:
+ GpuVideoDecoderHost(GpuVideoServiceHost* service_host,
+ GpuChannelHost* channel_host,
+ EventHandler* event_handler,
+ GpuVideoDecoderInfoParam decoder_info)
+ : gpu_video_service_host_(service_host),
+ channel_host_(channel_host),
+ event_handler_(event_handler),
+ decoder_info_(decoder_info),
+ buffer_id_serial_(0),
+ state_(kStateUninitialized),
+ input_buffer_busy_(false) {}
+ friend class GpuVideoServiceHost;
+
+ // Input message handler.
+ void OnInitializeDone(const GpuVideoDecoderInitDoneParam& param);
+ void OnUninitializeDone();
+ void OnFlushDone();
+ void OnEmptyThisBufferDone();
+ void OnFillThisBufferDone(const GpuVideoDecoderOutputBufferParam& param);
+ void OnEmptyThisBufferACK();
+
+ // Helper function.
+ void SendInputBufferToGpu();
+
+ // We expect that GpuVideoServiceHost's always available during our life span.
+ GpuVideoServiceHost* gpu_video_service_host_;
+
+ scoped_refptr<GpuChannelHost> channel_host_;
+
+ // We expect that the client of us will always available during our life span.
+ EventHandler* event_handler_;
+
+ // Globally identify this decoder in the GPU process.
+ GpuVideoDecoderInfoParam decoder_info_;
+
+ // Input buffer id serial number generator.
+ int32 buffer_id_serial_;
+
+ // Hold information about GpuVideoDecoder configuration.
+ GpuVideoDecoderInitParam init_param_;
+
+ // Hold information about output surface format, etc.
+ GpuVideoDecoderInitDoneParam done_param_;
+
+ // Current state of video decoder.
+ GpuVideoDecoderHostState state_;
+
+ // 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_;
+ scoped_ptr<base::SharedMemory> output_transfer_buffer_;
+
+ DISALLOW_COPY_AND_ASSIGN(GpuVideoDecoderHost);
+};
+
+#endif // CHROME_RENDERER_GPU_VIDEO_DECODER_HOST_H_
+