summaryrefslogtreecommitdiffstats
path: root/webkit
diff options
context:
space:
mode:
authorwjia@google.com <wjia@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2010-08-06 17:39:26 +0000
committerwjia@google.com <wjia@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2010-08-06 17:39:26 +0000
commita39dc2a043e50f2e0ccd0c5910397093b1673413 (patch)
treefeae42695069f77fc1eab913da39e663d3fedf32 /webkit
parentd8ef27bc919211c44a92d2c1fefc54aaabf0134b (diff)
downloadchromium_src-a39dc2a043e50f2e0ccd0c5910397093b1673413.zip
chromium_src-a39dc2a043e50f2e0ccd0c5910397093b1673413.tar.gz
chromium_src-a39dc2a043e50f2e0ccd0c5910397093b1673413.tar.bz2
add pepper video decoder glue and delegate
BUG=none TEST=compiles Review URL: http://codereview.chromium.org/3087009 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@55252 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'webkit')
-rw-r--r--webkit/glue/plugins/pepper_plugin_delegate.h18
-rw-r--r--webkit/glue/plugins/pepper_plugin_module.cc5
-rw-r--r--webkit/glue/plugins/pepper_resource.h3
-rw-r--r--webkit/glue/plugins/pepper_video_decoder.cc140
-rw-r--r--webkit/glue/plugins/pepper_video_decoder.h49
-rw-r--r--webkit/glue/webkit_glue.gypi2
6 files changed, 216 insertions, 1 deletions
diff --git a/webkit/glue/plugins/pepper_plugin_delegate.h b/webkit/glue/plugins/pepper_plugin_delegate.h
index c1cd15a6..e80e626 100644
--- a/webkit/glue/plugins/pepper_plugin_delegate.h
+++ b/webkit/glue/plugins/pepper_plugin_delegate.h
@@ -9,7 +9,10 @@
#include "base/shared_memory.h"
#include "base/sync_socket.h"
+#include "third_party/ppapi/c/pp_completion_callback.h"
+#include "third_party/ppapi/c/pp_errors.h"
#include "third_party/ppapi/c/pp_stdint.h"
+#include "third_party/ppapi/c/pp_video.h"
class AudioMessageFilter;
@@ -72,6 +75,17 @@ class PluginDelegate {
virtual void ShutDown() = 0;
};
+ class PlatformVideoDecoder {
+ public:
+ virtual ~PlatformVideoDecoder() {}
+
+ // Returns false on failure.
+ virtual bool Decode(PP_VideoCompressedDataBuffer& input_buffer) = 0;
+ virtual int32_t Flush(PP_CompletionCallback& callback) = 0;
+ virtual bool ReturnUncompressedDataBuffer(
+ PP_VideoUncompressedDataBuffer& buffer) = 0;
+ };
+
// Indicates that the given instance has been created.
virtual void InstanceCreated(pepper::PluginInstance* instance) = 0;
@@ -83,6 +97,10 @@ class PluginDelegate {
// The caller will own the pointer returned from this.
virtual PlatformImage2D* CreateImage2D(int width, int height) = 0;
+ // The caller will own the pointer returned from this.
+ virtual PlatformVideoDecoder* CreateVideoDecoder(
+ const PP_VideoDecoderConfig& decoder_config) = 0;
+
// Notifies that the number of find results has changed.
virtual void DidChangeNumberOfFindResults(int identifier,
int total,
diff --git a/webkit/glue/plugins/pepper_plugin_module.cc b/webkit/glue/plugins/pepper_plugin_module.cc
index 3e21d0a..a9ae150 100644
--- a/webkit/glue/plugins/pepper_plugin_module.cc
+++ b/webkit/glue/plugins/pepper_plugin_module.cc
@@ -29,6 +29,7 @@
#include "third_party/ppapi/c/ppb_url_response_info.h"
#include "third_party/ppapi/c/ppb_url_util.h"
#include "third_party/ppapi/c/ppb_var.h"
+#include "third_party/ppapi/c/ppb_video_decoder.h"
#include "third_party/ppapi/c/ppb_widget.h"
#include "third_party/ppapi/c/ppp.h"
#include "third_party/ppapi/c/ppp_instance.h"
@@ -54,6 +55,7 @@
#include "webkit/glue/plugins/pepper_url_response_info.h"
#include "webkit/glue/plugins/pepper_url_util.h"
#include "webkit/glue/plugins/pepper_var.h"
+#include "webkit/glue/plugins/pepper_video_decoder.h"
#include "webkit/glue/plugins/pepper_widget.h"
#include "webkit/glue/plugins/ppb_private.h"
@@ -200,7 +202,8 @@ const void* GetInterface(const char* name) {
return Private::GetInterface();
if (strcmp(name, PPB_FILECHOOSER_INTERFACE) == 0)
return FileChooser::GetInterface();
-
+ if (strcmp(name, PPB_VIDEODECODER_INTERFACE) == 0)
+ return VideoDecoder::GetInterface();
// Only support the testing interface when the command line switch is
// specified. This allows us to prevent people from (ab)using this interface
diff --git a/webkit/glue/plugins/pepper_resource.h b/webkit/glue/plugins/pepper_resource.h
index 773bcdc..568f02b 100644
--- a/webkit/glue/plugins/pepper_resource.h
+++ b/webkit/glue/plugins/pepper_resource.h
@@ -29,6 +29,7 @@ class Scrollbar;
class URLLoader;
class URLRequestInfo;
class URLResponseInfo;
+class VideoDecoder;
class Widget;
class Resource : public base::RefCountedThreadSafe<Resource> {
@@ -90,6 +91,7 @@ class Resource : public base::RefCountedThreadSafe<Resource> {
virtual URLLoader* AsURLLoader() { return NULL; }
virtual URLRequestInfo* AsURLRequestInfo() { return NULL; }
virtual URLResponseInfo* AsURLResponseInfo() { return NULL; }
+ virtual VideoDecoder* AsVideoDecoder() { return NULL; }
virtual Widget* AsWidget() { return NULL; }
private:
@@ -136,6 +138,7 @@ DEFINE_RESOURCE_CAST(Scrollbar)
DEFINE_RESOURCE_CAST(URLLoader)
DEFINE_RESOURCE_CAST(URLRequestInfo)
DEFINE_RESOURCE_CAST(URLResponseInfo)
+DEFINE_RESOURCE_CAST(VideoDecoder)
DEFINE_RESOURCE_CAST(Widget)
#undef DEFINE_RESOURCE_CAST
diff --git a/webkit/glue/plugins/pepper_video_decoder.cc b/webkit/glue/plugins/pepper_video_decoder.cc
new file mode 100644
index 0000000..3f86971
--- /dev/null
+++ b/webkit/glue/plugins/pepper_video_decoder.cc
@@ -0,0 +1,140 @@
+// 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 "webkit/glue/plugins/pepper_video_decoder.h"
+
+#include "base/logging.h"
+#include "third_party/ppapi/c/pp_completion_callback.h"
+#include "third_party/ppapi/c/pp_errors.h"
+#include "third_party/ppapi/c/pp_video.h"
+#include "third_party/ppapi/c/ppb_video_decoder.h"
+#include "webkit/glue/plugins/pepper_file_ref.h"
+#include "webkit/glue/plugins/pepper_plugin_instance.h"
+#include "webkit/glue/plugins/pepper_resource_tracker.h"
+
+namespace pepper {
+
+namespace {
+
+bool GetConfig(PP_Instance instance_id,
+ PP_VideoCodecId codec,
+ PP_VideoConfig* configs,
+ int32_t config_size,
+ int32_t *num_config) {
+ PluginInstance* instance = PluginInstance::FromPPInstance(instance_id);
+ *num_config = 0;
+ if (!instance)
+ return false;
+
+ // Get configs based on codec.
+
+ if (configs) {
+ // Fill in the array of configs.
+ }
+
+ // Update *num_config.
+
+ return true;
+}
+
+PP_Resource Create(PP_Instance instance_id,
+ const PP_VideoDecoderConfig* decoder_config) {
+ PluginInstance* instance = PluginInstance::FromPPInstance(instance_id);
+ if (!instance)
+ return 0;
+
+ scoped_refptr<VideoDecoder> decoder(new VideoDecoder(instance));
+
+ if (!decoder->Init(*decoder_config))
+ return 0;
+
+ return decoder->GetReference();
+}
+
+bool Decode(PP_Resource decoder_id,
+ PP_VideoCompressedDataBuffer* input_buffer) {
+ scoped_refptr<VideoDecoder> decoder(
+ Resource::GetAs<VideoDecoder>(decoder_id));
+ if (!decoder)
+ return false;
+
+ decoder->Decode(*input_buffer);
+ return true;
+}
+
+int32_t Flush(PP_Resource decoder_id, PP_CompletionCallback callback) {
+ scoped_refptr<VideoDecoder> decoder(
+ Resource::GetAs<VideoDecoder>(decoder_id));
+ if (!decoder)
+ return PP_ERROR_BADRESOURCE;
+
+ return decoder->Flush(callback);
+}
+
+bool ReturnUncompressedDataBuffer(PP_Resource decoder_id,
+ PP_VideoUncompressedDataBuffer* buffer) {
+ scoped_refptr<VideoDecoder> decoder(
+ Resource::GetAs<VideoDecoder>(decoder_id));
+ if (!decoder)
+ return false;
+
+ return decoder->ReturnUncompressedDataBuffer(*buffer);
+}
+
+const PPB_VideoDecoder ppb_videodecoder = {
+ &GetConfig,
+ &Create,
+ &Decode,
+ &Flush,
+ &ReturnUncompressedDataBuffer
+};
+
+} // namespace
+
+VideoDecoder::VideoDecoder(PluginInstance* instance)
+ : Resource(instance->module()),
+ instance_(instance) {
+}
+
+VideoDecoder::~VideoDecoder() {
+}
+
+// static
+const PPB_VideoDecoder* VideoDecoder::GetInterface() {
+ return &ppb_videodecoder;
+}
+
+bool VideoDecoder::Init(const PP_VideoDecoderConfig& decoder_config) {
+ if (!instance())
+ return false;
+
+ platform_video_decoder_.reset(
+ instance()->delegate()->CreateVideoDecoder(decoder_config));
+
+ return platform_video_decoder_.get()? true : false;
+}
+
+bool VideoDecoder::Decode(PP_VideoCompressedDataBuffer& input_buffer) {
+ if (!platform_video_decoder_.get())
+ return false;
+
+ return platform_video_decoder_->Decode(input_buffer);
+}
+
+int32_t VideoDecoder::Flush(PP_CompletionCallback& callback) {
+ if (!platform_video_decoder_.get())
+ return PP_ERROR_FAILED;
+
+ return platform_video_decoder_->Flush(callback);
+}
+
+bool VideoDecoder::ReturnUncompressedDataBuffer(
+ PP_VideoUncompressedDataBuffer& buffer) {
+ if (!platform_video_decoder_.get())
+ return false;
+
+ return platform_video_decoder_->ReturnUncompressedDataBuffer(buffer);
+}
+
+} // namespace pepper
diff --git a/webkit/glue/plugins/pepper_video_decoder.h b/webkit/glue/plugins/pepper_video_decoder.h
new file mode 100644
index 0000000..b92d277
--- /dev/null
+++ b/webkit/glue/plugins/pepper_video_decoder.h
@@ -0,0 +1,49 @@
+// 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 WEBKIT_GLUE_PLUGINS_PEPPER_VIDEO_DECODER_H_
+#define WEBKIT_GLUE_PLUGINS_PEPPER_VIDEO_DECODER_H_
+
+#include <queue>
+
+#include "base/scoped_ptr.h"
+#include "third_party/ppapi/c/pp_video.h"
+#include "third_party/ppapi/c/ppb_video_decoder.h"
+#include "webkit/glue/plugins/pepper_plugin_delegate.h"
+#include "webkit/glue/plugins/pepper_resource.h"
+
+namespace pepper {
+
+class PluginInstance;
+
+class VideoDecoder : public Resource {
+ public:
+ VideoDecoder(PluginInstance* instance);
+ virtual ~VideoDecoder();
+
+ // Returns a pointer to the interface implementing PPB_VideoDecoder that is
+ // exposed to the plugin.
+ static const PPB_VideoDecoder* GetInterface();
+
+ // Resource overrides.
+ VideoDecoder* AsVideoDecoder() { return this; }
+
+ PluginInstance* instance() { return instance_.get(); }
+
+ // PPB_VideoDecoder implementation.
+ bool Init(const PP_VideoDecoderConfig& decoder_config);
+ bool Decode(PP_VideoCompressedDataBuffer& input_buffer);
+ int32_t Flush(PP_CompletionCallback& callback);
+ bool ReturnUncompressedDataBuffer(PP_VideoUncompressedDataBuffer& buffer);
+
+ private:
+ // This is NULL before initialization, and if this VideoDecoder is
+ // swapped with another.
+ scoped_ptr<PluginDelegate::PlatformVideoDecoder> platform_video_decoder_;
+ scoped_refptr<PluginInstance> instance_;
+};
+
+} // namespace pepper
+
+#endif // WEBKIT_GLUE_PLUGINS_PEPPER_VIDEO_DECODER_H_
diff --git a/webkit/glue/webkit_glue.gypi b/webkit/glue/webkit_glue.gypi
index f098ad7..76ed312 100644
--- a/webkit/glue/webkit_glue.gypi
+++ b/webkit/glue/webkit_glue.gypi
@@ -207,6 +207,8 @@
'plugins/pepper_url_util.h',
'plugins/pepper_var.cc',
'plugins/pepper_var.h',
+ 'plugins/pepper_video_decoder.cc',
+ 'plugins/pepper_video_decoder.h',
'plugins/pepper_webplugin_impl.cc',
'plugins/pepper_webplugin_impl.h',
'plugins/pepper_widget.cc',