PlayCtrl.cs 28 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710
  1. using System;
  2. using System.Runtime.InteropServices;
  3. namespace DeviceCenter
  4. {
  5. class PlayCtrl
  6. {
  7. //various macro define
  8. public const string PLAYM4_API = "extern \"C\"__declspec(dllexport)";
  9. //Max channel numbers
  10. public const int PLAYM4_MAX_SUPPORTS = 500;
  11. //Wave coef range;
  12. public const int MIN_WAVE_COEF = -100;
  13. public const int MAX_WAVE_COEF = 100;
  14. //Timer type
  15. public const int TIMER_1 = 1; //Only 16 timers for every process.Default TIMER;
  16. public const int TIMER_2 = 2; //Not limit;But the precision less than TIMER_1;
  17. //BUFFER TYPE
  18. public const int BUF_VIDEO_SRC = 1;
  19. public const int BUF_AUDIO_SRC = 2;
  20. public const int BUF_VIDEO_RENDER = 3;
  21. public const int BUF_AUDIO_RENDER = 4;
  22. //Error code
  23. public const int PLAYM4_NOERROR = 0; //no error
  24. public const int PLAYM4_PARA_OVER = 1; //input parameter is invalid;
  25. public const int PLAYM4_ORDER_ERROR = 2; //The order of the function to be called is error.
  26. public const int PLAYM4_TIMER_ERROR = 3; //Create multimedia clock failed;
  27. public const int PLAYM4_DEC_VIDEO_ERROR = 4; //Decode video data failed.
  28. public const int PLAYM4_DEC_AUDIO_ERROR = 5; //Decode audio data failed.
  29. public const int PLAYM4_ALLOC_MEMORY_ERROR = 6; //Allocate memory failed.
  30. public const int PLAYM4_OPEN_FILE_ERROR = 7; //Open the file failed.
  31. public const int PLAYM4_CREATE_OBJ_ERROR = 8; //Create thread or event failed
  32. public const int PLAYM4_CREATE_DDRAW_ERROR = 9; //Create DirectDraw object failed.
  33. public const int PLAYM4_CREATE_OFFSCREEN_ERROR = 10; //failed when creating off-screen surface.
  34. public const int PLAYM4_BUF_OVER = 11; //buffer is overflow
  35. public const int PLAYM4_CREATE_SOUND_ERROR = 12; //failed when creating audio device.
  36. public const int PLAYM4_SET_VOLUME_ERROR = 13; //Set volume failed
  37. public const int PLAYM4_SUPPORT_FILE_ONLY = 14; //The function only support play file.
  38. public const int PLAYM4_SUPPORT_STREAM_ONLY = 15; //The function only support play stream.
  39. public const int PLAYM4_SYS_NOT_SUPPORT = 16; //System not support.
  40. public const int PLAYM4_FILEHEADER_UNKNOWN = 17; //No file header.
  41. public const int PLAYM4_VERSION_INCORRECT = 18; //The version of decoder and encoder is not adapted.
  42. public const int PLAYM4_INIT_DECODER_ERROR = 19; //Initialize decoder failed.
  43. public const int PLAYM4_CHECK_FILE_ERROR = 20; //The file data is unknown.
  44. public const int PLAYM4_INIT_TIMER_ERROR = 21; //Initialize multimedia clock failed.
  45. public const int PLAYM4_BLT_ERROR = 22; //Blt failed.
  46. public const int PLAYM4_UPDATE_ERROR = 23; //Update failed.
  47. public const int PLAYM4_OPEN_FILE_ERROR_MULTI = 24; //open file error, stream type is multi
  48. public const int PLAYM4_OPEN_FILE_ERROR_VIDEO = 25; //open file error, stream type is video
  49. public const int PLAYM4_JPEG_COMPRESS_ERROR = 26; //JPEG compress error
  50. public const int PLAYM4_EXTRACT_NOT_SUPPORT = 27; //Don't support the version of this file.
  51. public const int PLAYM4_EXTRACT_DATA_ERROR = 28; //extract video data failed.
  52. public const int PLAYM4_SECRET_KEY_ERROR = 29; //Secret key is error //add 20071218
  53. //Max display regions.
  54. public const int MAX_DISPLAY_WND = 4;
  55. //Display type
  56. public const int DISPLAY_NORMAL = 1;
  57. public const int DISPLAY_QUARTER = 2;
  58. //Display buffers
  59. public const int MAX_DIS_FRAMES = 50;
  60. public const int MIN_DIS_FRAMES = 1;
  61. //Locate by
  62. public const int BY_FRAMENUM = 1;
  63. public const int BY_FRAMETIME = 2;
  64. //Source buffer
  65. public const int SOURCE_BUF_MAX = 1024 * 100000;
  66. public const int SOURCE_BUF_MIN = 1024 * 50;
  67. //Stream type
  68. public const int STREAME_REALTIME = 0;
  69. public const int STREAME_FILE = 1;
  70. //frame type
  71. public const int T_AUDIO16 = 101;
  72. public const int T_AUDIO8 = 100;
  73. public const int T_UYVY = 1;
  74. public const int T_YV12 = 3;
  75. public const int T_RGB32 = 7;
  76. //capability
  77. public const int SUPPORT_DDRAW = 1;
  78. public const int SUPPORT_BLT = 2;
  79. public const int SUPPORT_BLTFOURCC = 4;
  80. public const int SUPPORT_BLTSHRINKX = 8;
  81. public const int SUPPORT_BLTSHRINKY = 16;
  82. public const int SUPPORT_BLTSTRETCHX = 32;
  83. public const int SUPPORT_BLTSTRETCHY = 64;
  84. public const int SUPPORT_SSE = 128;
  85. public const int SUPPORT_MMX = 256;
  86. // the following macro for the struct HIK_MEDIAINFO
  87. public const int FOURCC_HKMI = 0x484B4D49; // "HKMI" HIK_MEDIAINFO stuct tag
  88. // system package format
  89. public const int SYSTEM_NULL = 0; // without system layer, pure audio streams or video streams
  90. public const int SYSTEM_HIK = 1; // HIK file layer
  91. public const int SYSTEM_MPEG2_PS = 2;// PS package
  92. public const int SYSTEM_MPEG2_TS = 3;// TS package
  93. public const int SYSTEM_RTP = 4;// rtp package
  94. // video encode type
  95. public const int VIDEO_NULL = 0;// no videos
  96. public const int VIDEO_H264 = 1;// standard H.264 and HIK H.264
  97. public const int VIDEO_MPEG4 = 3;// standard MPEG4
  98. // audio encode type
  99. public const int AUDIO_NULL = 0;// no audios
  100. public const int AUDIO_ADPCM = 4096;// ADPCM
  101. public const int AUDIO_MPEG = 8192;// MPEG series audios, the decoder can decode various MPEG audios adaptively.
  102. // G series audios
  103. public const int AUDIO_G711_U = 28944;
  104. public const int AUDIO_G711_A = 28945;
  105. public const int AUDIO_G722_1 = 29217;
  106. public const int AUDIO_G723_1 = 29233;
  107. public const int AUDIO_G726 = 29280;
  108. public const int AUDIO_G729 = 29328;
  109. //various struct define
  110. //Frame position
  111. public struct SYSTEMTIME
  112. {
  113. public ushort wYear;
  114. public ushort wMonth;
  115. public ushort wDayOfWeek;
  116. public ushort wDay;
  117. public ushort wHour;
  118. public ushort wMinute;
  119. public ushort wSecond;
  120. public ushort wMilliseconds;
  121. public void Init()
  122. {
  123. wYear = 0;
  124. wMonth = 0;
  125. wDayOfWeek = 0;
  126. wDay = 0;
  127. wHour = 0;
  128. wMinute = 0;
  129. wSecond = 0;
  130. wMilliseconds = 0;
  131. }
  132. }
  133. public struct FRAME_POS
  134. {
  135. public int nFilePos;
  136. public int nFrameNum;
  137. public int nFrameTime;
  138. public int nErrorFrameNum;
  139. public IntPtr pErrorTime;
  140. public int nErrorLostFrameNum;
  141. public int nErrorFrameSize;
  142. public void Init()
  143. {
  144. nFilePos = 0;
  145. nFrameNum = 0;
  146. nFrameTime = 0;
  147. nErrorFrameNum = 0;
  148. pErrorTime = new IntPtr();
  149. nErrorLostFrameNum = 0;
  150. nErrorFrameSize = 0;
  151. }
  152. }
  153. //Frame Info
  154. public struct FRAME_INFO
  155. {
  156. public int nWidth;
  157. public int nHeight;
  158. public int nStamp;
  159. public int nType;
  160. public int nFrameRate;
  161. public uint dwFrameNum;
  162. public void Init()
  163. {
  164. nWidth = 0;
  165. nHeight = 0;
  166. nStamp = 0;
  167. nType = 0;
  168. nFrameRate = 0;
  169. dwFrameNum = 0;
  170. }
  171. }
  172. //Frame
  173. public struct FRAME_TYPE
  174. {
  175. [MarshalAsAttribute(UnmanagedType.LPStr)]
  176. public string pDataBuf;
  177. public int nSize;
  178. public int nFrameNum;
  179. public bool bIsAudio;
  180. public int nReserved;
  181. public void Init()
  182. {
  183. pDataBuf = "";
  184. nSize = 0;
  185. nFrameNum = 0;
  186. bIsAudio = false;
  187. nReserved = 0;
  188. }
  189. }
  190. //Watermark Info
  191. public struct WATERMARK_INFO
  192. {
  193. [MarshalAsAttribute(UnmanagedType.LPStr)]
  194. public string pDataBuf;
  195. public int nSize;
  196. public int nFrameNum;
  197. public bool bRsaRight;
  198. public int nReserved;
  199. public void Init()
  200. {
  201. pDataBuf = "";
  202. nSize = 0;
  203. nFrameNum = 0;
  204. bRsaRight = false;
  205. nReserved = 0;
  206. }
  207. }
  208. public struct HIK_MEDIAINFO
  209. {
  210. public uint media_fourcc; // "HKMI": 0x484B4D49 Hikvision Media Information
  211. public ushort media_version; // version:indicate this struct information version, now is 0x0101,also 1.01 ,01:major;01:minor。
  212. public ushort device_id; // device ID,for trace and analysis
  213. public ushort system_format; // system package format
  214. public ushort video_format; // video encode type
  215. public ushort audio_format;// audio encode type
  216. public byte audio_channels;// channel number
  217. public byte audio_bits_per_sample;// bits per sample
  218. public uint audio_samplesrate;// sample rates
  219. public uint audio_bitrate;// compressed audio bit rate ,unit:bit
  220. [MarshalAsAttribute(UnmanagedType.ByValArray, SizeConst = 4, ArraySubType = UnmanagedType.U4)]
  221. public uint[] reserved;// reserve
  222. public void Init()
  223. {
  224. media_fourcc = 0;
  225. media_version = 0;
  226. device_id = 0;
  227. system_format = 0;
  228. video_format = 0;
  229. audio_format = 0;
  230. audio_channels = 0;
  231. audio_bits_per_sample = 0;
  232. audio_samplesrate = 0;
  233. audio_bitrate = 0;
  234. reserved = new uint[4];
  235. }
  236. }
  237. //ver 3.0 added
  238. public struct tagRECT
  239. {
  240. public int left;
  241. public int top;
  242. public int right;
  243. public int bottom;
  244. public void Init()
  245. {
  246. left = 0;
  247. top = 0;
  248. right = 0;
  249. bottom = 0;
  250. }
  251. }
  252. // user-defined functions inerface
  253. // ConverUiTimeToDateTime
  254. public static DateTime ConverUiTimeToDateTime(uint uiTime)
  255. {
  256. int iYear = (int)((uiTime >> 26) + 2000);
  257. int iMonth = (int)((uiTime >> 22) & 15);
  258. int iDay = (int)((uiTime >> 17) & 31);
  259. int iHour = (int)((uiTime >> 12) & 31);
  260. int iMinute = (int)((uiTime >> 6) & 63);
  261. int iSecond = (int)((uiTime >> 0) & 63);
  262. DateTime dateTime = new DateTime(iYear, iMonth, iDay, iHour, iMinute, iSecond);
  263. return dateTime;
  264. }
  265. //Function: GetTimeFromUiTime
  266. public static void GetTimeFromUiTime(uint uiTime, ref uint uiHour, ref uint uiMinute, ref uint uiSecond)
  267. {
  268. uiHour = ((uiTime >> 12) & 31);
  269. uiMinute = ((uiTime >> 6) & 63);
  270. uiSecond = ((uiTime >> 0) & 63);
  271. }
  272. //function define
  273. //Initialize DirecDraw.Now invalid.
  274. [DllImport("PlayCtrl.dll")]
  275. public static extern bool PlayM4_InitDDraw(IntPtr hWnd);
  276. //Release directDraw; Now invalid.
  277. [DllImport("PlayCtrl.dll")]
  278. public static extern bool PlayM4_RealeseDDraw();
  279. [DllImport("PlayCtrl.dll")]
  280. public static extern bool PlayM4_OpenFile(int nPort, String sFileName);
  281. [DllImport("PlayCtrl.dll")]
  282. public static extern bool PlayM4_CloseFile(int nPort);
  283. [DllImport("PlayCtrl.dll")]
  284. public static extern bool PlayM4_Play(int nPort, IntPtr hWnd);
  285. [DllImport("PlayCtrl.dll")]
  286. public static extern bool PlayM4_Stop(int nPort);
  287. [DllImport("PlayCtrl.dll")]
  288. public static extern bool PlayM4_Pause(int nPort, uint nPause);
  289. [DllImport("PlayCtrl.dll")]
  290. public static extern bool PlayM4_Fast(int nPort);
  291. [DllImport("PlayCtrl.dll")]
  292. public static extern bool PlayM4_Slow(int nPort);
  293. [DllImport("PlayCtrl.dll")]
  294. public static extern bool PlayM4_OneByOne(int nPort);
  295. [DllImport("PlayCtrl.dll")]
  296. public static extern bool PlayM4_SetPlayPos(int nPort, float fRelativePos);
  297. [DllImport("PlayCtrl.dll")]
  298. public static extern float PlayM4_GetPlayPos(int nPort);
  299. [DllImport("PlayCtrl.dll")]
  300. public static extern bool PlayM4_SetFileEndMsg(int nPort, IntPtr hWnd, uint nMsg);
  301. [DllImport("PlayCtrl.dll")]
  302. public static extern bool PlayM4_SetVolume(int nPort, ushort nVolume);
  303. [DllImport("PlayCtrl.dll")]
  304. public static extern bool PlayM4_StopSound();
  305. [DllImport("PlayCtrl.dll")]
  306. public static extern bool PlayM4_PlaySound(int nPort);
  307. [DllImport("PlayCtrl.dll")]
  308. public static extern bool PlayM4_OpenStream(int nPort, ref byte pFileHeadBuf, uint nSize, uint nBufPoolSize);
  309. [DllImport("PlayCtrl.dll")]
  310. public static extern bool PlayM4_InputData(int nPort, ref byte pBuf, uint nSize);
  311. [DllImport("PlayCtrl.dll")]
  312. public static extern bool PlayM4_CloseStream(int nPort);
  313. [DllImport("PlayCtrl.dll")]
  314. public static extern int PlayM4_GetCaps();
  315. [DllImport("PlayCtrl.dll")]
  316. public static extern uint PlayM4_GetFileTime(int nPort);
  317. [DllImport("PlayCtrl.dll")]
  318. public static extern bool PlayM4_GetFileTimeEx(int nPort, ref uint pStart, ref uint pStop, ref uint pRev);
  319. [DllImport("PlayCtrl.dll")]
  320. public static extern uint PlayM4_GetPlayedTime(int nPort);
  321. [DllImport("PlayCtrl.dll")]
  322. public static extern uint PlayM4_GetPlayedFrames(int nPort);
  323. ////////////////ver 2.0 added///////////////////////////////////////
  324. public delegate void DECCBFUN(int nPort, IntPtr pBuf, int nSize, ref FRAME_INFO pFrameInfo, int nReserved1, int nReserved2);
  325. [DllImport("PlayCtrl.dll")]
  326. public static extern bool PlayM4_SetDecCallBack(int nPort, DECCBFUN DecCBFun);
  327. public delegate void DISPLAYCBFUN(int nPort, IntPtr pBuf, int nSize, int nWidth, int nHeight, int nStamp, int nType, int nReserved);
  328. [DllImport("PlayCtrl.dll")]
  329. public static extern bool PlayM4_SetDisplayCallBack(int nPort, DISPLAYCBFUN DisplayCBFun);
  330. [DllImport("PlayCtrl.dll")]
  331. public static extern bool PLayM4_ConvertToBmpFile(IntPtr pBuf, int nSize, int nWidth, int nHeight, int nType, string sFileName);
  332. [DllImport("PlayCtrl.dll")]
  333. public static extern uint PlayM4_GetFileTotalFrames(int nPort);
  334. [DllImport("PlayCtrl.dll")]
  335. public static extern uint PlayM4_GetCurrentFrameRate(int nPort);
  336. [DllImport("PlayCtrl.dll")]
  337. public static extern uint PlayM4_GetPlayedTimeEx(int nPort);
  338. [DllImport("PlayCtrl.dll")]
  339. public static extern bool PlayM4_SetPlayedTimeEx(int nPort, uint nTime);
  340. [DllImport("PlayCtrl.dll")]
  341. public static extern uint PlayM4_GetCurrentFrameNum(int nPort);
  342. [DllImport("PlayCtrl.dll")]
  343. public static extern bool PlayM4_SetStreamOpenMode(int nPort, uint nMode);
  344. [DllImport("PlayCtrl.dll")]
  345. public static extern uint PlayM4_GetFileHeadLength();
  346. [DllImport("PlayCtrl.dll")]
  347. public static extern uint PlayM4_GetSdkVersion();
  348. ////////////////ver 2.2 added///////////////////////////////////////
  349. [DllImport("PlayCtrl.dll")]
  350. public static extern uint PlayM4_GetLastError(int nPort);
  351. [DllImport("PlayCtrl.dll")]
  352. public static extern bool PlayM4_RefreshPlay(int nPort);
  353. [DllImport("PlayCtrl.dll")]
  354. public static extern bool PlayM4_SetOverlayMode(int nPort, int bOverlay, uint colorKey);
  355. [DllImport("PlayCtrl.dll")]
  356. public static extern bool PlayM4_GetPictureSize(int nPort, ref int pWidth, ref int pHeight);
  357. [DllImport("PlayCtrl.dll")]
  358. public static extern bool PlayM4_SetPicQuality(int nPort, int bHighQuality);
  359. [DllImport("PlayCtrl.dll")]
  360. public static extern bool PlayM4_PlaySoundShare(int nPort);
  361. [DllImport("PlayCtrl.dll")]
  362. public static extern bool PlayM4_StopSoundShare(int nPort);
  363. ////////////////ver 2.4 added///////////////////////////////////////
  364. [DllImport("PlayCtrl.dll")]
  365. public static extern int PlayM4_GetStreamOpenMode(int nPort);
  366. [DllImport("PlayCtrl.dll")]
  367. public static extern int PlayM4_GetOverlayMode(int nPort);
  368. [DllImport("PlayCtrl.dll")]
  369. public static extern uint PlayM4_GetColorKey(int nPort);
  370. [DllImport("PlayCtrl.dll")]
  371. public static extern ushort PlayM4_GetVolume(int nPort);
  372. [DllImport("PlayCtrl.dll")]
  373. public static extern bool PlayM4_GetPictureQuality(int nPort, ref int bHighQuality);
  374. [DllImport("PlayCtrl.dll")]
  375. public static extern uint PlayM4_GetSourceBufferRemain(int nPort);
  376. [DllImport("PlayCtrl.dll")]
  377. public static extern bool PlayM4_ResetSourceBuffer(int nPort);
  378. public delegate void SOURCEBUFCALLBACKI(int nPort, uint nBufSize, uint dwUser, IntPtr pResvered);
  379. [DllImport("PlayCtrl.dll")]
  380. public static extern bool PlayM4_SetSourceBufCallBack(int nPort, uint nThreShold, SOURCEBUFCALLBACKI SourceBufCallBack, uint dwUser, IntPtr pReserved);
  381. [DllImport("PlayCtrl.dll")]
  382. public static extern bool PlayM4_ResetSourceBufFlag(int nPort);
  383. [DllImport("PlayCtrl.dll")]
  384. public static extern bool PlayM4_SetDisplayBuf(int nPort, uint nNum);
  385. [DllImport("PlayCtrl.dll")]
  386. public static extern uint PlayM4_GetDisplayBuf(int nPort);
  387. [DllImport("PlayCtrl.dll")]
  388. public static extern bool PlayM4_OneByOneBack(int nPort);
  389. // PLAYM4_API BOOL __stdcall PlayM4_SetFileRefCallBack(LONG nPort, void (__stdcall *pFileRefDone)(DWORD nPort,DWORD nUser),DWORD nUser);
  390. public delegate void PFILEREFDONE(uint nPort, uint nUser);
  391. [DllImport("PlayCtrl.dll")]
  392. public static extern bool PlayM4_SetFileRefCallBack(int nPort, PFILEREFDONE pFileRefDone, uint nUser);
  393. [DllImport("PlayCtrl.dll")]
  394. public static extern bool PlayM4_GetKeyFramePos(int nPort, uint nValue, uint nType, ref FRAME_POS pFramePos);
  395. [DllImport("PlayCtrl.dll")]
  396. public static extern bool PlayM4_GetNextKeyFramePos(int nPort, uint nValue, uint nType, ref FRAME_POS pFramePos);
  397. //#if (WINVER >= 0x0400)
  398. //Note: These funtion must be builded under win2000 or above with Microsoft Platform sdk.
  399. // You can download the sdk from "http://www.microsoft.com/msdownload/platformsdk/sdkupdate/";
  400. [DllImport("PlayCtrl.dll")]
  401. public static extern bool PlayM4_InitDDrawDevice();
  402. [DllImport("PlayCtrl.dll")]
  403. public static extern void PlayM4_ReleaseDDrawDevice();
  404. [DllImport("PlayCtrl.dll")]
  405. public static extern uint PlayM4_GetDDrawDeviceTotalNums();
  406. [DllImport("PlayCtrl.dll")]
  407. public static extern bool PlayM4_SetDDrawDevice(int nPort, uint nDeviceNum);
  408. [DllImport("PlayCtrl.dll")]
  409. public static extern int PlayM4_GetCapsEx(uint nDDrawDeviceNum);
  410. //#endif
  411. [DllImport("PlayCtrl.dll")]
  412. public static extern bool PlayM4_ThrowBFrameNum(int nPort, uint nNum);
  413. ////////////////ver 2.5 added///////////////////////////////////////
  414. [DllImport("PlayCtrl.dll")]
  415. public static extern bool PlayM4_SetDisplayType(int nPort, int nType);
  416. [DllImport("PlayCtrl.dll")]
  417. public static extern int PlayM4_GetDisplayType(int nPort);
  418. [DllImport("PlayCtrl.dll")]
  419. public static extern bool PlayM4_SetDecCBStream(int nPort, uint nStream);
  420. [DllImport("PlayCtrl.dll")]
  421. public static extern bool PlayM4_SetDisplayRegion(int nPort, uint nRegionNum, ref tagRECT pSrcRect, System.IntPtr hDestWnd, [System.Runtime.InteropServices.MarshalAsAttribute(System.Runtime.InteropServices.UnmanagedType.Bool)] bool bEnable);
  422. [DllImport("PlayCtrl.dll")]
  423. public static extern bool PlayM4_RefreshPlayEx(int nPort, uint nRegionNum);
  424. //#if (WINVER >= 0x0400)
  425. //Note: The funtion must be builded under win2000 or above with Microsoft Platform sdk.
  426. // You can download the sdk from http://www.microsoft.com/msdownload/platformsdk/sdkupdate/;
  427. [DllImport("PlayCtrl.dll")]
  428. public static extern bool PlayM4_SetDDrawDeviceEx(int nPort, uint nRegionNum, uint nDeviceNum);
  429. //#endif
  430. /////////////////v3.2 added/////////////////////////////////////////
  431. [DllImport("PlayCtrl.dll")]
  432. public static extern bool PlayM4_GetRefValue(int nPort, ref byte pBuffer, ref uint pSize);
  433. [DllImport("PlayCtrl.dll")]
  434. public static extern bool PlayM4_SetRefValue(int nPort, ref byte pBuffer, uint nSize);
  435. [DllImport("PlayCtrl.dll")]
  436. public static extern bool PlayM4_OpenStreamEx(int nPort, ref byte pFileHeadBuf, uint nSize, uint nBufPoolSize);
  437. [DllImport("PlayCtrl.dll")]
  438. public static extern bool PlayM4_CloseStreamEx(int nPort);
  439. [DllImport("PlayCtrl.dll")]
  440. public static extern bool PlayM4_InputVideoData(int nPort, ref byte pBuf, uint nSize);
  441. [DllImport("PlayCtrl.dll")]
  442. public static extern bool PlayM4_InputAudioData(int nPort, ref byte pBuf, uint nSize);
  443. public delegate void DRAWFUN(int nPort, System.IntPtr hDc, int nUser);
  444. [DllImport("PlayCtrl.dll")]
  445. public static extern bool PlayM4_RigisterDrawFun(int nPort, DRAWFUN DrawFun, int nUser);
  446. [DllImport("PlayCtrl.dll")]
  447. public static extern bool PlayM4_RegisterDrawFun(int nPort, DRAWFUN DrawFun, int nUser);
  448. //////////////////v3.4/////////////////////////////////////////////////////
  449. [DllImport("PlayCtrl.dll")]
  450. public static extern bool PlayM4_SetTimerType(int nPort, uint nTimerType, uint nReserved);
  451. [DllImport("PlayCtrl.dll")]
  452. public static extern bool PlayM4_GetTimerType(int nPort, ref uint pTimerType, ref uint pReserved);
  453. [DllImport("PlayCtrl.dll")]
  454. public static extern bool PlayM4_ResetBuffer(int nPort, uint nBufType);
  455. [DllImport("PlayCtrl.dll")]
  456. public static extern uint PlayM4_GetBufferValue(int nPort, uint nBufType);
  457. //////////////////V3.6/////////////////////////////////////////////////////////
  458. [DllImport("PlayCtrl.dll")]
  459. public static extern bool PlayM4_AdjustWaveAudio(int nPort, int nCoefficient);
  460. public delegate void FUNVERYFY(int nPort, ref FRAME_POS pFilePos, uint bIsVideo, uint nUser);
  461. [DllImport("PlayCtrl.dll")]
  462. public static extern bool PlayM4_SetVerifyCallBack(int nPort, uint nBeginTime, uint nEndTime, FUNVERYFY funVerify, uint nUser);
  463. public delegate void FUNAUDIO(int nPort, string pAudioBuf, int nSize, int nStamp, int nType, int nUser);
  464. [DllImport("PlayCtrl.dll")]
  465. public static extern bool PlayM4_SetAudioCallBack(int nPort, FUNAUDIO funAudio, int nUser);
  466. public delegate void FUNENCCHANGE(int nPort, int nUser);
  467. [DllImport("PlayCtrl.dll")]
  468. public static extern bool PlayM4_SetEncTypeChangeCallBack(int nPort, FUNENCCHANGE funEncChange, int nUser);
  469. [DllImport("PlayCtrl.dll")]
  470. public static extern bool PlayM4_SetColor(int nPort, uint nRegionNum, int nBrightness, int nContrast, int nSaturation, int nHue);
  471. [DllImport("PlayCtrl.dll")]
  472. public static extern bool PlayM4_GetColor(int nPort, uint nRegionNum, ref int pBrightness, ref int pContrast, ref int pSaturation, ref int pHue);
  473. [DllImport("PlayCtrl.dll")]
  474. public static extern bool PlayM4_SetEncChangeMsg(int nPort, System.IntPtr hWnd, uint nMsg);
  475. public delegate void FUNGETORIGNALFRAME(int nPort, ref FRAME_TYPE frameType, int nUser);
  476. [DllImport("PlayCtrl.dll")]
  477. public static extern bool PlayM4_GetOriginalFrameCallBack(int nPort, int bIsChange, int bNormalSpeed, int nStartFrameNum, int nStartStamp, int nFileHeader, FUNGETORIGNALFRAME funGetOrignalFrame, int nUser);
  478. [DllImport("PlayCtrl.dll")]
  479. public static extern bool PlayM4_GetFileSpecialAttr(int nPort, ref uint pTimeStamp, ref uint pFileNum, ref uint pReserved);
  480. [DllImport("PlayCtrl.dll")]
  481. public static extern uint PlayM4_GetSpecialData(int nPort);
  482. public delegate void FUNCHECKWATERMARK(int nPort, ref WATERMARK_INFO pWatermarkInfo, uint nUser);
  483. [DllImport("PlayCtrl.dll")]
  484. public static extern bool PlayM4_SetCheckWatermarkCallBack(int nPort, FUNCHECKWATERMARK funCheckWatermark, uint nUser);
  485. [DllImport("PlayCtrl.dll")]
  486. public static extern bool PlayM4_SetImageSharpen(int nPort, uint nLevel);
  487. public delegate void FUNTHROWBFRAME(int nPort, uint nBFrame, uint nUser);
  488. [DllImport("PlayCtrl.dll")]
  489. public static extern bool PlayM4_GetThrowBFrameCallBack(int nPort, FUNTHROWBFRAME funThrowBFrame, uint nUser);
  490. [DllImport("PlayCtrl.dll")]
  491. public static extern bool PlayM4_SetDecodeFrameType(int nPort, uint nFrameType);
  492. [DllImport("PlayCtrl.dll")]
  493. public static extern bool PlayM4_SetPlayMode(int nPort, int bNormal);
  494. public delegate void FUNGETUSERDATA(int nPort, ref byte pUserBuf, uint nBufLen, uint nUser);
  495. [DllImport("PlayCtrl.dll")]
  496. public static extern bool PlayM4_SetGetUserDataCallBack(int nPort, FUNGETUSERDATA funGetUserData, uint nUser);
  497. [DllImport("PlayCtrl.dll")]
  498. public static extern bool PlayM4_SetOverlayFlipMode(int nPort, int bTrue);
  499. [DllImport("PlayCtrl.dll")]
  500. public static extern uint PlayM4_GetAbsFrameNum(int nPort);
  501. //////////////////V4.7.0.0//////////////////////////////////////////////////////
  502. ////convert yuv to jpeg
  503. [DllImport("PlayCtrl.dll")]
  504. public static extern bool PlayM4_ConvertToJpegFile(IntPtr pBuf, int nSize, int nWidth, int nHeight, int nType, string sFileName);
  505. [DllImport("PlayCtrl.dll")]
  506. public static extern bool PlayM4_SetJpegQuality(int nQuality);
  507. //set deflash
  508. [DllImport("PlayCtrl.dll")]
  509. public static extern bool PlayM4_SetDeflash(int nPort, int bDefalsh);
  510. //////////////////V4.8.0.0/////////////////////////////////////////////////////////
  511. //check discontinuous frame number as error data?
  512. [DllImport("PlayCtrl.dll")]
  513. public static extern bool PlayM4_CheckDiscontinuousFrameNum(int nPort, int bCheck);
  514. //get bmp or jpeg
  515. [DllImport("PlayCtrl.dll")]
  516. public static extern bool PlayM4_GetBMP(int nPort, ref byte pBitmap, uint nBufSize, ref uint pBmpSize);
  517. [DllImport("PlayCtrl.dll")]
  518. public static extern bool PlayM4_GetJPEG(int nPort, IntPtr pJpeg, uint nBufSize, ref uint pJpegSize);
  519. //dec call back mend
  520. //public delegate void DECCBFUN(int nPort, string pBuf, int nSize, ref FRAME_INFO pFrameInfo, int nUser, int nReserved2);
  521. [DllImport("PlayCtrl.dll")]
  522. public static extern bool PlayM4_SetDecCallBackMend(int nPort, DECCBFUN DecCBFun, int nUser);
  523. [DllImport("PlayCtrl.dll")]
  524. public static extern bool PlayM4_SetSecretKey(int nPort, int lKeyType, string pSecretKey, int lKeyLen);
  525. // add by gb 2007-12-23
  526. public delegate void FILEENDCALLBACK(int nPort, System.IntPtr pUser);
  527. [DllImport("PlayCtrl.dll")]
  528. public static extern bool PlayM4_SetFileEndCallback(int nPort, FILEENDCALLBACK FileEndCallback, IntPtr pUser);
  529. // add by gb 080131 version 4.9.0.1
  530. [DllImport("PlayCtrl.dll")]
  531. public static extern bool PlayM4_GetPort(ref int nPort);
  532. [DllImport("PlayCtrl.dll")]
  533. public static extern bool PlayM4_FreePort(int nPort);
  534. [DllImport("PlayCtrl.dll")]
  535. public static extern bool PlayM4_SyncToAudio(int nPort, int bSyncToAudio);
  536. //public delegate void Anonymous_b532dad6_7470_4b10_9638_c82a363cd853(int nPort, System.IntPtr pBuf, int nSize, ref FRAME_INFO pFrameInfo, int nReserved1, int nReserved2);
  537. [DllImport("PlayCtrl.dll")]
  538. public static extern bool PlayM4_SetDecCallBackEx(int nPort, DECCBFUN DecCBFun, IntPtr pDest, int nDestSize);
  539. }
  540. }