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