Home | History | Annotate | Download | only in dev
      1 /* Copyright (c) 2012 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 dev/ppb_video_decoder_dev.idl modified Wed Dec 14 18:08:00 2011. */
      7 
      8 #ifndef PPAPI_C_DEV_PPB_VIDEO_DECODER_DEV_H_
      9 #define PPAPI_C_DEV_PPB_VIDEO_DECODER_DEV_H_
     10 
     11 #include "ppapi/c/dev/pp_video_dev.h"
     12 #include "ppapi/c/pp_bool.h"
     13 #include "ppapi/c/pp_completion_callback.h"
     14 #include "ppapi/c/pp_instance.h"
     15 #include "ppapi/c/pp_macros.h"
     16 #include "ppapi/c/pp_resource.h"
     17 #include "ppapi/c/pp_size.h"
     18 #include "ppapi/c/pp_stdint.h"
     19 
     20 #define PPB_VIDEODECODER_DEV_INTERFACE_0_16 "PPB_VideoDecoder(Dev);0.16"
     21 #define PPB_VIDEODECODER_DEV_INTERFACE PPB_VIDEODECODER_DEV_INTERFACE_0_16
     22 
     23 /**
     24  * @file
     25  * This file defines the <code>PPB_VideoDecoder_Dev</code> interface.
     26  */
     27 
     28 
     29 /**
     30  * @addtogroup Interfaces
     31  * @{
     32  */
     33 /**
     34  * Video decoder interface.
     35  *
     36  * Typical usage:
     37  * - Use Create() to create & configure a new PPB_VideoDecoder_Dev resource.
     38  * - Call Decode() to decode some video data.
     39  * - Receive ProvidePictureBuffers callback
     40  *   - Supply the decoder with textures using AssignPictureBuffers.
     41  * - Receive PictureReady callbacks
     42  *   - Hand the textures back to the decoder using ReusePictureBuffer.
     43  * - To signal EOS to the decoder: call Flush() and wait for NotifyFlushDone
     44  *   callback.
     45  * - To reset the decoder (e.g. to implement Seek): call Reset() and wait for
     46  *   NotifyResetDone callback.
     47  * - To tear down the decoder call Destroy().
     48  *
     49  * See PPP_VideoDecoder_Dev for the notifications the decoder may send the
     50  * plugin.
     51  */
     52 struct PPB_VideoDecoder_Dev_0_16 {
     53   /**
     54    * Creates & initializes a video decoder.
     55    *
     56    * Parameters:
     57    *   |instance| pointer to the plugin instance.
     58    *   |context| a PPB_Graphics3D resource in which decoding will happen.
     59    *   |profile| the video stream's format profile.
     60    *
     61    * The created decoder is returned as PP_Resource. 0 means failure.
     62    */
     63   PP_Resource (*Create)(PP_Instance instance,
     64                         PP_Resource context,
     65                         PP_VideoDecoder_Profile profile);
     66   /**
     67    * Tests whether |resource| is a video decoder created through Create
     68    * function of this interface.
     69    *
     70    * Parameters:
     71    *   |resource| is handle to resource to test.
     72    *
     73    * Returns true if is a video decoder, false otherwise.
     74    */
     75   PP_Bool (*IsVideoDecoder)(PP_Resource resource);
     76   /**
     77    * Dispatches bitstream buffer to the decoder.
     78    *
     79    * Parameters:
     80    *   |video_decoder| is the previously created handle to the decoder resource.
     81    *   |bitstream_buffer| is the bitstream buffer that contains the input data.
     82    *   |callback| will be called when |bitstream_buffer| has been processed by
     83    *   the decoder.
     84    *
     85    * Returns an error code from pp_errors.h.
     86    */
     87   int32_t (*Decode)(PP_Resource video_decoder,
     88                     const struct PP_VideoBitstreamBuffer_Dev* bitstream_buffer,
     89                     struct PP_CompletionCallback callback);
     90   /**
     91    * Provides the decoder with texture-backed picture buffers for video
     92    * decoding.
     93    *
     94    * This function should be called when the plugin has its
     95    * ProvidePictureBuffers method called.  The decoder will stall until it has
     96    * received all the buffers it's asked for.
     97    *
     98    * Parameters:
     99    *   |video_decoder| is the previously created handle to the decoder resource.
    100    *   |no_of_buffers| how many buffers are behind picture buffer pointer.
    101    *   |buffers| contains the reference to the picture buffer that was
    102    *   allocated.
    103    */
    104   void (*AssignPictureBuffers)(PP_Resource video_decoder,
    105                                uint32_t no_of_buffers,
    106                                const struct PP_PictureBuffer_Dev buffers[]);
    107   /**
    108    * Tells the decoder to reuse the given picture buffer. Typical use of this
    109    * function is to call from PictureReady callback to recycle picture buffer
    110    * back to the decoder after blitting the image so that decoder can use the
    111    * image for output again.
    112    *
    113    * Parameters:
    114    *   |video_decoder| is the previously created handle to the decoder resource.
    115    *   |picture_buffer_id| contains the id of the picture buffer that was
    116    *   processed.
    117    */
    118   void (*ReusePictureBuffer)(PP_Resource video_decoder,
    119                              int32_t picture_buffer_id);
    120   /**
    121    * Flush input and output buffers in the decoder.  Any pending inputs are
    122    * decoded and pending outputs are delivered to the plugin.  Once done
    123    * flushing, the decoder will call |callback|.
    124    *
    125    * Parameters:
    126    *   |video_decoder| is the previously created handle to the decoder resource.
    127    *   |callback| is one-time callback that will be called once the flushing
    128    *   request has been completed.
    129    *
    130    * Returns an error code from pp_errors.h.
    131    */
    132   int32_t (*Flush)(PP_Resource video_decoder,
    133                    struct PP_CompletionCallback callback);
    134   /**
    135    * Reset the decoder as quickly as possible.  Pending inputs and outputs are
    136    * dropped and the decoder is put back into a state ready to receive further
    137    * Decode() calls.  |callback| will be called when the reset is done.
    138    *
    139    * Parameters:
    140    *   |video_decoder| is the previously created handle to the decoder resource.
    141    *   |callback| is one-time callback that will be called once the reset
    142    *   request has been completed.
    143    *
    144    * Returns an error code from pp_errors.h.
    145    */
    146   int32_t (*Reset)(PP_Resource video_decoder,
    147                    struct PP_CompletionCallback callback);
    148   /**
    149    * Tear down the decoder as quickly as possible.  Pending inputs and outputs
    150    * are dropped and the decoder frees all of its resources.  Although resources
    151    * may be freed asynchronously, after this method returns no more callbacks
    152    * will be made on the client.  Any resources held by the client at that point
    153    * may be freed.
    154    *
    155    * Parameters:
    156    *   |video_decoder| is the previously created handle to the decoder resource.
    157    */
    158   void (*Destroy)(PP_Resource video_decoder);
    159 };
    160 
    161 typedef struct PPB_VideoDecoder_Dev_0_16 PPB_VideoDecoder_Dev;
    162 /**
    163  * @}
    164  */
    165 
    166 #endif  /* PPAPI_C_DEV_PPB_VIDEO_DECODER_DEV_H_ */
    167 
    168