xvlib.nim 9.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235
  1. #***********************************************************
  2. #Copyright 1991 by Digital Equipment Corporation, Maynard, Massachusetts,
  3. #and the Massachusetts Institute of Technology, Cambridge, Massachusetts.
  4. #
  5. # All Rights Reserved
  6. #
  7. #Permission to use, copy, modify, and distribute this software and its
  8. #documentation for any purpose and without fee is hereby granted,
  9. #provided that the above copyright notice appear in all copies and that
  10. #both that copyright notice and this permission notice appear in
  11. #supporting documentation, and that the names of Digital or MIT not be
  12. #used in advertising or publicity pertaining to distribution of the
  13. #software without specific, written prior permission.
  14. #
  15. #DIGITAL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
  16. #ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
  17. #DIGITAL BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR
  18. #ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
  19. #WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
  20. #ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
  21. #SOFTWARE.
  22. #
  23. #******************************************************************
  24. # $XFree86: xc/include/extensions/Xvlib.h,v 1.3 1999/12/11 19:28:48 mvojkovi Exp $
  25. #*
  26. #** File:
  27. #**
  28. #** Xvlib.h --- Xv library public header file
  29. #**
  30. #** Author:
  31. #**
  32. #** David Carver (Digital Workstation Engineering/Project Athena)
  33. #**
  34. #** Revisions:
  35. #**
  36. #** 26.06.91 Carver
  37. #** - changed XvFreeAdaptors to XvFreeAdaptorInfo
  38. #** - changed XvFreeEncodings to XvFreeEncodingInfo
  39. #**
  40. #** 11.06.91 Carver
  41. #** - changed SetPortControl to SetPortAttribute
  42. #** - changed GetPortControl to GetPortAttribute
  43. #** - changed QueryBestSize
  44. #**
  45. #** 05.15.91 Carver
  46. #** - version 2.0 upgrade
  47. #**
  48. #** 01.24.91 Carver
  49. #** - version 1.4 upgrade
  50. #**
  51. #*
  52. import
  53. x, xlib, xshm, xv
  54. const
  55. libXv* = "libXv.so"
  56. type
  57. PXvRational* = ptr TXvRational
  58. TXvRational*{.final.} = object
  59. numerator*: cint
  60. denominator*: cint
  61. PXvAttribute* = ptr TXvAttribute
  62. TXvAttribute*{.final.} = object
  63. flags*: cint # XvGettable, XvSettable
  64. min_value*: cint
  65. max_value*: cint
  66. name*: cstring
  67. PPXvEncodingInfo* = ptr PXvEncodingInfo
  68. PXvEncodingInfo* = ptr TXvEncodingInfo
  69. TXvEncodingInfo*{.final.} = object
  70. encoding_id*: TXvEncodingID
  71. name*: cstring
  72. width*: culong
  73. height*: culong
  74. rate*: TXvRational
  75. num_encodings*: culong
  76. PXvFormat* = ptr TXvFormat
  77. TXvFormat*{.final.} = object
  78. depth*: cchar
  79. visual_id*: culong
  80. PPXvAdaptorInfo* = ptr PXvAdaptorInfo
  81. PXvAdaptorInfo* = ptr TXvAdaptorInfo
  82. TXvAdaptorInfo*{.final.} = object
  83. base_id*: TXvPortID
  84. num_ports*: culong
  85. thetype*: cchar
  86. name*: cstring
  87. num_formats*: culong
  88. formats*: PXvFormat
  89. num_adaptors*: culong
  90. PXvVideoNotifyEvent* = ptr TXvVideoNotifyEvent
  91. TXvVideoNotifyEvent*{.final.} = object
  92. theType*: cint
  93. serial*: culong # # of last request processed by server
  94. send_event*: TBool # true if this came from a SendEvent request
  95. display*: PDisplay # Display the event was read from
  96. drawable*: TDrawable # drawable
  97. reason*: culong # what generated this event
  98. port_id*: TXvPortID # what port
  99. time*: TTime # milliseconds
  100. PXvPortNotifyEvent* = ptr TXvPortNotifyEvent
  101. TXvPortNotifyEvent*{.final.} = object
  102. theType*: cint
  103. serial*: culong # # of last request processed by server
  104. send_event*: TBool # true if this came from a SendEvent request
  105. display*: PDisplay # Display the event was read from
  106. port_id*: TXvPortID # what port
  107. time*: TTime # milliseconds
  108. attribute*: TAtom # atom that identifies attribute
  109. value*: clong # value of attribute
  110. PXvEvent* = ptr TXvEvent
  111. TXvEvent*{.final.} = object
  112. pad*: array[0..23, clong] #case longint of
  113. # 0 : (
  114. # theType : cint;
  115. # );
  116. # 1 : (
  117. # xvvideo : TXvVideoNotifyEvent;
  118. # );
  119. # 2 : (
  120. # xvport : TXvPortNotifyEvent;
  121. # );
  122. # 3 : (
  123. #
  124. # );
  125. PXvImageFormatValues* = ptr TXvImageFormatValues
  126. TXvImageFormatValues*{.final.} = object
  127. id*: cint # Unique descriptor for the format
  128. theType*: cint # XvRGB, XvYUV
  129. byte_order*: cint # LSBFirst, MSBFirst
  130. guid*: array[0..15, cchar] # Globally Unique IDentifier
  131. bits_per_pixel*: cint
  132. format*: cint # XvPacked, XvPlanar
  133. num_planes*: cint # for RGB formats only
  134. depth*: cint
  135. red_mask*: cuint
  136. green_mask*: cuint
  137. blue_mask*: cuint # for YUV formats only
  138. y_sample_bits*: cuint
  139. u_sample_bits*: cuint
  140. v_sample_bits*: cuint
  141. horz_y_period*: cuint
  142. horz_u_period*: cuint
  143. horz_v_period*: cuint
  144. vert_y_period*: cuint
  145. vert_u_period*: cuint
  146. vert_v_period*: cuint
  147. component_order*: array[0..31, char] # eg. UYVY
  148. scanline_order*: cint # XvTopToBottom, XvBottomToTop
  149. PXvImage* = ptr TXvImage
  150. TXvImage*{.final.} = object
  151. id*: cint
  152. width*, height*: cint
  153. data_size*: cint # bytes
  154. num_planes*: cint
  155. pitches*: cint # bytes
  156. offsets*: cint # bytes
  157. data*: pointer
  158. obdata*: TXPointer
  159. proc XvQueryExtension*(display: PDisplay, p_version, p_revision, p_requestBase,
  160. p_eventBase, p_errorBase: cuint): cint{.cdecl, dynlib: libXv, importc.}
  161. proc XvQueryAdaptors*(display: PDisplay, window: TWindow, p_nAdaptors: cuint,
  162. p_pAdaptors: PPXvAdaptorInfo): cint{.cdecl, dynlib: libXv,
  163. importc.}
  164. proc XvQueryEncodings*(display: PDisplay, port: TXvPortID, p_nEncoding: cuint,
  165. p_pEncoding: PPXvEncodingInfo): cint{.cdecl,
  166. dynlib: libXv, importc.}
  167. proc XvPutVideo*(display: PDisplay, port: TXvPortID, d: TDrawable, gc: TGC,
  168. vx, vy: cint, vw, vh: cuint, dx, dy: cint, dw, dh: cuint): cint{.
  169. cdecl, dynlib: libXv, importc.}
  170. proc XvPutStill*(display: PDisplay, port: TXvPortID, d: TDrawable, gc: TGC,
  171. vx, vy: cint, vw, vh: cuint, dx, dy: cint, dw, dh: cuint): cint{.
  172. cdecl, dynlib: libXv, importc.}
  173. proc XvGetVideo*(display: PDisplay, port: TXvPortID, d: TDrawable, gc: TGC,
  174. vx, vy: cint, vw, vh: cuint, dx, dy: cint, dw, dh: cuint): cint{.
  175. cdecl, dynlib: libXv, importc.}
  176. proc XvGetStill*(display: PDisplay, port: TXvPortID, d: TDrawable, gc: TGC,
  177. vx, vy: cint, vw, vh: cuint, dx, dy: cint, dw, dh: cuint): cint{.
  178. cdecl, dynlib: libXv, importc.}
  179. proc XvStopVideo*(display: PDisplay, port: TXvPortID, drawable: TDrawable): cint{.
  180. cdecl, dynlib: libXv, importc.}
  181. proc XvGrabPort*(display: PDisplay, port: TXvPortID, time: TTime): cint{.cdecl,
  182. dynlib: libXv, importc.}
  183. proc XvUngrabPort*(display: PDisplay, port: TXvPortID, time: TTime): cint{.
  184. cdecl, dynlib: libXv, importc.}
  185. proc XvSelectVideoNotify*(display: PDisplay, drawable: TDrawable, onoff: TBool): cint{.
  186. cdecl, dynlib: libXv, importc.}
  187. proc XvSelectPortNotify*(display: PDisplay, port: TXvPortID, onoff: TBool): cint{.
  188. cdecl, dynlib: libXv, importc.}
  189. proc XvSetPortAttribute*(display: PDisplay, port: TXvPortID, attribute: TAtom,
  190. value: cint): cint{.cdecl, dynlib: libXv, importc.}
  191. proc XvGetPortAttribute*(display: PDisplay, port: TXvPortID, attribute: TAtom,
  192. p_value: cint): cint{.cdecl, dynlib: libXv, importc.}
  193. proc XvQueryBestSize*(display: PDisplay, port: TXvPortID, motion: TBool,
  194. vid_w, vid_h, drw_w, drw_h: cuint,
  195. p_actual_width, p_actual_height: cuint): cint{.cdecl,
  196. dynlib: libXv, importc.}
  197. proc XvQueryPortAttributes*(display: PDisplay, port: TXvPortID, number: cint): PXvAttribute{.
  198. cdecl, dynlib: libXv, importc.}
  199. proc XvFreeAdaptorInfo*(adaptors: PXvAdaptorInfo){.cdecl, dynlib: libXv, importc.}
  200. proc XvFreeEncodingInfo*(encodings: PXvEncodingInfo){.cdecl, dynlib: libXv,
  201. importc.}
  202. proc XvListImageFormats*(display: PDisplay, port_id: TXvPortID,
  203. count_return: cint): PXvImageFormatValues{.cdecl,
  204. dynlib: libXv, importc.}
  205. proc XvCreateImage*(display: PDisplay, port: TXvPortID, id: cint, data: pointer,
  206. width, height: cint): PXvImage{.cdecl, dynlib: libXv,
  207. importc.}
  208. proc XvPutImage*(display: PDisplay, id: TXvPortID, d: TDrawable, gc: TGC,
  209. image: PXvImage, src_x, src_y: cint, src_w, src_h: cuint,
  210. dest_x, dest_y: cint, dest_w, dest_h: cuint): cint{.cdecl,
  211. dynlib: libXv, importc.}
  212. proc XvShmPutImage*(display: PDisplay, id: TXvPortID, d: TDrawable, gc: TGC,
  213. image: PXvImage, src_x, src_y: cint, src_w, src_h: cuint,
  214. dest_x, dest_y: cint, dest_w, dest_h: cuint,
  215. send_event: TBool): cint{.cdecl, dynlib: libXv, importc.}
  216. proc XvShmCreateImage*(display: PDisplay, port: TXvPortID, id: cint,
  217. data: pointer, width, height: cint,
  218. shminfo: PXShmSegmentInfo): PXvImage{.cdecl,
  219. dynlib: libXv, importc.}
  220. # implementation