summaryrefslogtreecommitdiffstats
path: root/ppapi
diff options
context:
space:
mode:
authorvmr@chromium.org <vmr@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-06-03 19:33:39 +0000
committervmr@chromium.org <vmr@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-06-03 19:33:39 +0000
commit8d2f82798c1798f9fd85c425b188944564852658 (patch)
tree4f9f43157edcec20bd50a35cf91f694a03157897 /ppapi
parentb37dc5ab810852a3055addad6d6cd9cc45080ed1 (diff)
downloadchromium_src-8d2f82798c1798f9fd85c425b188944564852658.zip
chromium_src-8d2f82798c1798f9fd85c425b188944564852658.tar.gz
chromium_src-8d2f82798c1798f9fd85c425b188944564852658.tar.bz2
Implementation for Pepper C++ Video Decoder API (wrapper on top of C API).
BUG= TEST= Review URL: http://codereview.chromium.org/7085030 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@87831 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'ppapi')
-rw-r--r--ppapi/c/dev/ppb_video_decoder_dev.h10
-rw-r--r--ppapi/cpp/dev/video_decoder_dev.cc76
-rw-r--r--ppapi/cpp/dev/video_decoder_dev.h24
3 files changed, 60 insertions, 50 deletions
diff --git a/ppapi/c/dev/ppb_video_decoder_dev.h b/ppapi/c/dev/ppb_video_decoder_dev.h
index 46eded5..12f6d5f 100644
--- a/ppapi/c/dev/ppb_video_decoder_dev.h
+++ b/ppapi/c/dev/ppb_video_decoder_dev.h
@@ -116,7 +116,7 @@ struct PPB_VideoDecoder_Dev {
//
// Returns PP_TRUE on success, PP_FALSE otherwise.
PP_Bool (*GetConfigs)(PP_Instance instance,
- PP_VideoConfigElement* proto_config,
+ const PP_VideoConfigElement* proto_config,
PP_VideoConfigElement* matching_configs,
uint32_t matching_configs_size,
uint32_t* num_of_matching_configs);
@@ -135,7 +135,7 @@ struct PPB_VideoDecoder_Dev {
//
// The created decoder is returned as PP_Resource. NULL means failure.
PP_Resource (*Create)(PP_Instance instance,
- PP_VideoConfigElement* dec_config,
+ const PP_VideoConfigElement* dec_config,
struct PP_CompletionCallback callback);
// Tests whether |resource| is a video decoder created through Create
@@ -159,7 +159,7 @@ struct PPB_VideoDecoder_Dev {
// Returns PP_TRUE on decoder successfully accepting buffer, PP_FALSE
// otherwise.
PP_Bool (*Decode)(PP_Resource video_decoder,
- struct PP_VideoBitstreamBuffer_Dev* bitstream_buffer,
+ const struct PP_VideoBitstreamBuffer_Dev* bitstream_buffer,
struct PP_CompletionCallback callback);
// Provides the decoder with picture buffers for video decoding.
@@ -191,10 +191,10 @@ struct PPB_VideoDecoder_Dev {
// allocated.
void (*AssignGLESBuffers)(PP_Resource video_decoder,
uint32_t no_of_buffers,
- struct PP_GLESBuffer_Dev* buffers);
+ const struct PP_GLESBuffer_Dev* buffers);
void (*AssignSysmemBuffers)(PP_Resource video_decoder,
uint32_t no_of_buffers,
- struct PP_SysmemBuffer_Dev* buffers);
+ const struct PP_SysmemBuffer_Dev* buffers);
// Tells the decoder to reuse given picture buffer. Typical use of this
// function is to call from PictureReady callback to recycle picture buffer
diff --git a/ppapi/cpp/dev/video_decoder_dev.cc b/ppapi/cpp/dev/video_decoder_dev.cc
index 504530a..a6994b5 100644
--- a/ppapi/cpp/dev/video_decoder_dev.cc
+++ b/ppapi/cpp/dev/video_decoder_dev.cc
@@ -12,8 +12,6 @@
#include "ppapi/cpp/module.h"
#include "ppapi/cpp/module_impl.h"
-using std::vector;
-
namespace pp {
namespace {
@@ -24,64 +22,74 @@ template <> const char* interface_name<PPB_VideoDecoder_Dev>() {
} // namespace
-VideoDecoder::VideoDecoder(const Instance* /* instance */,
- const std::vector<uint32_t>& /* config */,
- CompletionCallback /* callback */,
+VideoDecoder::VideoDecoder(const Instance* instance,
+ const PP_VideoConfigElement* config,
+ CompletionCallback callback,
Client* client)
: client_(client) {
if (!has_interface<PPB_VideoDecoder_Dev>())
return;
- // TODO(vmr): Implement.
+ PassRefFromConstructor(get_interface<PPB_VideoDecoder_Dev>()->Create(
+ instance->pp_instance(), config, callback.pp_completion_callback()));
}
VideoDecoder::~VideoDecoder() {}
-vector<uint32_t> VideoDecoder::GetConfigs(
- Instance* /* instance */,
- const vector<uint32_t>& /* prototype_config */) {
- // TODO(vmr): Implement.
- vector<uint32_t> matching_configs;
+bool VideoDecoder::GetConfigs(Instance* instance,
+ const PP_VideoConfigElement* prototype_config,
+ PP_VideoConfigElement* matching_configs,
+ uint32_t matching_configs_size,
+ uint32_t* num_of_matching_configs) {
if (!has_interface<PPB_VideoDecoder_Dev>())
- return matching_configs;
- return matching_configs;
+ return false;
+ return PPBoolToBool(get_interface<PPB_VideoDecoder_Dev>()->GetConfigs(
+ instance->pp_instance(), prototype_config, matching_configs,
+ matching_configs_size, num_of_matching_configs));
}
-void VideoDecoder::AssignGLESBuffers(uint32_t /* no_of_buffers */,
- const PP_GLESBuffer_Dev& /* buffers */) {
- // TODO(vmr): Implement.
+void VideoDecoder::AssignGLESBuffers(
+ const std::vector<PP_GLESBuffer_Dev>& buffers) {
+ if (!has_interface<PPB_VideoDecoder_Dev>() || !pp_resource())
+ return;
+ get_interface<PPB_VideoDecoder_Dev>()->AssignGLESBuffers(
+ pp_resource(), buffers.size(), &buffers[0]);
}
void VideoDecoder::AssignSysmemBuffers(
- uint32_t /* no_of_buffers */,
- const PP_SysmemBuffer_Dev& /* buffers */) {
- // TODO(vmr): Implement.
+ const std::vector<PP_SysmemBuffer_Dev>& buffers) {
+ if (!has_interface<PPB_VideoDecoder_Dev>() || !pp_resource())
+ return;
+ get_interface<PPB_VideoDecoder_Dev>()->AssignSysmemBuffers(
+ pp_resource(), buffers.size(), &buffers[0]);
}
-bool VideoDecoder::Decode(
- const PP_VideoBitstreamBuffer_Dev& /* bitstream_buffer */,
- CompletionCallback /* callback */) {
- // TODO(vmr): Implement.
+bool VideoDecoder::Decode(const PP_VideoBitstreamBuffer_Dev& bitstream_buffer,
+ CompletionCallback callback) {
if (!has_interface<PPB_VideoDecoder_Dev>() || !pp_resource())
return false;
- return false;
+ return PPBoolToBool(get_interface<PPB_VideoDecoder_Dev>()->Decode(
+ pp_resource(), &bitstream_buffer, callback.pp_completion_callback()));
}
-void VideoDecoder::ReusePictureBuffer(int32_t /* picture_buffer_id */) {
- // TODO(vmr): Implement.
+void VideoDecoder::ReusePictureBuffer(int32_t picture_buffer_id) {
+ if (!has_interface<PPB_VideoDecoder_Dev>() || !pp_resource())
+ return;
+ get_interface<PPB_VideoDecoder_Dev>()->ReusePictureBuffer(
+ pp_resource(), picture_buffer_id);
}
-bool VideoDecoder::Flush(CompletionCallback /* callback */) {
- // TODO(vmr): Implement.
- if (!has_interface<PPB_VideoDecoder_Dev>())
+bool VideoDecoder::Flush(CompletionCallback callback) {
+ if (!has_interface<PPB_VideoDecoder_Dev>() || !pp_resource())
return false;
- return true;
+ return PPBoolToBool(get_interface<PPB_VideoDecoder_Dev>()->Flush(
+ pp_resource(), callback.pp_completion_callback()));
}
-bool VideoDecoder::Abort(CompletionCallback /* callback */) {
- // TODO(vmr): Implement.
- if (!has_interface<PPB_VideoDecoder_Dev>())
+bool VideoDecoder::Abort(CompletionCallback callback) {
+ if (!has_interface<PPB_VideoDecoder_Dev>() || !pp_resource())
return false;
- return true;
+ return PPBoolToBool(get_interface<PPB_VideoDecoder_Dev>()->Abort(
+ pp_resource(), callback.pp_completion_callback()));
}
} // namespace pp
diff --git a/ppapi/cpp/dev/video_decoder_dev.h b/ppapi/cpp/dev/video_decoder_dev.h
index ba29aba..51aa594 100644
--- a/ppapi/cpp/dev/video_decoder_dev.h
+++ b/ppapi/cpp/dev/video_decoder_dev.h
@@ -30,8 +30,9 @@ class VideoDecoder : public Resource {
// Callback to provide buffers for the decoded output pictures.
virtual void ProvidePictureBuffers(
- uint32_t requested_num_of_buffers,
- const std::vector<uint32_t>& buffer_properties) = 0;
+ uint32_t req_num_of_bufs,
+ struct PP_Size dimensions,
+ enum PP_PictureBufferType_Dev type);
// Callback for decoder to delivered unneeded picture buffers back to the
// plugin.
@@ -42,7 +43,7 @@ class VideoDecoder : public Resource {
// Callback to notify that decoder has decoded end of stream marker and has
// outputted all displayable pictures.
- virtual void NotifyEndOfStream() = 0;
+ virtual void EndOfStream() = 0;
// Callback to notify about decoding errors.
virtual void NotifyError(PP_VideoDecodeError_Dev error) = 0;
@@ -57,23 +58,24 @@ class VideoDecoder : public Resource {
// |callback| will be called when decoder is initialized.
// |client| is the pointer to the client object. Ownership of the object is
// not transferred and it must outlive the lifetime of this class.
- VideoDecoder(const Instance* instance, const std::vector<uint32_t>& config,
+ VideoDecoder(const Instance* instance,
+ const PP_VideoConfigElement* config,
CompletionCallback callback, Client* client);
~VideoDecoder();
// GetConfigs returns supported configurations that are subsets of given
// |prototype_config|.
- static std::vector<uint32_t> GetConfigs(
- Instance* instance,
- const std::vector<uint32_t>& prototype_config);
+ bool GetConfigs(Instance* instance,
+ const PP_VideoConfigElement* prototype_config,
+ PP_VideoConfigElement* matching_configs,
+ uint32_t matching_configs_size,
+ uint32_t* num_of_matching_configs);
// Provides the decoder with picture buffers for video decoding.
// AssignGLESBuffers provides texture-backed buffers, whereas
// AssignSysmemBuffers provides system memory-backed buffers.
- void AssignGLESBuffers(uint32_t no_of_buffers,
- const PP_GLESBuffer_Dev& buffers);
- void AssignSysmemBuffers(uint32_t no_of_buffers,
- const PP_SysmemBuffer_Dev& buffers);
+ void AssignGLESBuffers(const std::vector<PP_GLESBuffer_Dev>& buffers);
+ void AssignSysmemBuffers(const std::vector<PP_SysmemBuffer_Dev>& buffers);
// Decodes given bitstream buffer. Once decoder is done with processing
// |bitstream_buffer| is will call |callback| with provided user data.