PlayCtrl.cs 28 KB

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