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