diff options
author | bbudge@chromium.org <bbudge@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2014-05-06 21:35:49 +0000 |
---|---|---|
committer | bbudge@chromium.org <bbudge@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2014-05-06 21:35:49 +0000 |
commit | 4f0c4c41cd94564d7f62435a3baf5dd33b1eeb69 (patch) | |
tree | 1bd073fd23acae7a6987080e23971c60d335f096 /ppapi/api | |
parent | 6b6e354ab83d2ea9eea9b39014aa96ad153e44b2 (diff) | |
download | chromium_src-4f0c4c41cd94564d7f62435a3baf5dd33b1eeb69.zip chromium_src-4f0c4c41cd94564d7f62435a3baf5dd33b1eeb69.tar.gz chromium_src-4f0c4c41cd94564d7f62435a3baf5dd33b1eeb69.tar.bz2 |
Adds IDL for enums and structs for encoding/decoding.
Adds IDL for PPB_VideoDecoder.
Adds C++ wrappers and generated files.
BUG=281689
R=binji@chromium.org, dmichael@chromium.org, igorc@chromium.org
Review URL: https://codereview.chromium.org/210373003
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@268618 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'ppapi/api')
-rw-r--r-- | ppapi/api/pp_codecs.idl | 56 | ||||
-rw-r--r-- | ppapi/api/ppb_video_decoder.idl | 203 |
2 files changed, 259 insertions, 0 deletions
diff --git a/ppapi/api/pp_codecs.idl b/ppapi/api/pp_codecs.idl new file mode 100644 index 0000000..8a7c0f7 --- /dev/null +++ b/ppapi/api/pp_codecs.idl @@ -0,0 +1,56 @@ +/* Copyright (c) 2014 The Chromium Authors. All rights reserved. + * Use of this source code is governed by a BSD-style license that can be + * found in the LICENSE file. + */ + +/** + * Video profiles. + */ +enum PP_VideoProfile { + PP_VIDEOPROFILE_H264BASELINE = 0, + PP_VIDEOPROFILE_H264MAIN = 1, + PP_VIDEOPROFILE_H264EXTENDED = 2, + PP_VIDEOPROFILE_H264HIGH = 3, + PP_VIDEOPROFILE_H264HIGH10PROFILE = 4, + PP_VIDEOPROFILE_H264HIGH422PROFILE = 5, + PP_VIDEOPROFILE_H264HIGH444PREDICTIVEPROFILE = 6, + PP_VIDEOPROFILE_H264SCALABLEBASELINE = 7, + PP_VIDEOPROFILE_H264SCALABLEHIGH = 8, + PP_VIDEOPROFILE_H264STEREOHIGH = 9, + PP_VIDEOPROFILE_H264MULTIVIEWHIGH = 10, + PP_VIDEOPROFILE_VP8MAIN = 11, + PP_VIDEOPROFILE_MAX = PP_VIDEOPROFILE_VP8MAIN +}; + +/** + * Struct describing a decoded video picture. The decoded picture data is stored + * in the GL texture corresponding to |texture_id|. The plugin can determine + * which Decode call generated the picture using |decode_id|. + */ +struct PP_VideoPicture { + /** + * |decode_id| parameter of the Decode call which generated this picture. + * See the PPB_VideoDecoder function Decode() for more details. + */ + uint32_t decode_id; + + /** + * Texture ID in the plugin's GL context. The plugin can use this to render + * the decoded picture. + */ + uint32_t texture_id; + + /** + * The GL texture target for the decoded picture. Possible values are: + * GL_TEXTURE_2D (normalized texture coordinates) + * GL_TEXTURE_RECTANGLE_ARB (dimension dependent texture coordinates) + * + * The pixel format of the texture is GL_BGRA. + */ + uint32_t texture_target; + + /** + * Dimensions of the texture holding the decoded picture. + */ + PP_Size texture_size; +}; diff --git a/ppapi/api/ppb_video_decoder.idl b/ppapi/api/ppb_video_decoder.idl new file mode 100644 index 0000000..90a3520 --- /dev/null +++ b/ppapi/api/ppb_video_decoder.idl @@ -0,0 +1,203 @@ +/* Copyright (c) 2014 The Chromium Authors. All rights reserved. + * Use of this source code is governed by a BSD-style license that can be + * found in the LICENSE file. + */ + +/** + * This file defines the <code>PPB_VideoDecoder</code> interface. + */ + +[generate_thunk] + +label Chrome { + [channel=dev] M36 = 0.1 +}; + +/** + * 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. + */ +interface PPB_VideoDecoder { + /** + * Creates a new video decoder resource. + * + * @param[in] instance A <code>PP_Instance</code> identifying the instance + * with the video decoder. + * + * @return A <code>PP_Resource</code> corresponding to a video decoder if + * successful or 0 otherwise. + */ + PP_Resource Create( + [in] PP_Instance instance); + + /** + * Determines if the given resource is a video decoder. + * + * @param[in] resource A <code>PP_Resource</code> identifying a resource. + * + * @return <code>PP_TRUE</code> if the resource is a + * <code>PPB_VideoDecoder</code>, <code>PP_FALSE</code> if the resource is + * invalid or some other type. + */ + PP_Bool IsVideoDecoder( + [in] PP_Resource resource); + + /** + * Initializes a video decoder resource. This should be called after Create() + * and before any other functions. + * + * @param[in] video_decoder A <code>PP_Resource</code> identifying the video + * decoder. + * @param[in] graphics3d_context A <code>PPB_Graphics3D</code> resource to use + * during decoding. + * @param[in] profile A <code>PP_VideoProfile</code> specifying the video + * codec profile. + * @param[in] allow_software_fallback A <code>PP_Bool</code> specifying + * whether the decoder can fall back to software decoding if a suitable + * hardware decoder isn't available. + * @param[in] callback A <code>PP_CompletionCallback</code> to be called upon + * completion. + * + * @return An int32_t containing an error code from <code>pp_errors.h</code>. + * 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. + */ + int32_t Initialize( + [in] PP_Resource video_decoder, + [in] PP_Resource graphics3d_context, + [in] PP_VideoProfile profile, + [in] PP_Bool allow_software_fallback, + [in] PP_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. + * + * @param[in] video_decoder A <code>PP_Resource</code> identifying the video + * decoder. + * @param[in] decode_id An optional value, chosen by the plugin, that can be + * used to associate calls to Decode() with decoded pictures returned by + * GetPicture(). + * @param[in] size Buffer size in bytes. + * @param[in] buffer Starting address of buffer. + * @param[in] callback A <code>PP_CompletionCallback</code> to be called on + * completion. + * + * @return An int32_t containing an error code from <code>pp_errors.h</code>. + */ + int32_t Decode( + [in] PP_Resource video_decoder, + [in] uint32_t decode_id, + [in] uint32_t size, + [in] mem_t buffer, + [in] PP_CompletionCallback 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(). + * + * @param[in] video_decoder A <code>PP_Resource</code> identifying the video + * decoder. + * @param[out] picture A <code>PP_VideoPicture</code> to hold the decoded + * picture. + * @param[in] callback A <code>PP_CompletionCallback</code> to be called on + * completion. + * + * @return An int32_t containing an error code from <code>pp_errors.h</code>. + * 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 GetPicture( + [in] PP_Resource video_decoder, + [out] PP_VideoPicture picture, + [in] PP_CompletionCallback callback); + + /** + * 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. + * + * @param[in] video_decoder A <code>PP_Resource</code> identifying the video + * decoder. + * @param[in] picture A <code>PP_VideoPicture</code> to return to + * the decoder. + */ + void RecyclePicture( + [in] PP_Resource video_decoder, + [in] PP_VideoPicture picture); + + /** + * 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. + * + * @param[in] video_decoder A <code>PP_Resource</code> identifying the video + * decoder. + * @param[in] callback A <code>PP_CompletionCallback</code> to be called on + * completion. + * + * @return An int32_t containing an error code from <code>pp_errors.h</code>. + */ + int32_t Flush( + [in] PP_Resource video_decoder, + [in] PP_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|. + * + * @param[in] video_decoder A <code>PP_Resource</code> identifying the video + * decoder. + * @param[in] callback A <code>PP_CompletionCallback</code> to be called on + * completion. + * + * @return An int32_t containing an error code from <code>pp_errors.h</code>. + */ + int32_t Reset( + [in] PP_Resource video_decoder, + [in] PP_CompletionCallback callback); +}; |