summaryrefslogtreecommitdiffstats
path: root/ppapi
diff options
context:
space:
mode:
authorpolina@google.com <polina@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2011-06-04 01:33:11 +0000
committerpolina@google.com <polina@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2011-06-04 01:33:11 +0000
commitb47815f17b42a73d3da78364bd10b501450db00b (patch)
tree2158508cbe879ac10076191e31681347eabf8ef2 /ppapi
parent1b576261ac143b13a290be9b2c3be0f246a6e466 (diff)
downloadchromium_src-b47815f17b42a73d3da78364bd10b501450db00b.zip
chromium_src-b47815f17b42a73d3da78364bd10b501450db00b.tar.gz
chromium_src-b47815f17b42a73d3da78364bd10b501450db00b.tar.bz2
PPAPI: Fix interface functions that take PP_CompletionCallbacks, but don't
return codes from pp_errors.h BUG=none TEST=compile + manually run ppapi_tests::VideoDecoder Review URL: http://codereview.chromium.org/6975053 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@87905 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'ppapi')
-rw-r--r--ppapi/c/dev/ppb_layer_compositor_dev.h4
-rw-r--r--ppapi/c/dev/ppb_video_decoder_dev.h50
-rw-r--r--ppapi/cpp/dev/video_decoder_dev.cc54
-rw-r--r--ppapi/cpp/dev/video_decoder_dev.h22
-rw-r--r--ppapi/tests/arch_dependent_sizes_32.h2
-rw-r--r--ppapi/tests/arch_dependent_sizes_64.h2
-rw-r--r--ppapi/tests/test_video_decoder.cc19
-rw-r--r--ppapi/tests/test_video_decoder.h2
8 files changed, 93 insertions, 62 deletions
diff --git a/ppapi/c/dev/ppb_layer_compositor_dev.h b/ppapi/c/dev/ppb_layer_compositor_dev.h
index b07431e21..1ee4594 100644
--- a/ppapi/c/dev/ppb_layer_compositor_dev.h
+++ b/ppapi/c/dev/ppb_layer_compositor_dev.h
@@ -68,8 +68,8 @@ struct PPB_LayerCompositor_Dev {
// Since this is an asynchronous operation, |callback| will be called when
// this operation is done.
//
- // Returns PP_TRUE if the operation was successful. PP_FALSE otherwise.
- PP_Bool (*SwapBuffers)(PP_Resource compositor,
+ // Returns an error code from pp_errors.h.
+ int32_t (*SwapBuffers)(PP_Resource compositor,
struct PP_CompletionCallback callback);
};
diff --git a/ppapi/c/dev/ppb_video_decoder_dev.h b/ppapi/c/dev/ppb_video_decoder_dev.h
index 12f6d5f..4ec65df 100644
--- a/ppapi/c/dev/ppb_video_decoder_dev.h
+++ b/ppapi/c/dev/ppb_video_decoder_dev.h
@@ -52,7 +52,7 @@
// |###########################|
// | GetConfigs |
// |-------------------------->|
-// | Create |
+// | Create + Initialize |
// |-------------------------->| Decoder will ask for certain number
// | (Decode) | of PictureBuffers. This may happen
// |- - - - - - - - - - - - - >| either directly after constructor or
@@ -121,7 +121,16 @@ struct PPB_VideoDecoder_Dev {
uint32_t matching_configs_size,
uint32_t* num_of_matching_configs);
- // Creates a video decoder with requested |decoder_config|.
+ // Creates a video decoder. Initialize() must be called afterwards to
+ // set its configuration.
+ //
+ // Parameters:
+ // |instance| pointer to the plugin instance.
+ //
+ // The created decoder is returned as PP_Resource. 0 means failure.
+ PP_Resource (*Create)(PP_Instance instance);
+
+ // Initializes the video decoder with requested configuration.
// |input_format| in |decoder_config| specifies the format of input access
// unit, with PP_VIDEOKEY_CODECID and PP_VIDEOKEY_PAYLOADFORMAT required.
// Plugin has the option to specify codec profile/level and other
@@ -129,13 +138,13 @@ struct PPB_VideoDecoder_Dev {
// the most appropriate decoder.
//
// Parameters:
- // |instance| pointer to the plugin instance.
- // |dec_config| the configuration which to use to initialize the decoder.
- // |callback| called after initialize is complete.
+ // |video_decoder| is the previously created handle to the decoder resource.
+ // |decoder_config| the configuration to use to initialize the decoder.
+ // |callback| called after initialization is complete.
//
- // The created decoder is returned as PP_Resource. NULL means failure.
- PP_Resource (*Create)(PP_Instance instance,
- const PP_VideoConfigElement* dec_config,
+ // Returns an error code from pp_errors.h.
+ int32_t (*Initialize)(PP_Resource video_decoder,
+ const PP_VideoConfigElement* decoder_config,
struct PP_CompletionCallback callback);
// Tests whether |resource| is a video decoder created through Create
@@ -151,14 +160,13 @@ struct PPB_VideoDecoder_Dev {
// non-blocking function.
//
// Parameters:
- // |video_decoder| is the previously created handle to the decoder instance.
+ // |video_decoder| is the previously created handle to the decoder resource.
// |bitstream_buffer| is the bitstream buffer that contains the input data.
// |callback| will be called when |bitstream_buffer| has been processed by
// the decoder.
//
- // Returns PP_TRUE on decoder successfully accepting buffer, PP_FALSE
- // otherwise.
- PP_Bool (*Decode)(PP_Resource video_decoder,
+ // Returns an error code from pp_errors.h.
+ int32_t (*Decode)(PP_Resource video_decoder,
const struct PP_VideoBitstreamBuffer_Dev* bitstream_buffer,
struct PP_CompletionCallback callback);
@@ -185,7 +193,7 @@ struct PPB_VideoDecoder_Dev {
// PPB API.
//
// Parameters:
- // |video_decoder| is the previously created handle to the decoder instance.
+ // |video_decoder| is the previously created handle to the decoder resource.
// |no_of_buffers| how many buffers are behind picture buffer pointer.
// |buffers| contains the reference to the picture buffer that was
// allocated.
@@ -210,7 +218,7 @@ struct PPB_VideoDecoder_Dev {
// the GL textures for writing output again.
//
// Parameters:
- // |video_decoder| is the previously created handle to the decoder instance.
+ // |video_decoder| is the previously created handle to the decoder resource.
// |picture_buffer_id| contains the id of the picture buffer that was
// processed.
void (*ReusePictureBuffer)(PP_Resource video_decoder,
@@ -223,13 +231,12 @@ struct PPB_VideoDecoder_Dev {
// decode will call the |callback|.
//
// Parameters:
- // |video_decoder| is the previously created handle to the decoder instance.
+ // |video_decoder| is the previously created handle to the decoder resource.
// |callback| is one-time callback that will be called once the flushing
// request has been completed.
//
- // Returns PP_TRUE on acceptance of flush request and PP_FALSE if request to
- // flush is rejected by the decoder.
- PP_Bool (*Flush)(PP_Resource video_decoder,
+ // Returns an error code from pp_errors.h.
+ int32_t (*Flush)(PP_Resource video_decoder,
struct PP_CompletionCallback callback);
// Dispatches abortion request to the decoder to abort decoding as soon as
@@ -239,13 +246,12 @@ struct PPB_VideoDecoder_Dev {
// to dismiss them.
//
// Parameters:
- // |video_decoder| is the previously created handle to the decoder instance.
+ // |video_decoder| is the previously created handle to the decoder resource.
// |callback| is one-time callback that will be called once the abortion
// request has been completed.
//
- // Returns PP_TRUE on acceptance of abort request and PP_FALSE if request to
- // abort is rejected by the decoder.
- PP_Bool (*Abort)(PP_Resource video_decoder,
+ // Returns an error code from pp_errors.h.
+ int32_t (*Abort)(PP_Resource video_decoder,
struct PP_CompletionCallback callback);
};
diff --git a/ppapi/cpp/dev/video_decoder_dev.cc b/ppapi/cpp/dev/video_decoder_dev.cc
index a6994b5..b1ebcfb 100644
--- a/ppapi/cpp/dev/video_decoder_dev.cc
+++ b/ppapi/cpp/dev/video_decoder_dev.cc
@@ -22,19 +22,24 @@ template <> const char* interface_name<PPB_VideoDecoder_Dev>() {
} // namespace
-VideoDecoder::VideoDecoder(const Instance* instance,
- const PP_VideoConfigElement* config,
- CompletionCallback callback,
- Client* client)
+VideoDecoder::VideoDecoder(const Instance* instance, Client* client)
: client_(client) {
if (!has_interface<PPB_VideoDecoder_Dev>())
return;
PassRefFromConstructor(get_interface<PPB_VideoDecoder_Dev>()->Create(
- instance->pp_instance(), config, callback.pp_completion_callback()));
+ instance->pp_instance()));
}
VideoDecoder::~VideoDecoder() {}
+int32_t VideoDecoder::Initialize(const PP_VideoConfigElement* config,
+ CompletionCallback callback) {
+ if (!has_interface<PPB_VideoDecoder_Dev>())
+ return PP_ERROR_NOINTERFACE;
+ return get_interface<PPB_VideoDecoder_Dev>()->Initialize(
+ pp_resource(), config, callback.pp_completion_callback());
+}
+
bool VideoDecoder::GetConfigs(Instance* instance,
const PP_VideoConfigElement* prototype_config,
PP_VideoConfigElement* matching_configs,
@@ -63,12 +68,15 @@ void VideoDecoder::AssignSysmemBuffers(
pp_resource(), buffers.size(), &buffers[0]);
}
-bool VideoDecoder::Decode(const PP_VideoBitstreamBuffer_Dev& bitstream_buffer,
- CompletionCallback callback) {
- if (!has_interface<PPB_VideoDecoder_Dev>() || !pp_resource())
- return false;
- return PPBoolToBool(get_interface<PPB_VideoDecoder_Dev>()->Decode(
- pp_resource(), &bitstream_buffer, callback.pp_completion_callback()));
+int32_t VideoDecoder::Decode(
+ const PP_VideoBitstreamBuffer_Dev& bitstream_buffer,
+ CompletionCallback callback) {
+ if (!has_interface<PPB_VideoDecoder_Dev>())
+ return PP_ERROR_NOINTERFACE;
+ if (!pp_resource())
+ return PP_ERROR_BADRESOURCE;
+ return get_interface<PPB_VideoDecoder_Dev>()->Decode(
+ pp_resource(), &bitstream_buffer, callback.pp_completion_callback());
}
void VideoDecoder::ReusePictureBuffer(int32_t picture_buffer_id) {
@@ -78,18 +86,22 @@ void VideoDecoder::ReusePictureBuffer(int32_t picture_buffer_id) {
pp_resource(), picture_buffer_id);
}
-bool VideoDecoder::Flush(CompletionCallback callback) {
- if (!has_interface<PPB_VideoDecoder_Dev>() || !pp_resource())
- return false;
- return PPBoolToBool(get_interface<PPB_VideoDecoder_Dev>()->Flush(
- pp_resource(), callback.pp_completion_callback()));
+int32_t VideoDecoder::Flush(CompletionCallback callback) {
+ if (!has_interface<PPB_VideoDecoder_Dev>())
+ return PP_ERROR_NOINTERFACE;
+ if (!pp_resource())
+ return PP_ERROR_BADRESOURCE;
+ return get_interface<PPB_VideoDecoder_Dev>()->Flush(
+ pp_resource(), callback.pp_completion_callback());
}
-bool VideoDecoder::Abort(CompletionCallback callback) {
- if (!has_interface<PPB_VideoDecoder_Dev>() || !pp_resource())
- return false;
- return PPBoolToBool(get_interface<PPB_VideoDecoder_Dev>()->Abort(
- pp_resource(), callback.pp_completion_callback()));
+int32_t VideoDecoder::Abort(CompletionCallback callback) {
+ if (!has_interface<PPB_VideoDecoder_Dev>())
+ return PP_ERROR_NOINTERFACE;
+ if (!pp_resource())
+ return PP_ERROR_BADRESOURCE;
+ return 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 51aa594..e6558b1 100644
--- a/ppapi/cpp/dev/video_decoder_dev.h
+++ b/ppapi/cpp/dev/video_decoder_dev.h
@@ -54,15 +54,21 @@ class VideoDecoder : public Resource {
//
// Parameters:
// |instance| is the pointer to the plug-in instance.
- // |config| is the configuration on which the decoder should be initialized.
// |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 PP_VideoConfigElement* config,
- CompletionCallback callback, Client* client);
+ VideoDecoder(const Instance* instance, Client* client);
~VideoDecoder();
+ // Initializates the video decoder with a requested configuration.
+ // Calls Init() on PPB_VideoDecoder_Dev interface.
+ //
+ // Parameters:
+ // |config| is the configuration on which the decoder should be initialized.
+ // |callback| will be called when decoder is initialized.
+ int32_t Initialize(const PP_VideoConfigElement* config,
+ CompletionCallback callback);
+
// GetConfigs returns supported configurations that are subsets of given
// |prototype_config|.
bool GetConfigs(Instance* instance,
@@ -79,19 +85,19 @@ class VideoDecoder : public Resource {
// Decodes given bitstream buffer. Once decoder is done with processing
// |bitstream_buffer| is will call |callback| with provided user data.
- bool Decode(const PP_VideoBitstreamBuffer_Dev& bitstream_buffer,
- CompletionCallback callback);
+ int32_t Decode(const PP_VideoBitstreamBuffer_Dev& bitstream_buffer,
+ CompletionCallback callback);
// Tells the decoder to reuse given picture buffer.
void ReusePictureBuffer(int32_t picture_buffer_id);
// Flushes the decoder. |callback| will be called as soon as Flush has been
// finished.
- bool Flush(CompletionCallback callback);
+ int32_t Flush(CompletionCallback callback);
// Dispatches abortion request to the decoder to abort decoding as soon as
// possible. |callback| will be called as soon as abortion has been finished.
- bool Abort(CompletionCallback callback);
+ int32_t Abort(CompletionCallback callback);
private:
// Pointer to the plugin's video decoder support interface for providing the
diff --git a/ppapi/tests/arch_dependent_sizes_32.h b/ppapi/tests/arch_dependent_sizes_32.h
index b7661cb..f797494 100644
--- a/ppapi/tests/arch_dependent_sizes_32.h
+++ b/ppapi/tests/arch_dependent_sizes_32.h
@@ -19,7 +19,7 @@ PP_COMPILE_ASSERT_STRUCT_SIZE_IN_BYTES(PP_CompletionCallback, 8);
PP_COMPILE_ASSERT_STRUCT_SIZE_IN_BYTES(PP_FileChooserOptions_Dev, 8);
PP_COMPILE_ASSERT_STRUCT_SIZE_IN_BYTES(PP_Picture_Dev, 24);
PP_COMPILE_ASSERT_STRUCT_SIZE_IN_BYTES(PP_VideoBitstreamBuffer_Dev, 12);
-PP_COMPILE_ASSERT_STRUCT_SIZE_IN_BYTES(PPB_VideoDecoder_Dev, 36);
+PP_COMPILE_ASSERT_STRUCT_SIZE_IN_BYTES(PPB_VideoDecoder_Dev, 40);
PP_COMPILE_ASSERT_STRUCT_SIZE_IN_BYTES(PPP_VideoDecoder_Dev, 20);
#endif /* PPAPI_TESTS_ARCH_DEPENDENT_SIZES_32_H_ */
diff --git a/ppapi/tests/arch_dependent_sizes_64.h b/ppapi/tests/arch_dependent_sizes_64.h
index de68721..378c5b3 100644
--- a/ppapi/tests/arch_dependent_sizes_64.h
+++ b/ppapi/tests/arch_dependent_sizes_64.h
@@ -19,7 +19,7 @@ PP_COMPILE_ASSERT_STRUCT_SIZE_IN_BYTES(PP_CompletionCallback, 16);
PP_COMPILE_ASSERT_STRUCT_SIZE_IN_BYTES(PP_FileChooserOptions_Dev, 16);
PP_COMPILE_ASSERT_STRUCT_SIZE_IN_BYTES(PP_Picture_Dev, 24);
PP_COMPILE_ASSERT_STRUCT_SIZE_IN_BYTES(PP_VideoBitstreamBuffer_Dev, 12);
-PP_COMPILE_ASSERT_STRUCT_SIZE_IN_BYTES(PPB_VideoDecoder_Dev, 72);
+PP_COMPILE_ASSERT_STRUCT_SIZE_IN_BYTES(PPB_VideoDecoder_Dev, 80);
PP_COMPILE_ASSERT_STRUCT_SIZE_IN_BYTES(PPP_VideoDecoder_Dev, 40);
#endif /* PPAPI_TESTS_ARCH_DEPENDENT_SIZES_64_H_ */
diff --git a/ppapi/tests/test_video_decoder.cc b/ppapi/tests/test_video_decoder.cc
index db0da55..82f99c7 100644
--- a/ppapi/tests/test_video_decoder.cc
+++ b/ppapi/tests/test_video_decoder.cc
@@ -6,6 +6,7 @@
#include "ppapi/c/dev/ppb_video_decoder_dev.h"
#include "ppapi/c/dev/ppb_testing_dev.h"
+#include "ppapi/c/pp_errors.h"
#include "ppapi/c/ppb_var.h"
#include "ppapi/tests/testing_instance.h"
@@ -20,18 +21,24 @@ bool TestVideoDecoder::Init() {
}
void TestVideoDecoder::RunTest() {
- instance_->LogTest("Create", TestCreate());
+ RUN_TEST(CreateAndInitialize);
}
void TestVideoDecoder::QuitMessageLoop() {
testing_interface_->QuitMessageLoop(instance_->pp_instance());
}
-std::string TestVideoDecoder::TestCreate() {
+std::string TestVideoDecoder::TestCreateAndInitialize() {
PP_Resource decoder = video_decoder_interface_->Create(
- instance_->pp_instance(), NULL, PP_MakeCompletionCallback(NULL, NULL));
- if (decoder == 0) {
- return "Error creating the decoder";
- }
+ instance_->pp_instance());
+ if (decoder == 0)
+ return "Create: error creating the decoder";
+
+ int32_t pp_error = video_decoder_interface_->Initialize(
+ decoder, NULL, PP_BlockUntilComplete());
+ pp::Module::Get()->core()->ReleaseResource(decoder);
+ if (pp_error != PP_ERROR_BADARGUMENT)
+ return "Initialize: error detecting null callback";
+
PASS();
}
diff --git a/ppapi/tests/test_video_decoder.h b/ppapi/tests/test_video_decoder.h
index 15e0b39..dbef66f 100644
--- a/ppapi/tests/test_video_decoder.h
+++ b/ppapi/tests/test_video_decoder.h
@@ -22,7 +22,7 @@ class TestVideoDecoder : public TestCase {
void QuitMessageLoop();
private:
- std::string TestCreate();
+ std::string TestCreateAndInitialize();
// Used by the tests that access the C API directly.
const PPB_VideoDecoder_Dev* video_decoder_interface_;