1 /* 2 * Copyright (c) 2011 The Khronos Group Inc. 3 * 4 * Permission is hereby granted, free of charge, to any person obtaining 5 * a copy of this software and associated documentation files (the 6 * "Software"), to deal in the Software without restriction, including 7 * without limitation the rights to use, copy, modify, merge, publish, 8 * distribute, sublicense, and/or sell copies of the Software, and to 9 * permit persons to whom the Software is furnished to do so, subject 10 * to the following conditions: 11 * The above copyright notice and this permission notice shall be included 12 * in all copies or substantial portions of the Software. 13 * 14 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS 15 * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 16 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. 17 * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY 18 * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, 19 * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE 20 * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 21 * 22 */ 23 24 #ifndef CPA_ContentPipe_h 25 #define CPA_ContentPipe_h 26 27 #ifdef __cplusplus 28 extern "C" { 29 #endif /* __cplusplus 30 /** CPA_IN is used to identify inputs to an CP function. This designation 31 will also be used in the case of a pointer that points 32 to a parameter that is used as an input. */ 33 #ifndef CPA_IN 34 #define CPA_IN 35 #endif 36 37 /** CPA_OUT is used to identify outputs from an CP function. This designation 38 will also be used in the case of a pointer that points to a parameter 39 that is used as an output. */ 40 #ifndef CPA_OUT 41 #define CPA_OUT 42 #endif 43 44 45 /** CPA_INOUT is used to identify parameters that may be either inputs or 46 outputs from an CP function at the same time. This designation will 47 also be used in the case of a pointer that points to a parameter that 48 is used both as an input and an output. */ 49 #ifndef CPA_INOUT 50 #define CPA_INOUT 51 #endif 52 53 typedef enum CPA_BOOL { 54 CPA_FALSE = 0, 55 CPA_TRUE = !CPA_FALSE, 56 CPA_BOOL_MAX = 0x7FFFFFFF 57 } CPA_BOOL; 58 59 typedef void* CPA_PTR; 60 61 typedef char* CPA_STRING; 62 63 typedef unsigned char CPA_BYTE; 64 65 typedef void* CPA_INTERFACE; 66 67 typedef void* CPA_HANDLE; 68 69 typedef unsigned char CPA_U8; 70 71 typedef signed char CPA_S8; 72 73 typedef unsigned short CPA_U16; 74 75 typedef signed short CPA_S16; 76 77 typedef unsigned long CPA_U32; 78 79 typedef signed long CPA_S32; 80 81 /* Users with compilers that cannot accept 64 bits arithmetic shall not 82 define the CPA_64BITSSUPPORTED macro. It should be noted that this may cause 83 some components to fail to compile if the component was written to require 84 64 bit integral types. However, these components would NOT compile anyway 85 since the compiler does not support the way the component was written. 86 */ 87 #ifdef CPA_64BITSSUPPORTED 88 89 typedef uint64_t CPA_U64; 90 91 typedef int64_t CPA_S64; 92 93 #else /* unknown*/ 94 95 typedef unsigned long long CPA_U64; 96 97 typedef signed long long CPA_S64; 98 99 #endif /* CPA_64BITSSUPPORTED */ 100 101 typedef enum CPA_RESULTTYPE{ 102 CPA_OK, 103 CPA_OKEOS, 104 CPA_OKPOSITIONEXCEED2GB, 105 CPA_EPOSNOTAVAIL, 106 CPA_EUNKNOWN, 107 CPA_EACCESS, 108 CPA_EAGAIN, 109 CPA_EALREADY, 110 CPA_EBUSY, 111 CPA_ECONNREFUSED, 112 CPA_ECONNRESET, 113 CPA_EEXIST, 114 CPA_EFBIG, 115 CPA_EINVAL, 116 CPA_EIO, 117 CPA_ENOENT, 118 CPA_EURINOTSUPP, 119 CPA_ENOMEM, 120 CPA_ENOSPC, 121 CPA_ENO_RECOVERY, 122 CPA_EOPNOTSUPP, 123 CPA_ETIMEDOUT, 124 CPA_EVERSION, 125 CPA_RESULTKhronosExtensions = 0x6F000000, /* Reserved region for introducing Khronos Standard Extensions */ 126 CPA_RESULTVendorStartUnused = 0x7F000000, /* Reserved region for introducing Vendor Extensions */ 127 CPA_RESULTMax = 0x7FFFFFFF 128 } CPA_RESULTTYPE; 129 130 #define CPA_POSITION_NA -1 131 132 #ifdef CPA_64BITSSUPPORTED 133 #define CPA_POSITION_32_MAX 0x000000007FFFFFFF 134 typedef CPA_S64 CPA_POSITIONTYPE; 135 #else 136 #define CPA_POSITION_32_MAX 0x7FFFFFFF 137 typedef CPA_S32 CPA_POSITIONTYPE; 138 #endif 139 140 typedef union CPA_VERSIONTYPE 141 { 142 struct 143 { 144 CPA_U8 nVersionMajor; 145 CPA_U8 nVersionMinor; 146 CPA_U8 nRevision; 147 }; 148 CPA_U32 nVersionID; 149 } CPA_VERSIONTYPE; 150 151 typedef enum CPA_ORIGINTYPE { 152 CPA_OriginBegin, 153 CPA_OriginFirst, 154 CPA_OriginCur, 155 CPA_OriginLast, 156 CPA_OriginEnd, 157 CPA_OriginKhronosExtensions = 0x6F000000, /* Reserved region for introducing Khronos Standard Extensions */ 158 CPA_OriginVendorStartUnused = 0x7F000000, /* Reserved region for introducing Vendor Extensions */ 159 CPA_OriginMax = 0X7FFFFFFF 160 } CPA_ORIGINTYPE; 161 162 typedef struct CPA_POSITIONINFOTYPE { 163 CPA_POSITIONTYPE nDataBegin; 164 CPA_POSITIONTYPE nDataFirst; 165 CPA_POSITIONTYPE nDataCur; 166 CPA_POSITIONTYPE nDataLast; 167 CPA_POSITIONTYPE nDataEnd; 168 } CPA_POSITIONINFOTYPE; 169 170 typedef enum CPA_ACCESSTYPE { 171 CPA_AccessRead, 172 CPA_AccessWrite, 173 CPA_AccessReadWrite , 174 CPA_AccessKhronosExtensions = 0x6F000000, /* Reserved region for introducing Khronos Standard Extensions */ 175 CPA_AccessVendorStartUnused = 0x7F000000, /* Reserved region for introducing Vendor Extensions */ 176 CPA_AccessMax = 0X7FFFFFFF 177 } CPA_ACCESSTYPE; 178 179 typedef enum CPA_CHECKBYTESRESULTTYPE 180 { 181 CPA_CheckBytesOk, 182 CPA_CheckBytesNotReady, 183 CPA_CheckBytesInsufficientBytes, 184 CPA_CheckBytesTooLargeRequest, 185 CPA_CheckBytesKhronosExtensions = 0x6F000000, /* Reserved region for introducing Khronos Standard Extensions */ 186 CPA_CheckBytesVendorStartUnused = 0x7F000000, /* Reserved region for introducing Vendor Extensions */ 187 CPA_CheckBytesMax = 0X7FFFFFFF 188 } CPA_CHECKBYTESRESULTTYPE; 189 190 typedef enum CPA_EVENTTYPE{ 191 CPA_EventBytesToReadAvailable, 192 CPA_EventBytesToWriteAvailable, 193 CPA_EventPipeDisconnected, 194 CPA_EventEndOfStream, 195 CPA_EventKhronosExtensions = 0x6F000000, /* Reserved region for introducing Khronos Standard Extensions. */ 196 CPA_EventVendorStartUnused = 0x7F000000, /* Reserved region for introducing Vendor Extensions. */ 197 CPA_EventMax = 0X7FFFFFFF 198 } CPA_EVENTTYPE; 199 200 typedef CPA_RESULTTYPE (*CPA_CALLBACKTYPE)(CPA_HANDLE hPipe, CPA_EVENTTYPE eEvent, CPA_PTR ClientContext); 201 202 CPA_RESULTTYPE CPA_GetContentPipe( CPA_OUT CPA_HANDLE *hPipe); 203 204 typedef struct CPA_PIPETYPE 205 { 206 CPA_VERSIONTYPE nApiVersion; 207 208 CPA_RESULTTYPE (*CPA_ReleaseContentPipeType)( CPA_INOUT CPA_HANDLE *hPipe); 209 210 CPA_RESULTTYPE (*CPA_SetConfig)( CPA_IN CPA_HANDLE hPipe, CPA_IN CPA_HANDLE hContent,CPA_IN CPA_STRING szKey, CPA_IN CPA_PTR value); 211 212 CPA_RESULTTYPE (*CPA_GetConfig)( CPA_IN CPA_HANDLE hPipe, CPA_IN CPA_HANDLE hContent,CPA_IN CPA_STRING szKey, CPA_OUT CPA_PTR value); 213 214 CPA_RESULTTYPE (*CPA_Open)( CPA_IN CPA_HANDLE hPipe, CPA_OUT CPA_HANDLE *hContent, CPA_IN CPA_STRING szURI, CPA_IN CPA_ACCESSTYPE eAccess ); 215 216 CPA_RESULTTYPE (*CPA_Create)( CPA_IN CPA_HANDLE hPipe, CPA_OUT CPA_HANDLE *hContent, CPA_IN CPA_STRING szURI ); 217 218 CPA_RESULTTYPE (*CPA_Close)( CPA_IN CPA_HANDLE hPipe, CPA_INOUT CPA_HANDLE *hContent ); 219 220 CPA_RESULTTYPE (*CPA_CheckAvailableBytesToRead)( CPA_IN CPA_HANDLE hPipe, CPA_IN CPA_HANDLE hContent, CPA_IN CPA_U32 nBytesRequested, CPA_OUT CPA_CHECKBYTESRESULTTYPE* peResult ); 221 222 CPA_RESULTTYPE (*CPA_CheckAvailableBytesToWrite)( CPA_IN CPA_HANDLE hPipe, CPA_IN CPA_HANDLE hContent, CPA_IN CPA_U32 nBytesRequested, CPA_OUT CPA_CHECKBYTESRESULTTYPE* peResult ); 223 224 CPA_RESULTTYPE (*CPA_SetPosition)( CPA_IN CPA_HANDLE hPipe, CPA_IN CPA_HANDLE hContent, CPA_IN CPA_POSITIONTYPE nOffset, CPA_IN CPA_ORIGINTYPE eOrigin ); 225 226 CPA_RESULTTYPE (*CPA_GetPositions)( CPA_IN CPA_HANDLE hPipe, CPA_IN CPA_HANDLE hContent, CPA_OUT CPA_POSITIONINFOTYPE* pPosition ); 227 228 CPA_RESULTTYPE (*CPA_GetCurrentPosition)( CPA_IN CPA_HANDLE hPipe, CPA_IN CPA_HANDLE hContent, CPA_OUT CPA_POSITIONINFOTYPE* pPosition ); 229 230 CPA_RESULTTYPE (*CPA_Read)( CPA_IN CPA_HANDLE hPipe, CPA_IN CPA_HANDLE hContent, CPA_OUT CPA_BYTE* pData, CPA_INOUT CPA_U32* pSize ); 231 232 CPA_RESULTTYPE (*CPA_ReadBuffer)( CPA_IN CPA_HANDLE hPipe, CPA_IN CPA_HANDLE hContent, CPA_OUT CPA_BYTE** ppBuffer, CPA_INOUT CPA_U32* pSize, CPA_IN CPA_BOOL bForbidCopy ); 233 234 CPA_RESULTTYPE (*CPA_ReleaseReadBuffer)( CPA_IN CPA_HANDLE hPipe, CPA_IN CPA_HANDLE hContent, CPA_IN CPA_BYTE* pBuffer ); 235 236 CPA_RESULTTYPE (*CPA_Write)( CPA_IN CPA_HANDLE hPipe, CPA_IN CPA_HANDLE hContent, CPA_IN CPA_BYTE *pData, CPA_INOUT CPA_U32* pSize ); 237 238 CPA_RESULTTYPE (*CPA_RegisterCallback)( CPA_IN CPA_HANDLE hPipe, CPA_IN CPA_CALLBACKTYPE ClientCallback, CPA_IN CPA_PTR ClientContext ); 239 240 } CPA_PIPETYPE; 241 242 #define CP_GetApiVersion( hPipe ) \ 243 ((CP_PIPETYPE*)hPipe)->nApiVersion 244 245 #ifdef __cplusplus 246 } 247 #endif /* __cplusplus */ 248 #endif /* CPA_ContentPipe_h */ 249