CVBase.pas 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410
  1. {
  2. * CVBase.h
  3. * CoreVideo
  4. *
  5. * Copyright (c) 2004-2008 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 CVBase;
  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. { will require compiler define when/if other Apple devices with ARM cpus ship }
  139. {$setc TARGET_OS_MAC := FALSE}
  140. {$setc TARGET_OS_IPHONE := TRUE}
  141. {$setc TARGET_IPHONE_SIMULATOR := FALSE}
  142. {$setc TARGET_OS_EMBEDDED := TRUE}
  143. {$elifc defined __arm64__ and __arm64__}
  144. {$setc TARGET_CPU_PPC := FALSE}
  145. {$setc TARGET_CPU_PPC64 := FALSE}
  146. {$setc TARGET_CPU_X86 := FALSE}
  147. {$setc TARGET_CPU_X86_64 := FALSE}
  148. {$setc TARGET_CPU_ARM := FALSE}
  149. {$setc TARGET_CPU_ARM64 := TRUE}
  150. { will require compiler define when/if other Apple devices with ARM cpus ship }
  151. {$setc TARGET_OS_MAC := FALSE}
  152. {$setc TARGET_OS_IPHONE := TRUE}
  153. {$setc TARGET_IPHONE_SIMULATOR := FALSE}
  154. {$setc TARGET_OS_EMBEDDED := TRUE}
  155. {$elsec}
  156. {$error __ppc__ nor __ppc64__ nor __i386__ nor __x86_64__ nor __arm__ nor __arm64__ is defined.}
  157. {$endc}
  158. {$ifc defined __LP64__ and __LP64__ }
  159. {$setc TARGET_CPU_64 := TRUE}
  160. {$elsec}
  161. {$setc TARGET_CPU_64 := FALSE}
  162. {$endc}
  163. {$ifc defined FPC_BIG_ENDIAN}
  164. {$setc TARGET_RT_BIG_ENDIAN := TRUE}
  165. {$setc TARGET_RT_LITTLE_ENDIAN := FALSE}
  166. {$elifc defined FPC_LITTLE_ENDIAN}
  167. {$setc TARGET_RT_BIG_ENDIAN := FALSE}
  168. {$setc TARGET_RT_LITTLE_ENDIAN := TRUE}
  169. {$elsec}
  170. {$error Neither FPC_BIG_ENDIAN nor FPC_LITTLE_ENDIAN are defined.}
  171. {$endc}
  172. {$setc ACCESSOR_CALLS_ARE_FUNCTIONS := TRUE}
  173. {$setc CALL_NOT_IN_CARBON := FALSE}
  174. {$setc OLDROUTINENAMES := FALSE}
  175. {$setc OPAQUE_TOOLBOX_STRUCTS := TRUE}
  176. {$setc OPAQUE_UPP_TYPES := TRUE}
  177. {$setc OTCARBONAPPLICATION := TRUE}
  178. {$setc OTKERNEL := FALSE}
  179. {$setc PM_USE_SESSION_APIS := TRUE}
  180. {$setc TARGET_API_MAC_CARBON := TRUE}
  181. {$setc TARGET_API_MAC_OS8 := FALSE}
  182. {$setc TARGET_API_MAC_OSX := TRUE}
  183. {$setc TARGET_CARBON := TRUE}
  184. {$setc TARGET_CPU_68K := FALSE}
  185. {$setc TARGET_CPU_MIPS := FALSE}
  186. {$setc TARGET_CPU_SPARC := FALSE}
  187. {$setc TARGET_OS_UNIX := FALSE}
  188. {$setc TARGET_OS_WIN32 := FALSE}
  189. {$setc TARGET_RT_MAC_68881 := FALSE}
  190. {$setc TARGET_RT_MAC_CFM := FALSE}
  191. {$setc TARGET_RT_MAC_MACHO := TRUE}
  192. {$setc TYPED_FUNCTION_POINTERS := TRUE}
  193. {$setc TYPE_BOOL := FALSE}
  194. {$setc TYPE_EXTENDED := FALSE}
  195. {$setc TYPE_LONGLONG := TRUE}
  196. uses MacTypes, CFBase;
  197. {$endc} {not MACOSALLINCLUDE}
  198. {$ALIGN POWER}
  199. {! @header CVBase.h
  200. @copyright 2004 Apple Computer, Inc. All rights reserved.
  201. @availability Mac OS X 10.4 or later
  202. @discussion Here you can find the type declarations for CoreVideo. CoreVideo uses a CVTimeStamp structure to store video display time stamps.
  203. }
  204. {
  205. #ifndef AVAILABLE_MAC_OS_X_VERSION_10_6_AND_LATER
  206. #define AVAILABLE_MAC_OS_X_VERSION_10_6_AND_LATER WEAK_IMPORT_ATTRIBUTE
  207. #endif
  208. #ifndef __AVAILABILITY_INTERNAL__MAC_10_7
  209. #define __AVAILABILITY_INTERNAL__MAC_10_7 __AVAILABILITY_INTERNAL_WEAK_IMPORT
  210. #endif
  211. #ifndef __AVAILABILITY_INTERNAL__MAC_10_8
  212. #define __AVAILABILITY_INTERNAL__MAC_10_8 __AVAILABILITY_INTERNAL_WEAK_IMPORT
  213. #endif
  214. #ifndef __AVAILABILITY_INTERNAL__MAC_10_9
  215. #define __AVAILABILITY_INTERNAL__MAC_10_9 __AVAILABILITY_INTERNAL_WEAK_IMPORT
  216. #endif
  217. #define COREVIDEO_SUPPORTS_DIRECT3D (TARGET_OS_WIN32)
  218. #define COREVIDEO_SUPPORTS_OPENGL (TARGET_OS_MAC && ! TARGET_OS_IPHONE)
  219. #define COREVIDEO_SUPPORTS_OPENGLES (TARGET_OS_MAC && TARGET_OS_IPHONE)
  220. #define COREVIDEO_SUPPORTS_COLORSPACE ((TARGET_OS_MAC && ! TARGET_OS_IPHONE) || (TARGET_OS_WIN32))
  221. #define COREVIDEO_SUPPORTS_DISPLAYLINK (TARGET_OS_MAC && ! TARGET_OS_IPHONE)
  222. #define COREVIDEO_SUPPORTS_IOSURFACE (TARGET_OS_IPHONE ? TARGET_OS_EMBEDDED : (TARGET_OS_MAC && ((MAC_OS_X_VERSION_MAX_ALLOWED >= 1060))))
  223. #define extern extern
  224. #define CV_INLINE CF_INLINE
  225. }
  226. {!
  227. @typedef CVOptionFlags
  228. @abstract Flags to be used for the display and render call back functions.
  229. @discussion ***Values to be defined***
  230. }
  231. type
  232. CVOptionFlags = UInt64;
  233. {!
  234. @struct CVSMPTETime
  235. @abstract A structure for holding a SMPTE time.
  236. @field subframes
  237. The number of subframes in the full message.
  238. @field subframeDivisor
  239. The number of subframes per frame (typically 80).
  240. @field counter
  241. The total number of messages received.
  242. @field type
  243. The kind of SMPTE time using the SMPTE time type constants.
  244. @field flags
  245. A set of flags that indicate the SMPTE state.
  246. @field hours
  247. The number of hours in the full message.
  248. @field minutes
  249. The number of minutes in the full message.
  250. @field seconds
  251. The number of seconds in the full message.
  252. @field frames
  253. The number of frames in the full message.
  254. }
  255. type
  256. CVSMPTETime = record
  257. subframes: SInt16;
  258. subframeDivisor: SInt16;
  259. counter: UInt32;
  260. typ: UInt32;
  261. flags: UInt32;
  262. hours: SInt16;
  263. minutes: SInt16;
  264. seconds: SInt16;
  265. frames: SInt16;
  266. end;
  267. {!
  268. @enum SMPTE Time Types
  269. @abstract Constants that describe the type of SMPTE time.
  270. @constant kCVSMPTETimeType24
  271. 24 Frame
  272. @constant kCVSMPTETimeType25
  273. 25 Frame
  274. @constant kCVSMPTETimeType30Drop
  275. 30 Drop Frame
  276. @constant kCVSMPTETimeType30
  277. 30 Frame
  278. @constant kCVSMPTETimeType2997
  279. 29.97 Frame
  280. @constant kCVSMPTETimeType2997Drop
  281. 29.97 Drop Frame
  282. @constant kCVSMPTETimeType60
  283. 60 Frame
  284. @constant kCVSMPTETimeType5994
  285. 59.94 Frame
  286. }
  287. const
  288. kCVSMPTETimeType24 = 0;
  289. kCVSMPTETimeType25 = 1;
  290. kCVSMPTETimeType30Drop = 2;
  291. kCVSMPTETimeType30 = 3;
  292. kCVSMPTETimeType2997 = 4;
  293. kCVSMPTETimeType2997Drop = 5;
  294. kCVSMPTETimeType60 = 6;
  295. kCVSMPTETimeType5994 = 7;
  296. {!
  297. @enum SMPTE State Flags
  298. @abstract Flags that describe the SMPTE time state.
  299. @constant kCVSMPTETimeValid
  300. The full time is valid.
  301. @constant kCVSMPTETimeRunning
  302. Time is running.
  303. }
  304. const
  305. kCVSMPTETimeValid = 1 shl 0;
  306. kCVSMPTETimeRunning = 1 shl 1;
  307. const
  308. kCVTimeIsIndefinite = 1 shl 0;
  309. type
  310. CVTime = record
  311. timeValue: SInt64;
  312. timeScale: SInt32;
  313. flags: SInt32;
  314. end;
  315. {!
  316. @struct CVTimeStamp
  317. @abstract CoreVideo uses a CVTimeStamp structure to store video display time stamps.
  318. @discussion This structure is purposely very similar to AudioTimeStamp defined in the CoreAudio framework.
  319. Most of the CVTimeStamp struct should be fairly self-explanatory. However, it is probably worth pointing out that unlike the audio time stamps, floats are not used to represent the video equivalent of sample times. This was done partly to avoid precision issues, and partly because QuickTime still uses integers for time values and time scales. In the actual implementation it has turned out to be very convenient to use integers, and we can represent framerates like NTSC (30000/1001 fps) exactly. The mHostTime structure field uses the same Mach absolute time base that is used in CoreAudio, so that clients of the CoreVideo API can synchronize between the two subsystems.
  320. @field videoTimeScale The scale (in units per second) of the videoTime and videoPeriod values
  321. @field videoTime This represents the start of a frame (or field for interlaced)
  322. @field hostTime Host root timebase time
  323. @field rateScalar This is the current rate of the device as measured by the timestamps, divided by the nominal rate
  324. @field videoPeriod This is the nominal update period of the current output device
  325. @field smpteTime SMPTE time representation of the time stamp.
  326. @field flags Possible values are:
  327. kCVTimeStampVideoTimeValid
  328. kCVTimeStampHostTimeValid
  329. kCVTimeStampSMPTETimeValid
  330. kCVTimeStampVideoPeriodValid
  331. kCVTimeStampRateScalarValid
  332. There are flags for each field to make it easier to detect interlaced vs progressive output
  333. kCVTimeStampTopField
  334. kCVTimeStampBottomField
  335. Some commonly used combinations of timestamp flags
  336. kCVTimeStampVideoHostTimeValid
  337. kCVTimeStampIsInterlaced
  338. @field version The current CVTimeStamp is version 0.
  339. @field reserved Reserved. Do not use.
  340. }
  341. type
  342. CVTimeStampPtr = ^CVTimeStamp;
  343. CVTimeStamp = record
  344. version: UInt32; // Currently will be 0.
  345. videoTimeScale: SInt32; // Video timescale (units per second)
  346. videoTime: SInt64; // This represents the start of a frame (or field for interlaced) .. think vsync - still not 100% sure on the name
  347. hostTime: UInt64; // Host root timebase time
  348. rateScalar: Float64; // Current rate as measured by the timestamps divided by the nominal rate
  349. videoRefreshPeriod: SInt64; // Hint for nominal output rate
  350. smpteTime: CVSMPTETime;
  351. flags: UInt64;
  352. reserved: UInt64;
  353. end;
  354. // Flags for the CVTimeStamp structure
  355. const
  356. kCVTimeStampVideoTimeValid = 1 shl 0;
  357. kCVTimeStampHostTimeValid = 1 shl 1;
  358. kCVTimeStampSMPTETimeValid = 1 shl 2;
  359. kCVTimeStampVideoRefreshPeriodValid = 1 shl 3;
  360. kCVTimeStampRateScalarValid = 1 shl 4;
  361. // There are flags for each field to make it easier to detect interlaced vs progressive output
  362. kCVTimeStampTopField = 1 shl 16;
  363. kCVTimeStampBottomField = 1 shl 17;
  364. // Some commonly used combinations of timestamp flags
  365. const
  366. kCVTimeStampVideoHostTimeValid = kCVTimeStampVideoTimeValid or kCVTimeStampHostTimeValid;
  367. kCVTimeStampIsInterlaced = kCVTimeStampTopField or kCVTimeStampBottomField;
  368. var kCVZeroTime: CVTime; external name '_kCVZeroTime'; (* attribute const *)
  369. var kCVIndefiniteTime: CVTime; external name '_kCVIndefiniteTime'; (* attribute const *)
  370. {$ifc not defined MACOSALLINCLUDE or not MACOSALLINCLUDE}
  371. end.
  372. {$endc} {not MACOSALLINCLUDE}