Index: ppapi/c/ppb_video_encoder.h |
diff --git a/ppapi/c/ppb_video_encoder.h b/ppapi/c/ppb_video_encoder.h |
new file mode 100644 |
index 0000000000000000000000000000000000000000..865b4b3186f462dab11423e361a9fc76e8bb31e8 |
--- /dev/null |
+++ b/ppapi/c/ppb_video_encoder.h |
@@ -0,0 +1,228 @@ |
+/* 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_encoder.idl modified Thu Jul 10 15:27:41 2014. */ |
+ |
+#ifndef PPAPI_C_PPB_VIDEO_ENCODER_H_ |
+#define PPAPI_C_PPB_VIDEO_ENCODER_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_VIDEOENCODER_INTERFACE_0_1 "PPB_VideoEncoder;0.1" /* dev */ |
+/** |
+ * @file |
+ * This file defines the <code>PPB_VideoEncoder</code> interface. |
+ */ |
+ |
+ |
+/** |
+ * @addtogroup Typedefs |
+ * @{ |
+ */ |
+/** |
+ * This typedef defines the signature that you implement to receive the |
+ * encoder's initialization result. |
+ * |
+ * @param[in] encoder The encoder being initialized. |
+ * @param[in] result If result is 0 (PP_OK), the operation succeeded. Negative |
+ * values (other than -1 or PP_OK_COMPLETE) indicate error and are specified |
+ * in pp_errors.h. |
+ * @param[in] input_frames_count A number of video frames the caller needs to |
+ * allocate in order to make sure it's always capable of feeding the encoder. |
+ * @param[in] input_coded_size The size of the video frames the caller should |
+ * allocate to match the hardware constrains. |
+ * @param[inout] user_data An opaque pointer that was passed into |
+ * <code>PPB_VideoEncoder.Initialize()</code>. |
+ */ |
+typedef void (*PPB_VideoEncoder_Ready_Func)( |
+ PP_Resource encoder, |
+ int32_t result, |
+ uint32_t input_frames_count, |
+ const struct PP_Size* input_coded_size, |
+ void* user_data); |
+/** |
+ * @} |
+ */ |
+ |
+/** |
+ * @addtogroup Structs |
+ * @{ |
+ */ |
+/** |
+ * The <code>PPB_VideoEncoderParams</code> struct contains the parameters |
+ * given to the video encoder to initialize itself. |
+ */ |
+struct PP_VideoEncoderParams { /* dev */ |
+ /** |
+ * A <code>PP_Size</code> specifying the size of the frames to encode. |
+ */ |
+ struct PP_Size input_size; |
+ /** |
+ * A <code>PP_VideoProfile</code> specifying the video codec profile. |
+ */ |
+ PP_VideoProfile profile; |
+ /** |
+ * The bitrate of the video encoding. |
+ */ |
+ uint32_t bitrate; |
+ /** |
+ * A <code>PP_Bool</code> specifying whether the encoder can fall back to |
+ * software encoding if a suitable hardware encoder isn't available. |
+ */ |
+ PP_Bool allow_software_fallback; |
+}; |
+ |
+/** |
+ * Struct describing a video picture to encode. |
+ */ |
+struct PP_VideoEncoderPicture { /* dev */ |
+ /** |
+ * Texture ID of the picture to encode in the plugin's GL context. |
+ */ |
+ uint32_t texture_id; |
+ /** |
+ * The GL texture target for the picture to encode. |
+ * 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_RGBA. |
+ */ |
+ uint32_t texture_target; |
+ /** |
+ * Dimensions of the texture holding the picture to encode. |
+ */ |
+ struct PP_Size texture_size; |
+}; |
+/** |
+ * @} |
+ */ |
+ |
+/** |
+ * @addtogroup Interfaces |
+ * @{ |
+ */ |
+/** |
+ * Video encoder interface. |
+ * |
+ * Typical usage: |
+ * - Call Create() to create a new video encoder resource. |
+ * - Call Initialize() to initialize it with a 3d graphics context and the |
+ * desired codec profile. |
+ * - Call Encode() continuously (waiting for each previous call to complete) to |
+ * push video frames to the encoder. |
+ * - Call Reset() to quickly stop the encoder (e.g. to implement Seek) and wait |
+ * for the callback before restarting decoding at another point. |
+ * - To destroy the encoder, the plugin should release all of its references to |
+ * it. Any pending callbacks will abort before the encoder is destroyed. |
+ * |
+ * Available video codecs vary by platform. |
+ * All: vp8, vp9. |
+ */ |
+struct PPB_VideoEncoder_0_1 { /* dev */ |
+ /** |
+ * Creates a new video encoder resource. |
+ * |
+ * @param[in] instance A <code>PP_Instance</code> identifying the instance |
+ * with the video encoder. |
+ * |
+ * @return A <code>PP_Resource</code> corresponding to a video encoder if |
+ * successful or 0 otherwise. |
+ */ |
+ PP_Resource (*Create)(PP_Instance instance); |
+ /** |
+ * Determines if the given resource is a video encoder. |
+ * |
+ * @param[in] resource A <code>PP_Resource</code> identifying a resource. |
+ * |
+ * @return <code>PP_TRUE</code> if the resource is a |
+ * <code>PPB_VideoEncoder</code>, <code>PP_FALSE</code> if the resource is |
+ * invalid or some other type. |
+ */ |
+ PP_Bool (*IsVideoEncoder)(PP_Resource resource); |
+ /** |
+ * Initializes a video encoder resource. This should be called after |
+ * Create() and before any other functions. |
+ * |
+ * @param[in] video_encoder A <code>PP_Resource</code> identifying the video |
+ * encoder. |
+ * @param[in] params A <code>PP_VideoEncoderParams</code> specifying the |
+ * parameters to initialize the video encoder. |
+ * @param[inout] user_data An opaque pointer that will be passed into |
+ * <code>callback</code>. |
+ * @param[in] callback A <code>PPB_VideoEncoder_Ready_Func</code> to be |
+ * called upon completion. |
+ * |
+ * @return An int32_t containing an error code from <code>pp_errors.h</code>. |
+ * Returns PP_ERROR_FAILED if the video encoder has already been initialized |
+ * or the submitted 3d context is invalid. |
+ * Returns PP_ERROR_NOTSUPPORTED if video encoding 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_encoder, |
+ PP_Resource graphics3d_context, |
+ const struct PP_VideoEncoderParams* params, |
+ void* user_data, |
+ PPB_VideoEncoder_Ready_Func callback); |
+ /** |
+ * Encodes a video frame. The plugin should wait until the encoder signals |
+ * completion by returning PP_OK or by running |callback| before calling |
+ * Encode() again. The plugin will be notified by the |
+ * <code>PPP_VideoEncoder</code> interface when video bitstream buffer are |
+ * ready. |
+ * |
+ * @param[in] video_encoder A <code>PP_Resource</code> identifying the video |
+ * encoder. |
+ * @param[in] picture A <code>PP_VideoEncoderPicture</code> picture. |
+ * @param[in] force_keyframe Forces the encoding of a keyframe for this |
+ * picture. |
+ * @param[in] callback A <code>PP_CompletionCallback_Dev</code> to be called |
+ on |
+ * completion. |
+ * |
+ * @return An int32_t containing an error code from <code>pp_errors.h</code>. |
+ * Returns PP_ERROR_BADARGUMENT if the |picture| argument is invalid. |
+ * Returns PP_ERROR_FAILED if the encoder isn't initialized or the picture |
+ * buffer submitted is already used by the encoder. |
+ * Returns PP_ERROR_INPROGRESS if this function has already been called and is |
+ * already for an encoding operation to complete. |
+ */ |
+ int32_t (*Encode)(PP_Resource video_encoder, |
+ uint32_t encode_id, |
+ const struct PP_VideoEncoderPicture* picture, |
+ PP_Bool force_keyframe, |
+ struct PP_CompletionCallback callback); |
+ /** |
+ * Resets the encoder as quickly as possible. The plugin can call Reset() to |
+ * skip to another position in the video stream. After Reset() returns, any |
+ * pending calls to Encode() abort, causing their callbacks to run with |
+ * PP_ERROR_ABORTED. The plugin should not make further calls to the encoder |
+ * until the encoder signals completion by running |callback|. |
+ * |
+ * @param[in] video_encoder A <code>PP_Resource</code> identifying the video |
+ * encoder. |
+ * @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_ERROR_FAILED if the encoder isn't initialized. |
+ */ |
+ int32_t (*Reset)(PP_Resource video_encoder, |
+ struct PP_CompletionCallback callback); |
+}; |
+/** |
+ * @} |
+ */ |
+ |
+#endif /* PPAPI_C_PPB_VIDEO_ENCODER_H_ */ |
+ |