{{+bindTo:partials.standard_nacl_api}}

pp::VideoDecoder Class Reference

{{- dummy div to appease doxygen -}}
Inheritance diagram for pp::VideoDecoder:

List of all members.

Public Member Functions

 VideoDecoder ()
 VideoDecoder (const InstanceHandle &instance)
 VideoDecoder (const VideoDecoder &other)
int32_t Initialize (const Graphics3D &graphics3d_context, PP_VideoProfile profile, bool allow_software_fallback, const CompletionCallback &callback)
int32_t Decode (uint32_t decode_id, uint32_t size, const void *buffer, const CompletionCallback &callback)
int32_t GetPicture (const CompletionCallbackWithOutput< PP_VideoPicture > &callback)
void RecyclePicture (const PP_VideoPicture &picture)
int32_t Flush (const CompletionCallback &callback)
int32_t Reset (const CompletionCallback &callback)

Detailed Description

Video decoder interface.

Typical usage:

  • Call Create() to create a new video decoder resource.
  • Call Initialize() to initialize it with a 3d graphics context and the desired codec profile.
  • Call Decode() continuously (waiting for each previous call to complete) to push bitstream buffers to the decoder.
  • Call GetPicture() continuously (waiting for each previous call to complete) to pull decoded pictures from the decoder.
  • Call Flush() to signal end of stream to the decoder and perform shutdown when it completes.
  • Call Reset() to quickly stop the decoder (e.g. to implement Seek) and wait for the callback before restarting decoding at another point.
  • To destroy the decoder, the plugin should release all of its references to it. Any pending callbacks will abort before the decoder is destroyed.

Available video codecs vary by platform. All: theora, vorbis, vp8. Chrome and ChromeOS: aac, h264. ChromeOS: mpeg4.


Constructor & Destructor Documentation

Default constructor for creating an is_null() VideoDecoder object.

pp::VideoDecoder::VideoDecoder ( const InstanceHandle instance) [explicit]

A constructor used to create a VideoDecoder and associate it with the provided Instance.

Parameters:
[in]instanceThe instance with which this resource will be associated.

The copy constructor for VideoDecoder.

Parameters:
[in]otherA reference to a VideoDecoder.

Member Function Documentation

int32_t pp::VideoDecoder::Decode ( uint32_t  decode_id,
uint32_t  size,
const void *  buffer,
const CompletionCallback callback 
)

Decodes a bitstream buffer.

Copies |size| bytes of data from the plugin's |buffer|. The plugin should maintain the buffer and not call Decode() again until the decoder signals completion by returning PP_OK or by running |callback|.

In general, each bitstream buffer should contain a demuxed bitstream frame for the selected video codec. For example, H264 decoders expect to receive one AnnexB NAL unit, including the 4 byte start code prefix, while VP8 decoders expect to receive a bitstream frame without the IVF frame header.

If the call to Decode() eventually results in a picture, the |decode_id| parameter is copied into the returned picture. The plugin can use this to associate decoded pictures with Decode() calls (e.g. to assign timestamps or frame numbers to pictures.) This value is opaque to the API so the plugin is free to pass any value.

Parameters:
[in]decode_idAn optional value, chosen by the plugin, that can be used to associate calls to Decode() with decoded pictures returned by GetPicture().
[in]sizeBuffer size in bytes.
[in]bufferStarting address of buffer.
[in]callbackA CompletionCallback to be called on completion.
Returns:
An int32_t containing an error code from pp_errors.h.
int32_t pp::VideoDecoder::Flush ( const CompletionCallback callback)

Flushes the decoder.

The plugin should call this when it reaches the end of its video stream in order to stop cleanly. The decoder will run all pending calls to completion. The plugin should make no further calls to the decoder other than GetPicture() and RecyclePicture() until the decoder signals completion by running the callback. Just before completion, any pending GetPicture() call will complete by running the callback with result PP_ERROR_ABORTED to signal that no more pictures are available.

Parameters:
[in]callbackA CompletionCallback to be called on completion.
Returns:
An int32_t containing an error code from pp_errors.h.
int32_t pp::VideoDecoder::GetPicture ( const CompletionCallbackWithOutput< PP_VideoPicture > &  callback)

Gets the next picture from the decoder.

The picture is valid after the decoder signals completion by returning PP_OK or running |callback|. The plugin can call GetPicture() again after the decoder signals completion. When the plugin is finished using the picture, it should return it to the system by calling RecyclePicture().

Parameters:
[in]video_decoderA PP_Resource identifying the video decoder.
[in]callbackA CompletionCallbackWithOutput to be called on completion, and on success, to hold the picture descriptor.
Returns:
An int32_t containing an error code from pp_errors.h. Returns PP_OK if a picture is available. Returns PP_ERROR_ABORTED when Reset() is called, or if a call to Flush() completes while GetPicture() is pending.
int32_t pp::VideoDecoder::Initialize ( const Graphics3D graphics3d_context,
PP_VideoProfile  profile,
bool  allow_software_fallback,
const CompletionCallback callback 
)

Initializes a video decoder resource.

This should be called after Create() and before any other functions.

Parameters:
[in]video_decoderA PP_Resource identifying the video decoder.
[in]profileA PP_VideoProfile specifying the video codec profile.
[in]allow_software_fallbackA PP_Bool specifying whether the decoder can fall back to software decoding if a suitable hardware decoder isn't available.
[in]callbackA CompletionCallback to be called on completion.
Returns:
An int32_t containing an error code from pp_errors.h. Returns PP_ERROR_NOTSUPPORTED if video decoding is not available, or the requested profile is not supported. In this case, the client may call Initialize() again with different parameters to find a good configuration.
void pp::VideoDecoder::RecyclePicture ( const PP_VideoPicture &  picture)

Recycles a picture that the plugin has received from the decoder.

The plugin should call this as soon as it has finished using the texture so the decoder can decode more pictures.

Parameters:
[in]pictureA PP_VideoPicture to return to the decoder.
int32_t pp::VideoDecoder::Reset ( const CompletionCallback callback)

Resets the decoder as quickly as possible.

The plugin can call Reset() to skip to another position in the video stream. Pending calls to Decode() and GetPicture()) are immediately aborted, causing their callbacks to run with PP_ERROR_ABORTED. The plugin should not make any further calls to the decoder until the decoder signals completion by running |callback|.

Parameters:
[in]callbackA CompletionCallback to be called on completion.
Returns:
An int32_t containing an error code from pp_errors.h.

The documentation for this class was generated from the following file:
{{/partials.standard_nacl_api}}