OLD | NEW |
(Empty) | |
| 1 /* Copyright (c) 2015 The Chromium Authors. All rights reserved. |
| 2 * Use of this source code is governed by a BSD-style license that can be |
| 3 * found in the LICENSE file. |
| 4 */ |
| 5 |
| 6 /* From ppb_video_encoder.idl modified Fri Jan 9 18:10:26 2015. */ |
| 7 |
| 8 #ifndef PPAPI_C_PPB_VIDEO_ENCODER_H_ |
| 9 #define PPAPI_C_PPB_VIDEO_ENCODER_H_ |
| 10 |
| 11 #include "ppapi/c/pp_array_output.h" |
| 12 #include "ppapi/c/pp_bool.h" |
| 13 #include "ppapi/c/pp_codecs.h" |
| 14 #include "ppapi/c/pp_completion_callback.h" |
| 15 #include "ppapi/c/pp_instance.h" |
| 16 #include "ppapi/c/pp_macros.h" |
| 17 #include "ppapi/c/pp_resource.h" |
| 18 #include "ppapi/c/pp_size.h" |
| 19 #include "ppapi/c/pp_stdint.h" |
| 20 #include "ppapi/c/ppb_video_frame.h" |
| 21 |
| 22 #define PPB_VIDEOENCODER_INTERFACE_0_1 "PPB_VideoEncoder;0.1" |
| 23 #define PPB_VIDEOENCODER_INTERFACE PPB_VIDEOENCODER_INTERFACE_0_1 |
| 24 |
| 25 /** |
| 26 * @file |
| 27 * This file defines the <code>PPB_VideoEncoder</code> interface. |
| 28 */ |
| 29 |
| 30 |
| 31 /** |
| 32 * @addtogroup Interfaces |
| 33 * @{ |
| 34 */ |
| 35 /** |
| 36 * Video encoder interface. |
| 37 * |
| 38 * Typical usage: |
| 39 * - Call Create() to create a new video encoder resource. |
| 40 * - Call GetSupportedFormats() to determine which codecs and profiles are |
| 41 * - available. |
| 42 * - Call Initialize() to initialize the encoder for a supported profile. |
| 43 * - Call GetVideoFrame() to get a video frame resource, copy the frame into |
| 44 * - its buffer, and call Encode() to push the video frame to the encoder. Do |
| 45 * - this continuously, waiting for completion of each call. |
| 46 * - Call GetBitstreamBuffer() continuously (waiting for each previous call to |
| 47 * complete) to pull encoded pictures from the encoder. |
| 48 * - Call RecycleBitstreamBuffer() after consuming the data in the bitstream |
| 49 * - buffer. |
| 50 * - To destroy the decoder, the plugin should release all of its references to |
| 51 * it. Any pending callbacks will abort before the decoder is destroyed. |
| 52 * |
| 53 * Available video codecs vary by platform. |
| 54 * All: theora, vorbis, vp8. |
| 55 * Chrome and ChromeOS: aac, h264. |
| 56 * ChromeOS: mpeg4. |
| 57 */ |
| 58 struct PPB_VideoEncoder_0_1 { |
| 59 /** |
| 60 * Creates a new video encoder resource. |
| 61 * |
| 62 * @param[in] instance A <code>PP_Instance</code> identifying the instance |
| 63 * with the video encoder. |
| 64 * |
| 65 * @return A <code>PP_Resource</code> corresponding to a video encoder if |
| 66 * successful or 0 otherwise. |
| 67 */ |
| 68 PP_Resource (*Create)(PP_Instance instance); |
| 69 /** |
| 70 * Determines if the given resource is a video encoder. |
| 71 * |
| 72 * @param[in] resource A <code>PP_Resource</code> identifying a resource. |
| 73 * |
| 74 * @return <code>PP_TRUE</code> if the resource is a |
| 75 * <code>PPB_VideoEncoder</code>, <code>PP_FALSE</code> if the resource is |
| 76 * invalid or some other type. |
| 77 */ |
| 78 PP_Bool (*IsVideoEncoder)(PP_Resource resource); |
| 79 /** |
| 80 * Gets an array of supported video encoder profiles. |
| 81 * These can be used to choose profiles when calling Initialize(). |
| 82 * |
| 83 * @param[in] video_encoder A <code>PP_Resource</code> identifying the video |
| 84 * encoder. |
| 85 * @param[in] output A <code>PP_ArrayOutput</code> to hold the supported |
| 86 * <code>PP_SupportedVideoProfile</code> structs. |
| 87 * @param[in] callback A <code>PP_CompletionCallback</code> to be called upon |
| 88 * completion of GetSupportedProfiles. |
| 89 * |
| 90 * @return If >= 0, the number of supported profiles returned, otherwise an |
| 91 * error code from <code>pp_errors.h</code>. |
| 92 */ |
| 93 int32_t (*GetSupportedProfiles)(PP_Resource video_encoder, |
| 94 struct PP_ArrayOutput output, |
| 95 struct PP_CompletionCallback callback); |
| 96 /** |
| 97 * Initializes a video encoder resource. This should be called after Create() |
| 98 * and before any functions below. |
| 99 * |
| 100 * @param[in] video_encoder A <code>PP_Resource</code> identifying the video |
| 101 * encoder. |
| 102 * @param[in] input_format The <code>PP_VideoFrame_Format</code> of the |
| 103 * frames which will be encoded. |
| 104 * @param[in] input_visible_size A <code>PP_Size</code> specifying the |
| 105 * dimensions of the visible part of the input frames. |
| 106 * @param[in] output_profile A <code>PP_VideoProfile</code> specifying the |
| 107 * codec profile of the encoded output stream. |
| 108 * @param[in] acceleration A <code>PP_HardwareAcceleration</code> specifying |
| 109 * whether to use a hardware accelerated or a software implementation. |
| 110 * @param[in] callback A <code>PP_CompletionCallback</code> to be called upon |
| 111 * completion. |
| 112 * |
| 113 * @return An int32_t containing an error code from <code>pp_errors.h</code>. |
| 114 * Returns PP_ERROR_NOTSUPPORTED if video encoding is not available, or the |
| 115 * requested codec profile is not supported. |
| 116 */ |
| 117 int32_t (*Initialize)(PP_Resource video_decoder, |
| 118 PP_VideoFrame_Format input_format, |
| 119 const struct PP_Size* input_visible_size, |
| 120 PP_VideoProfile output_profile, |
| 121 uint32_t initial_bitrate, |
| 122 PP_HardwareAcceleration acceleration, |
| 123 struct PP_CompletionCallback callback); |
| 124 int32_t (*GetVideoFrame)(PP_Resource video_encoder, |
| 125 PP_Resource* video_frame, |
| 126 struct PP_CompletionCallback callback); |
| 127 int32_t (*Encode)(PP_Resource video_encoder, |
| 128 PP_Resource video_frame, |
| 129 PP_Bool force_keyframe, |
| 130 struct PP_CompletionCallback callback); |
| 131 int32_t (*GetBitstreamBuffer)(PP_Resource video_encoder, |
| 132 struct PP_BitstreamBuffer* bitstream_buffer, |
| 133 struct PP_CompletionCallback callback); |
| 134 void (*RecycleBitstreamBuffer)( |
| 135 PP_Resource video_decoder, |
| 136 const struct PP_BitstreamBuffer* bitstream_buffer); |
| 137 void (*RequestEncodingParametersChange)(PP_Resource video_decoder, |
| 138 uint32_t bitrate, |
| 139 uint32_t framerate); |
| 140 }; |
| 141 |
| 142 typedef struct PPB_VideoEncoder_0_1 PPB_VideoEncoder; |
| 143 /** |
| 144 * @} |
| 145 */ |
| 146 |
| 147 #endif /* PPAPI_C_PPB_VIDEO_ENCODER_H_ */ |
| 148 |
OLD | NEW |