Guest User

Untitled

a guest
May 29th, 2015
384
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 58.53 KB | None | 0 0
  1. using System;
  2. using System.Runtime.InteropServices;
  3.  
  4. namespace TH.Parking.Wrapper.HBCamera
  5. {
  6. public class T1800
  7. {
  8. public const int T18_ERR_SUCCESS = 0;//succeed
  9. public const int T18_ERR_WAIT_TIMEOUT = 1;//sdk time out
  10. public const int T18_ERR_DSP_ERROR = 2;//dsp error
  11. public const int T18_ERR_INVALID_HANDLE = 3;//invaild channel handle
  12. public const int T18_ERR_INVALID_ARGUMENT = 4;//invaild parameter
  13. public const int T18_ERR_DDRAW_CREATE_FAILED = 5;//fail to create ddraw surface
  14. public const int T18_ERR_DSP_CANNOT_BE_FOUND = 6;//dsp can't be found
  15. public const int T18_ERR_DSP_IS_RUNNING = 7;//dsp is open
  16. public const int T18_ERR_CANNOT_FIND_IMGFILE = 8;//can't found img file
  17. public const int T18_ERR_NOT_SUPPORT = 9;//sdk no support
  18. public const int T18_ERR_RECEIVE_MSG = 10;//receive msg error
  19. public const int T18_ERR_GET_CHANNELS = 11;//get total channel
  20.  
  21. //public const ulong COLORREF;
  22.  
  23. public enum FrameType
  24. {
  25. PktError = 0,
  26. PktIFrames = 0x0001,
  27. PktPFrames = 0x0002,
  28. PktBBPFrames = 0x0004,
  29. PktAudioFrames = 0x0008,
  30. PktMotionDetection = 0x00010,
  31. PktDspStatus = 0x00020,
  32. PktOrigImage = 0x00040,
  33. PktSysHeader = 0x00080,
  34. PktBPFrames = 0x00100,
  35. PktSFrames = 0x00200
  36. }
  37. public struct PREVIEWRECTREGION
  38. {
  39. public RECT previewRect;
  40. public bool bFullScreen;
  41. public bool bSingle;
  42. public int nPreviewNum;//1 4 9 16 25 36
  43. public int nStartChannel;
  44. public int nCurChannel;
  45. public ulong nSizeFlag;//0-ORIGINAL 1-QCIF 2-CIF 3-FULLWINDOW
  46. }
  47. //Video Encode Size
  48. public enum PictureFormat
  49. {
  50. ENC_CIF_FORMAT = 0,
  51. ENC_QCIF_FORMAT = 1,
  52. ENC_2CIF_FORMAT = 2,
  53. ENC_4CIF_FORMAT = 3,
  54. ENC_SQD1_FORMAT = 4,
  55. ENC_CIFQCIF_FORMAT = 5,
  56. ENC_CIFQQCIF_FORMAT = 6,
  57. ENC_CIFCIF_FORMAT = 7,
  58. ENC_4CIFCIF_FORMAT = 8,
  59. ENC_4CIFQCIF_FORMAT = 9,
  60. ENC_DCIF_FORMAT = 10
  61. }
  62.  
  63. public enum VideoStandard
  64. {
  65. StandardNone = unchecked((int)0x80000000),
  66. StandardNTSC = 0x00000001,
  67. StandardPAL = 0x00000002,
  68. StandardSECAM = 0x00000004,
  69. }
  70. public enum BitrateControlType
  71. {
  72. brCBR = 0,
  73. brVBR = 1
  74. }
  75.  
  76. public struct FRAMES_STATISTICS
  77. {
  78. ulong VideoFrames;
  79. ulong AudioFrames;
  80. ulong FramesLost;
  81. ulong QueueOverflow;
  82. ulong CurBps;
  83. }
  84. public struct VERSION_INFO
  85. {
  86. ulong DspVersion, DspBuildNum;
  87. ulong DriverVersion, DriverBuildNum;
  88. ulong SDKVersion, SDKBuildNum;
  89. }
  90. public struct RECT
  91. {
  92. public long left;
  93. public long top;
  94. public long right;
  95. public long bottom;
  96. }
  97.  
  98. [UnmanagedFunctionPointerAttribute(CallingConvention.ThisCall, SetLastError = true, CharSet = CharSet.Unicode)]
  99. public delegate int STREAM_READ_CALLBACK(ulong channelNumber, IntPtr context);
  100.  
  101.  
  102. public delegate int IMAGE_STREAM_CALLBACK(int channelNumber, ref IntPtr context);
  103. #region Initialize & Close
  104.  
  105. #region DLLImport
  106. [DllImport("T1800.dll", EntryPoint = "T18_InitDSPs", CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Unicode)]
  107. private static extern int dll_T18_InitDSPs();
  108.  
  109. [DllImport("T1800.dll", EntryPoint = "T18_DeInitDSPs", CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Unicode)]
  110. private static extern int dll_T18_DeInitDSPs();
  111.  
  112. [DllImport("T1800.dll", EntryPoint = "T18_ChannelOpen", CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Unicode)]
  113. private static extern IntPtr dll_T18_ChannelOpen(int channelNum);
  114.  
  115. [DllImport("T1800.dll", EntryPoint = "T18_ChannelClose", CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Unicode)]
  116. private static extern int dll_T18_ChannelClose(IntPtr hChannelHandle);
  117.  
  118. [DllImport("T1800.dll", EntryPoint = "T18_ResetDSP", CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Unicode)]
  119. private static extern int dll_T18_ResetDSP(IntPtr hChannelHandle);
  120.  
  121. [DllImport("T1800.dll", EntryPoint = "T18_GetTotalChannels", CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Unicode)]
  122. private static extern int dll_T18_GetTotalChannels();
  123.  
  124. [DllImport("T1800.dll", EntryPoint = "T18_GetTotalDSPs", CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Unicode)]
  125. private static extern int dll_T18_GetTotalDSPs();
  126.  
  127. [DllImport("T1800.dll", EntryPoint = "T18_GetLastErrorNum", CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Unicode)]
  128. private static extern int dll_T18_GetLastErrorNum(IntPtr hChannelHandle, ref ulong dspError, ref ulong sdkError);
  129.  
  130. [DllImport("T1800.dll", EntryPoint = "T18_GetSDKVersion", CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Unicode)]
  131. private static extern int dll_T18_GetSDKVersion(VERSION_INFO VersionInfo);
  132.  
  133. [DllImport("T1800.dll", EntryPoint = "T18_GetFramesStatistics", CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Unicode)]
  134. private static extern int dll_T18_GetFramesStatistics(IntPtr hChannelHandle, ref FRAMES_STATISTICS frameStatistics);
  135.  
  136. [DllImport("T1800.dll", EntryPoint = "T18_RegisterMessageNotifyHandle", CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Unicode)]
  137. private static extern int dll_T18_RegisterMessageNotifyHandle(IntPtr hChannelHandle, uint messageId);
  138.  
  139. [DllImport("T1800.dll", EntryPoint = "T18_GetBoardInfo", CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Unicode)]
  140. private static extern int dll_T18_GetBoardInfo(IntPtr hChannelHandle, ref ulong boardType, ref string serialNo);
  141.  
  142. //[DllImport("T1800.dll", EntryPoint = "T18_RegisterStreamReadCallback", CallingConvention = CallingConvention.Cdecl)]
  143. [DllImport("T1800.dll", EntryPoint = "T18_RegisterStreamReadCallback", CallingConvention = CallingConvention.Cdecl, SetLastError = true, CharSet = CharSet.Unicode)]
  144. private static extern int dll_T18_RegisterStreamReadCallback(STREAM_READ_CALLBACK STREAM_READ_CALLBACK, ref IntPtr context);
  145.  
  146. [DllImport("T1800.dll", EntryPoint = "T18_StartVideoPreviewEx", CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Unicode)]
  147. private static extern int dll_T18_StartVideoPreviewEx(IntPtr hChannelHandle, IntPtr wndHandle, ref System.Drawing.Rectangle rect, bool bOverlay, int videoFormat, int frameRate);
  148.  
  149. [DllImport("T1800.dll", EntryPoint = "T18_StopVideoPreview", CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Unicode)]
  150. private static extern int dll_T18_StopVideoPreview(IntPtr hChannelHandle);
  151.  
  152. [DllImport("T1800.dll", EntryPoint = "T18_SetOverlayColorKey", CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Unicode)]
  153. private static extern int dll_T18_SetOverlayColorKey(ulong destColorKey);
  154.  
  155. [DllImport("T1800.dll", EntryPoint = "T18_SetOverlayColorKey", CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Unicode)]
  156. private static extern int dll_T18_SetLogoDisplayMode(IntPtr hChannelHandle, ulong ColorKey, bool bTranslucent, int nReserve);
  157.  
  158. [DllImport("T1800.dll", EntryPoint = "T18_UpdateOverlay", CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Unicode)]
  159. private static extern int dll_T18_UpdateOverlay();
  160.  
  161. [DllImport("T1800.dll", EntryPoint = "T18_ReleaseOverlay", CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Unicode)]
  162. private static extern int dll_T18_ReleaseOverlay();
  163.  
  164. [DllImport("T1800.dll", EntryPoint = "T18_RestoreOverlay", CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Unicode)]
  165. private static extern int dll_T18_RestoreOverlay();
  166.  
  167. [DllImport("T1800.dll", EntryPoint = "T18_SetAudioPreview", CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Unicode)]
  168. private static extern int dll_T18_SetAudioPreview(IntPtr hChannelHandle, bool bEnable);
  169.  
  170. [DllImport("T1800.dll", EntryPoint = "T18_SetAudioPreviewVolume", CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Unicode)]
  171. private static extern int dll_T18_SetAudioPreviewVolume(IntPtr hChannelHandle, ulong nVolume);
  172.  
  173. [DllImport("T1800.dll", EntryPoint = "T18_GetSoundLevel", CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Unicode)]
  174. private static extern int dll_T18_GetSoundLevel(IntPtr hChannelHandle);
  175.  
  176. [DllImport("T1800.dll", EntryPoint = "T18_SetVideoStandard", CallingConvention = CallingConvention.Cdecl)]
  177. private static extern int dll_T18_SetVideoStandard(IntPtr hChannelHandle, VideoStandard videoStandard);
  178.  
  179. [DllImport("T1800.dll", EntryPoint = "T18_GetVideoSignal", CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Unicode)]
  180. private static extern int dll_T18_GetVideoSignal(IntPtr hChannelHandle);
  181.  
  182. [DllImport("T1800.dll", EntryPoint = "T18_SetVideoPara", CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Unicode)]
  183. private static extern int dll_T18_SetVideoPara(IntPtr hChannelHandle, int nBrightness, int nContrast, int nSaturation, int nHue);
  184.  
  185. [DllImport("T1800.dll", EntryPoint = "T18_GetVideoPara", CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Unicode)]
  186. private static extern int dll_T18_GetVideoPara(IntPtr hChannelHandle, ref VideoStandard videoStandard, ref int brightness, ref int contrast, ref int saturation, ref int hue);
  187.  
  188. [DllImport("T1800.dll", EntryPoint = "T18_SetVideoLostMode", CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Unicode)]
  189. private static extern int dll_T18_SetVideoLostMode(int mode);
  190.  
  191. [DllImport("T1800.dll", EntryPoint = "T18_SetVideoClip", CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Unicode)]
  192. private static extern int dll_T18_SetVideoClip(IntPtr hChannelHandle, int x, int y);
  193.  
  194. [DllImport("T1800.dll", EntryPoint = "T18_SetVideoNightFilter", CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Unicode)]
  195. private static extern int dll_T18_SetVideoNightFilter(IntPtr hChannelHandle, int nVideoNightFilter);
  196.  
  197. [DllImport("T1800.dll", EntryPoint = "T18_SetDefaultVideoStandard", CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Unicode)]
  198. private static extern int dll_T18_SetDefaultVideoStandard(VideoStandard videoStandard);
  199.  
  200. [DllImport("T1800.dll", EntryPoint = "T18_SetVideoSharp", CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Unicode)]
  201. private static extern int dll_T18_SetVideoSharp(IntPtr hChannelHandle, int nLevel);
  202.  
  203. [DllImport("T1800.dll", EntryPoint = "T18_GetRawAudioVolume", CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Unicode)]
  204. private static extern int dll_T18_GetRawAudioVolume(IntPtr hChannelHandle, out ulong nVolume);
  205.  
  206. [DllImport("T1800.dll", EntryPoint = "T18_StartVideoCapture", CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Unicode)]
  207. private static extern int dll_T18_StartVideoCapture(IntPtr hChannelHandle);
  208.  
  209. [DllImport("T1800.dll", EntryPoint = "T18_StopVideoCapture", CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Unicode)]
  210. private static extern int dll_T18_StopVideoCapture(IntPtr hChannelHandle);
  211.  
  212. [DllImport("T1800.dll", EntryPoint = "T18_SetStreamType", CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Unicode)]
  213. private static extern int dll_T18_SetStreamType(IntPtr hChannelHandle, ushort type);
  214.  
  215. [DllImport("T1800.dll", EntryPoint = "T18_GetStreamType", CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Unicode)]
  216. private static extern int dll_T18_GetStreamType(IntPtr hChannelHandle, ref ushort streamType);
  217.  
  218. [DllImport("T1800.dll", EntryPoint = "T18_SetEncoderPictureFormat", CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Unicode)]
  219. private static extern int dll_T18_SetEncoderPictureFormat(IntPtr hChannelHandle, PictureFormat pictureFormat);
  220.  
  221. [DllImport("T1800.dll", EntryPoint = "T18_SetAllEncoderPictureFormat", CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Unicode)]
  222. private static extern int dll_T18_SetAllEncoderPictureFormat(ref PictureFormat pPictureFormat);
  223.  
  224. [DllImport("T1800.dll", EntryPoint = "T15_SetIBPMode", CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Unicode)]
  225. private static extern int dll_T15_SetIBPMode(IntPtr hChannelHandle, int keyFrameIntervals, int bFrames, int pFrames, int frameRate);
  226.  
  227. [DllImport("T1800.dll", EntryPoint = "T18_SetDefaultQuant", CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Unicode)]
  228. private static extern int dll_T18_SetDefaultQuant(IntPtr hChannelHandle, int iQuantVal, int pQuantVal, int bQuantVal);
  229.  
  230. [DllImport("T1800.dll", EntryPoint = "T18_SetBitrateControlMode", CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Unicode)]
  231. private static extern int dll_T18_SetBitrateControlMode(IntPtr hChannelHandle, BitrateControlType brc);
  232.  
  233. [DllImport("T1800.dll", EntryPoint = "T18_SetupBitrateControl", CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Unicode)]
  234. private static extern int dll_T18_SetupBitrateControl(IntPtr hChannelHandle, ulong maxBps);
  235.  
  236. [DllImport("T1800.dll", EntryPoint = "T18_SetEncodeAudioType", CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Unicode)]
  237. private static extern int dll_T18_SetEncodeAudioType(IntPtr hChannelHandle, int nType);
  238.  
  239. [DllImport("T1800.dll", EntryPoint = "T18_GetOriginalImage", CallingConvention = CallingConvention.Cdecl, BestFitMapping = true)]
  240. private static extern int dll_T18_GetOriginalImage(IntPtr hChannelHandle, IntPtr imageBuf, ref ulong size, ulong nPictureType);
  241.  
  242. [DllImport("T1800.dll", EntryPoint = "T18_CaptureIFrame", CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Unicode)]
  243. private static extern int dll_T18_CaptureIFrame(IntPtr hChannelHandle);
  244.  
  245. [DllImport("T1800.dll", EntryPoint = "T18_GetSystemHeader", CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Unicode)]
  246. private static extern int dll_T18_GetSystemHeader(IntPtr hChannelHandle, [Out] byte[] pSystemHeader, ref ulong length);
  247.  
  248. [DllImport("T1800.dll", EntryPoint = "T18_SetupNotifyThreshold", CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Unicode)]
  249. private static extern int dll_T18_SetupNotifyThreshold(IntPtr hChannelHandle, int iFramesThreshold);
  250.  
  251. [DllImport("T1800.dll", EntryPoint = "T18_ReadStreamData", CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Unicode)]
  252. private static extern int dll_T18_ReadStreamData(IntPtr hChannelHandle, [Out] byte[] DataBuf, ref ulong length, ref int frameType);
  253.  
  254. [DllImport("T1800.dll", EntryPoint = "T18_SetupSubChannel", CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Unicode)]
  255. private static extern int dll_T18_SetupSubChannel(IntPtr hChannelHandle, int iSubChannel);
  256.  
  257. [DllImport("T1800.dll", EntryPoint = "T18_GetSubChannelStreamType", CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Unicode)]
  258. private static extern int dll_T18_GetSubChannelStreamType(ref IntPtr dataBuf, int frameType);
  259.  
  260. [DllImport("T1800.dll", EntryPoint = "T18_SetImageStream", CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Unicode)]
  261. private static extern int dll_T18_SetImageStream(IntPtr hChannelHandle, bool bStart, int fps, int width, int height, ref IntPtr imageBuffer);
  262.  
  263. [DllImport("T1800.dll", EntryPoint = "T18_RegisterImageStreamCallback", CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Unicode)]
  264. private static extern int dll_T18_RegisterImageStreamCallback(MulticastDelegate ImageStreamCallback, ref IntPtr context);
  265.  
  266. [DllImport("T1800.dll", EntryPoint = "T18_SetEncoderFormat", CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Unicode)]
  267. private static extern int dll_T18_SetEncoderFormat(IntPtr hChannelHandle, PictureFormat pictureFormat);
  268.  
  269. [DllImport("T1800.dll", EntryPoint = "T18_GetOriginalImageEx", CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Unicode)]
  270. private static extern int dll_T18_GetOriginalImageEx(IntPtr hChannelHandle, ref IntPtr imageBuf, ref ulong Size, ulong nPictureType);
  271.  
  272. [DllImport("T1800.dll", EntryPoint = "T18_SaveYUVToBmpFile", CallingConvention = CallingConvention.Cdecl)]
  273. private static extern int dll_T18_SaveYUVToBmpFile(string FileName, IntPtr yuv, int Width, int Height, ulong nYUVType);
  274.  
  275. [DllImport("T1800.dll", EntryPoint = "T18_LoadYUV444FromBmpFile", CallingConvention = CallingConvention.Cdecl)]
  276. private static extern int dll_T18_LoadYUV444FromBmpFile(string FileName, ref IntPtr yuv, ref int BufLen, ref int Width, ref int Height);
  277.  
  278. [DllImport("T1800.dll", EntryPoint = "T18_SetLogo", CallingConvention = CallingConvention.Cdecl)]
  279. private static extern int dll_T18_SetLogo(IntPtr hChannelHandle, int x, int y, int w, int h, IntPtr yuv);
  280.  
  281. #endregion
  282.  
  283. #region Functions
  284. /// <summary>
  285. /// T18_s the init DS ps.
  286. /// Parameters: None
  287. /// Description: To initialize every card in system. It must be called in application
  288. /// Startup.
  289. /// Return: Number of DSPs in system, 0 means initializing failed.
  290. /// </summary>
  291. /// <returns></returns>
  292. public static int T18_InitDSPs()
  293. {
  294. return dll_T18_InitDSPs();
  295. }
  296.  
  297. /// <summary>
  298. /// T18_s the de init DS ps.
  299. ///1.02 Close DSP :T18_DeInitDSPs()
  300. ///Parameters: None
  301. ///Description: To close all cards in system and release resources. It must be called
  302. ///before application exit.
  303. ///Return: Number of DSPs closed
  304. /// </summary>
  305. /// <returns></returns>
  306. public static int T18_DeInitDSPs()
  307. {
  308. return dll_T18_DeInitDSPs();
  309. }
  310.  
  311. /// <summary>
  312. /// T18_s the channel open.
  313. /// Parameters:int ChannelNum Channel number(0 is first channel)
  314. ///Description: Open a channel and get handle for channel operations.
  315. ///Return: Valid handle when success or return 0xFFFFFFFF if failed
  316. /// </summary>
  317. /// <param name="channelNum">The channel num.</param>
  318. /// <returns></returns>
  319. public static IntPtr T18_ChannelOpen(int channelNum)
  320. {
  321. return dll_T18_ChannelOpen(channelNum);
  322. }
  323.  
  324. /// <summary>
  325. /// T18_s the channel close.
  326. /// Parameters: HANDLE hChannelHandle Channel number(0 is first channel)
  327. ///Description: Close a channel and release its resources. It must be called before call
  328. ///T18_DeInitDSPs().
  329. ///Return: 0 when success
  330. /// </summary>
  331. /// <param name="hChannelHandle">The h channel handle.</param>
  332. /// <returns></returns>
  333. public static int T18_ChannelClose(IntPtr hChannelHandle)
  334. {
  335. return dll_T18_ChannelClose(hChannelHandle);
  336. }
  337.  
  338. /// <summary>
  339. /// T18_s the reset DSP.
  340. /// Parameters: HANDLE hChannelHandle
  341. ///Description Reset DSP system;
  342. ///Return 0 when success
  343. /// </summary>
  344. /// <param name="hChannelHandle">The h channel handle.</param>
  345. /// <returns></returns>
  346. public static int T18_ResetDSP(IntPtr hChannelHandle)
  347. {
  348. return dll_T18_ResetDSP(hChannelHandle);
  349. }
  350.  
  351. /// <summary>
  352. /// T18_s the get total channels.
  353. /// Parameters: None
  354. /// Description: To get total number of channels in system
  355. /// Return: Number of channels in system
  356. /// </summary>
  357. /// <returns></returns>
  358. public static int T18_GetTotalChannels()
  359. {
  360. return dll_T18_GetTotalChannels();
  361. }
  362.  
  363. /// <summary>
  364. /// T18_s the get total DS ps.
  365. /// Parameters: None
  366. /// Description: To get total number of DSPs in system
  367. /// Return: Number of channels in system
  368. /// </summary>
  369. /// <returns></returns>
  370. public static int T18_GetTotalDSPs()
  371. {
  372. return dll_T18_GetTotalDSPs();
  373. }
  374.  
  375. /// <summary>
  376. /// T18_s the get last error num.
  377. /// Parameters: HANDLE hChannelHandle (Channel Handle)
  378. ///ULONG *DspError, DSP error number
  379. ///ULONG *SdkError SDK error number
  380. ///Description: To get SDK and DSP errors number, you can get detailed information
  381. ///about error. You can call it to get error code(detailed in T1800.h) when functions
  382. ///return fail.
  383. ///Return: 0 when success
  384. /// </summary>
  385. /// <param name="hChannelHandle">The h channel handle.</param>
  386. /// <param name="dspError">The DSP error.</param>
  387. /// <param name="sdkError">The SDK error.</param>
  388. /// <returns></returns>
  389. public static int T18_GetLastErrorNum(IntPtr hChannelHandle, ref ulong dspError, ref ulong sdkError)
  390. {
  391. return dll_T18_GetLastErrorNum(hChannelHandle, ref dspError, ref sdkError);
  392. }
  393.  
  394. /// <summary>
  395. /// T18_s the get SDK version.
  396. /// Parameters: None
  397. ///Description: Get the version of SDK currently used.
  398. ///Return: first 16 bits is BCD code in which high 8 bits is main version number, low 8
  399. ///bits is sub-version number, then 32 bits is BUILD number.
  400. /// </summary>
  401. /// <param name="versionInfo">The version info.</param>
  402. /// <returns></returns>
  403. public static int T18_GetSDKVersion(VERSION_INFO versionInfo)
  404. {
  405. return dll_T18_GetSDKVersion(versionInfo);
  406. }
  407.  
  408. /// <summary>
  409. /// T18_s the get frames statistics.
  410. ///Parameters: HANDLE hChannelHandle, handle of channel
  411. ///PFRAMES_STATISTICS ,framesStatistics frames statistics information
  412. ///Description: Get frames statistics of video encoding
  413. ///Return: 0 when success
  414. /// </summary>
  415. /// <param name="hChannelHandle">The h channel handle.</param>
  416. /// <param name="framesStatistics">The frames statistics.</param>
  417. /// <returns></returns>
  418. public static int T18_GetFramesStatistics(IntPtr hChannelHandle, ref FRAMES_STATISTICS framesStatistics)
  419. {
  420. return dll_T18_GetFramesStatistics(hChannelHandle, ref framesStatistics);
  421. }
  422.  
  423. /// <summary>
  424. /// T18_s the register message notify handle.
  425. /// Parameters: HWND hWnd handle of window
  426. ///UINT MessageId message ID
  427. ///Description: When encoding data is ready, SDK will send message MessageId to
  428. ///window hWnd, after window hWnd receive message, call
  429. ///ReadStreamData read encoding data of a frame.
  430. ///Return: 0 when success
  431. /// </summary>
  432. /// <param name="hChannelHandle">The h channel handle.</param>
  433. /// <param name="messageId">The message id.</param>
  434. /// <returns></returns>
  435. public static int T18_RegisterMessageNotifyHandle(IntPtr hChannelHandle, uint messageId)
  436. {
  437. return dll_T18_RegisterMessageNotifyHandle(hChannelHandle, messageId);
  438. }
  439.  
  440. /// <summary>
  441. /// T18_s the get board info.
  442. /// Parameters: HANDLE hChannelHandle, handle of channel
  443. /// ULONG *BoardType, card type (0x18004:HB18004, 0x18008:HB18008,
  444. /// 0x18016:HB18016)
  445. /// UCHAR *SerialNo serial number of card, SerialNo[0] is the highest
  446. /// number, for example serial number “04040025” is array of integer
  447. /// (0,4,0,4,0,0,2,5)
  448. /// Description: Get hardware information of card
  449. /// Return: 0 when success
  450. /// </summary>
  451. /// <param name="hChannelHandle">The h channel handle.</param>
  452. /// <param name="boardType">Type of the board.</param>
  453. /// <param name="serialNo">The serial no.</param>
  454. /// <returns></returns>
  455. public static int T18_GetBoardInfo(IntPtr hChannelHandle, ref ulong boardType, ref string serialNo)
  456. {
  457. return dll_T18_GetBoardInfo(hChannelHandle, ref boardType, ref serialNo);
  458. }
  459.  
  460. /// <summary>
  461. /// Parameters: STREAM_READ_CALLBACK StreamReadCallback
  462. /// Void *Context transfer the context of the Callback function
  463. /// Description: when transferring the function,it will support the channel no and pointer
  464. /// of context
  465. /// Return: 0 when success
  466. /// </summary>
  467. /// <param name="stream_Read_CallBack"></param>
  468. /// <param name="context"></param>
  469. /// <returns></returns>
  470. public static int T18_RegisterStreamReadCallback(STREAM_READ_CALLBACK stream_Read_CallBack, ref IntPtr context)
  471. {
  472. return dll_T18_RegisterStreamReadCallback(stream_Read_CallBack, ref context);
  473. }
  474.  
  475. /// <summary>
  476. ///Parameters: HANDLE hChannelHandle handle of channel
  477. ///HWND WndHandle handle of window
  478. ///RECT *rect rectangle area
  479. ///BOOLEAN bOverlay open or close the Overlay mode
  480. ///int VideoFormat video format,only support YUV422
  481. ///int FrameRate Frame Rate,(PAL:25,NTSC:30)
  482. ///Description: Set video preview parameters. It must use one window to preview video
  483. ///of all channels. This function must be called with new handle of window
  484. ///when you switch display window, then restart video preview. Start video
  485. ///preview
  486. ///Return: 0 when success
  487. /// </summary>
  488. /// <param name="hChannelHandle"></param>
  489. /// <param name="wndHandle"></param>
  490. /// <param name="rect"></param>
  491. /// <param name="bOverlay"></param>
  492. /// <param name="videoFormat"></param>
  493. /// <param name="frameRate"></param>
  494. /// <returns></returns>
  495. public static int T18_StartVideoPreviewEx(IntPtr hChannelHandle, IntPtr wndHandle, ref System.Drawing.Rectangle rect, bool bOverlay, int videoFormat, int frameRate)
  496. {
  497.  
  498. return dll_T18_StartVideoPreviewEx(hChannelHandle, wndHandle, ref rect, bOverlay, videoFormat, frameRate);
  499. }
  500.  
  501. /// <summary>
  502. /// Parameters: HANDLE hChannelHandle ,handle of channel
  503. ///Description: Stop video preview
  504. ///Return: 0 when success
  505. /// </summary>
  506. /// <param name="hChannelHandle"></param>
  507. /// <returns></returns>
  508. public static int T18_StopVideoPreview(IntPtr hChannelHandle)
  509. {
  510. return dll_T18_StopVideoPreview(hChannelHandle);
  511. }
  512.  
  513. /// <summary>
  514. /// Parameters: COLORREF DestColorKey Overlay Key Color
  515. /// Description: Set overlay key color
  516. /// Return: 0 when success
  517. /// </summary>
  518. /// <param name="destColorKey"></param>
  519. /// <returns></returns>
  520. public static int T18_SetOverlayColorKey(ulong destColorKey)
  521. {
  522. return dll_T18_SetOverlayColorKey(destColorKey);
  523. }
  524.  
  525. public static int T18_SetLogoDisplayMode(IntPtr hChannelHandle, ulong ColorKey, bool bTranslucent, int nReserve)
  526. {
  527. return dll_T18_SetLogoDisplayMode(hChannelHandle, ColorKey, bTranslucent, nReserve);
  528. }
  529.  
  530. /// <summary>
  531. /// Parameters: None
  532. /// Description: Update overlay display area, work in with T18_ StartVideoPreviewEx
  533. /// when all the video preview is starting ,transfer this function.
  534. /// Return: 0 when success
  535. /// </summary>
  536. /// <returns></returns>
  537. public static int T18_UpdateOverlay()
  538. {
  539. return dll_T18_UpdateOverlay();
  540. }
  541.  
  542. /// <summary>
  543. /// Parameters: None
  544. ///Description: Release Overlay resource,when transfering the function, all the video
  545. ///preview must be enabled. Work in with T18_RestoreOverlay;
  546. ///Return: 0 when success
  547. /// </summary>
  548. /// <returns></returns>
  549. public static int T18_ReleaseOverlay()
  550. {
  551. return dll_T18_ReleaseOverlay();
  552. }
  553.  
  554. /// <summary>
  555. /// Parameters: None
  556. /// Description: Restore Overlay resource,,when transfering the function, all the video
  557. /// preview must be enabled. Work in with T18_ReleaseOverlay;
  558. /// </summary>
  559. /// <returns></returns>
  560. public static int T18_RestoreOverlay()
  561. {
  562. return dll_T18_RestoreOverlay();
  563. }
  564.  
  565. /// <summary>
  566. /// Parameters: HANDLE hChannelHandle, handle of channel
  567. /// BOOL bEnable enable
  568. /// Description: Enable or disable audio preview, audio preview means you can choose
  569. /// one channel live audio played by PC.
  570. /// Return: 0 when success
  571. /// </summary>
  572. /// <param name="hChannelHandle"></param>
  573. /// <param name="bEnable"></param>
  574. /// <returns></returns>
  575. public static int T18_SetAudioPreview(IntPtr hChannelHandle, bool bEnable)
  576. {
  577. return dll_T18_SetAudioPreview(hChannelHandle, bEnable);
  578. }
  579.  
  580. /// <summary>
  581. /// Parameters: HANDLE hChannelHandle, handle of channel
  582. /// DWORD nVolume audio volume (0-100)
  583. /// Description: set audio preview volume
  584. /// Return: 0 when success
  585. /// </summary>
  586. /// <param name="hChannelHandle"></param>
  587. /// <param name="nVolume"></param>
  588. /// <returns></returns>
  589. public static int T18_SetAudioPreviewVolume(IntPtr hChannelHandle, ulong nVolume)
  590. {
  591. return dll_T18_SetAudioPreviewVolume(hChannelHandle, nVolume);
  592. }
  593.  
  594. /// <summary>
  595. /// Parameters: HANDLE hChannelHandle, handle of channel
  596. /// Description: get audio preview volume
  597. /// Return: audio volume (0-100)
  598. /// </summary>
  599. /// <param name="hChannelHandle"></param>
  600. /// <returns></returns>
  601. public static int T18_GetSoundLevel(IntPtr hChannelHandle)
  602. {
  603. return dll_T18_GetSoundLevel(hChannelHandle);
  604. }
  605.  
  606. /// <summary>
  607. /// Parameters: HANDLE hChannelHandle handle of channel
  608. /// VideoStandard_t VideoStandard Video Standard
  609. /// Description: Set video standard PAL or NTSC, it must be called before calling
  610. /// T18_InitDSPs. It will set all channels to same video standard.
  611. /// Return: 0 when success
  612. /// </summary>
  613. /// <param name="hChannelHandle"></param>
  614. /// <param name="videoStandard"></param>
  615. /// <returns></returns>
  616. public static int T18_SetVideoStandard(IntPtr hChannelHandle, VideoStandard videoStandard)
  617. {
  618. return dll_T18_SetVideoStandard(hChannelHandle, videoStandard);
  619. }
  620.  
  621. /// <summary>
  622. /// Parameters: HANDLE hChannelHandle, handle of channel
  623. /// Description: get video input status, we can know if video input signal is OK
  624. /// Return: 0 means video input OK, otherwise means no video input or video input lost
  625. /// </summary>
  626. /// <param name="hChannelHandle"></param>
  627. /// <returns></returns>
  628. public static int T18_GetVideoSignal(IntPtr hChannelHandle)
  629. {
  630. return dll_T18_GetVideoSignal(hChannelHandle);
  631. }
  632.  
  633. /// <summary>
  634. /// Parameters: HANDLE hChannelHandle, handle of channel
  635. /// int nBrightness Brightness(0-255)
  636. /// int nContrast Contrast(0-255)
  637. /// int nSaturation Saturation(0-255)
  638. /// int nHue Hue(0-255)
  639. /// Description: Set video color parameters
  640. /// Return: 0 when success
  641. /// </summary>
  642. /// <param name="hChannelHandle"></param>
  643. /// <param name="nBrightness"></param>
  644. /// <param name="nContrast"></param>
  645. /// <param name="nSaturation"></param>
  646. /// <param name="nHue"></param>
  647. /// <returns></returns>
  648. public static int T18_SetVideoPara(IntPtr hChannelHandle, int nBrightness, int nContrast, int nSaturation, int nHue)
  649. {
  650. return dll_T18_SetVideoPara(hChannelHandle, nBrightness, nContrast, nSaturation, nHue);
  651. }
  652.  
  653. /// <summary>
  654. /// Parameters: HANDLE hChannelHandle handle of channel
  655. /// VideoStandard_t *VideoStandard Video Standard
  656. /// int *Brightness, pointer of Brightness(0-255)
  657. /// int *Contrast, pointer of Contrast(0-255)
  658. /// int *Saturation, pointer of Saturation(0-255)
  659. /// int *Hue pointer of Hue(0-255)
  660. /// Description: Get video color parameters
  661. /// Return: 0 when success
  662. /// </summary>
  663. /// <param name="hChannelHandle"></param>
  664. /// <param name="videoStandard"></param>
  665. /// <param name="brightness"></param>
  666. /// <param name="contrast"></param>
  667. /// <param name="saturation"></param>
  668. /// <param name="hue"></param>
  669. /// <returns></returns>
  670. public static int T18_GetVideoPara(IntPtr hChannelHandle, ref VideoStandard videoStandard, ref int brightness, ref int contrast, ref int saturation, ref int hue)
  671. {
  672. return dll_T18_GetVideoPara(hChannelHandle, ref videoStandard, ref brightness, ref contrast, ref saturation, ref hue);
  673. }
  674.  
  675. /// <summary>
  676. /// Parameters: :int nMode Video Lost Mode(0-2),Default value is 0
  677. ///Description: Set video lost mode, when the signal is lost , the video add information,
  678. ///0 not add;1 add Chinese“无视频信号“; 2 add English“No Signal”;
  679. ///Return: 0 when success
  680. /// </summary>
  681. /// <param name="mode"></param>
  682. /// <returns></returns>
  683. public static int T18_SetVideoLostMode(int mode)
  684. {
  685. return dll_T18_SetVideoLostMode(mode);
  686. }
  687.  
  688. /// <summary>
  689. /// Parameters: HANDLE hChannelHandle handle of channel
  690. /// int X center position horizontally
  691. /// int Y center position vertically
  692. /// Description: Set the video clip position,could solve the black border problem.
  693. /// Return: 0 when success
  694. /// </summary>
  695. /// <param name="hChannelHandle"></param>
  696. /// <param name="x"></param>
  697. /// <param name="y"></param>
  698. /// <returns></returns>
  699. public static int T18_SetVideoClip(IntPtr hChannelHandle, int x, int y)
  700. {
  701. return dll_T18_SetVideoClip(hChannelHandle, x, y);
  702. }
  703.  
  704. /// <summary>
  705. /// Parameters: HANDLE hChannelHandle handle of channel
  706. /// int nVideoNightFilter night video filter switch 0-off 1-on
  707. /// Description: Set night video filter, if set on it will reduce data rate.
  708. /// Return: 0 when success
  709. /// </summary>
  710. /// <param name="hChannelHandle"></param>
  711. /// <param name="nVideoNightFilter"></param>
  712. /// <returns></returns>
  713. public static int T18_SetVideoNightFilter(IntPtr hChannelHandle, int nVideoNightFilter)
  714. {
  715. return dll_T18_SetVideoNightFilter(hChannelHandle, nVideoNightFilter);
  716. }
  717.  
  718. /// <summary>
  719. /// Parameters: VideoStandard_t VideoStandard video standard
  720. /// Description: Set default video standard, default is PAL;it must be called before calling
  721. /// T18_InitDSPs.
  722. /// </summary>
  723. /// <param name="videoStandard"></param>
  724. /// <returns></returns>
  725. public static int T18_SetDefaultVideoStandard(VideoStandard videoStandard)
  726. {
  727. return dll_T18_SetDefaultVideoStandard(videoStandard);
  728. }
  729.  
  730. /// <summary>
  731. /// Parameters: HANDLE hChannelHandle handle of channel
  732. /// int nLevel video sharp level (0-1)
  733. /// 0 : close,1: open
  734. /// Default is 0
  735. /// Description:Set video sharp
  736. /// Return: 0 when success
  737. /// </summary>
  738. /// <param name="hChannelHandle"></param>
  739. /// <param name="nLevel"></param>
  740. /// <returns></returns>
  741. public static int T18_SetVideoSharp(IntPtr hChannelHandle, int nLevel)
  742. {
  743. return dll_T18_SetVideoSharp(hChannelHandle, nLevel);
  744. }
  745.  
  746. /// <summary>
  747. /// Parameter: HANDLE hChannelHandle handle of channel
  748. /// DWORD &nVolume audio volume (0-32768)
  749. /// Description: Get original audio volume;
  750. /// Return: 0 when success
  751. /// </summary>
  752. /// <param name="hChannelHandle"></param>
  753. /// <param name="nVolume"></param>
  754. /// <returns></returns>
  755. public static int T18_GetRawAudioVolume(IntPtr hChannelHandle, out ulong nVolume)
  756. {
  757. return dll_T18_GetRawAudioVolume(hChannelHandle, out nVolume);
  758. }
  759.  
  760. /// <summary>
  761. /// Parameters: HANDLE hChannelHandle, handle of channel
  762. /// Description: Start video encoder and send messages registered in
  763. /// T18_RegisterMessageNotifyHandle to application, application can call
  764. /// function T18_ReadStreamData to get data.
  765. /// Return: 0 when success
  766. /// </summary>
  767. /// <param name="hChannelHandle"></param>
  768. /// <returns></returns>
  769. public static int T18_StartVideoCapture(IntPtr hChannelHandle)
  770. {
  771. return dll_T18_StartVideoCapture(hChannelHandle);
  772. }
  773.  
  774. /// <summary>
  775. /// Parameters: HANDLE hChannelHandle, handle of channel
  776. /// Description: Stop video capture
  777. /// Return: 0 when success
  778. /// </summary>
  779. /// <param name="hChannelHandle"></param>
  780. /// <returns></returns>
  781. public static int T18_StopVideoCapture(IntPtr hChannelHandle)
  782. {
  783. return dll_T18_StopVideoCapture(hChannelHandle);
  784. }
  785.  
  786. /// <summary>
  787. /// Parameters: HANDLE hChannelHandle, handle of channel
  788. /// USHORT Type Stream type:
  789. /// #define STREAM_TYPE_VIDEO 1 //video only
  790. /// #define STREAM_TYPE_AUDIO 2 //audio only
  791. /// #define STREAM_TYPE_AVSYNC 3 //video and audio
  792. /// Description: Set data stream type
  793. /// Return: 0 when success
  794. /// </summary>
  795. /// <param name="hChannelHandle"></param>
  796. /// <param name="type"></param>
  797. /// <returns></returns>
  798. public static int T18_SetStreamType(IntPtr hChannelHandle, ushort type)
  799. {
  800. return dll_T18_SetStreamType(hChannelHandle, type);
  801. }
  802.  
  803. /// <summary>
  804. /// Parameters: HANDLE hChannelHandle handle of channel
  805. /// USHORT *StreamType Pointer to stream type
  806. /// Description: Get data stream type
  807. /// Return: 0 when success
  808. /// </summary>
  809. /// <param name="hChannelHandle"></param>
  810. /// <param name="streamType"></param>
  811. /// <returns></returns>
  812. public static int T18_GetStreamType(IntPtr hChannelHandle, ref ushort streamType)
  813. {
  814. return dll_T18_GetStreamType(hChannelHandle, ref streamType);
  815. }
  816.  
  817. /// <summary>
  818. /// Parameters: HANDLE hChannelHandle handle of channel
  819. /// PictureForamt_t PictureFormat image format (CIF, Half D1, D1)
  820. /// Description: Set image format for encoding. It is called after T18_InitDSPs() and
  821. /// before other functions. It is more efficiency to call
  822. /// T18_SetAllEncoderPictureFormat to set image format for all channels at
  823. /// same time.
  824. /// Return: 0 when success
  825. /// </summary>
  826. /// <param name="hChannelHandle"></param>
  827. /// <param name="pictureFormat"></param>
  828. /// <returns></returns>
  829. public static int T18_SetEncoderPictureFormat(IntPtr hChannelHandle, PictureFormat pictureFormat)
  830. {
  831. return dll_T18_SetEncoderPictureFormat(hChannelHandle, pictureFormat);
  832. }
  833.  
  834. /// <summary>
  835. /// Parameters: PictureForamt_t *pPictureFormat the pointer of the encode image size
  836. /// array
  837. /// Description: Set all encoder picture format,after initialization is done, transfer it
  838. /// immediately;
  839. /// Return: 0 when success
  840. /// </summary>
  841. /// <param name="pPictureFormat"></param>
  842. /// <returns></returns>
  843. public static int T18_SetAllEncoderPictureFormat(ref PictureFormat pPictureFormat)
  844. {
  845. return dll_T18_SetAllEncoderPictureFormat(ref pPictureFormat);
  846. }
  847.  
  848. /// <summary>
  849. /// Parameters: HANDLE hChannelHandle, handle of channel
  850. /// int KeyFrameIntervals, Key frame intervals(default 64)
  851. /// int BFrames, reserved
  852. /// int PFrames, reserved
  853. /// int FrameRate Frame rate(default 25)
  854. /// Description: Set encoding parameters. Key frame intervals must not be less than 12,
  855. /// frame rate is 1-25(PAL) or 1-30(NTSC) which can be set while encoding.
  856. /// Key frame is I frame in compressed video data and it is decoded by itself.
  857. /// P frames is compressed referring I frame and need I frame to decode. I
  858. /// frame data rate is much more than P frame. Less key frame interval
  859. /// means larger data rate and better video quality.
  860. /// Return: 0 when success
  861. /// </summary>
  862. /// <param name="hChannelHandle"></param>
  863. /// <param name="keyFrameIntervals"></param>
  864. /// <param name="bFrames"></param>
  865. /// <param name="pFrames"></param>
  866. /// <param name="frameRate"></param>
  867. /// <returns></returns>
  868. public static int T15_SetIBPMode(IntPtr hChannelHandle, int keyFrameIntervals, int bFrames, int pFrames, int frameRate)
  869. {
  870. return dll_T15_SetIBPMode(hChannelHandle, keyFrameIntervals, bFrames, pFrames, frameRate);
  871. }
  872.  
  873. /// <summary>
  874. /// Parameters: HANDLE hChannelHandle, handle of channel
  875. /// int IQuantVal, I frame Q factor
  876. /// int PQuantVal, reserved
  877. /// int BQuantVal reserved
  878. /// Description: Set video encoder Q factor. Lower value means better video quality and
  879. /// higher data rate. Valid value is 1-31. 5 or 6 is better value and can set
  880. /// while encoding.
  881. /// Return: 0 when success
  882. /// </summary>
  883. /// <param name="hChannelHandle"></param>
  884. /// <param name="iQuantVal"></param>
  885. /// <param name="pQuantVal"></param>
  886. /// <param name="bQuantVal"></param>
  887. /// <returns></returns>
  888. public static int T18_SetDefaultQuant(IntPtr hChannelHandle, int iQuantVal, int pQuantVal, int bQuantVal)
  889. {
  890. return dll_T18_SetDefaultQuant(hChannelHandle, iQuantVal, pQuantVal, bQuantVal);
  891. }
  892.  
  893. /// <summary>
  894. /// Parameters: HANDLE hChannelHandle handle of channel
  895. /// BitrateControlType_t brc encoder mode, brCBR Constant bit rate,
  896. /// brVBR Variable bit rate
  897. /// Description: Set encoder mode
  898. /// Return: 0 when success
  899. /// </summary>
  900. /// <param name="hChannelHandle"></param>
  901. /// <param name="brc"></param>
  902. /// <returns></returns>
  903. public static int T18_SetBitrateControlMode(IntPtr hChannelHandle, BitrateControlType brc)
  904. {
  905. return dll_T18_SetBitrateControlMode(hChannelHandle, brc);
  906. }
  907.  
  908. /// <summary>
  909. /// Parameters: HANDLE hChannelHandle handle of channel
  910. /// ULONG MaxBps maximum level of bit rate in Bit
  911. /// Description: Set video data rate control after calling T18_SetBitrateControlMode.In
  912. /// mode brVBR, MaxBps means maximum level of bit rate. The video
  913. /// data rate is decided by IQuantVal and KeyFrameIntervals. In mode
  914. /// brCBR, MaxBps means actual data bit rate.
  915. /// </summary>
  916. /// <param name="hChannelHandle"></param>
  917. /// <param name="maxBps"></param>
  918. /// <returns></returns>
  919. public static int T18_SetupBitrateControl(IntPtr hChannelHandle, ulong maxBps)
  920. {
  921. return dll_T18_SetupBitrateControl(hChannelHandle, maxBps);
  922. }
  923.  
  924. /// <summary>
  925. /// Parameters: HANDLE hChannelHandle handle of channel
  926. /// int nType audio encoder type(Random value) A-law 8k*8
  927. /// Description: Set audio encoder type. Do not call it in default. A-law is 64Kbit/s
  928. /// Return: 0 when success
  929. /// </summary>
  930. /// <param name="hChannelHandle"></param>
  931. /// <param name="nType"></param>
  932. /// <returns></returns>
  933. public static int T18_SetEncodeAudioType(IntPtr hChannelHandle, int nType)
  934. {
  935. return dll_T18_SetEncodeAudioType(hChannelHandle, nType);
  936. }
  937.  
  938. /// <summary>
  939. /// Parameters: HANDLE hChannelHandle handle of channel
  940. /// UCHAR *ImageBuf pointer to original image
  941. /// ULONG *Size size of original image, it is size of imagebuf before
  942. /// calling, It is number of actual image in Byte.
  943. /// DWORD nPictureType image type: 0-non standard yuv,1-standard
  944. /// yuv422
  945. /// Description: Get original image data. It is used to capture still image from live video.
  946. /// Call T18_SaveYUVToBmpFile to save bmp file. nPictureType must be
  947. /// same to nYUVType in T18_SaveYUVToBmpFile.
  948. /// Return: 0 when success
  949. /// </summary>
  950. /// <param name="hChannelHandle"></param>
  951. /// <param name="imageBuf"></param>
  952. /// <param name="size"></param>
  953. /// <param name="nPictureType"></param>
  954. /// <returns></returns>
  955. public static int T18_GetOriginalImage(IntPtr hChannelHandle, IntPtr imageBuf, ref ulong size, ulong nPictureType)
  956. {
  957. try
  958. {
  959. return dll_T18_GetOriginalImage(hChannelHandle, imageBuf, ref size, nPictureType);
  960. }
  961. catch
  962. {
  963. return 0;
  964. }
  965. }
  966.  
  967. /// <summary>
  968. /// Parameters: HANDLE hChannelHandle handle of channel
  969. /// Description: Set frame type of next frame is I frame. It is used when you start to save
  970. /// file or send data to network.
  971. /// Return: 0 when success
  972. /// </summary>
  973. /// <param name="hChannelHandle"></param>
  974. /// <returns></returns>
  975. public static int T18_CaptureIFrame(IntPtr hChannelHandle)
  976. {
  977. return dll_T18_CaptureIFrame(hChannelHandle);
  978. }
  979.  
  980. /// <summary>
  981. /// Parameters: HANDLE hChannelHandle handle of channel
  982. /// UCHAR **pSystemHeader pointer to head buffer
  983. /// DWORD *Length length of head buffer
  984. /// Description: Get head of file, must get for each file
  985. /// Return: 0 when success
  986. /// </summary>
  987. /// <param name="hChannelHandle"></param>
  988. /// <param name="pSystemHeader"></param>
  989. /// <param name="length"></param>
  990. /// <returns></returns>
  991. public static int T18_GetSystemHeader(IntPtr hChannelHandle, byte[] pSystemHeader, ref ulong length)
  992. {
  993. return dll_T18_GetSystemHeader(hChannelHandle, pSystemHeader, ref length);
  994. }
  995.  
  996. /// <summary>
  997. /// Parameters: HANDLE hChannelHandle handle of channel
  998. /// int iFramesThreshold read notify threshold, Valid value is 1-10, default is 3
  999. /// Description: User setup notify threshold ,when the quantity of data frames in the
  1000. /// buffer area exceed the threshold,System will send message to notify user.
  1001. /// </summary>
  1002. /// <param name="hChannelHandle"></param>
  1003. /// <param name="iFramesThreshold"></param>
  1004. /// <returns></returns>
  1005. public static int T18_SetupNotifyThreshold(IntPtr hChannelHandle, int iFramesThreshold)
  1006. {
  1007. return dll_T18_SetupNotifyThreshold(hChannelHandle, iFramesThreshold);
  1008. }
  1009.  
  1010. /// <summary>
  1011. /// Parameters: HANDLE hChannelHandle, handle of channel
  1012. /// void *DataBuf, user buffer to store data of a frame
  1013. /// DWORD *Length input: size of buffer output: length of frame
  1014. /// Int *FrameType frame type
  1015. /// Description: Read stream data, after call StartVideoCapture or StartMotionDetection
  1016. /// system will send message with channel number to application’s window
  1017. /// message process function. When application receive message
  1018. /// T18_ReadStreamData must be called to get data. T18_ReadStreamData
  1019. /// will return length of frame if size of buffer is larger than size of frame,
  1020. /// or return error. T18_ReadStreamData must be called sequentially until
  1021. /// length is 0 or data maybe lost.
  1022. /// Return: length of frame
  1023. /// </summary>
  1024. /// <param name="hChannelHandle"></param>
  1025. /// <param name="DataBuf"></param>
  1026. /// <param name="length"></param>
  1027. /// <param name="frameType"></param>
  1028. /// <returns></returns>
  1029. public static int T18_ReadStreamData(IntPtr hChannelHandle, byte[] DataBuf, ref ulong length, ref int frameType)
  1030. {
  1031. return dll_T18_ReadStreamData(hChannelHandle, DataBuf, ref length, ref frameType);
  1032. }
  1033.  
  1034. /// <summary>
  1035. /// Parameters: HANDLE hChannelHandle handle of channel
  1036. /// int iSubChannel sub channel no
  1037. /// Description: There are two different conditions,For CIF card
  1038. /// (18004,18008,18016,18016E),main channel resolution is CIF,Sub
  1039. /// channel is CIF;For D1 card(18204),main channel resolution is D1
  1040. /// (4CIF),sub channel is CIF. User can setup some parameters on sub
  1041. /// channel 0,1 separately. The parameters ,such as stream
  1042. /// type,OSD,LOGO,MOSAIC in sub channel 0 are the same as the
  1043. /// parameters in sub channel 1.User should setup the parameters, such as
  1044. /// frame rate, I frame interval, quantity modulus, VBR/CBR, bit rate in sub
  1045. /// channel 0,1 separately, the default value is sub channel 0.
  1046. /// The functions are as follows:
  1047. /// T18_StartVideoCapture
  1048. /// T18_StopVideoCapture
  1049. /// T18_SetEncodeSettings
  1050. /// T18_SetIBPMode
  1051. /// T18_SetDefaultQuant
  1052. /// T18_SetBitrateControlMode
  1053. /// T18_SetupBitrateControl
  1054. /// T18_GetSystemHeader
  1055. /// T18_CaptureIFrame
  1056. /// The data stream of the sub channel 1 need to transfer functions
  1057. /// T18_StartVideoCapture(it required that the encoding of the sub-channel 0
  1058. /// must be started up firstly)and T18_StopVideoCapture to start or stop the
  1059. /// encoding of sub channel 1.
  1060. /// Return: 0 when success
  1061. /// </summary>
  1062. /// <param name="hChannelHandle"></param>
  1063. /// <param name="iSubChannel"></param>
  1064. /// <returns></returns>
  1065. public static int T18_SetupSubChannel(IntPtr hChannelHandle, int iSubChannel)
  1066. {
  1067. return dll_T18_SetupSubChannel(hChannelHandle, iSubChannel);
  1068. }
  1069.  
  1070. /// <summary>
  1071. /// Parameters: void *DataBuf input data buffer
  1072. /// Int FrameType input frame type
  1073. /// Description: There are two different conditions , For CIF card
  1074. /// (18004,18008,18016,18016E),main channel resolution is CIF,Sub
  1075. /// channel is CIF;For D1 card(18204),main channel resolution is D1
  1076. ///(4CIF),sub channel is CIF. After start recording ,DSP will send two
  1077. /// different kinds of data stream upwards for each channel. The application
  1078. /// software can get the type of the sub channel stream by transferring the
  1079. /// function.
  1080. /// Return: 0 when success
  1081. /// </summary>
  1082. /// <param name="dataBuf"></param>
  1083. /// <param name="frameType"></param>
  1084. /// <returns></returns>
  1085. public static int T18_GetSubChannelStreamType(ref IntPtr dataBuf, int frameType)
  1086. {
  1087. return dll_T18_GetSubChannelStreamType(ref dataBuf, frameType);
  1088. }
  1089.  
  1090. /// <summary>
  1091. /// Parameters: HANDLE hChannelHandle handle of channel
  1092. /// BOOL bStart TRUE/start capturing,FALSE/stop capturing
  1093. /// int fps framerate
  1094. /// int width width of the picture
  1095. /// int height height of the picture
  1096. /// unsigned char *imageBuffer The address where the image saved.
  1097. /// Description: There are two different conditions , For CIF card
  1098. /// (18004,18008,18016,18016E),main channel resolution is CIF,Sub channel is CIF;
  1099. /// For D1 card (18204) ,main channel resolution is D1 (4CIF) ,sub channel is CIF. User
  1100. /// could start or stop capturing the original image data stream.
  1101. /// Return: 0 when success
  1102. /// </summary>
  1103. /// <param name="hChannelHandle"></param>
  1104. /// <param name="bStart"></param>
  1105. /// <param name="fps"></param>
  1106. /// <param name="width"></param>
  1107. /// <param name="height"></param>
  1108. /// <param name="imageBuffer"></param>
  1109. /// <returns></returns>
  1110. public static int T18_SetImageStream(IntPtr hChannelHandle, bool bStart, int fps, int width, int height, ref IntPtr imageBuffer)
  1111. {
  1112. return dll_T18_SetImageStream(hChannelHandle, bStart, fps, width, height, ref imageBuffer);
  1113. }
  1114.  
  1115. /// <summary>
  1116. /// Parameters: IMAGE_STREAM_CALLBACK ImageStreamCallback Callback
  1117. /// function
  1118. /// (*IMAGE_STREAM_CALLBACK)(int channelNumber,void *context);
  1119. /// int channnelNumber; channel No
  1120. /// void *context; transfer the context of the callback function
  1121. /// Description: Registered user use the function to capture the original image data
  1122. /// stream,User could capture the real-time preview data which format is
  1123. /// planar422
  1124. /// Return: 0 when success
  1125. /// </summary>
  1126. /// <param name="imageStreamCallBack"></param>
  1127. /// <param name="context"></param>
  1128. /// <returns></returns>
  1129. public static int T18_RegisterImageStreamCallback(MulticastDelegate imageStreamCallBack, ref IntPtr context)
  1130. {
  1131. return dll_T18_RegisterImageStreamCallback(imageStreamCallBack, ref context);
  1132. }
  1133.  
  1134. /// <summary>
  1135. /// Description:Set current channel encoder format,example:ENC_2CIF_FORMAT is
  1136. /// HALF D1 format,ENC_4CIF_FORMAT is D1 format;
  1137. /// Note:Only support D1 card.
  1138. /// Return: 0 when success
  1139. /// </summary>
  1140. /// <param name="hChannelHandle"></param>
  1141. /// <param name="pictureFormat"></param>
  1142. /// <returns></returns>
  1143. public static int T18_SetEncoderFormat(IntPtr hChannelHandle, PictureFormat pictureFormat)
  1144. {
  1145. return dll_T18_SetEncoderFormat(hChannelHandle, pictureFormat);
  1146. }
  1147.  
  1148. /// <summary>
  1149. /// Parameters: HANDLE hChannelHandle handle of channel
  1150. /// UCHAR *ImageBuf pointer to original image
  1151. /// ULONG *Size size of original image, it is size of imagebuf before
  1152. /// calling, It is number of actual image in Byte.
  1153. /// DWORD nPictureType image type: 0-non standard yuv,1-standard
  1154. /// yuv422
  1155. /// Description: Get original image data. It is used to capture still image from live video.
  1156. /// Call T18_SaveYUVToBmpFile to save bmp file. nPictureType must be
  1157. /// same to nYUVType in T18_SaveYUVToBmpFile.
  1158. /// Return: 0 when success
  1159. /// </summary>
  1160. /// <param name="hChannelHandle"></param>
  1161. /// <param name="imageBuf"></param>
  1162. /// <param name="size"></param>
  1163. /// <param name="nPictureType"></param>
  1164. /// <returns></returns>000
  1165. public static int T18_GetOriginalImageEx(IntPtr hChannelHandle, ref IntPtr imageBuf, ref ulong size, ulong nPictureType)
  1166. {
  1167. return dll_T18_GetOriginalImageEx(hChannelHandle, ref imageBuf, ref size, nPictureType);
  1168. }
  1169.  
  1170. public static int T18_SaveYUVToBmpFile(string FileName, IntPtr yuv, int Width, int Height, ulong nYUVType)
  1171. {
  1172. return dll_T18_SaveYUVToBmpFile(FileName, yuv, Width, Height, nYUVType);
  1173. }
  1174.  
  1175. public static int T18_SetLogo(IntPtr hChannelHandle, int x, int y, int w, int h, IntPtr yuv)
  1176. {
  1177. return dll_T18_SetLogo(hChannelHandle, x, y, w, h, yuv);
  1178. }
  1179.  
  1180. public static int T18_LoadYUV444FromBmpFile(string FileName, ref IntPtr yuv, ref int BufLen, ref int Width, ref int Height)
  1181. {
  1182. return dll_T18_LoadYUV444FromBmpFile(FileName, ref yuv, ref BufLen, ref Width, ref Height);
  1183. }
  1184.  
  1185. public static ulong ToUlong(int red, int green, int blue)
  1186. {
  1187. long i;
  1188. i = red;
  1189. i = i + 256 * green;
  1190. i = i + 256 * 256 * blue;
  1191. return Convert.ToUInt32(i);
  1192. }
  1193. #endregion
  1194.  
  1195. #endregion
  1196. }
  1197. }
Advertisement
Add Comment
Please, Sign In to add comment