summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--chrome/chrome_renderer.gypi2
-rw-r--r--chrome/renderer/DEPS1
-rw-r--r--chrome/renderer/media/gles2_video_decode_context.cc34
-rw-r--r--chrome/renderer/media/gles2_video_decode_context.h117
-rw-r--r--chrome/renderer/render_view.cc3
-rw-r--r--media/video/video_decode_context.h51
6 files changed, 208 insertions, 0 deletions
diff --git a/chrome/chrome_renderer.gypi b/chrome/chrome_renderer.gypi
index d566bda..81131f5 100644
--- a/chrome/chrome_renderer.gypi
+++ b/chrome/chrome_renderer.gypi
@@ -69,6 +69,8 @@
'renderer/loadtimes_extension_bindings.cc',
'renderer/media/audio_renderer_impl.cc',
'renderer/media/audio_renderer_impl.h',
+ 'renderer/media/gles2_video_decode_context.cc',
+ 'renderer/media/gles2_video_decode_context.h',
'renderer/media/ipc_video_decoder.cc',
'renderer/media/ipc_video_decoder.h',
'renderer/media/ipc_video_renderer.cc',
diff --git a/chrome/renderer/DEPS b/chrome/renderer/DEPS
index 9f70ed0..b7bf978 100644
--- a/chrome/renderer/DEPS
+++ b/chrome/renderer/DEPS
@@ -6,6 +6,7 @@ include_rules = [
"+media/base",
"+media/ffmpeg",
"+media/filters",
+ "+media/video",
"+sandbox/src",
"+skia/include",
"+webkit/extensions",
diff --git a/chrome/renderer/media/gles2_video_decode_context.cc b/chrome/renderer/media/gles2_video_decode_context.cc
new file mode 100644
index 0000000..d54334b
--- /dev/null
+++ b/chrome/renderer/media/gles2_video_decode_context.cc
@@ -0,0 +1,34 @@
+// 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/renderer/media/gles2_video_decode_context.h"
+
+Gles2VideoDecodeContext::Gles2VideoDecodeContext(
+ StorageType type, WebKit::WebGLES2Context* context)
+ : type_(type), context_(context) {
+}
+
+Gles2VideoDecodeContext::~Gles2VideoDecodeContext() {
+ // TODO(hclam): Implement.
+}
+
+void* Gles2VideoDecodeContext::GetDevice() {
+ // This decode context is used inside the renderer and so hardware decoder
+ // device handler should be used.
+ return NULL;
+}
+
+void Gles2VideoDecodeContext::AllocateVideoFrames(
+ int n, size_t width, size_t height, AllocationCompleteCallback* callback) {
+ // TODO(hclam): Implement.
+}
+
+void Gles2VideoDecodeContext::ReleaseVideoFrames(int n,
+ media::VideoFrame* frames) {
+ // TODO(hclam): Implement.
+}
+
+void Gles2VideoDecodeContext::Destroy(DestructionCompleteCallback* callback) {
+ // TODO(hclam): Implement.
+}
diff --git a/chrome/renderer/media/gles2_video_decode_context.h b/chrome/renderer/media/gles2_video_decode_context.h
new file mode 100644
index 0000000..fd9c9233
--- /dev/null
+++ b/chrome/renderer/media/gles2_video_decode_context.h
@@ -0,0 +1,117 @@
+// 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_MEDIA_GLES2_VIDEO_DECODE_CONTEXT_H_
+#define CHROME_RENDERER_MEDIA_GLES2_VIDEO_DECODE_CONTEXT_H_
+
+#include "media/video/video_decode_context.h"
+
+namespace WebKit {
+class WebGLES2Context;
+} // namespace WebKit
+
+// FUNCTIONS
+//
+// This is a class that provides a video decode context using a GLES2 backend.
+// It provides resources for a VideoDecodeEngine to store decoded video frames
+// in the GLES2 context.
+//
+// This class is aware of the command buffer implementation of GLES2 inside the
+// Chrome renderer and keeps a reference of ggl::Context. It might use GLES2
+// commands specific to Chrome's renderer process to provide needed resources.
+//
+// There are two different kinds of video frame storage provided by this class:
+// 1. Memory mapped YUV textures (aka software decoding mode).
+// Each video frame allocated is backed by 3 luminance textures carrying
+// the Y, U and V planes.
+//
+// Furthermore each texture is memory mapped and appears to the
+// VideoDecodeEngine as 3 planes backed by system memory.
+//
+// The usage of these 3 textures is that the VideoDecodeEngine is performing
+// software video decoding and use them as if they are allocated in plain
+// system memory (in fact they are allocated in system memory and shared
+// bwith the GPU process). An additional step of uploading the content to
+// video memory is needed. Since VideoDecodeEngine is unaware of the video
+// memory, this upload operation is performed by video renderer provided by
+// Chrome.
+//
+// After the content is uploaded to video memory, WebKit will see the video
+// frame as 3 textures and will perform the necessary operations for
+// rendering.
+//
+// 2. RGBA texture (aka hardware decoding mode).
+// In this mode of operation each video frame is backed by a RGBA texture.
+// This is used only when hardware video decoding is used. The texture needs
+// to be generated and allocated inside the renderer process first. This
+// will establish a translation between texture ID in the renderer process
+// and the GPU process.
+//
+// The texture ID generated is used by IpcVideoDecodeEngine only to be sent
+// the GPU process. Inside the GPU process the texture ID is translated to
+// a real texture ID inside the actual GLES context. The real texture ID is
+// then assigned to the hardware video decoder for storing the video frame.
+//
+// WebKit will see the video frame as a normal RGBA texture and perform
+// necessary render operations.
+//
+// In both operation modes, the objective is to have WebKit see the video frames
+// as regular textures.
+//
+// THREAD SEMANTICS
+//
+// This class is accessed on two threads, namely the Render Thread and the
+// Video Decoder Thread.
+//
+// GLES2 context and all OpenGL method calls should be accessed on the Render
+// Thread.
+//
+// VideoDecodeContext implementations are accessed on the Video Decoder Thread.
+//
+class Gles2VideoDecodeContext : public media::VideoDecodeContext {
+ public:
+ enum StorageType {
+ // This video decode context provides YUV textures as storage. This is used
+ // only in software decoding mode.
+ kMemoryMappedYuvTextures,
+
+ // This video decode context provides RBGA textures as storage. This is
+ // used in hardware decoding mode.
+ kRgbaTextures,
+ };
+
+ //--------------------------------------------------------------------------
+ // Render Thread
+ Gles2VideoDecodeContext(StorageType type,
+ WebKit::WebGLES2Context* gles2context);
+
+ // TODO(hclam): Need to figure out which thread destroys this object.
+ virtual ~Gles2VideoDecodeContext();
+
+ //--------------------------------------------------------------------------
+ // Video Decoder Thread
+
+ // media::VideoDecodeContext implementation.
+ virtual void* GetDevice();
+ virtual void AllocateVideoFrames(int n, size_t width, size_t height,
+ AllocationCompleteCallback* callback);
+ virtual void ReleaseVideoFrames(int n, media::VideoFrame* frames);
+ virtual void Destroy(DestructionCompleteCallback* callback);
+
+ //--------------------------------------------------------------------------
+ // Any thread
+ // Accessor of the current mode of this decode context.
+ bool IsMemoryMapped() const { return type_ == kMemoryMappedYuvTextures; }
+
+ private:
+ // Type of storage provided by this class.
+ StorageType type_;
+
+ // TODO(hclam): We should keep a ggl::Context instead.
+ WebKit::WebGLES2Context* context_;
+
+ DISALLOW_COPY_AND_ASSIGN(Gles2VideoDecodeContext);
+};
+
+#endif // CHROME_RENDERER_MEDIA_GLES2_VIDEO_DECODE_CONTEXT_H_
diff --git a/chrome/renderer/render_view.cc b/chrome/renderer/render_view.cc
index 0c2eb5a..065b691 100644
--- a/chrome/renderer/render_view.cc
+++ b/chrome/renderer/render_view.cc
@@ -2436,6 +2436,9 @@ WebMediaPlayer* RenderView::createMediaPlayer(
AudioRendererImpl::CreateFactory(audio_message_filter()));
}
+ // TODO(hclam): Need to inject Gles2VideoDecodeContext here. Also I need
+ // to create a factory for FFmpegVideoDecoder here so that it can use
+ // the Gles2VideoDecodeContext.
if (cmd_line->HasSwitch(switches::kEnableAcceleratedDecoding) &&
cmd_line->HasSwitch(switches::kEnableAcceleratedCompositing)) {
// Add the hardware video decoder factory.
diff --git a/media/video/video_decode_context.h b/media/video/video_decode_context.h
new file mode 100644
index 0000000..0bea382
--- /dev/null
+++ b/media/video/video_decode_context.h
@@ -0,0 +1,51 @@
+// 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 MEDIA_VIDEO_VIDEO_DECODE_CONTEXT_H_
+#define MEDIA_VIDEO_VIDEO_DECODE_CONTEXT_H_
+
+#include "base/callback.h"
+
+namespace media {
+
+class VideoFrame;
+
+// A VideoDecodeContext provides resources like output video frame storage and
+// hardware decoder handle to a VideoDecodeEngine, it hides all the platform and
+// subsystem details from the decode engine.
+class VideoDecodeContext {
+ public:
+ typedef Callback2<int, VideoFrame*[]>::Type AllocationCompleteCallback;
+ typedef Callback0::Type DestructionCompleteCallback;
+
+ virtual ~VideoDecodeContext() {};
+
+ // Obtain a handle to the hardware video decoder device. The type of the
+ // handle is a contract between the implementation of VideoDecodeContext and
+ // VideoDecodeEngine.
+ //
+ // If a hardware device is not needed this method should return NULL.
+ virtual void* GetDevice() = 0;
+
+ // Allocate |n| video frames with dimension |width| and |height|. |callback|
+ // is called when allocation has completed.
+ virtual void AllocateVideoFrames(int n, size_t width, size_t height,
+ AllocationCompleteCallback* callback) = 0;
+
+ // Release video frames allocated by the context. After making this call
+ // VideoDecodeEngine should not use the VideoFrame allocated because they
+ // could be destroyed.
+ virtual void ReleaseVideoFrames(int n, VideoFrame* frames) = 0;
+
+ // Destroy this context asynchronously. When the operation is done |callback|
+ // is called.
+ //
+ // ReleaseVideoFrames() need to be called with all the video frames allocated
+ // before making this call.
+ virtual void Destroy(DestructionCompleteCallback* callback) = 0;
+};
+
+} // namespace media
+
+#endif // MEDIA_VIDEO_VIDEO_DECODE_CONTEXT_H_