Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(178)

Unified Diff: ppapi/cpp/dev/video_decoder_dev.cc

Issue 7085030: Implementation for Pepper C++ Video Decoder API (wrapper on top of C API). (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Minor style fixes. Created 9 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: ppapi/cpp/dev/video_decoder_dev.cc
diff --git a/ppapi/cpp/dev/video_decoder_dev.cc b/ppapi/cpp/dev/video_decoder_dev.cc
index 504530a29616642ddb08da314695e13f02a0d2cb..b98ddcc46bc5082deaba2dd2995e1cce93c1ad85 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,87 @@ 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 std::vector<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[0], 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;
+std::vector<PP_VideoConfigElement> VideoDecoder::GetConfigs(
+ Instance* instance,
+ const std::vector<PP_VideoConfigElement>& prototype_config) {
+ std::vector<PP_VideoConfigElement> matching_configs;
if (!has_interface<PPB_VideoDecoder_Dev>())
return matching_configs;
+ if (prototype_config.size() == 0)
+ return matching_configs;
+
+ // First ask the number of matching configs.
+ uint32_t num_of_matching_configs = 0;
+ get_interface<PPB_VideoDecoder_Dev>()->GetConfigs(
+ instance->pp_instance(), &prototype_config[0], NULL, 0,
+ &num_of_matching_configs);
+ if (num_of_matching_configs == 0)
+ return matching_configs;
+
+ // Then ask the actually matching configs and return them in the vector.
+ matching_configs.resize(num_of_matching_configs);
+ get_interface<PPB_VideoDecoder_Dev>()->GetConfigs(
+ instance->pp_instance(), &prototype_config[0], &matching_configs[0],
+ num_of_matching_configs, &num_of_matching_configs);
return 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

Powered by Google App Engine
This is Rietveld 408576698