summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorscherkus@chromium.org <scherkus@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-03-30 19:31:30 +0000
committerscherkus@chromium.org <scherkus@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-03-30 19:31:30 +0000
commite785780e0ac206abf27dff864be6aebdf91cbdda (patch)
tree2dd2e652b43f63014e582a780a1939a353dbe4c9
parentf677a530fdaebae4104da112627874e4877348fe (diff)
downloadchromium_src-e785780e0ac206abf27dff864be6aebdf91cbdda.zip
chromium_src-e785780e0ac206abf27dff864be6aebdf91cbdda.tar.gz
chromium_src-e785780e0ac206abf27dff864be6aebdf91cbdda.tar.bz2
Checking in media::BitstreamBuffer and media::VideoDecodeAccelerator interfaces.
Also includes stubbed out implementation VideoDecodeAcceleratorHost. Part of a patch by vmr@chromium.org: http://codereview.chromium.org/6541068/ BUG=none TEST=none Review URL: http://codereview.chromium.org/6675040 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@79878 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r--content/content_renderer.gypi2
-rw-r--r--content/renderer/video_decode_accelerator_host.cc87
-rw-r--r--content/renderer/video_decode_accelerator_host.h75
-rw-r--r--media/base/bitstream_buffer.h38
-rw-r--r--media/media.gyp2
-rw-r--r--media/video/video_decode_accelerator.h189
6 files changed, 393 insertions, 0 deletions
diff --git a/content/content_renderer.gypi b/content/content_renderer.gypi
index 082d607..77c1b4a 100644
--- a/content/content_renderer.gypi
+++ b/content/content_renderer.gypi
@@ -119,6 +119,8 @@
'renderer/renderer_webstoragenamespace_impl.h',
'renderer/speech_input_dispatcher.cc',
'renderer/speech_input_dispatcher.h',
+ 'renderer/video_decode_accelerator_host.cc',
+ 'renderer/video_decode_accelerator_host.h',
'renderer/webgraphicscontext3d_command_buffer_impl.cc',
'renderer/webgraphicscontext3d_command_buffer_impl.h',
'renderer/webplugin_delegate_proxy.cc',
diff --git a/content/renderer/video_decode_accelerator_host.cc b/content/renderer/video_decode_accelerator_host.cc
new file mode 100644
index 0000000..013277a
--- /dev/null
+++ b/content/renderer/video_decode_accelerator_host.cc
@@ -0,0 +1,87 @@
+// 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/video_decode_accelerator_host.h"
+
+#include "base/logging.h"
+#include "base/task.h"
+
+using media::VideoDecodeAccelerator;
+using media::VideoDecodeAcceleratorCallback;
+
+VideoDecodeAcceleratorHost::VideoDecodeAcceleratorHost(
+ MessageRouter* router,
+ IPC::Message::Sender* ipc_sender,
+ int32 decoder_host_id)
+ : message_loop_(NULL),
+ router_(router),
+ ipc_sender_(ipc_sender),
+ context_route_id_(0),
+ decoder_host_id_(decoder_host_id),
+ decoder_id_(0) {
+}
+
+VideoDecodeAcceleratorHost::~VideoDecodeAcceleratorHost() {}
+
+void VideoDecodeAcceleratorHost::OnChannelConnected(int32 peer_pid) {}
+
+void VideoDecodeAcceleratorHost::OnChannelError() {
+ ipc_sender_ = NULL;
+}
+
+bool VideoDecodeAcceleratorHost::OnMessageReceived(const IPC::Message& msg) {
+ bool handled = true;
+ DCHECK(handled);
+ return handled;
+}
+
+const std::vector<uint32>& VideoDecodeAcceleratorHost::GetConfig(
+ const std::vector<uint32>& prototype_config) {
+ // TODO(vmr): implement.
+ NOTIMPLEMENTED();
+ return configs_;
+}
+
+bool VideoDecodeAcceleratorHost::Initialize(
+ const std::vector<uint32>& config) {
+ // TODO(vmr): implement.
+ NOTIMPLEMENTED();
+ return false;
+}
+
+bool VideoDecodeAcceleratorHost::Decode(
+ media::BitstreamBuffer* bitstream_buffer,
+ VideoDecodeAcceleratorCallback* callback) {
+ // TODO(vmr): implement.
+ NOTIMPLEMENTED();
+ return false;
+}
+
+void VideoDecodeAcceleratorHost::AssignPictureBuffer(
+ std::vector<PictureBuffer*> picture_buffers) {
+ // TODO(vmr): implement.
+ NOTIMPLEMENTED();
+}
+
+void VideoDecodeAcceleratorHost::ReusePictureBuffer(
+ PictureBuffer* picture_buffer) {
+ // TODO(vmr): implement.
+ NOTIMPLEMENTED();
+}
+
+bool VideoDecodeAcceleratorHost::Flush(
+ VideoDecodeAcceleratorCallback* callback) {
+ // TODO(vmr): implement.
+ NOTIMPLEMENTED();
+ return false;
+}
+
+bool VideoDecodeAcceleratorHost::Abort(
+ VideoDecodeAcceleratorCallback* callback) {
+ // TODO(vmr): implement.
+ NOTIMPLEMENTED();
+ return false;
+}
+
+DISABLE_RUNNABLE_METHOD_REFCOUNT(VideoDecodeAcceleratorHost);
diff --git a/content/renderer/video_decode_accelerator_host.h b/content/renderer/video_decode_accelerator_host.h
new file mode 100644
index 0000000..c19b0b5
--- /dev/null
+++ b/content/renderer/video_decode_accelerator_host.h
@@ -0,0 +1,75 @@
+// 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_VIDEO_DECODE_ACCELERATOR_HOST_H_
+#define CONTENT_RENDERER_VIDEO_DECODE_ACCELERATOR_HOST_H_
+
+#include <vector>
+
+#include "base/memory/scoped_ptr.h"
+#include "base/shared_memory.h"
+#include "ipc/ipc_channel.h"
+#include "media/video/video_decode_accelerator.h"
+
+class MessageLoop;
+class MessageRouter;
+
+// This class is used to talk to VideoDecodeAccelerator in the GPU process
+// through IPC messages.
+class VideoDecodeAcceleratorHost : public IPC::Channel::Listener,
+ public media::VideoDecodeAccelerator {
+ public:
+ // |router| is used to dispatch IPC messages to this object.
+ // |ipc_sender| is used to send IPC messages to GPU process.
+ VideoDecodeAcceleratorHost(MessageRouter* router,
+ IPC::Message::Sender* ipc_sender,
+ int32 decoder_host_id);
+ virtual ~VideoDecodeAcceleratorHost();
+
+ // IPC::Channel::Listener implementation.
+ virtual void OnChannelConnected(int32 peer_pid);
+ virtual void OnChannelError();
+ virtual bool OnMessageReceived(const IPC::Message& message);
+
+ // media::VideoDecodeAccelerator implementation.
+ virtual const std::vector<uint32>& GetConfig(
+ const std::vector<uint32>& prototype_config);
+ virtual bool Initialize(const std::vector<uint32>& config);
+ virtual bool Decode(media::BitstreamBuffer* bitstream_buffer,
+ media::VideoDecodeAcceleratorCallback* callback);
+ virtual void AssignPictureBuffer(
+ std::vector<PictureBuffer*> picture_buffers);
+ virtual void ReusePictureBuffer(PictureBuffer* picture_buffer);
+ virtual bool Flush(media::VideoDecodeAcceleratorCallback* callback);
+ virtual bool Abort(media::VideoDecodeAcceleratorCallback* callback);
+
+ private:
+ // Message loop that this object runs on.
+ MessageLoop* message_loop_;
+
+ // 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_;
+
+ // ID of this VideoDecodeAcceleratorHost.
+ int32 decoder_host_id_;
+
+ // ID of VideoDecodeAccelerator in the GPU process.
+ int32 decoder_id_;
+
+ // Transfer buffers for both input and output.
+ // TODO(vmr): move into plugin provided IPC buffers.
+ scoped_ptr<base::SharedMemory> input_transfer_buffer_;
+
+ std::vector<uint32> configs_;
+
+ DISALLOW_COPY_AND_ASSIGN(VideoDecodeAcceleratorHost);
+};
+
+#endif // CONTENT_RENDERER_VIDEO_DECODE_ACCELERATOR_HOST_H_
diff --git a/media/base/bitstream_buffer.h b/media/base/bitstream_buffer.h
new file mode 100644
index 0000000..9a68efb
--- /dev/null
+++ b/media/base/bitstream_buffer.h
@@ -0,0 +1,38 @@
+// 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 MEDIA_BASE_BITSTREAM_BUFFER_H_
+#define MEDIA_BASE_BITSTREAM_BUFFER_H_
+
+#include "base/basictypes.h"
+
+namespace media {
+
+// Class for passing bitstream buffers around. Ownership of the bitstream
+// pointer remains with whoever uses this class.
+class BitstreamBuffer {
+ public:
+ BitstreamBuffer(uint8* bitstream, size_t bitstream_size, void* user_handle)
+ : bitstream_(bitstream),
+ bitstream_size_(bitstream_size),
+ user_handle_(user_handle) {
+ }
+
+ ~BitstreamBuffer() {}
+
+ uint8* bitstream() { return bitstream_; }
+ size_t bitstream_size() { return bitstream_size_; }
+ void* user_handle() { return user_handle_; }
+
+ private:
+ uint8* bitstream_;
+ size_t bitstream_size_;
+ void* user_handle_;
+
+ DISALLOW_IMPLICIT_CONSTRUCTORS(BitstreamBuffer);
+};
+
+} // namespace media
+
+#endif // MEDIA_BASE_BITSTREAM_BUFFER_H_
diff --git a/media/media.gyp b/media/media.gyp
index c5b457e..0796fb8 100644
--- a/media/media.gyp
+++ b/media/media.gyp
@@ -75,6 +75,7 @@
'audio/win/waveout_output_win.h',
'base/async_filter_factory_base.cc',
'base/async_filter_factory_base.h',
+ 'base/bitstream_buffer.h',
'base/buffers.cc',
'base/buffers.h',
'base/callback.cc',
@@ -170,6 +171,7 @@
'video/ffmpeg_video_allocator.h',
'video/ffmpeg_video_decode_engine.cc',
'video/ffmpeg_video_decode_engine.h',
+ 'video/video_decode_accelerator.h',
'video/video_decode_engine.cc',
'video/video_decode_engine.h',
],
diff --git a/media/video/video_decode_accelerator.h b/media/video/video_decode_accelerator.h
new file mode 100644
index 0000000..0c4405f
--- /dev/null
+++ b/media/video/video_decode_accelerator.h
@@ -0,0 +1,189 @@
+// 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 MEDIA_VIDEO_VIDEO_DECODE_ACCELERATOR_H_
+#define MEDIA_VIDEO_VIDEO_DECODE_ACCELERATOR_H_
+
+#include <vector>
+
+#include "base/basictypes.h"
+#include "base/callback.h"
+#include "media/base/bitstream_buffer.h"
+#include "ui/gfx/size.h"
+
+namespace media {
+
+typedef Callback0::Type VideoDecodeAcceleratorCallback;
+
+// Video decoder interface.
+class VideoDecodeAccelerator {
+ public:
+ virtual ~VideoDecodeAccelerator() {}
+
+ // Enumeration of potential errors generated by the API.
+ enum Error {
+ VIDEODECODERERROR_NONE = 0,
+ VIDEODECODERERROR_UNINITIALIZED,
+ VIDEODECODERERROR_UNSUPPORTED,
+ VIDEODECODERERROR_INSUFFICIENT_BUFFERS,
+ VIDEODECODERERROR_INSUFFICIENT_RESOURCES,
+ VIDEODECODERERROR_HARDWARE,
+ };
+
+ // Interface expected from PictureBuffers where pictures are stored.
+ class PictureBuffer {
+ public:
+ enum MemoryType {
+ PICTUREBUFFER_MEMORYTYPE_SYSTEM = 0,
+ PICTUREBUFFER_MEMORYTYPE_GL_TEXTURE,
+ };
+
+ virtual ~PictureBuffer();
+ virtual uint32 GetId() = 0;
+ virtual gfx::Size GetSize() = 0;
+ virtual const std::vector<uint32>& GetColorFormat() = 0;
+ virtual MemoryType GetMemoryType() = 0;
+ };
+
+ class Picture {
+ public:
+ virtual ~Picture();
+
+ // Picture size related functions.
+ // There are three types of logical picture sizes that applications using
+ // video decoder should be aware of:
+ // - Visible picture size,
+ // - Decoded picture size, and
+ // - Picture buffer size.
+ //
+ // Visible picture size means the actual picture size that is intended to be
+ // displayed from the decoded output.
+ //
+ // Decoded picture size might vary from the visible size of the picture,
+ // because of the underlying properties of the codec. Vast majority of
+ // modern video compression algorithms are based on (macro)block-based
+ // transforms and therefore process the picture in small windows (usually
+ // of size 16x16 pixels) one by one. However, if the native picture size
+ // does not happen to match the block-size of the algorithm, there may be
+ // redundant data left on the sides of the output picture, which are not
+ // intended for display. For example, this happens to video of size 854x480
+ // and H.264 codec. Since the width (854 pixels) is not multiple of the
+ // block size of the coding format (16 pixels), pixel columns 854-863
+ // contain garbage data which is notintended for display.
+ //
+ // Plugin is providing the buffers for output decoding and it should know
+ // the picture buffer size it has provided to the decoder. Thus, there is
+ // no function to query the buffer size from this class.
+
+ // Returns the decoded size of the decoded picture in pixels.
+ virtual gfx::Size GetDecodedSize() const = 0;
+
+ // Returns the visible size of the decoded picture in pixels.
+ virtual gfx::Size GetVisibleSize() const = 0;
+
+ // Returns metadata associated with the picture.
+ virtual void* GetUserHandle() = 0;
+ };
+
+ // Interface for collaborating with picture interface to provide memory for
+ // output picture and blitting them.
+ class Client {
+ public:
+ virtual ~Client() {}
+
+ // Callback to tell the information needed by the client to provide decoding
+ // buffer to the decoder.
+ virtual void ProvidePictureBuffers(
+ uint32 requested_num_of_buffers,
+ const std::vector<uint32>& buffer_properties) = 0;
+
+ // Callback to dismiss picture buffer that was assigned earlier.
+ virtual void DismissPictureBuffer(PictureBuffer* picture_buffer) = 0;
+
+ // Callback to deliver decoded pictures ready to be displayed.
+ virtual void PictureReady(Picture* picture) = 0;
+
+ // Callback to notify that decoder has decoded end of stream marker and has
+ // outputted all displayable pictures.
+ virtual void NotifyEndOfStream() = 0;
+
+ // Callback to notify about decoding errors.
+ virtual void NotifyError(Error error) = 0;
+ };
+
+ // Video decoder functions.
+ // GetConfig returns supported configurations that are subsets of given
+ // |prototype_config|.
+ // Parameters:
+ // |instance| is the pointer to the plug-in instance.
+ // |prototype_config| is the prototypical configuration.
+ //
+ // Returns std::vector containing all the configurations that match the
+ // prototypical configuration.
+ virtual const std::vector<uint32>& GetConfig(
+ const std::vector<uint32>& prototype_config) = 0;
+
+ // Initializes the video decoder with specific configuration.
+ // Parameters:
+ // |config| is the configuration on which the decoder should be initialized.
+ //
+ // Returns true when command successfully accepted. Otherwise false.
+ virtual bool Initialize(const std::vector<uint32>& config) = 0;
+
+ // Decodes given bitstream buffer. Once decoder is done with processing
+ // |bitstream_buffer| is will call |callback|.
+ // Parameters:
+ // |bitstream_buffer| is the input bitstream that is sent for decoding.
+ // |callback| contains the callback function pointer for informing about
+ // finished processing for |bitstream_buffer|.
+ //
+ // Returns true when command successfully accepted. Otherwise false.
+ virtual bool Decode(BitstreamBuffer* bitstream_buffer,
+ VideoDecodeAcceleratorCallback* callback) = 0;
+
+ // Assigns picture buffer to the video decoder. This function must be called
+ // at latest when decoder has made a ProvidePictureBuffers callback to the
+ // client. Ownership of the picture buffer remains with the client, but it is
+ // not allowed to deallocate picture buffer before DismissPictureBuffer
+ // callback has been initiated for a given buffer.
+ //
+ // Parameters:
+ // |picture_buffers| contains the allocated picture buffers for the output.
+ virtual void AssignPictureBuffer(
+ std::vector<PictureBuffer*> picture_buffers) = 0;
+
+ // Sends picture buffers to be reused by the decoder. This needs to be called
+ // for each buffer that has been processed so that decoder may know onto which
+ // picture buffers it can write the output to.
+ //
+ // Parameters:
+ // |picture_buffer| points to the picture buffer that is to be reused.
+ virtual void ReusePictureBuffer(PictureBuffer* picture_buffer) = 0;
+
+ // Flushes the decoder. Flushing will result in output of the
+ // pictures and buffers held inside the decoder and returning of bitstream
+ // buffers using the callbacks implemented by the plug-in. Once done with
+ // flushing, the decode will call the |callback|.
+ //
+ // Parameters:
+ // |callback| contains the callback function pointer.
+ //
+ // Returns true when command successfully accepted. Otherwise false.
+ virtual bool Flush(VideoDecodeAcceleratorCallback* callback) = 0;
+
+ // Aborts the decoder. Decode will abort the decoding as soon as possible and
+ // will not output anything. |callback| will be called as soon as abort has
+ // been finished. After abort all buffers can be considered dismissed, even
+ // when there has not been callbacks to dismiss them.
+ //
+ // Parameters:
+ // |callback| contains the callback function pointer.
+ //
+ // Returns true when command successfully accepted. Otherwise false.
+ virtual bool Abort(VideoDecodeAcceleratorCallback* callback) = 0;
+};
+
+} // namespace media
+
+#endif // MEDIA_VIDEO_VIDEO_DECODE_ACCELERATOR_H_