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 | |
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
-rw-r--r-- | native_client_sdk/src/libraries/ppapi/library.dsc | 2 | ||||
-rw-r--r-- | native_client_sdk/src/libraries/ppapi_cpp/library.dsc | 2 | ||||
-rw-r--r-- | ppapi/api/pp_codecs.idl | 56 | ||||
-rw-r--r-- | ppapi/api/ppb_video_decoder.idl | 203 | ||||
-rw-r--r-- | ppapi/c/pp_codecs.h | 82 | ||||
-rw-r--r-- | ppapi/c/ppb_video_decoder.h | 209 | ||||
-rw-r--r-- | ppapi/cpp/video_decoder.cc | 96 | ||||
-rw-r--r-- | ppapi/cpp/video_decoder.h | 168 | ||||
-rw-r--r-- | ppapi/native_client/src/untrusted/pnacl_irt_shim/pnacl_shim.c | 64 | ||||
-rw-r--r-- | ppapi/ppapi_shared.gypi | 1 | ||||
-rw-r--r-- | ppapi/ppapi_sources.gypi | 4 | ||||
-rw-r--r-- | ppapi/thunk/ppb_video_decoder_api.h | 40 | ||||
-rw-r--r-- | ppapi/thunk/ppb_video_decoder_thunk.cc | 120 |
13 files changed, 1047 insertions, 0 deletions
diff --git a/native_client_sdk/src/libraries/ppapi/library.dsc b/native_client_sdk/src/libraries/ppapi/library.dsc index 919f1f6..7f96b9b 100644 --- a/native_client_sdk/src/libraries/ppapi/library.dsc +++ b/native_client_sdk/src/libraries/ppapi/library.dsc @@ -59,9 +59,11 @@ 'ppb_var_array.h', 'ppb_var_dictionary.h', 'ppb_var.h', + 'ppb_video_decoder.h', 'ppb_video_frame.h', 'ppb_view.h', 'ppb_websocket.h', + 'pp_codecs.h', 'pp_completion_callback.h', 'pp_directory_entry.h', 'pp_errors.h', diff --git a/native_client_sdk/src/libraries/ppapi_cpp/library.dsc b/native_client_sdk/src/libraries/ppapi_cpp/library.dsc index b0d13ff..60abc3f 100644 --- a/native_client_sdk/src/libraries/ppapi_cpp/library.dsc +++ b/native_client_sdk/src/libraries/ppapi_cpp/library.dsc @@ -55,6 +55,7 @@ 'var_array.cc', 'var.cc', 'var_dictionary.cc', + 'video_decoder.cc', 'video_frame.cc', 'view.cc', 'websocket.cc', @@ -138,6 +139,7 @@ 'var_array.h', 'var_dictionary.h', 'var.h', + 'video_decoder.h', 'video_frame.h', 'view.h', 'websocket.h', 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); +}; diff --git a/ppapi/c/pp_codecs.h b/ppapi/c/pp_codecs.h new file mode 100644 index 0000000..b98769e --- /dev/null +++ b/ppapi/c/pp_codecs.h @@ -0,0 +1,82 @@ +/* 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. + */ + +/* From pp_codecs.idl modified Tue May 6 05:14:19 2014. */ + +#ifndef PPAPI_C_PP_CODECS_H_ +#define PPAPI_C_PP_CODECS_H_ + +#include "ppapi/c/pp_macros.h" +#include "ppapi/c/pp_size.h" +#include "ppapi/c/pp_stdint.h" + +/** + * @file + * Video profiles. + */ + + +/** + * @addtogroup Enums + * @{ + */ +typedef enum { + 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 +} PP_VideoProfile; +/** + * @} + */ + +/** + * @addtogroup Structs + * @{ + */ +/** + * 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. + */ + struct PP_Size texture_size; +}; +/** + * @} + */ + +#endif /* PPAPI_C_PP_CODECS_H_ */ + diff --git a/ppapi/c/ppb_video_decoder.h b/ppapi/c/ppb_video_decoder.h new file mode 100644 index 0000000..f09908c --- /dev/null +++ b/ppapi/c/ppb_video_decoder.h @@ -0,0 +1,209 @@ +/* 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. + */ + +/* From ppb_video_decoder.idl modified Tue May 6 05:19:45 2014. */ + +#ifndef PPAPI_C_PPB_VIDEO_DECODER_H_ +#define PPAPI_C_PPB_VIDEO_DECODER_H_ + +#include "ppapi/c/pp_bool.h" +#include "ppapi/c/pp_codecs.h" +#include "ppapi/c/pp_completion_callback.h" +#include "ppapi/c/pp_instance.h" +#include "ppapi/c/pp_macros.h" +#include "ppapi/c/pp_resource.h" +#include "ppapi/c/pp_size.h" +#include "ppapi/c/pp_stdint.h" + +#define PPB_VIDEODECODER_INTERFACE_0_1 "PPB_VideoDecoder;0.1" /* dev */ +/** + * @file + * This file defines the <code>PPB_VideoDecoder</code> interface. + */ + + +/** + * @addtogroup Interfaces + * @{ + */ +/** + * 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. + */ +struct PPB_VideoDecoder_0_1 { /* dev */ + /** + * 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)(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)(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)(PP_Resource video_decoder, + PP_Resource graphics3d_context, + PP_VideoProfile profile, + PP_Bool allow_software_fallback, + struct 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)(PP_Resource video_decoder, + uint32_t decode_id, + uint32_t size, + const void* buffer, + struct 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)(PP_Resource video_decoder, + struct PP_VideoPicture* picture, + struct 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)(PP_Resource video_decoder, + const struct 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)(PP_Resource video_decoder, + struct 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)(PP_Resource video_decoder, + struct PP_CompletionCallback callback); +}; +/** + * @} + */ + +#endif /* PPAPI_C_PPB_VIDEO_DECODER_H_ */ + diff --git a/ppapi/cpp/video_decoder.cc b/ppapi/cpp/video_decoder.cc new file mode 100644 index 0000000..3277a21 --- /dev/null +++ b/ppapi/cpp/video_decoder.cc @@ -0,0 +1,96 @@ +// 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. + +#include "ppapi/cpp/video_decoder.h" + +#include "ppapi/c/pp_errors.h" +#include "ppapi/c/ppb_video_decoder.h" +#include "ppapi/cpp/completion_callback.h" +#include "ppapi/cpp/instance_handle.h" +#include "ppapi/cpp/module.h" +#include "ppapi/cpp/module_impl.h" + +namespace pp { + +namespace { + +template <> +const char* interface_name<PPB_VideoDecoder_0_1>() { + return PPB_VIDEODECODER_INTERFACE_0_1; +} + +} // namespace + +VideoDecoder::VideoDecoder() { +} + +VideoDecoder::VideoDecoder(const InstanceHandle& instance) { + if (has_interface<PPB_VideoDecoder_0_1>()) { + PassRefFromConstructor( + get_interface<PPB_VideoDecoder_0_1>()->Create(instance.pp_instance())); + } +} + +VideoDecoder::VideoDecoder(const VideoDecoder& other) : Resource(other) { +} + +int32_t VideoDecoder::Initialize(const Graphics3D& context, + PP_VideoProfile profile, + bool allow_software_fallback, + const CompletionCallback& cc) { + if (has_interface<PPB_VideoDecoder_0_1>()) { + return get_interface<PPB_VideoDecoder_0_1>()->Initialize( + pp_resource(), + context.pp_resource(), + profile, + PP_FromBool(allow_software_fallback), + cc.pp_completion_callback()); + } + return cc.MayForce(PP_ERROR_NOINTERFACE); +} + +int32_t VideoDecoder::Decode(uint32_t decode_id, + uint32_t size, + const void* buffer, + const CompletionCallback& cc) { + if (has_interface<PPB_VideoDecoder_0_1>()) { + return get_interface<PPB_VideoDecoder_0_1>()->Decode( + pp_resource(), decode_id, size, buffer, cc.pp_completion_callback()); + } + return cc.MayForce(PP_ERROR_NOINTERFACE); +} + +int32_t VideoDecoder::GetPicture( + const CompletionCallbackWithOutput<PP_VideoPicture>& cc) { + if (has_interface<PPB_VideoDecoder_0_1>()) { + return get_interface<PPB_VideoDecoder_0_1>()->GetPicture( + pp_resource(), cc.output(), cc.pp_completion_callback()); + } + return cc.MayForce(PP_ERROR_NOINTERFACE); +} + +void VideoDecoder::RecyclePicture(const PP_VideoPicture& picture) { + if (has_interface<PPB_VideoDecoder_0_1>()) { + get_interface<PPB_VideoDecoder_0_1>()->RecyclePicture(pp_resource(), + &picture); + } +} + +int32_t VideoDecoder::Flush(const CompletionCallback& cc) { + if (has_interface<PPB_VideoDecoder_0_1>()) { + return get_interface<PPB_VideoDecoder_0_1>()->Flush( + pp_resource(), cc.pp_completion_callback()); + } + return cc.MayForce(PP_ERROR_NOINTERFACE); +} + +int32_t VideoDecoder::Reset(const CompletionCallback& cc) { + if (has_interface<PPB_VideoDecoder_0_1>()) { + return get_interface<PPB_VideoDecoder_0_1>()->Reset( + pp_resource(), cc.pp_completion_callback()); + } + return cc.MayForce(PP_ERROR_NOINTERFACE); +} + +} // namespace pp diff --git a/ppapi/cpp/video_decoder.h b/ppapi/cpp/video_decoder.h new file mode 100644 index 0000000..f1f2d91 --- /dev/null +++ b/ppapi/cpp/video_decoder.h @@ -0,0 +1,168 @@ +// 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. + +#ifndef PPAPI_CPP_VIDEO_DECODER_H_ +#define PPAPI_CPP_VIDEO_DECODER_H_ + +#include "ppapi/c/pp_codecs.h" +#include "ppapi/c/pp_size.h" +#include "ppapi/cpp/completion_callback.h" +#include "ppapi/cpp/graphics_3d.h" +#include "ppapi/cpp/resource.h" +#include "ppapi/cpp/size.h" + +/// @file +/// This file defines the API to create and use a VideoDecoder resource. + +struct PP_FileInfo; + +namespace pp { + +class InstanceHandle; + +/// 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. +class VideoDecoder : public Resource { + public: + /// Default constructor for creating an is_null() <code>VideoDecoder</code> + /// object. + VideoDecoder(); + + /// A constructor used to create a <code>VideoDecoder</code> and associate it + /// with the provided <code>Instance</code>. + /// @param[in] instance The instance with which this resource will be + /// associated. + explicit VideoDecoder(const InstanceHandle& instance); + + /// The copy constructor for <code>VideoDecoder</code>. + /// @param[in] other A reference to a <code>VideoDecoder</code>. + VideoDecoder(const VideoDecoder& other); + + /// 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] 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>CompletionCallback</code> to be called on + /// 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(const Graphics3D& graphics3d_context, + PP_VideoProfile profile, + bool allow_software_fallback, + 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. + /// + /// @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>CompletionCallback</code> to be called on + /// completion. + /// + /// @return An int32_t containing an error code from <code>pp_errors.h</code>. + int32_t Decode(uint32_t decode_id, + uint32_t size, + const void* buffer, + const 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[in] callback A <code>CompletionCallbackWithOutput</code> to be + /// called on completion, and on success, to hold the picture descriptor. + /// + /// @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( + const CompletionCallbackWithOutput<PP_VideoPicture>& 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] picture A <code>PP_VideoPicture</code> to return to the + /// decoder. + void RecyclePicture(const 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] callback A <code>CompletionCallback</code> to be called on + /// completion. + /// + /// @return An int32_t containing an error code from <code>pp_errors.h</code>. + int32_t Flush(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|. + /// + /// @param[in] callback A <code>CompletionCallback</code> to be called on + /// completion. + /// + /// @return An int32_t containing an error code from <code>pp_errors.h</code>. + int32_t Reset(const CompletionCallback& callback); +}; + +} // namespace pp + +#endif // PPAPI_CPP_VIDEO_DECODER_H_ diff --git a/ppapi/native_client/src/untrusted/pnacl_irt_shim/pnacl_shim.c b/ppapi/native_client/src/untrusted/pnacl_irt_shim/pnacl_shim.c index a85ac72..a3f8a63 100644 --- a/ppapi/native_client/src/untrusted/pnacl_irt_shim/pnacl_shim.c +++ b/ppapi/native_client/src/untrusted/pnacl_irt_shim/pnacl_shim.c @@ -48,6 +48,7 @@ #include "ppapi/c/ppb_var_array.h" #include "ppapi/c/ppb_var_array_buffer.h" #include "ppapi/c/ppb_var_dictionary.h" +#include "ppapi/c/ppb_video_decoder.h" #include "ppapi/c/ppb_websocket.h" #include "ppapi/c/ppp_messaging.h" #include "ppapi/c/private/ppb_content_decryptor_private.h" @@ -136,6 +137,7 @@ static struct __PnaclWrapperInfo Pnacl_WrapperInfo_PPB_Var_1_2; static struct __PnaclWrapperInfo Pnacl_WrapperInfo_PPB_VarArray_1_0; static struct __PnaclWrapperInfo Pnacl_WrapperInfo_PPB_VarArrayBuffer_1_0; static struct __PnaclWrapperInfo Pnacl_WrapperInfo_PPB_VarDictionary_1_0; +static struct __PnaclWrapperInfo Pnacl_WrapperInfo_PPB_VideoDecoder_0_1; static struct __PnaclWrapperInfo Pnacl_WrapperInfo_PPB_WebSocket_1_0; static struct __PnaclWrapperInfo Pnacl_WrapperInfo_PPP_Messaging_1_0; static struct __PnaclWrapperInfo Pnacl_WrapperInfo_PPB_Alarms_Dev_0_1; @@ -1762,6 +1764,50 @@ static void Pnacl_M29_PPB_VarDictionary_GetKeys(struct PP_Var* _struct_result, s /* End wrapper methods for PPB_VarDictionary_1_0 */ +/* Begin wrapper methods for PPB_VideoDecoder_0_1 */ + +static PP_Resource Pnacl_M36_PPB_VideoDecoder_Create(PP_Instance instance) { + const struct PPB_VideoDecoder_0_1 *iface = Pnacl_WrapperInfo_PPB_VideoDecoder_0_1.real_iface; + return iface->Create(instance); +} + +static PP_Bool Pnacl_M36_PPB_VideoDecoder_IsVideoDecoder(PP_Resource resource) { + const struct PPB_VideoDecoder_0_1 *iface = Pnacl_WrapperInfo_PPB_VideoDecoder_0_1.real_iface; + return iface->IsVideoDecoder(resource); +} + +static int32_t Pnacl_M36_PPB_VideoDecoder_Initialize(PP_Resource video_decoder, PP_Resource graphics3d_context, PP_VideoProfile profile, PP_Bool allow_software_fallback, struct PP_CompletionCallback* callback) { + const struct PPB_VideoDecoder_0_1 *iface = Pnacl_WrapperInfo_PPB_VideoDecoder_0_1.real_iface; + return iface->Initialize(video_decoder, graphics3d_context, profile, allow_software_fallback, *callback); +} + +static int32_t Pnacl_M36_PPB_VideoDecoder_Decode(PP_Resource video_decoder, uint32_t decode_id, uint32_t size, const void* buffer, struct PP_CompletionCallback* callback) { + const struct PPB_VideoDecoder_0_1 *iface = Pnacl_WrapperInfo_PPB_VideoDecoder_0_1.real_iface; + return iface->Decode(video_decoder, decode_id, size, buffer, *callback); +} + +static int32_t Pnacl_M36_PPB_VideoDecoder_GetPicture(PP_Resource video_decoder, struct PP_VideoPicture* picture, struct PP_CompletionCallback* callback) { + const struct PPB_VideoDecoder_0_1 *iface = Pnacl_WrapperInfo_PPB_VideoDecoder_0_1.real_iface; + return iface->GetPicture(video_decoder, picture, *callback); +} + +static void Pnacl_M36_PPB_VideoDecoder_RecyclePicture(PP_Resource video_decoder, const struct PP_VideoPicture* picture) { + const struct PPB_VideoDecoder_0_1 *iface = Pnacl_WrapperInfo_PPB_VideoDecoder_0_1.real_iface; + iface->RecyclePicture(video_decoder, picture); +} + +static int32_t Pnacl_M36_PPB_VideoDecoder_Flush(PP_Resource video_decoder, struct PP_CompletionCallback* callback) { + const struct PPB_VideoDecoder_0_1 *iface = Pnacl_WrapperInfo_PPB_VideoDecoder_0_1.real_iface; + return iface->Flush(video_decoder, *callback); +} + +static int32_t Pnacl_M36_PPB_VideoDecoder_Reset(PP_Resource video_decoder, struct PP_CompletionCallback* callback) { + const struct PPB_VideoDecoder_0_1 *iface = Pnacl_WrapperInfo_PPB_VideoDecoder_0_1.real_iface; + return iface->Reset(video_decoder, *callback); +} + +/* End wrapper methods for PPB_VideoDecoder_0_1 */ + /* Not generating wrapper methods for PPB_VideoFrame_0_1 */ /* Not generating wrapper methods for PPB_View_1_0 */ @@ -4650,6 +4696,17 @@ static const struct PPB_VarDictionary_1_0 Pnacl_Wrappers_PPB_VarDictionary_1_0 = .GetKeys = (struct PP_Var (*)(struct PP_Var dict))&Pnacl_M29_PPB_VarDictionary_GetKeys }; +static const struct PPB_VideoDecoder_0_1 Pnacl_Wrappers_PPB_VideoDecoder_0_1 = { + .Create = (PP_Resource (*)(PP_Instance instance))&Pnacl_M36_PPB_VideoDecoder_Create, + .IsVideoDecoder = (PP_Bool (*)(PP_Resource resource))&Pnacl_M36_PPB_VideoDecoder_IsVideoDecoder, + .Initialize = (int32_t (*)(PP_Resource video_decoder, PP_Resource graphics3d_context, PP_VideoProfile profile, PP_Bool allow_software_fallback, struct PP_CompletionCallback callback))&Pnacl_M36_PPB_VideoDecoder_Initialize, + .Decode = (int32_t (*)(PP_Resource video_decoder, uint32_t decode_id, uint32_t size, const void* buffer, struct PP_CompletionCallback callback))&Pnacl_M36_PPB_VideoDecoder_Decode, + .GetPicture = (int32_t (*)(PP_Resource video_decoder, struct PP_VideoPicture* picture, struct PP_CompletionCallback callback))&Pnacl_M36_PPB_VideoDecoder_GetPicture, + .RecyclePicture = (void (*)(PP_Resource video_decoder, const struct PP_VideoPicture* picture))&Pnacl_M36_PPB_VideoDecoder_RecyclePicture, + .Flush = (int32_t (*)(PP_Resource video_decoder, struct PP_CompletionCallback callback))&Pnacl_M36_PPB_VideoDecoder_Flush, + .Reset = (int32_t (*)(PP_Resource video_decoder, struct PP_CompletionCallback callback))&Pnacl_M36_PPB_VideoDecoder_Reset +}; + /* Not generating wrapper interface for PPB_VideoFrame_0_1 */ /* Not generating wrapper interface for PPB_View_1_0 */ @@ -5603,6 +5660,12 @@ static struct __PnaclWrapperInfo Pnacl_WrapperInfo_PPB_VarDictionary_1_0 = { .real_iface = NULL }; +static struct __PnaclWrapperInfo Pnacl_WrapperInfo_PPB_VideoDecoder_0_1 = { + .iface_macro = PPB_VIDEODECODER_INTERFACE_0_1, + .wrapped_iface = (const void *) &Pnacl_Wrappers_PPB_VideoDecoder_0_1, + .real_iface = NULL +}; + static struct __PnaclWrapperInfo Pnacl_WrapperInfo_PPB_WebSocket_1_0 = { .iface_macro = PPB_WEBSOCKET_INTERFACE_1_0, .wrapped_iface = (const void *) &Pnacl_Wrappers_PPB_WebSocket_1_0, @@ -6007,6 +6070,7 @@ static struct __PnaclWrapperInfo *s_ppb_wrappers[] = { &Pnacl_WrapperInfo_PPB_VarArray_1_0, &Pnacl_WrapperInfo_PPB_VarArrayBuffer_1_0, &Pnacl_WrapperInfo_PPB_VarDictionary_1_0, + &Pnacl_WrapperInfo_PPB_VideoDecoder_0_1, &Pnacl_WrapperInfo_PPB_WebSocket_1_0, &Pnacl_WrapperInfo_PPB_Alarms_Dev_0_1, &Pnacl_WrapperInfo_PPB_AudioInput_Dev_0_3, diff --git a/ppapi/ppapi_shared.gypi b/ppapi/ppapi_shared.gypi index 551eea3..94f88f9 100644 --- a/ppapi/ppapi_shared.gypi +++ b/ppapi/ppapi_shared.gypi @@ -266,6 +266,7 @@ 'thunk/ppb_var_dictionary_thunk.cc', 'thunk/ppb_video_capture_api.h', 'thunk/ppb_video_capture_thunk.cc', + 'thunk/ppb_video_decoder_api.h', 'thunk/ppb_video_decoder_dev_api.h', 'thunk/ppb_video_decoder_dev_thunk.cc', 'thunk/ppb_video_destination_private_api.h', diff --git a/ppapi/ppapi_sources.gypi b/ppapi/ppapi_sources.gypi index 066fcd0..6f72e03 100644 --- a/ppapi/ppapi_sources.gypi +++ b/ppapi/ppapi_sources.gypi @@ -7,6 +7,7 @@ 'c_source_files': [ 'c/pp_array_output.h', 'c/pp_bool.h', + 'c/pp_codecs.h', 'c/pp_completion_callback.h', 'c/pp_errors.h', 'c/pp_file_info.h', @@ -62,6 +63,7 @@ 'c/ppb_var_array.h', 'c/ppb_var_array_buffer.h', 'c/ppb_var_dictionary.h', + 'c/ppb_video_decoder.h', 'c/ppb_video_frame.h', 'c/ppb_view.h', 'c/ppb_websocket.h', @@ -236,6 +238,8 @@ 'cpp/var_array_buffer.h', 'cpp/var_dictionary.cc', 'cpp/var_dictionary.h', + 'cpp/video_decoder.cc', + 'cpp/video_decoder.h', 'cpp/video_frame.cc', 'cpp/video_frame.h', 'cpp/view.cc', diff --git a/ppapi/thunk/ppb_video_decoder_api.h b/ppapi/thunk/ppb_video_decoder_api.h new file mode 100644 index 0000000..c40845e --- /dev/null +++ b/ppapi/thunk/ppb_video_decoder_api.h @@ -0,0 +1,40 @@ +// 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. + +#ifndef PPAPI_THUNK_PPB_VIDEO_DECODER_API_H_ +#define PPAPI_THUNK_PPB_VIDEO_DECODER_API_H_ + +#include "ppapi/c/pp_codecs.h" +#include "ppapi/c/ppb_video_decoder.h" +#include "ppapi/thunk/ppapi_thunk_export.h" + +namespace ppapi { + +class TrackedCallback; + +namespace thunk { + +class PPAPI_THUNK_EXPORT PPB_VideoDecoder_API { + public: + virtual ~PPB_VideoDecoder_API() {} + + virtual int32_t Initialize(PP_Resource context, + PP_VideoProfile profile, + PP_Bool allow_software_fallback, + scoped_refptr<TrackedCallback> callback) = 0; + virtual int32_t Decode(uint32_t decode_id, + uint32_t size, + const void* buffer, + scoped_refptr<TrackedCallback> callback) = 0; + virtual int32_t GetPicture(PP_VideoPicture* picture, + scoped_refptr<TrackedCallback> callback) = 0; + virtual void RecyclePicture(const PP_VideoPicture* picture) = 0; + virtual int32_t Flush(scoped_refptr<TrackedCallback> callback) = 0; + virtual int32_t Reset(scoped_refptr<TrackedCallback> callback) = 0; +}; + +} // namespace thunk +} // namespace ppapi + +#endif // PPAPI_THUNK_PPB_VIDEO_DECODER_API_H_ diff --git a/ppapi/thunk/ppb_video_decoder_thunk.cc b/ppapi/thunk/ppb_video_decoder_thunk.cc new file mode 100644 index 0000000..d84617c --- /dev/null +++ b/ppapi/thunk/ppb_video_decoder_thunk.cc @@ -0,0 +1,120 @@ +// 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. + +// From ppb_video_decoder.idl modified Tue May 6 05:06:35 2014. + +#include "ppapi/c/pp_completion_callback.h" +#include "ppapi/c/pp_errors.h" +#include "ppapi/c/ppb_video_decoder.h" +#include "ppapi/shared_impl/tracked_callback.h" +#include "ppapi/thunk/enter.h" +#include "ppapi/thunk/ppapi_thunk_export.h" +#include "ppapi/thunk/ppb_video_decoder_api.h" + +namespace ppapi { +namespace thunk { + +namespace { + +PP_Resource Create(PP_Instance instance) { + VLOG(4) << "PPB_VideoDecoder::Create()"; + EnterResourceCreation enter(instance); + if (enter.failed()) + return 0; + return enter.functions()->CreateVideoDecoder(instance); +} + +PP_Bool IsVideoDecoder(PP_Resource resource) { + VLOG(4) << "PPB_VideoDecoder::IsVideoDecoder()"; + EnterResource<PPB_VideoDecoder_API> enter(resource, false); + return PP_FromBool(enter.succeeded()); +} + +int32_t Initialize(PP_Resource video_decoder, + PP_Resource graphics3d_context, + PP_VideoProfile profile, + PP_Bool allow_software_fallback, + struct PP_CompletionCallback callback) { + VLOG(4) << "PPB_VideoDecoder::Initialize()"; + EnterResource<PPB_VideoDecoder_API> enter(video_decoder, callback, true); + if (enter.failed()) + return enter.retval(); + return enter.SetResult(enter.object()->Initialize(graphics3d_context, + profile, + allow_software_fallback, + enter.callback())); +} + +int32_t Decode(PP_Resource video_decoder, + uint32_t decode_id, + uint32_t size, + const void* buffer, + struct PP_CompletionCallback callback) { + VLOG(4) << "PPB_VideoDecoder::Decode()"; + EnterResource<PPB_VideoDecoder_API> enter(video_decoder, callback, true); + if (enter.failed()) + return enter.retval(); + return enter.SetResult(enter.object()->Decode(decode_id, + size, + buffer, + enter.callback())); +} + +int32_t GetPicture(PP_Resource video_decoder, + struct PP_VideoPicture* picture, + struct PP_CompletionCallback callback) { + VLOG(4) << "PPB_VideoDecoder::GetPicture()"; + EnterResource<PPB_VideoDecoder_API> enter(video_decoder, callback, true); + if (enter.failed()) + return enter.retval(); + return enter.SetResult(enter.object()->GetPicture(picture, enter.callback())); +} + +void RecyclePicture(PP_Resource video_decoder, + const struct PP_VideoPicture* picture) { + VLOG(4) << "PPB_VideoDecoder::RecyclePicture()"; + EnterResource<PPB_VideoDecoder_API> enter(video_decoder, true); + if (enter.failed()) + return; + enter.object()->RecyclePicture(picture); +} + +int32_t Flush(PP_Resource video_decoder, + struct PP_CompletionCallback callback) { + VLOG(4) << "PPB_VideoDecoder::Flush()"; + EnterResource<PPB_VideoDecoder_API> enter(video_decoder, callback, true); + if (enter.failed()) + return enter.retval(); + return enter.SetResult(enter.object()->Flush(enter.callback())); +} + +int32_t Reset(PP_Resource video_decoder, + struct PP_CompletionCallback callback) { + VLOG(4) << "PPB_VideoDecoder::Reset()"; + EnterResource<PPB_VideoDecoder_API> enter(video_decoder, callback, true); + if (enter.failed()) + return enter.retval(); + return enter.SetResult(enter.object()->Reset(enter.callback())); +} + +const PPB_VideoDecoder_0_1 g_ppb_videodecoder_thunk_0_1 = { + &Create, + &IsVideoDecoder, + &Initialize, + &Decode, + &GetPicture, + &RecyclePicture, + &Flush, + &Reset +}; + +} // namespace + +PPAPI_THUNK_EXPORT const PPB_VideoDecoder_0_1* + GetPPB_VideoDecoder_0_1_Thunk() { + return &g_ppb_videodecoder_thunk_0_1; +} + +} // namespace thunk +} // namespace ppapi |