CVBase.pas 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420
  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. {$IFNDEF FPC_DOTTEDUNITS}
  25. unit CVBase;
  26. {$ENDIF FPC_DOTTEDUNITS}
  27. interface
  28. {$setc UNIVERSAL_INTERFACES_VERSION := $0400}
  29. {$setc GAP_INTERFACES_VERSION := $0308}
  30. {$ifc not defined USE_CFSTR_CONSTANT_MACROS}
  31. {$setc USE_CFSTR_CONSTANT_MACROS := TRUE}
  32. {$endc}
  33. {$ifc defined CPUPOWERPC and defined CPUI386}
  34. {$error Conflicting initial definitions for CPUPOWERPC and CPUI386}
  35. {$endc}
  36. {$ifc defined FPC_BIG_ENDIAN and defined FPC_LITTLE_ENDIAN}
  37. {$error Conflicting initial definitions for FPC_BIG_ENDIAN and FPC_LITTLE_ENDIAN}
  38. {$endc}
  39. {$ifc not defined __ppc__ and defined CPUPOWERPC32}
  40. {$setc __ppc__ := 1}
  41. {$elsec}
  42. {$setc __ppc__ := 0}
  43. {$endc}
  44. {$ifc not defined __ppc64__ and defined CPUPOWERPC64}
  45. {$setc __ppc64__ := 1}
  46. {$elsec}
  47. {$setc __ppc64__ := 0}
  48. {$endc}
  49. {$ifc not defined __i386__ and defined CPUI386}
  50. {$setc __i386__ := 1}
  51. {$elsec}
  52. {$setc __i386__ := 0}
  53. {$endc}
  54. {$ifc not defined __x86_64__ and defined CPUX86_64}
  55. {$setc __x86_64__ := 1}
  56. {$elsec}
  57. {$setc __x86_64__ := 0}
  58. {$endc}
  59. {$ifc not defined __arm__ and defined CPUARM}
  60. {$setc __arm__ := 1}
  61. {$elsec}
  62. {$setc __arm__ := 0}
  63. {$endc}
  64. {$ifc not defined __arm64__ and defined CPUAARCH64}
  65. {$setc __arm64__ := 1}
  66. {$elsec}
  67. {$setc __arm64__ := 0}
  68. {$endc}
  69. {$ifc defined cpu64}
  70. {$setc __LP64__ := 1}
  71. {$elsec}
  72. {$setc __LP64__ := 0}
  73. {$endc}
  74. {$ifc defined __ppc__ and __ppc__ and defined __i386__ and __i386__}
  75. {$error Conflicting definitions for __ppc__ and __i386__}
  76. {$endc}
  77. {$ifc defined __ppc__ and __ppc__}
  78. {$setc TARGET_CPU_PPC := TRUE}
  79. {$setc TARGET_CPU_PPC64 := FALSE}
  80. {$setc TARGET_CPU_X86 := FALSE}
  81. {$setc TARGET_CPU_X86_64 := FALSE}
  82. {$setc TARGET_CPU_ARM := FALSE}
  83. {$setc TARGET_CPU_ARM64 := FALSE}
  84. {$setc TARGET_OS_MAC := TRUE}
  85. {$setc TARGET_OS_IPHONE := FALSE}
  86. {$setc TARGET_IPHONE_SIMULATOR := FALSE}
  87. {$setc TARGET_OS_EMBEDDED := FALSE}
  88. {$elifc defined __ppc64__ and __ppc64__}
  89. {$setc TARGET_CPU_PPC := FALSE}
  90. {$setc TARGET_CPU_PPC64 := TRUE}
  91. {$setc TARGET_CPU_X86 := FALSE}
  92. {$setc TARGET_CPU_X86_64 := FALSE}
  93. {$setc TARGET_CPU_ARM := FALSE}
  94. {$setc TARGET_CPU_ARM64 := FALSE}
  95. {$setc TARGET_OS_MAC := TRUE}
  96. {$setc TARGET_OS_IPHONE := FALSE}
  97. {$setc TARGET_IPHONE_SIMULATOR := FALSE}
  98. {$setc TARGET_OS_EMBEDDED := FALSE}
  99. {$elifc defined __i386__ and __i386__}
  100. {$setc TARGET_CPU_PPC := FALSE}
  101. {$setc TARGET_CPU_PPC64 := FALSE}
  102. {$setc TARGET_CPU_X86 := TRUE}
  103. {$setc TARGET_CPU_X86_64 := FALSE}
  104. {$setc TARGET_CPU_ARM := FALSE}
  105. {$setc TARGET_CPU_ARM64 := FALSE}
  106. {$ifc defined iphonesim}
  107. {$setc TARGET_OS_MAC := FALSE}
  108. {$setc TARGET_OS_IPHONE := TRUE}
  109. {$setc TARGET_IPHONE_SIMULATOR := TRUE}
  110. {$elsec}
  111. {$setc TARGET_OS_MAC := TRUE}
  112. {$setc TARGET_OS_IPHONE := FALSE}
  113. {$setc TARGET_IPHONE_SIMULATOR := FALSE}
  114. {$endc}
  115. {$setc TARGET_OS_EMBEDDED := FALSE}
  116. {$elifc defined __x86_64__ and __x86_64__}
  117. {$setc TARGET_CPU_PPC := FALSE}
  118. {$setc TARGET_CPU_PPC64 := FALSE}
  119. {$setc TARGET_CPU_X86 := FALSE}
  120. {$setc TARGET_CPU_X86_64 := TRUE}
  121. {$setc TARGET_CPU_ARM := FALSE}
  122. {$setc TARGET_CPU_ARM64 := FALSE}
  123. {$ifc defined iphonesim}
  124. {$setc TARGET_OS_MAC := FALSE}
  125. {$setc TARGET_OS_IPHONE := TRUE}
  126. {$setc TARGET_IPHONE_SIMULATOR := TRUE}
  127. {$elsec}
  128. {$setc TARGET_OS_MAC := TRUE}
  129. {$setc TARGET_OS_IPHONE := FALSE}
  130. {$setc TARGET_IPHONE_SIMULATOR := FALSE}
  131. {$endc}
  132. {$setc TARGET_OS_EMBEDDED := FALSE}
  133. {$elifc defined __arm__ and __arm__}
  134. {$setc TARGET_CPU_PPC := FALSE}
  135. {$setc TARGET_CPU_PPC64 := FALSE}
  136. {$setc TARGET_CPU_X86 := FALSE}
  137. {$setc TARGET_CPU_X86_64 := FALSE}
  138. {$setc TARGET_CPU_ARM := TRUE}
  139. {$setc TARGET_CPU_ARM64 := FALSE}
  140. {$setc TARGET_OS_MAC := FALSE}
  141. {$setc TARGET_OS_IPHONE := TRUE}
  142. {$setc TARGET_IPHONE_SIMULATOR := FALSE}
  143. {$setc TARGET_OS_EMBEDDED := TRUE}
  144. {$elifc defined __arm64__ and __arm64__}
  145. {$setc TARGET_CPU_PPC := FALSE}
  146. {$setc TARGET_CPU_PPC64 := FALSE}
  147. {$setc TARGET_CPU_X86 := FALSE}
  148. {$setc TARGET_CPU_X86_64 := FALSE}
  149. {$setc TARGET_CPU_ARM := FALSE}
  150. {$setc TARGET_CPU_ARM64 := TRUE}
  151. {$ifc defined ios}
  152. {$setc TARGET_OS_MAC := FALSE}
  153. {$setc TARGET_OS_IPHONE := TRUE}
  154. {$setc TARGET_OS_EMBEDDED := TRUE}
  155. {$elsec}
  156. {$setc TARGET_OS_MAC := TRUE}
  157. {$setc TARGET_OS_IPHONE := FALSE}
  158. {$setc TARGET_OS_EMBEDDED := FALSE}
  159. {$endc}
  160. {$setc TARGET_IPHONE_SIMULATOR := FALSE}
  161. {$elsec}
  162. {$error __ppc__ nor __ppc64__ nor __i386__ nor __x86_64__ nor __arm__ nor __arm64__ is defined.}
  163. {$endc}
  164. {$ifc defined __LP64__ and __LP64__ }
  165. {$setc TARGET_CPU_64 := TRUE}
  166. {$elsec}
  167. {$setc TARGET_CPU_64 := FALSE}
  168. {$endc}
  169. {$ifc defined FPC_BIG_ENDIAN}
  170. {$setc TARGET_RT_BIG_ENDIAN := TRUE}
  171. {$setc TARGET_RT_LITTLE_ENDIAN := FALSE}
  172. {$elifc defined FPC_LITTLE_ENDIAN}
  173. {$setc TARGET_RT_BIG_ENDIAN := FALSE}
  174. {$setc TARGET_RT_LITTLE_ENDIAN := TRUE}
  175. {$elsec}
  176. {$error Neither FPC_BIG_ENDIAN nor FPC_LITTLE_ENDIAN are defined.}
  177. {$endc}
  178. {$setc ACCESSOR_CALLS_ARE_FUNCTIONS := TRUE}
  179. {$setc CALL_NOT_IN_CARBON := FALSE}
  180. {$setc OLDROUTINENAMES := FALSE}
  181. {$setc OPAQUE_TOOLBOX_STRUCTS := TRUE}
  182. {$setc OPAQUE_UPP_TYPES := TRUE}
  183. {$setc OTCARBONAPPLICATION := TRUE}
  184. {$setc OTKERNEL := FALSE}
  185. {$setc PM_USE_SESSION_APIS := TRUE}
  186. {$setc TARGET_API_MAC_CARBON := TRUE}
  187. {$setc TARGET_API_MAC_OS8 := FALSE}
  188. {$setc TARGET_API_MAC_OSX := TRUE}
  189. {$setc TARGET_CARBON := TRUE}
  190. {$setc TARGET_CPU_68K := FALSE}
  191. {$setc TARGET_CPU_MIPS := FALSE}
  192. {$setc TARGET_CPU_SPARC := FALSE}
  193. {$setc TARGET_OS_UNIX := FALSE}
  194. {$setc TARGET_OS_WIN32 := FALSE}
  195. {$setc TARGET_RT_MAC_68881 := FALSE}
  196. {$setc TARGET_RT_MAC_CFM := FALSE}
  197. {$setc TARGET_RT_MAC_MACHO := TRUE}
  198. {$setc TYPED_FUNCTION_POINTERS := TRUE}
  199. {$setc TYPE_BOOL := FALSE}
  200. {$setc TYPE_EXTENDED := FALSE}
  201. {$setc TYPE_LONGLONG := TRUE}
  202. {$IFDEF FPC_DOTTEDUNITS}
  203. uses MacOsApi.MacTypes, MacOsApi.CFBase;
  204. {$ELSE FPC_DOTTEDUNITS}
  205. uses MacTypes, CFBase;
  206. {$ENDIF FPC_DOTTEDUNITS}
  207. {$endc} {not MACOSALLINCLUDE}
  208. {$ALIGN POWER}
  209. {! @header CVBase.h
  210. @copyright 2004 Apple Computer, Inc. All rights reserved.
  211. @availability Mac OS X 10.4 or later
  212. @discussion Here you can find the type declarations for CoreVideo. CoreVideo uses a CVTimeStamp structure to store video display time stamps.
  213. }
  214. {
  215. #ifndef AVAILABLE_MAC_OS_X_VERSION_10_6_AND_LATER
  216. #define AVAILABLE_MAC_OS_X_VERSION_10_6_AND_LATER WEAK_IMPORT_ATTRIBUTE
  217. #endif
  218. #ifndef __AVAILABILITY_INTERNAL__MAC_10_7
  219. #define __AVAILABILITY_INTERNAL__MAC_10_7 __AVAILABILITY_INTERNAL_WEAK_IMPORT
  220. #endif
  221. #ifndef __AVAILABILITY_INTERNAL__MAC_10_8
  222. #define __AVAILABILITY_INTERNAL__MAC_10_8 __AVAILABILITY_INTERNAL_WEAK_IMPORT
  223. #endif
  224. #ifndef __AVAILABILITY_INTERNAL__MAC_10_9
  225. #define __AVAILABILITY_INTERNAL__MAC_10_9 __AVAILABILITY_INTERNAL_WEAK_IMPORT
  226. #endif
  227. #define COREVIDEO_SUPPORTS_DIRECT3D (TARGET_OS_WIN32)
  228. #define COREVIDEO_SUPPORTS_OPENGL (TARGET_OS_MAC && ! TARGET_OS_IPHONE)
  229. #define COREVIDEO_SUPPORTS_OPENGLES (TARGET_OS_MAC && TARGET_OS_IPHONE)
  230. #define COREVIDEO_SUPPORTS_COLORSPACE ((TARGET_OS_MAC && ! TARGET_OS_IPHONE) || (TARGET_OS_WIN32))
  231. #define COREVIDEO_SUPPORTS_DISPLAYLINK (TARGET_OS_MAC && ! TARGET_OS_IPHONE)
  232. #define COREVIDEO_SUPPORTS_IOSURFACE (TARGET_OS_IPHONE ? TARGET_OS_EMBEDDED : (TARGET_OS_MAC && ((MAC_OS_X_VERSION_MAX_ALLOWED >= 1060))))
  233. #define extern extern
  234. #define CV_INLINE CF_INLINE
  235. }
  236. {!
  237. @typedef CVOptionFlags
  238. @abstract Flags to be used for the display and render call back functions.
  239. @discussion ***Values to be defined***
  240. }
  241. type
  242. CVOptionFlags = UInt64;
  243. {!
  244. @struct CVSMPTETime
  245. @abstract A structure for holding a SMPTE time.
  246. @field subframes
  247. The number of subframes in the full message.
  248. @field subframeDivisor
  249. The number of subframes per frame (typically 80).
  250. @field counter
  251. The total number of messages received.
  252. @field type
  253. The kind of SMPTE time using the SMPTE time type constants.
  254. @field flags
  255. A set of flags that indicate the SMPTE state.
  256. @field hours
  257. The number of hours in the full message.
  258. @field minutes
  259. The number of minutes in the full message.
  260. @field seconds
  261. The number of seconds in the full message.
  262. @field frames
  263. The number of frames in the full message.
  264. }
  265. type
  266. CVSMPTETime = record
  267. subframes: SInt16;
  268. subframeDivisor: SInt16;
  269. counter: UInt32;
  270. typ: UInt32;
  271. flags: UInt32;
  272. hours: SInt16;
  273. minutes: SInt16;
  274. seconds: SInt16;
  275. frames: SInt16;
  276. end;
  277. {!
  278. @enum SMPTE Time Types
  279. @abstract Constants that describe the type of SMPTE time.
  280. @constant kCVSMPTETimeType24
  281. 24 Frame
  282. @constant kCVSMPTETimeType25
  283. 25 Frame
  284. @constant kCVSMPTETimeType30Drop
  285. 30 Drop Frame
  286. @constant kCVSMPTETimeType30
  287. 30 Frame
  288. @constant kCVSMPTETimeType2997
  289. 29.97 Frame
  290. @constant kCVSMPTETimeType2997Drop
  291. 29.97 Drop Frame
  292. @constant kCVSMPTETimeType60
  293. 60 Frame
  294. @constant kCVSMPTETimeType5994
  295. 59.94 Frame
  296. }
  297. const
  298. kCVSMPTETimeType24 = 0;
  299. kCVSMPTETimeType25 = 1;
  300. kCVSMPTETimeType30Drop = 2;
  301. kCVSMPTETimeType30 = 3;
  302. kCVSMPTETimeType2997 = 4;
  303. kCVSMPTETimeType2997Drop = 5;
  304. kCVSMPTETimeType60 = 6;
  305. kCVSMPTETimeType5994 = 7;
  306. {!
  307. @enum SMPTE State Flags
  308. @abstract Flags that describe the SMPTE time state.
  309. @constant kCVSMPTETimeValid
  310. The full time is valid.
  311. @constant kCVSMPTETimeRunning
  312. Time is running.
  313. }
  314. const
  315. kCVSMPTETimeValid = 1 shl 0;
  316. kCVSMPTETimeRunning = 1 shl 1;
  317. const
  318. kCVTimeIsIndefinite = 1 shl 0;
  319. type
  320. CVTime = record
  321. timeValue: SInt64;
  322. timeScale: SInt32;
  323. flags: SInt32;
  324. end;
  325. {!
  326. @struct CVTimeStamp
  327. @abstract CoreVideo uses a CVTimeStamp structure to store video display time stamps.
  328. @discussion This structure is purposely very similar to AudioTimeStamp defined in the CoreAudio framework.
  329. 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.
  330. @field videoTimeScale The scale (in units per second) of the videoTime and videoPeriod values
  331. @field videoTime This represents the start of a frame (or field for interlaced)
  332. @field hostTime Host root timebase time
  333. @field rateScalar This is the current rate of the device as measured by the timestamps, divided by the nominal rate
  334. @field videoPeriod This is the nominal update period of the current output device
  335. @field smpteTime SMPTE time representation of the time stamp.
  336. @field flags Possible values are:
  337. kCVTimeStampVideoTimeValid
  338. kCVTimeStampHostTimeValid
  339. kCVTimeStampSMPTETimeValid
  340. kCVTimeStampVideoPeriodValid
  341. kCVTimeStampRateScalarValid
  342. There are flags for each field to make it easier to detect interlaced vs progressive output
  343. kCVTimeStampTopField
  344. kCVTimeStampBottomField
  345. Some commonly used combinations of timestamp flags
  346. kCVTimeStampVideoHostTimeValid
  347. kCVTimeStampIsInterlaced
  348. @field version The current CVTimeStamp is version 0.
  349. @field reserved Reserved. Do not use.
  350. }
  351. type
  352. CVTimeStampPtr = ^CVTimeStamp;
  353. CVTimeStamp = record
  354. version: UInt32; // Currently will be 0.
  355. videoTimeScale: SInt32; // Video timescale (units per second)
  356. videoTime: SInt64; // This represents the start of a frame (or field for interlaced) .. think vsync - still not 100% sure on the name
  357. hostTime: UInt64; // Host root timebase time
  358. rateScalar: Float64; // Current rate as measured by the timestamps divided by the nominal rate
  359. videoRefreshPeriod: SInt64; // Hint for nominal output rate
  360. smpteTime: CVSMPTETime;
  361. flags: UInt64;
  362. reserved: UInt64;
  363. end;
  364. // Flags for the CVTimeStamp structure
  365. const
  366. kCVTimeStampVideoTimeValid = 1 shl 0;
  367. kCVTimeStampHostTimeValid = 1 shl 1;
  368. kCVTimeStampSMPTETimeValid = 1 shl 2;
  369. kCVTimeStampVideoRefreshPeriodValid = 1 shl 3;
  370. kCVTimeStampRateScalarValid = 1 shl 4;
  371. // There are flags for each field to make it easier to detect interlaced vs progressive output
  372. kCVTimeStampTopField = 1 shl 16;
  373. kCVTimeStampBottomField = 1 shl 17;
  374. // Some commonly used combinations of timestamp flags
  375. const
  376. kCVTimeStampVideoHostTimeValid = kCVTimeStampVideoTimeValid or kCVTimeStampHostTimeValid;
  377. kCVTimeStampIsInterlaced = kCVTimeStampTopField or kCVTimeStampBottomField;
  378. var kCVZeroTime: CVTime; external name '_kCVZeroTime'; (* attribute const *)
  379. var kCVIndefiniteTime: CVTime; external name '_kCVIndefiniteTime'; (* attribute const *)
  380. {$ifc not defined MACOSALLINCLUDE or not MACOSALLINCLUDE}
  381. end.
  382. {$endc} {not MACOSALLINCLUDE}