summaryrefslogtreecommitdiffstats
path: root/ppapi/cpp/dev
diff options
context:
space:
mode:
Diffstat (limited to 'ppapi/cpp/dev')
-rw-r--r--ppapi/cpp/dev/video_decoder_dev.cc54
-rw-r--r--ppapi/cpp/dev/video_decoder_dev.h183
2 files changed, 86 insertions, 151 deletions
diff --git a/ppapi/cpp/dev/video_decoder_dev.cc b/ppapi/cpp/dev/video_decoder_dev.cc
index f0d10b6..1749ab0 100644
--- a/ppapi/cpp/dev/video_decoder_dev.cc
+++ b/ppapi/cpp/dev/video_decoder_dev.cc
@@ -4,9 +4,6 @@
#include "ppapi/cpp/dev/video_decoder_dev.h"
-#include <algorithm>
-#include <iterator>
-
#include "ppapi/c/dev/ppb_video_decoder_dev.h"
#include "ppapi/c/dev/ppp_video_decoder_dev.h"
#include "ppapi/c/pp_errors.h"
@@ -27,54 +24,63 @@ template <> const char* interface_name<PPB_VideoDecoder_Dev>() {
} // namespace
-VideoDecoder::VideoDecoder(
- const Instance* /* instance */,
- VideoDecoderClient* /* picture_interface */) {
+VideoDecoder::VideoDecoder(const Instance* /* instance */,
+ const std::vector<uint32_t>& /* config */,
+ Client* client)
+ : client_(client) {
if (!has_interface<PPB_VideoDecoder_Dev>())
return;
+ // TODO(vmr): Implement.
}
VideoDecoder::~VideoDecoder() {}
-vector<uint32_t> VideoDecoder::GetConfig(
+vector<uint32_t> VideoDecoder::GetConfigs(
Instance* /* instance */,
const vector<uint32_t>& /* prototype_config */) {
+ // TODO(vmr): Implement.
vector<uint32_t> matching_configs;
if (!has_interface<PPB_VideoDecoder_Dev>())
return matching_configs;
return matching_configs;
}
-bool VideoDecoder::Initialize(const std::vector<uint32_t>& /* config */) {
- if (!has_interface<PPB_VideoDecoder_Dev>())
- return false;
- return false;
+void VideoDecoder::AssignGLESBuffers(uint32_t /* no_of_buffers */,
+ const PP_GLESBuffer_Dev& /* buffers */) {
+ // TODO(vmr): Implement.
+}
+
+void VideoDecoder::AssignSysmemBuffers(
+ uint32_t /* no_of_buffers */,
+ const PP_SysmemBuffer_Dev& /* buffers */) {
+ // TODO(vmr): Implement.
}
bool VideoDecoder::Decode(
const PP_VideoBitstreamBuffer_Dev& /* bitstream_buffer */,
- PP_CompletionCallback /* callback */) {
+ CompletionCallback /* callback */) {
+ // TODO(vmr): Implement.
if (!has_interface<PPB_VideoDecoder_Dev>() || !pp_resource())
return false;
return false;
}
-int32_t VideoDecoder::Flush(PP_CompletionCallback /* callback */) {
- if (!has_interface<PPB_VideoDecoder_Dev>())
- return PP_ERROR_NOINTERFACE;
- return PP_ERROR_ABORTED;
+void VideoDecoder::ReusePictureBuffer(int32_t /* picture_buffer_id */) {
+ // TODO(vmr): Implement.
}
-int32_t VideoDecoder::Abort(PP_CompletionCallback /* callback */) {
+bool VideoDecoder::Flush(CompletionCallback /* callback */) {
+ // TODO(vmr): Implement.
if (!has_interface<PPB_VideoDecoder_Dev>())
- return PP_ERROR_NOINTERFACE;
- return PP_ERROR_ABORTED;
+ return false;
+ return true;
}
-void VideoDecoder::EventPicture(struct PP_Picture_Dev* /* picture */) {}
-
-void VideoDecoder::EventEndOfStream() {}
-
-void VideoDecoder::EventError(PP_VideoDecodeError_Dev /* error */) {}
+bool VideoDecoder::Abort(CompletionCallback /* callback */) {
+ // TODO(vmr): Implement.
+ if (!has_interface<PPB_VideoDecoder_Dev>())
+ return false;
+ return true;
+}
} // namespace pp
diff --git a/ppapi/cpp/dev/video_decoder_dev.h b/ppapi/cpp/dev/video_decoder_dev.h
index 698e81e..ff7be2a 100644
--- a/ppapi/cpp/dev/video_decoder_dev.h
+++ b/ppapi/cpp/dev/video_decoder_dev.h
@@ -5,13 +5,10 @@
#ifndef PPAPI_CPP_DEV_VIDEO_DECODER_DEV_H_
#define PPAPI_CPP_DEV_VIDEO_DECODER_DEV_H_
-#include <map>
-#include <set>
#include <vector>
#include "ppapi/c/dev/pp_video_dev.h"
-#include "ppapi/c/pp_completion_callback.h"
-#include "ppapi/c/pp_var.h"
+#include "ppapi/cpp/completion_callback.h"
#include "ppapi/cpp/dev/buffer_dev.h"
#include "ppapi/cpp/resource.h"
@@ -19,154 +16,86 @@ namespace pp {
class Instance;
-// Convenience C++ wrapper around video decoder output picture that allows easy
-// manipulation of the object properties.
-class VideoDecoderPicture {
+// C++ wrapper for the Pepper Video Decoder interface. For more detailed
+// documentation refer to PPB_VideoDecoder_Dev and PPP_VideoDecoder_Dev
+// interfaces.
+//
+// C++ version of the PPB_VideoDecoder_Dev interface.
+class VideoDecoder : public Resource {
public:
- explicit VideoDecoderPicture(struct PP_Picture_Dev* picture);
- ~VideoDecoderPicture();
-
- // Picture size related functions.
- // There are three types of logical picture sizes that applications using
- // video decoder should be aware of:
- // - Visible picture size,
- // - Decoded picture size, and
- // - Picture buffer size.
- //
- // Visible picture size means the actual picture size that is intended to be
- // displayed from the decoded output.
- //
- // Decoded picture size might vary from the visible size of the picture,
- // because of the underlying properties of the codec. Vast majority of modern
- // video compression algorithms are based on (macro)block-based transforms and
- // therefore process the picture in small windows (usually of size 16x16
- // pixels) one by one. However, if the native picture size does not happen to
- // match the block-size of the algorithm, there may be redundant data left on
- // the sides of the output picture, which are not intended for display. For
- // example, this happens to video of size 854x480 and H.264 codec. Since the
- // width (854 pixels) is not multiple of the block size of the coding format
- // (16 pixels), pixel columns 854-863 contain garbage data which is not
- // intended for display.
- //
- // Plugin is providing the buffers for output decoding and it should know the
- // picture buffer size it has provided to the decoder. Thus, there is no
- // function to query the buffer size from this class.
- //
- // GetDecodedPictureSize returns the decoded size of the decoded picture.
- // Returns PP_Size telling the decoded size of the picture in pixels.
- PP_Size GetDecodedPictureSize() const;
+ // C++ version of PPP_VideoDecoder_Dev interface.
+ class Client {
+ public:
+ virtual ~Client();
- // GetVisiblePictureSize returns the visible size of the decoded picture.
- // Returns PP_Size telling the visible size of the picture in pixels.
- PP_Size GetVisiblePictureSize() const;
+ // 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;
- // GetPictureFlags returns flags associated with the picture.
- // Returns bitmask containing values from PP_PictureInfoFlag_Dev enumeration.
- uint32_t GetPictureFlags() const;
+ // Callback for decoder to delivered unneeded picture buffers back to the
+ // plugin.
+ virtual void DismissPictureBuffer(int32_t picture_buffer_id) = 0;
- // GetMetadata returns metadata associated with the picture.
- // Returns Buffer_Dev object representing the buffer with the metadata.
- Buffer_Dev GetMetadata() const;
+ // Callback to deliver decoded pictures ready to be displayed.
+ virtual void PictureReady(const PP_Picture_Dev& picture) = 0;
- private:
- PP_Picture_Dev picture;
-};
-
-// Interface for collaborating with picture interface to provide memory for
-// output picture and blitting them.
-class VideoDecoderClient {
- public:
- virtual ~VideoDecoderClient();
+ // Callback to notify that decoder has decoded end of stream marker and has
+ // outputted all displayable pictures.
+ virtual void NotifyEndOfStream() = 0;
- // Callback to provide buffers for the decoded output pictures.
- virtual std::vector<Resource> ProvidePictureBuffers(
- uint32_t requested_num_of_buffers,
- const std::vector<uint32_t>& buffer_properties) = 0;
+ // Callback to notify about decoding errors.
+ virtual void NotifyError(PP_VideoDecodeError_Dev error) = 0;
+ };
- // Callback to deliver decoded pictures ready to be displayed.
- virtual void PictureReady(struct PP_Picture_Dev* picture) = 0;
-
- // Callback to notify that decoder has decoded end of stream marker and has
- // outputted all displayable pictures.
- virtual void NotifyEndOfStream() = 0;
-
- // Callback to notify about decoding errors.
- virtual void NotifyError(PP_VideoDecodeError_Dev error) = 0;
-};
-
-// C++ wrapper for the Pepper Video Decoder interface.
-class VideoDecoder : public Resource {
- public:
- VideoDecoder(const Instance* instance,
- VideoDecoderClient* picture_interface);
+ // Constructor for the video decoder. Calls the Create on the
+ // PPB_VideoDecoder_Dev interface.
+ //
+ // Parameters:
+ // |instance| is the pointer to the plug-in instance.
+ // |config| is the configuration on which the decoder should be 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,
+ Client* client);
~VideoDecoder();
- // GetConfig returns supported configurations that are subsets of given
+ // GetConfigs returns supported configurations that are subsets of given
// |prototype_config|.
- // Parameters:
- // |instance| is the pointer to the plug-in instance.
- // |prototype_config| is the prototypical configuration.
- //
- // Returns std::vector containing all the configurations that match the
- // prototypical configuration.
- std::vector<uint32_t> GetConfig(
+ static std::vector<uint32_t> GetConfigs(
Instance* instance,
const std::vector<uint32_t>& prototype_config);
- // Initializes the video decoder with specific configuration.
- // Parameters:
- // |config| is the configuration on which the decoder should be initialized.
- //
- // Returns true when command successfully accepted. Otherwise false.
- bool Initialize(const std::vector<uint32_t>& config);
+ // 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);
// Decodes given bitstream buffer. Once decoder is done with processing
// |bitstream_buffer| is will call |callback| with provided user data.
- // Parameters:
- // |bitstream_buffer| is the input bitstream that is sent for decoding.
- // |callback| contains the callback function pointer with the custom userdata
- // plugin wants to associate with the callback.
- //
- // Returns true when command successfully accepted. Otherwise false.
bool Decode(const PP_VideoBitstreamBuffer_Dev& bitstream_buffer,
- PP_CompletionCallback callback);
+ CompletionCallback callback);
- // Flushes the decoder. Once decoder has released pending bitstream buffers
- // and pictures and reset internal picture state it will call |callback| with
- // the user provided user data.
- // Parameters:
- // |callback| contains the callback function pointer with the custom userdata
- // plugin wants to associate with the callback.
- //
- // Returns true when command successfully accepted. Otherwise false.
- int32_t Flush(PP_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);
// Dispatches abortion request to the decoder to abort decoding as soon as
- // possible and will not output anything or generate new callbacks. |callback|
- // will be called as soon as abortion has been finished. After abortion all
- // buffers can be considered dismissed even when there has not been callbacks
- // to dismiss them.
- //
- // Parameters:
- // |callback| is one-time callback that will be called once the abortion
- // request has been completed.
- //
- // Returns true when command successfully accepted. Otherwise false.
- int32_t Abort(PP_CompletionCallback callback);
+ // possible. |callback| will be called as soon as abortion has been finished.
+ bool Abort(CompletionCallback callback);
private:
- // Functions that handle event notification to all the relevant interfaces.
- // Function to handle event when a picture is ready.
- virtual void EventPicture(struct PP_Picture_Dev* picture);
- // Function to handle event when end of stream occurs.
- virtual void EventEndOfStream();
- // Function to handle event when error occurs.
- virtual void EventError(PP_VideoDecodeError_Dev error);
-
// Pointer to the plugin's video decoder support interface for providing the
// buffers for video decoding.
- VideoDecoderClient* picture_if_;
+ Client* client_;
+ // Suppress compiler-generated copy constructors.
VideoDecoder(const VideoDecoder&);
void operator=(const VideoDecoder&);
};