OLD | NEW |
(Empty) | |
| 1 // Copyright (c) 2010 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 #ifndef PPAPI_C_PPB_VIDEO_DECODER_H_ |
| 6 #define PPAPI_C_PPB_VIDEO_DECODER_H_ |
| 7 |
| 8 #include "ppapi/c/pp_module.h" |
| 9 #include "ppapi/c/pp_resource.h" |
| 10 #include "ppapi/c/pp_stdint.h" |
| 11 #include "ppapi/c/pp_video.h" |
| 12 #include "ppapi/c/pp_completion_callback.h" |
| 13 |
| 14 #define PPB_VIDEODECODER_INTERFACE "PPB_VideoDecoder;1" |
| 15 |
| 16 typedef struct _ppb_VideoDecoder { |
| 17 // Queries capability of the decoder for |codec|. |
| 18 // |codec| is the requested codec id. |
| 19 // |configs| is a pointer to a buffer containing |config_size| elements. |
| 20 // The number of configurations is returned in |num_config|. Element 0 through |
| 21 // |num_config| - 1 of |configs| are filled in with valid PP_VideoConfig's. |
| 22 // No more than |config_size| PP_VideoConfig's will be returned even if more |
| 23 // are available on the device. |
| 24 // When this function is called with |configs| = NULL, then no configurations |
| 25 // are returned, but the total number of configurations available will be |
| 26 // returned in |num_config|. |
| 27 // |
| 28 // Returns true on success, false otherwise. |
| 29 // NOTE: browser owns the memory of all PP_VideoConfig's. |
| 30 bool (*GetConfig)(PP_Instance instance, |
| 31 PP_VideoCodecId codec, |
| 32 PP_VideoConfig* configs, |
| 33 int32_t config_size, |
| 34 int32_t* num_config); |
| 35 |
| 36 // Creates a video decoder with requested |decoder_config|. |
| 37 // |input_format| in |decoder_config| specifies the format of input access |
| 38 // unit, with PP_VIDEOKEY_CODECID and PP_VIDEOKEY_PAYLOADFORMAT required. |
| 39 // Plugin has the option to specify codec profile/level and other |
| 40 // information such as PP_VIDEOKEY_ACCELERATION, to let browser choose |
| 41 // the most appropriate decoder. |
| 42 // |
| 43 // |output_format| in |decoder_config| specifies desired decoded frame buffer |
| 44 // format, with PP_VIDEOKEY_COLORTYPE and PP_VIDEOKEY_SURFACETYPE required. |
| 45 // |
| 46 // |output_callback| in |decoder_config| specifies the callback function |
| 47 // for decoder to deliver decoded frame buffers. Decoder shall retain it. |
| 48 // |
| 49 // |input_callback| in |decoder_config| specifies the callback function |
| 50 // for decoder to return compressed data buffers to plugin. Decoder shall |
| 51 // retain it. When plugin doesn't expect buffer recycling, it shall set |
| 52 // |input_callback| to NULL. In this case, plugin shall allocate buffer via |
| 53 // |MemAlloc| in PPB_Core interface, and decoder will free buffer via |
| 54 // |MemFree| in the same API. |
| 55 // |
| 56 // |event_handler| in |decoder_config| specifies the function for decoder |
| 57 // to deliver events to plugin. Decoder shall retain it. |
| 58 // |
| 59 // The created decoder is returned as PP_Resource. NULL means failure. |
| 60 PP_Resource (*Create)(PP_Instance instance, |
| 61 const PP_VideoDecoderConfig* decoder_config); |
| 62 |
| 63 // Sends bit stream in |input_buffer| to the decoder. |frame_info| contains |
| 64 // associated information about the frame. |
| 65 // This is a non-blocking call. |
| 66 // The decoded frame will be returned by decoder calling |output_callback| |
| 67 // provided by plugin during creation of decoder. |
| 68 // The input data buffer is returned to plugin by decoder only when plugin |
| 69 // provides |input_callback|. |
| 70 // Decoder shall retain frame info and return them to plugin when it returns |
| 71 // decoded frame. |
| 72 // Returns true on decoder successfully accepting buffer, false otherwise. |
| 73 // |
| 74 bool (*Decode)(PP_Resource decoder, |
| 75 PP_VideoCompressedDataBuffer* input_buffer, |
| 76 PP_VideoFrameInfo* frame_info); |
| 77 |
| 78 // Requests the decoder to flush its input and output buffers. Once done with |
| 79 // flushing, the decode will call the |callback|. |
| 80 void (*Flush)(PP_Resource decoder, |
| 81 PP_CompletionCallback callback); |
| 82 |
| 83 // Plugin sends uncompressed data buffers to the decoder. |
| 84 // Returns true on decoder successfully accepting the buffer, false otherwise. |
| 85 bool (*ReturnUncompressedDataBuffer)(PP_Resource decoder, |
| 86 PP_VideoUncompressedDataBuffer* buffer); |
| 87 } PPB_VideoDecoder; |
| 88 |
| 89 #endif // PPAPI_C_PPB_VIDEO_DECODER_H_ |
OLD | NEW |