CVPixelBufferPool.pas 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338
  1. {
  2. * CVPixelBufferPool.h
  3. * CoreVideo
  4. *
  5. * Copyright 2004 Apple Computer, Inc. All rights reserved.
  6. *
  7. }
  8. { Pascal Translation: Gale R Paeper, <[email protected]>, 2008 }
  9. { Pascal Translation Update: Gorazd Krosl, <[email protected]>, 2009 }
  10. { Pascal Translation Update: Jonas Maebe <[email protected]>, October 2012 }
  11. { Pascal Translation Update: Jonas Maebe <[email protected]>, August 2015 }
  12. {
  13. Modified for use with Free Pascal
  14. Version 308
  15. Please report any bugs to <[email protected]>
  16. }
  17. {$ifc not defined MACOSALLINCLUDE or not MACOSALLINCLUDE}
  18. {$mode macpas}
  19. {$modeswitch cblocks}
  20. {$packenum 1}
  21. {$macro on}
  22. {$inline on}
  23. {$calling mwpascal}
  24. unit CVPixelBufferPool;
  25. interface
  26. {$setc UNIVERSAL_INTERFACES_VERSION := $0400}
  27. {$setc GAP_INTERFACES_VERSION := $0308}
  28. {$ifc not defined USE_CFSTR_CONSTANT_MACROS}
  29. {$setc USE_CFSTR_CONSTANT_MACROS := TRUE}
  30. {$endc}
  31. {$ifc defined CPUPOWERPC and defined CPUI386}
  32. {$error Conflicting initial definitions for CPUPOWERPC and CPUI386}
  33. {$endc}
  34. {$ifc defined FPC_BIG_ENDIAN and defined FPC_LITTLE_ENDIAN}
  35. {$error Conflicting initial definitions for FPC_BIG_ENDIAN and FPC_LITTLE_ENDIAN}
  36. {$endc}
  37. {$ifc not defined __ppc__ and defined CPUPOWERPC32}
  38. {$setc __ppc__ := 1}
  39. {$elsec}
  40. {$setc __ppc__ := 0}
  41. {$endc}
  42. {$ifc not defined __ppc64__ and defined CPUPOWERPC64}
  43. {$setc __ppc64__ := 1}
  44. {$elsec}
  45. {$setc __ppc64__ := 0}
  46. {$endc}
  47. {$ifc not defined __i386__ and defined CPUI386}
  48. {$setc __i386__ := 1}
  49. {$elsec}
  50. {$setc __i386__ := 0}
  51. {$endc}
  52. {$ifc not defined __x86_64__ and defined CPUX86_64}
  53. {$setc __x86_64__ := 1}
  54. {$elsec}
  55. {$setc __x86_64__ := 0}
  56. {$endc}
  57. {$ifc not defined __arm__ and defined CPUARM}
  58. {$setc __arm__ := 1}
  59. {$elsec}
  60. {$setc __arm__ := 0}
  61. {$endc}
  62. {$ifc not defined __arm64__ and defined CPUAARCH64}
  63. {$setc __arm64__ := 1}
  64. {$elsec}
  65. {$setc __arm64__ := 0}
  66. {$endc}
  67. {$ifc defined cpu64}
  68. {$setc __LP64__ := 1}
  69. {$elsec}
  70. {$setc __LP64__ := 0}
  71. {$endc}
  72. {$ifc defined __ppc__ and __ppc__ and defined __i386__ and __i386__}
  73. {$error Conflicting definitions for __ppc__ and __i386__}
  74. {$endc}
  75. {$ifc defined __ppc__ and __ppc__}
  76. {$setc TARGET_CPU_PPC := TRUE}
  77. {$setc TARGET_CPU_PPC64 := FALSE}
  78. {$setc TARGET_CPU_X86 := FALSE}
  79. {$setc TARGET_CPU_X86_64 := FALSE}
  80. {$setc TARGET_CPU_ARM := FALSE}
  81. {$setc TARGET_CPU_ARM64 := FALSE}
  82. {$setc TARGET_OS_MAC := TRUE}
  83. {$setc TARGET_OS_IPHONE := FALSE}
  84. {$setc TARGET_IPHONE_SIMULATOR := FALSE}
  85. {$setc TARGET_OS_EMBEDDED := FALSE}
  86. {$elifc defined __ppc64__ and __ppc64__}
  87. {$setc TARGET_CPU_PPC := FALSE}
  88. {$setc TARGET_CPU_PPC64 := TRUE}
  89. {$setc TARGET_CPU_X86 := FALSE}
  90. {$setc TARGET_CPU_X86_64 := FALSE}
  91. {$setc TARGET_CPU_ARM := FALSE}
  92. {$setc TARGET_CPU_ARM64 := FALSE}
  93. {$setc TARGET_OS_MAC := TRUE}
  94. {$setc TARGET_OS_IPHONE := FALSE}
  95. {$setc TARGET_IPHONE_SIMULATOR := FALSE}
  96. {$setc TARGET_OS_EMBEDDED := FALSE}
  97. {$elifc defined __i386__ and __i386__}
  98. {$setc TARGET_CPU_PPC := FALSE}
  99. {$setc TARGET_CPU_PPC64 := FALSE}
  100. {$setc TARGET_CPU_X86 := TRUE}
  101. {$setc TARGET_CPU_X86_64 := FALSE}
  102. {$setc TARGET_CPU_ARM := FALSE}
  103. {$setc TARGET_CPU_ARM64 := FALSE}
  104. {$ifc defined iphonesim}
  105. {$setc TARGET_OS_MAC := FALSE}
  106. {$setc TARGET_OS_IPHONE := TRUE}
  107. {$setc TARGET_IPHONE_SIMULATOR := TRUE}
  108. {$elsec}
  109. {$setc TARGET_OS_MAC := TRUE}
  110. {$setc TARGET_OS_IPHONE := FALSE}
  111. {$setc TARGET_IPHONE_SIMULATOR := FALSE}
  112. {$endc}
  113. {$setc TARGET_OS_EMBEDDED := FALSE}
  114. {$elifc defined __x86_64__ and __x86_64__}
  115. {$setc TARGET_CPU_PPC := FALSE}
  116. {$setc TARGET_CPU_PPC64 := FALSE}
  117. {$setc TARGET_CPU_X86 := FALSE}
  118. {$setc TARGET_CPU_X86_64 := TRUE}
  119. {$setc TARGET_CPU_ARM := FALSE}
  120. {$setc TARGET_CPU_ARM64 := FALSE}
  121. {$ifc defined iphonesim}
  122. {$setc TARGET_OS_MAC := FALSE}
  123. {$setc TARGET_OS_IPHONE := TRUE}
  124. {$setc TARGET_IPHONE_SIMULATOR := TRUE}
  125. {$elsec}
  126. {$setc TARGET_OS_MAC := TRUE}
  127. {$setc TARGET_OS_IPHONE := FALSE}
  128. {$setc TARGET_IPHONE_SIMULATOR := FALSE}
  129. {$endc}
  130. {$setc TARGET_OS_EMBEDDED := FALSE}
  131. {$elifc defined __arm__ and __arm__}
  132. {$setc TARGET_CPU_PPC := FALSE}
  133. {$setc TARGET_CPU_PPC64 := FALSE}
  134. {$setc TARGET_CPU_X86 := FALSE}
  135. {$setc TARGET_CPU_X86_64 := FALSE}
  136. {$setc TARGET_CPU_ARM := TRUE}
  137. {$setc TARGET_CPU_ARM64 := FALSE}
  138. {$setc TARGET_OS_MAC := FALSE}
  139. {$setc TARGET_OS_IPHONE := TRUE}
  140. {$setc TARGET_IPHONE_SIMULATOR := FALSE}
  141. {$setc TARGET_OS_EMBEDDED := TRUE}
  142. {$elifc defined __arm64__ and __arm64__}
  143. {$setc TARGET_CPU_PPC := FALSE}
  144. {$setc TARGET_CPU_PPC64 := FALSE}
  145. {$setc TARGET_CPU_X86 := FALSE}
  146. {$setc TARGET_CPU_X86_64 := FALSE}
  147. {$setc TARGET_CPU_ARM := FALSE}
  148. {$setc TARGET_CPU_ARM64 := TRUE}
  149. {$ifc defined ios}
  150. {$setc TARGET_OS_MAC := FALSE}
  151. {$setc TARGET_OS_IPHONE := TRUE}
  152. {$setc TARGET_OS_EMBEDDED := TRUE}
  153. {$elsec}
  154. {$setc TARGET_OS_MAC := TRUE}
  155. {$setc TARGET_OS_IPHONE := FALSE}
  156. {$setc TARGET_OS_EMBEDDED := FALSE}
  157. {$endc}
  158. {$setc TARGET_IPHONE_SIMULATOR := FALSE}
  159. {$elsec}
  160. {$error __ppc__ nor __ppc64__ nor __i386__ nor __x86_64__ nor __arm__ nor __arm64__ is defined.}
  161. {$endc}
  162. {$ifc defined __LP64__ and __LP64__ }
  163. {$setc TARGET_CPU_64 := TRUE}
  164. {$elsec}
  165. {$setc TARGET_CPU_64 := FALSE}
  166. {$endc}
  167. {$ifc defined FPC_BIG_ENDIAN}
  168. {$setc TARGET_RT_BIG_ENDIAN := TRUE}
  169. {$setc TARGET_RT_LITTLE_ENDIAN := FALSE}
  170. {$elifc defined FPC_LITTLE_ENDIAN}
  171. {$setc TARGET_RT_BIG_ENDIAN := FALSE}
  172. {$setc TARGET_RT_LITTLE_ENDIAN := TRUE}
  173. {$elsec}
  174. {$error Neither FPC_BIG_ENDIAN nor FPC_LITTLE_ENDIAN are defined.}
  175. {$endc}
  176. {$setc ACCESSOR_CALLS_ARE_FUNCTIONS := TRUE}
  177. {$setc CALL_NOT_IN_CARBON := FALSE}
  178. {$setc OLDROUTINENAMES := FALSE}
  179. {$setc OPAQUE_TOOLBOX_STRUCTS := TRUE}
  180. {$setc OPAQUE_UPP_TYPES := TRUE}
  181. {$setc OTCARBONAPPLICATION := TRUE}
  182. {$setc OTKERNEL := FALSE}
  183. {$setc PM_USE_SESSION_APIS := TRUE}
  184. {$setc TARGET_API_MAC_CARBON := TRUE}
  185. {$setc TARGET_API_MAC_OS8 := FALSE}
  186. {$setc TARGET_API_MAC_OSX := TRUE}
  187. {$setc TARGET_CARBON := TRUE}
  188. {$setc TARGET_CPU_68K := FALSE}
  189. {$setc TARGET_CPU_MIPS := FALSE}
  190. {$setc TARGET_CPU_SPARC := FALSE}
  191. {$setc TARGET_OS_UNIX := FALSE}
  192. {$setc TARGET_OS_WIN32 := FALSE}
  193. {$setc TARGET_RT_MAC_68881 := FALSE}
  194. {$setc TARGET_RT_MAC_CFM := FALSE}
  195. {$setc TARGET_RT_MAC_MACHO := TRUE}
  196. {$setc TYPED_FUNCTION_POINTERS := TRUE}
  197. {$setc TYPE_BOOL := FALSE}
  198. {$setc TYPE_EXTENDED := FALSE}
  199. {$setc TYPE_LONGLONG := TRUE}
  200. uses MacTypes, CFBase, CFDictionary, CVBase, CVPixelBuffer, CVReturns;
  201. {$endc} {not MACOSALLINCLUDE}
  202. {$ALIGN POWER}
  203. {! @header CVPixelBufferPool.h
  204. @copyright 2004 Apple Computer, Inc. All rights reserved.
  205. @availability Mac OS X 10.4 or later
  206. @discussion CVPixelBufferPool is a utility object for managing a set of CVPixelBuffer objects that are going to be recycled.
  207. }
  208. type
  209. CVPixelBufferPoolRef = ^__CVPixelBufferPool; { an opaque type }
  210. __CVPixelBufferPool = record end;
  211. // By default, buffers will age out after one second. If required, setting an age of zero will disable
  212. // the age-out mechanism completely.
  213. var kCVPixelBufferPoolMinimumBufferCountKey: CFStringRef; external name '_kCVPixelBufferPoolMinimumBufferCountKey'; (* attribute const *)
  214. (* __OSX_AVAILABLE_STARTING(__MAC_10_4,__IPHONE_4_0) *)
  215. var kCVPixelBufferPoolMaximumBufferAgeKey: CFStringRef; external name '_kCVPixelBufferPoolMaximumBufferAgeKey'; (* attribute const *)
  216. (* __OSX_AVAILABLE_STARTING(__MAC_10_4,__IPHONE_4_0) *)
  217. function CVPixelBufferPoolGetTypeID: CFTypeID; external name '_CVPixelBufferPoolGetTypeID';
  218. (* __OSX_AVAILABLE_STARTING(__MAC_10_4,__IPHONE_4_0) *)
  219. {!
  220. @function CVPixelBufferPoolRetain
  221. @abstract Retains a CVPixelBufferPoolRef object
  222. @discussion Equivalent to CFRetain, but NULL safe
  223. @param buffer A CVPixelBufferPoolRef object that you want to retain.
  224. @result A CVPixelBufferPoolRef object that is the same as the passed in buffer.
  225. }
  226. function CVPixelBufferPoolRetain( pixelBufferPool: CVPixelBufferPoolRef ): CVPixelBufferPoolRef; external name '_CVPixelBufferPoolRetain';
  227. (* __OSX_AVAILABLE_STARTING(__MAC_10_4,__IPHONE_4_0) *) // NULL-safe
  228. {!
  229. @function CVPixelBufferPoolRelease
  230. @abstract Releases a CVPixelBufferPoolRef object
  231. @discussion Equivalent to CFRelease, but NULL safe
  232. @param buffer A CVPixelBufferPoolRef object that you want to release.
  233. }
  234. procedure CVPixelBufferPoolRelease( pixelBufferPool: CVPixelBufferPoolRef ); external name '_CVPixelBufferPoolRelease';
  235. (* __OSX_AVAILABLE_STARTING(__MAC_10_4,__IPHONE_4_0) *) // NULL-safe
  236. {!
  237. @function CVPixelBufferPoolCreate
  238. @abstract Creates a new Pixel Buffer pool.
  239. @param allocator The CFAllocatorRef to use for allocating this buffer pool. May be NULL.
  240. @param attributes A CFDictionaryRef containing the attributes to be used for creating new PixelBuffers within the pool.
  241. @param poolOut The newly created pool will be placed here
  242. @result Returns kCVReturnSuccess on success
  243. }
  244. function CVPixelBufferPoolCreate( allocator: CFAllocatorRef; poolAttributes: CFDictionaryRef; pixelBufferAttributes: CFDictionaryRef; var poolOut: CVPixelBufferPoolRef ): CVReturn; external name '_CVPixelBufferPoolCreate';
  245. (* __OSX_AVAILABLE_STARTING(__MAC_10_4,__IPHONE_4_0) *)
  246. {!
  247. @function CVPixelBufferPoolGetAttributes
  248. @abstract Returns the pool attributes dictionary for a CVPixelBufferPool
  249. @param pool The CVPixelBufferPoolRef to retrieve the attributes from
  250. @result Returns the pool attributes dictionary, or NULL on failure.
  251. }
  252. function CVPixelBufferPoolGetAttributes( pool: CVPixelBufferPoolRef ): CFDictionaryRef; external name '_CVPixelBufferPoolGetAttributes';
  253. (* __OSX_AVAILABLE_STARTING(__MAC_10_4,__IPHONE_4_0) *)
  254. {!
  255. @function CVPixelBufferPoolGetPixelBufferAttributes
  256. @abstract Returns the attributes of pixel buffers that will be created from this pool.
  257. @discussion This function is provided for those cases where you may need to know some information about the buffers that
  258. will be created up front.
  259. @param pool The CVPixelBufferPoolRef to retrieve the attributes from
  260. @result Returns the pixel buffer attributes dictionary, or NULL on failure.
  261. }
  262. function CVPixelBufferPoolGetPixelBufferAttributes( pool: CVPixelBufferPoolRef ): CFDictionaryRef; external name '_CVPixelBufferPoolGetPixelBufferAttributes';
  263. (* __OSX_AVAILABLE_STARTING(__MAC_10_4,__IPHONE_4_0) *)
  264. {!
  265. @function CVPixelBufferPoolCreatePixelBuffer
  266. @abstract Creates a new PixelBuffer object from the pool.
  267. @discussion The function creates a new (attachment-free) CVPixelBuffer using the pixel buffer attributes specifed during pool creation.
  268. @param allocator The CFAllocatorRef to use for creating the pixel buffer. May be NULL.
  269. @param pool The CVPixelBufferPool that should create the new CVPixelBuffer.
  270. @param pixelBufferOut The newly created pixel buffer will be placed here
  271. @result Returns kCVReturnSuccess on success
  272. }
  273. function CVPixelBufferPoolCreatePixelBuffer( allocator: CFAllocatorRef; pixelBufferPool: CVPixelBufferPoolRef; var pixelBufferOut: CVPixelBufferRef ): CVReturn; external name '_CVPixelBufferPoolCreatePixelBuffer';
  274. (* __OSX_AVAILABLE_STARTING(__MAC_10_4,__IPHONE_4_0) *)
  275. {
  276. @function CVPixelBufferPoolCreatePixelBufferWithAuxAttributes
  277. @abstract Creates a new PixelBuffer object from the pool.
  278. @discussion This function creates a new CVPixelBuffer using the pixel buffer attributes specified during pool creation and the attributes specified in the auxAttributes parameter.
  279. @param allocator The CFAllocatorRef to use for creating the pixel buffer. May be NULL.
  280. @param pixelBufferPool The CVPixelBufferPool that should create the new CVPixelBuffer.
  281. @param auxAttributes Attributes describing this specific allocation request. May be NULL.
  282. @param pixelBufferOut The newly created pixel buffer will be placed here
  283. @result Returns kCVReturnSuccess on success
  284. }
  285. function CVPixelBufferPoolCreatePixelBufferWithAuxAttributes( allocator: CFAllocatorRef; pixelBufferPool: CVPixelBufferPoolRef; auxAttributes: CFDictionaryRef; var pixelBufferOut: CVPixelBufferRef ): CVReturn; external name '_CVPixelBufferPoolCreatePixelBufferWithAuxAttributes';
  286. (* __OSX_AVAILABLE_STARTING(__MAC_10_7,__IPHONE_4_0) *)
  287. // Key for the auxiliary attributes dictionary passed to CVPixelBufferPoolCreatePixelBufferWithAuxAttributes().
  288. // When set, indicates that a new pixel buffer should not be allocated if
  289. // the pool already has this many or more pixel buffers allocated.
  290. // This does not prevent already-allocated buffers from being recycled.
  291. // If this key causes CVPixelBufferPoolCreatePixelBufferWithAuxAttributes to fail,
  292. // it will return kCVReturnWouldExceedAllocationThreshold.
  293. var kCVPixelBufferPoolAllocationThresholdKey: CFStringRef; external name '_kCVPixelBufferPoolAllocationThresholdKey'; (* attribute const *)
  294. (* __OSX_AVAILABLE_STARTING(__MAC_10_7,__IPHONE_4_0) *) // CFNumberRef -- for use only in auxAttributes
  295. // kCVPixelBufferPoolFreeBufferNotification is posted if a buffer becomes available after
  296. // CVPixelBufferPoolCreatePixelBufferWithAuxAttributes has failed due to kCVPixelBufferPoolAllocationThresholdKey.
  297. // This notification will not be posted by the pool if kCVPixelBufferPoolAllocationThresholdKey
  298. // has never been passed to CVPixelBufferPoolCreatePixelBufferWithAuxAttributes.
  299. var kCVPixelBufferPoolFreeBufferNotification: CFStringRef; external name '_kCVPixelBufferPoolFreeBufferNotification'; (* attribute const *)
  300. (* __OSX_AVAILABLE_STARTING(__MAC_10_7,__IPHONE_4_0) *)
  301. {$ifc not defined MACOSALLINCLUDE or not MACOSALLINCLUDE}
  302. end.
  303. {$endc} {not MACOSALLINCLUDE}