summaryrefslogtreecommitdiffstats
path: root/content
diff options
context:
space:
mode:
Diffstat (limited to 'content')
-rw-r--r--content/common/gpu/media/gpu_video_decode_accelerator.cc6
-rw-r--r--content/common/gpu/media/vt_video_decode_accelerator.cc63
-rw-r--r--content/common/gpu/media/vt_video_decode_accelerator.h56
-rw-r--r--content/content_common.gypi2
4 files changed, 127 insertions, 0 deletions
diff --git a/content/common/gpu/media/gpu_video_decode_accelerator.cc b/content/common/gpu/media/gpu_video_decode_accelerator.cc
index ab97618..4abbe91a 100644
--- a/content/common/gpu/media/gpu_video_decode_accelerator.cc
+++ b/content/common/gpu/media/gpu_video_decode_accelerator.cc
@@ -26,6 +26,8 @@
#if defined(OS_WIN)
#include "base/win/windows_version.h"
#include "content/common/gpu/media/dxva_video_decode_accelerator.h"
+#elif defined(OS_MACOSX)
+#include "content/common/gpu/media/vt_video_decode_accelerator.h"
#elif defined(OS_CHROMEOS) && defined(ARCH_CPU_ARMEL) && defined(USE_X11)
#include "content/common/gpu/media/v4l2_video_decode_accelerator.h"
#include "content/common/gpu/media/v4l2_video_device.h"
@@ -251,6 +253,10 @@ void GpuVideoDecodeAccelerator::Initialize(
DVLOG(0) << "Initializing DXVA HW decoder for windows.";
video_decode_accelerator_.reset(
new DXVAVideoDecodeAccelerator(make_context_current_));
+#elif defined(OS_MACOSX)
+ video_decode_accelerator_.reset(new VTVideoDecodeAccelerator(
+ static_cast<CGLContextObj>(
+ stub_->decoder()->GetGLContext()->GetHandle())));
#elif defined(OS_CHROMEOS) && defined(ARCH_CPU_ARMEL) && defined(USE_X11)
scoped_ptr<V4L2Device> device = V4L2Device::Create(V4L2Device::kDecoder);
if (!device.get()) {
diff --git a/content/common/gpu/media/vt_video_decode_accelerator.cc b/content/common/gpu/media/vt_video_decode_accelerator.cc
new file mode 100644
index 0000000..59251d2
--- /dev/null
+++ b/content/common/gpu/media/vt_video_decode_accelerator.cc
@@ -0,0 +1,63 @@
+// Copyright 2014 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/vt_video_decode_accelerator.h"
+
+namespace content {
+
+VTVideoDecodeAccelerator::VTVideoDecodeAccelerator(CGLContextObj cgl_context)
+ : loop_proxy_(base::MessageLoopProxy::current()),
+ cgl_context_(cgl_context),
+ client_(NULL),
+ weak_this_factory_(this) {
+}
+
+VTVideoDecodeAccelerator::~VTVideoDecodeAccelerator() {
+}
+
+bool VTVideoDecodeAccelerator::Initialize(
+ media::VideoCodecProfile profile,
+ Client* client) {
+ DCHECK(CalledOnValidThread());
+ DVLOG(2) << __FUNCTION__;
+ client_ = client;
+
+ // Only H.264 is supported.
+ if (profile < media::H264PROFILE_MIN || profile > media::H264PROFILE_MAX)
+ return false;
+
+ // Prevent anyone from using VTVideoDecoder for now. http://crbug.com/133828
+ return false;
+}
+
+void VTVideoDecodeAccelerator::Decode(const media::BitstreamBuffer& bitstream) {
+ DCHECK(CalledOnValidThread());
+}
+
+void VTVideoDecodeAccelerator::AssignPictureBuffers(
+ const std::vector<media::PictureBuffer>& pictures) {
+ DCHECK(CalledOnValidThread());
+}
+
+void VTVideoDecodeAccelerator::ReusePictureBuffer(int32_t picture_id) {
+ DCHECK(CalledOnValidThread());
+}
+
+void VTVideoDecodeAccelerator::Flush() {
+ DCHECK(CalledOnValidThread());
+}
+
+void VTVideoDecodeAccelerator::Reset() {
+ DCHECK(CalledOnValidThread());
+}
+
+void VTVideoDecodeAccelerator::Destroy() {
+ DCHECK(CalledOnValidThread());
+}
+
+bool VTVideoDecodeAccelerator::CanDecodeOnIOThread() {
+ return false;
+}
+
+} // namespace content
diff --git a/content/common/gpu/media/vt_video_decode_accelerator.h b/content/common/gpu/media/vt_video_decode_accelerator.h
new file mode 100644
index 0000000..5b5d8be
--- /dev/null
+++ b/content/common/gpu/media/vt_video_decode_accelerator.h
@@ -0,0 +1,56 @@
+// Copyright 2014 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_MEDIA_VT_VIDEO_DECODE_ACCELERATOR_H_
+#define CONTENT_COMMON_GPU_MEDIA_VT_VIDEO_DECODE_ACCELERATOR_H_
+
+#include <stdint.h>
+
+#include "base/memory/ref_counted.h"
+#include "base/memory/weak_ptr.h"
+#include "base/message_loop/message_loop.h"
+#include "base/message_loop/message_loop_proxy.h"
+#include "media/video/video_decode_accelerator.h"
+#include "ui/gl/gl_context_cgl.h"
+
+namespace content {
+
+// (Stub of a) VideoToolbox.framework implementation of the
+// VideoDecodeAccelerator interface for Mac OS X.
+class VTVideoDecodeAccelerator
+ : public media::VideoDecodeAccelerator,
+ public base::NonThreadSafe {
+ public:
+ explicit VTVideoDecodeAccelerator(CGLContextObj cgl_context);
+ virtual ~VTVideoDecodeAccelerator();
+
+ // VideoDecodeAccelerator implementation.
+ virtual bool Initialize(
+ media::VideoCodecProfile profile,
+ Client* client) OVERRIDE;
+ virtual void Decode(const media::BitstreamBuffer& bitstream) OVERRIDE;
+ virtual void AssignPictureBuffers(
+ const std::vector<media::PictureBuffer>& pictures) OVERRIDE;
+ virtual void ReusePictureBuffer(int32_t picture_id) OVERRIDE;
+ virtual void Flush() OVERRIDE;
+ virtual void Reset() OVERRIDE;
+ virtual void Destroy() OVERRIDE;
+ virtual bool CanDecodeOnIOThread() OVERRIDE;
+
+ private:
+ scoped_refptr<base::MessageLoopProxy> loop_proxy_;
+ CGLContextObj cgl_context_;
+ media::VideoDecodeAccelerator::Client* client_;
+
+ // Member variables should appear before the WeakPtrFactory, to ensure
+ // that any WeakPtrs to Controller are invalidated before its members
+ // variable's destructors are executed, rendering them invalid.
+ base::WeakPtrFactory<VTVideoDecodeAccelerator> weak_this_factory_;
+
+ DISALLOW_COPY_AND_ASSIGN(VTVideoDecodeAccelerator);
+};
+
+} // namespace content
+
+#endif // CONTENT_COMMON_GPU_MEDIA_VT_VIDEO_DECODE_ACCELERATOR_H_
diff --git a/content/content_common.gypi b/content/content_common.gypi
index 0600b9f..ad5dd98 100644
--- a/content/content_common.gypi
+++ b/content/content_common.gypi
@@ -564,6 +564,8 @@
'sources': [
'common/gpu/client/gpu_memory_buffer_impl_io_surface.cc',
'common/gpu/client/gpu_memory_buffer_impl_io_surface.h',
+ 'common/gpu/media/vt_video_decode_accelerator.cc',
+ 'common/gpu/media/vt_video_decode_accelerator.h',
],
'sources!': [
'common/plugin_list_posix.cc',