VideoEditorBuffer.h revision 7c9d8018755adf1857571125ba1b3598c96ea506
1/* 2 * Copyright (C) 2011 NXP Software 3 * Copyright (C) 2011 The Android Open Source Project 4 * 5 * Licensed under the Apache License, Version 2.0 (the "License"); 6 * you may not use this file except in compliance with the License. 7 * You may obtain a copy of the License at 8 * 9 * http://www.apache.org/licenses/LICENSE-2.0 10 * 11 * Unless required by applicable law or agreed to in writing, software 12 * distributed under the License is distributed on an "AS IS" BASIS, 13 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 * See the License for the specific language governing permissions and 15 * limitations under the License. 16 */ 17/** 18************************************************************************* 19* @file VideoEditorBuffer.c 20* @brief StageFright shell Buffer 21************************************************************************* 22*/ 23#ifndef VIDEOEDITOR_BUFFER_H 24#define VIDEOEDITOR_BUFFER_H 25 26#include "M4OSA_Types.h" 27#include "M4OSA_Debug.h" 28#include "M4OSA_Memory.h" 29#include "M4OSA_CharStar.h" 30#include "M4_Utils.h" 31 32#include "LV_Macros.h" 33 34/*--- Core id for VIDEOEDITOR Buffer allocations ---*/ 35#define VIDEOEDITOR_BUFFER_EXTERNAL 0x012F 36 37/* ----- errors -----*/ 38#define M4ERR_NO_BUFFER_AVAILABLE \ 39 M4OSA_ERR_CREATE(M4_ERR,VIDEOEDITOR_BUFFER_EXTERNAL,0x000001) 40#define M4ERR_NO_BUFFER_MATCH \ 41 M4OSA_ERR_CREATE(M4_ERR,VIDEOEDITOR_BUFFER_EXTERNAL,0x000002) 42 43typedef enum { 44 VIDEOEDITOR_BUFFER_kEmpty = 0, 45 VIDEOEDITOR_BUFFER_kFilled, 46} VIDEOEDITOR_BUFFER_State; 47 48/** 49 ************************************************************************ 50 * Structure LVOMX_BUFFER_Buffer 51 * @brief One OMX Buffer and data related to it 52 ************************************************************************ 53*/ 54typedef struct { 55 M4OSA_Void* pData; /**< Pointer to the data*/ 56 M4OSA_UInt32 size; 57 VIDEOEDITOR_BUFFER_State state; /**< Buffer state */ 58 M4OSA_UInt32 idx; /**< Index of the buffer inside the pool */ 59 M4_MediaTime buffCTS; /**< Time stamp of the buffer */ 60} VIDEOEDITOR_BUFFER_Buffer; 61 62/** 63 ************************************************************************ 64 * Structure LVOMX_BUFFER_Pool 65 * @brief Structure to manage buffers 66 ************************************************************************ 67*/ 68typedef struct { 69 VIDEOEDITOR_BUFFER_Buffer* pNXPBuffer; 70 M4OSA_UInt32 NB; 71 M4OSA_Char* poolName; 72} VIDEOEDITOR_BUFFER_Pool; 73 74#ifdef __cplusplus 75extern "C" 76{ 77#endif //__cplusplus 78 79/** 80 ************************************************************************ 81 M4OSA_ERR VIDEOEDITOR_BUFFER_allocatePool(VIDEOEDITOR_BUFFER_Pool** ppool, 82 * M4OSA_UInt32 nbBuffers) 83 * @brief Allocate a pool of nbBuffers buffers 84 * 85 * @param ppool : IN The buffer pool to create 86 * @param nbBuffers : IN The number of buffers in the pool 87 * @param poolName : IN a name given to the pool 88 * @return Error code 89 ************************************************************************ 90*/ 91M4OSA_ERR VIDEOEDITOR_BUFFER_allocatePool(VIDEOEDITOR_BUFFER_Pool** ppool, 92 M4OSA_UInt32 nbBuffers, M4OSA_Char* poolName); 93 94/** 95 ************************************************************************ 96 M4OSA_ERR VIDEOEDITOR_BUFFER_freePool(LVOMX_BUFFER_Pool* ppool) 97 * @brief Deallocate a buffer pool 98 * 99 * @param ppool : IN The buffer pool to free 100 * @return Error code 101 ************************************************************************ 102*/ 103M4OSA_ERR VIDEOEDITOR_BUFFER_freePool(VIDEOEDITOR_BUFFER_Pool* ppool); 104 105/** 106 ************************************************************************ 107 M4OSA_ERR VIDEOEDITOR_BUFFER_getBuffer(VIDEOEDITOR_BUFFER_Pool* ppool, 108 * VIDEOEDITOR_BUFFER_Buffer** pNXPBuffer) 109 * @brief Returns a buffer in a given state 110 * 111 * @param ppool : IN The buffer pool 112 * @param desiredState : IN The buffer state 113 * @param pNXPBuffer : IN The selected buffer 114 * @return Error code 115 ************************************************************************ 116*/ 117M4OSA_ERR VIDEOEDITOR_BUFFER_getBuffer(VIDEOEDITOR_BUFFER_Pool* ppool, 118 VIDEOEDITOR_BUFFER_State desiredState, 119 VIDEOEDITOR_BUFFER_Buffer** pNXPBuffer); 120 121 122M4OSA_ERR VIDEOEDITOR_BUFFER_initPoolBuffers(VIDEOEDITOR_BUFFER_Pool* ppool, 123 M4OSA_UInt32 lSize); 124 125M4OSA_ERR VIDEOEDITOR_BUFFER_getOldestBuffer(VIDEOEDITOR_BUFFER_Pool *pool, 126 VIDEOEDITOR_BUFFER_State desiredState, 127 VIDEOEDITOR_BUFFER_Buffer** pNXPBuffer); 128 129#ifdef __cplusplus 130} 131#endif //__cplusplus 132#endif /*VIDEOEDITOR_BUFFER_H*/ 133 134