CVBase.pas 13 KB

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