plaympeg4.h 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247
  1. ///////////////////////////////////////////////////////////////////
  2. //File: PlayMpeg4.h
  3. //Date: 2004-07-10
  4. //Description: Interface for PlayM4.dll
  5. ///////////////////////////////////////////////////////////////////
  6. #ifndef PLAY_M4
  7. #define PLAY_M4
  8. #if defined( _WINDLL)
  9. #define PLAYM4_API extern "C"__declspec(dllexport)
  10. #else
  11. #define PLAYM4_API extern "C" __declspec(dllimport)
  12. #endif
  13. //Max channel numbers
  14. #define PLAYM4_MAX_SUPPORTS 100
  15. //Wave coef range;
  16. #define MIN_WAVE_COEF -100
  17. #define MAX_WAVE_COEF 100
  18. //Timer type
  19. #define TIMER_1 1 //Only 16 timers for every process.Default TIMER;
  20. #define TIMER_2 2 //Not limit;But the precision less than TIMER_1;
  21. //BUFFER TYPE
  22. #define BUF_VIDEO_SRC 1
  23. #define BUF_AUDIO_SRC 2
  24. #define BUF_VIDEO_RENDER 3
  25. #define BUF_AUDIO_RENDER 4
  26. //Error code
  27. #define PLAYM4_NOERROR 0 //no error
  28. #define PLAYM4_PARA_OVER 1 //input parameter is invalid;
  29. #define PLAYM4_ORDER_ERROR 2 //The order of the function to be called is error.
  30. #define PLAYM4_TIMER_ERROR 3 //Create multimedia clock failed;
  31. #define PLAYM4_DEC_VIDEO_ERROR 4 //Decode video data failed.
  32. #define PLAYM4_DEC_AUDIO_ERROR 5 //Decode audio data failed.
  33. #define PLAYM4_ALLOC_MEMORY_ERROR 6 //Allocate memory failed.
  34. #define PLAYM4_OPEN_FILE_ERROR 7 //Open the file failed.
  35. #define PLAYM4_CREATE_OBJ_ERROR 8 //Create thread or event failed
  36. #define PLAYM4_CREATE_DDRAW_ERROR 9 //Create DirectDraw object failed.
  37. #define PLAYM4_CREATE_OFFSCREEN_ERROR 10 //failed when creating off-screen surface.
  38. #define PLAYM4_BUF_OVER 11 //buffer is overflow
  39. #define PLAYM4_CREATE_SOUND_ERROR 12 //failed when creating audio device.
  40. #define PLAYM4_SET_VOLUME_ERROR 13 //Set volume failed
  41. #define PLAYM4_SUPPORT_FILE_ONLY 14 //The function only support play file.
  42. #define PLAYM4_SUPPORT_STREAM_ONLY 15 //The function only support play stream.
  43. #define PLAYM4_SYS_NOT_SUPPORT 16 //System not support.
  44. #define PLAYM4_FILEHEADER_UNKNOWN 17 //No file header.
  45. #define PLAYM4_VERSION_INCORRECT 18 //The version of decoder and encoder is not adapted.
  46. #define PALYM4_INIT_DECODER_ERROR 19 //Initialize decoder failed.
  47. #define PLAYM4_CHECK_FILE_ERROR 20 //The file data is unknown.
  48. #define PLAYM4_INIT_TIMER_ERROR 21 //Initialize multimedia clock failed.
  49. #define PLAYM4_BLT_ERROR 22 //Blt failed.
  50. #define PLAYM4_UPDATE_ERROR 23 //Update failed.
  51. //Max display regions.
  52. #define MAX_DISPLAY_WND 4
  53. //Display type
  54. #define DISPLAY_NORMAL 1
  55. #define DISPLAY_QUARTER 2
  56. //Display buffers
  57. #define MAX_DIS_FRAMES 50
  58. #define MIN_DIS_FRAMES 6
  59. //Locate by
  60. #define BY_FRAMENUM 1
  61. #define BY_FRAMETIME 2
  62. //Source buffer
  63. #define SOURCE_BUF_MAX 1024*100000
  64. #define SOURCE_BUF_MIN 1024*50
  65. //Stream type
  66. #define STREAME_REALTIME 0
  67. #define STREAME_FILE 1
  68. //frame type
  69. #define T_AUDIO16 101
  70. #define T_AUDIO8 100
  71. #define T_UYVY 1
  72. #define T_YV12 3
  73. #define T_RGB32 7
  74. //capability
  75. #define SUPPORT_DDRAW 1
  76. #define SUPPORT_BLT 2
  77. #define SUPPORT_BLTFOURCC 4
  78. #define SUPPORT_BLTSHRINKX 8
  79. #define SUPPORT_BLTSHRINKY 16
  80. #define SUPPORT_BLTSTRETCHX 32
  81. #define SUPPORT_BLTSTRETCHY 64
  82. #define SUPPORT_SSE 128
  83. #define SUPPORT_MMX 256
  84. //Frame position
  85. typedef struct{
  86. long nFilePos;
  87. long nFrameNum;
  88. long nFrameTime;
  89. long nErrorFrameNum;
  90. SYSTEMTIME *pErrorTime;
  91. long nErrorLostFrameNum;
  92. long nErrorFrameSize;
  93. }FRAME_POS,*PFRAME_POS;
  94. //Frame Info
  95. typedef struct{
  96. long nWidth;
  97. long nHeight;
  98. long nStamp;
  99. long nType;
  100. long nFrameRate;
  101. }FRAME_INFO;
  102. //Frame
  103. typedef struct{
  104. char *pDataBuf;
  105. long nSize;
  106. long nFrameNum;
  107. BOOL bIsAudio;
  108. long nReserved;
  109. }FRAME_TYPE;
  110. //////////////////////////////////////////////////////////////////////////////
  111. //API
  112. //////////////////////////////////////////////////////////////////////////////
  113. ////////////////ver 1.0///////////////////////////////////////
  114. //Initialize DirecDraw.Now invalid.
  115. PLAYM4_API BOOL __stdcall PlayM4_InitDDraw(HWND hWnd);
  116. //Release directDraw; Now invalid.
  117. PLAYM4_API BOOL __stdcall PlayM4_RealeseDDraw();
  118. PLAYM4_API BOOL __stdcall PlayM4_OpenFile(LONG nPort,LPSTR sFileName);
  119. PLAYM4_API BOOL __stdcall PlayM4_CloseFile(LONG nPort);
  120. PLAYM4_API BOOL __stdcall PlayM4_Play(LONG nPort, HWND hWnd);
  121. PLAYM4_API BOOL __stdcall PlayM4_Stop(LONG nPort);
  122. PLAYM4_API BOOL __stdcall PlayM4_Pause(LONG nPort,DWORD nPause);
  123. PLAYM4_API BOOL __stdcall PlayM4_Fast(LONG nPort);
  124. PLAYM4_API BOOL __stdcall PlayM4_Slow(LONG nPort);
  125. PLAYM4_API BOOL __stdcall PlayM4_OneByOne(LONG nPort);
  126. PLAYM4_API BOOL __stdcall PlayM4_SetPlayPos(LONG nPort,float fRelativePos);
  127. PLAYM4_API float __stdcall PlayM4_GetPlayPos(LONG nPort);
  128. PLAYM4_API BOOL __stdcall PlayM4_SetFileEndMsg(LONG nPort,HWND hWnd,UINT nMsg);
  129. PLAYM4_API BOOL __stdcall PlayM4_SetVolume(LONG nPort,WORD nVolume);
  130. PLAYM4_API BOOL __stdcall PlayM4_StopSound();
  131. PLAYM4_API BOOL __stdcall PlayM4_PlaySound(LONG nPort);
  132. PLAYM4_API BOOL __stdcall PlayM4_OpenStream(LONG nPort,PBYTE pFileHeadBuf,DWORD nSize,DWORD nBufPoolSize);
  133. PLAYM4_API BOOL __stdcall PlayM4_InputData(LONG nPort,PBYTE pBuf,DWORD nSize);
  134. PLAYM4_API BOOL __stdcall PlayM4_CloseStream(LONG nPort);
  135. PLAYM4_API int __stdcall PlayM4_GetCaps();
  136. PLAYM4_API DWORD __stdcall PlayM4_GetFileTime(LONG nPort);
  137. PLAYM4_API DWORD __stdcall PlayM4_GetPlayedTime(LONG nPort);
  138. PLAYM4_API DWORD __stdcall PlayM4_GetPlayedFrames(LONG nPort);
  139. ////////////////ver 2.0 added///////////////////////////////////////
  140. PLAYM4_API BOOL __stdcall PlayM4_SetDecCallBack(LONG nPort,void (CALLBACK* DecCBFun)(long nPort,char * pBuf,long nSize,FRAME_INFO * pFrameInfo, long nReserved1,long nReserved2));
  141. PLAYM4_API BOOL __stdcall PlayM4_SetDisplayCallBack(LONG nPort,void (CALLBACK* DisplayCBFun)(long nPort,char * pBuf,long nSize,long nWidth,long nHeight,long nStamp,long nType,long nReserved));
  142. PLAYM4_API BOOL __stdcall PlayM4_ConvertToBmpFile(char * pBuf,long nSize,long nWidth,long nHeight,long nType,char *sFileName);
  143. PLAYM4_API DWORD __stdcall PlayM4_GetFileTotalFrames(LONG nPort);
  144. PLAYM4_API DWORD __stdcall PlayM4_GetCurrentFrameRate(LONG nPort);
  145. PLAYM4_API DWORD __stdcall PlayM4_GetPlayedTimeEx(LONG nPort);
  146. PLAYM4_API BOOL __stdcall PlayM4_SetPlayedTimeEx(LONG nPort,DWORD nTime);
  147. PLAYM4_API DWORD __stdcall PlayM4_GetCurrentFrameNum(LONG nPort);
  148. PLAYM4_API BOOL __stdcall PlayM4_SetStreamOpenMode(LONG nPort,DWORD nMode);
  149. PLAYM4_API DWORD __stdcall PlayM4_GetFileHeadLength();
  150. PLAYM4_API DWORD __stdcall PlayM4_GetSdkVersion();
  151. ////////////////ver 2.2 added///////////////////////////////////////
  152. PLAYM4_API DWORD __stdcall PlayM4_GetLastError(LONG nPort);
  153. PLAYM4_API BOOL __stdcall PlayM4_RefreshPlay(LONG nPort);
  154. PLAYM4_API BOOL __stdcall PlayM4_SetOverlayMode(LONG nPort,BOOL bOverlay,COLORREF colorKey);
  155. PLAYM4_API BOOL __stdcall PlayM4_GetPictureSize(LONG nPort,LONG *pWidth,LONG *pHeight);
  156. PLAYM4_API BOOL __stdcall PlayM4_SetPicQuality(LONG nPort,BOOL bHighQuality);
  157. PLAYM4_API BOOL __stdcall PlayM4_PlaySoundShare(LONG nPort);
  158. PLAYM4_API BOOL __stdcall PlayM4_StopSoundShare(LONG nPort);
  159. ////////////////ver 2.4 added///////////////////////////////////////
  160. PLAYM4_API LONG __stdcall PlayM4_GetStreamOpenMode(LONG nPort);
  161. PLAYM4_API LONG __stdcall PlayM4_GetOverlayMode(LONG nPort);
  162. PLAYM4_API COLORREF __stdcall PlayM4_GetColorKey(LONG nPort);
  163. PLAYM4_API WORD __stdcall PlayM4_GetVolume(LONG nPort);
  164. PLAYM4_API BOOL __stdcall PlayM4_GetPictureQuality(LONG nPort,BOOL *bHighQuality);
  165. PLAYM4_API DWORD __stdcall PlayM4_GetSourceBufferRemain(LONG nPort);
  166. PLAYM4_API BOOL __stdcall PlayM4_ResetSourceBuffer(LONG nPort);
  167. PLAYM4_API BOOL __stdcall PlayM4_SetSourceBufCallBack(LONG nPort,DWORD nThreShold,void (CALLBACK * SourceBufCallBack)(long nPort,DWORD nBufSize,DWORD dwUser,void*pResvered),DWORD dwUser,void *pReserved);
  168. PLAYM4_API BOOL __stdcall PlayM4_ResetSourceBufFlag(LONG nPort);
  169. PLAYM4_API BOOL __stdcall PlayM4_SetDisplayBuf(LONG nPort,DWORD nNum);
  170. PLAYM4_API DWORD __stdcall PlayM4_GetDisplayBuf(LONG nPort);
  171. PLAYM4_API BOOL __stdcall PlayM4_OneByOneBack(LONG nPort);
  172. PLAYM4_API BOOL __stdcall PlayM4_SetFileRefCallBack(LONG nPort, void (__stdcall *pFileRefDone)(DWORD nPort,DWORD nUser),DWORD nUser);
  173. PLAYM4_API BOOL __stdcall PlayM4_SetCurrentFrameNum(LONG nPort,DWORD nFrameNum);
  174. PLAYM4_API BOOL __stdcall PlayM4_GetKeyFramePos(LONG nPort,DWORD nValue, DWORD nType, PFRAME_POS pFramePos);
  175. PLAYM4_API BOOL __stdcall PlayM4_GetNextKeyFramePos(LONG nPort,DWORD nValue, DWORD nType, PFRAME_POS pFramePos);
  176. #if (WINVER > 0x0400)
  177. //Note: These funtion must be builded under win2000 or above with Microsoft Platform sdk.
  178. // You can download the sdk from "http://www.microsoft.com/msdownload/platformsdk/sdkupdate/";
  179. PLAYM4_API BOOL __stdcall PlayM4_InitDDrawDevice();
  180. PLAYM4_API void __stdcall PlayM4_ReleaseDDrawDevice();
  181. PLAYM4_API DWORD __stdcall PlayM4_GetDDrawDeviceTotalNums();
  182. PLAYM4_API BOOL __stdcall PlayM4_SetDDrawDevice(LONG nPort,DWORD nDeviceNum);
  183. PLAYM4_API BOOL __stdcall PlayM4_GetDDrawDeviceInfo(DWORD nDeviceNum,LPSTR lpDriverDescription,DWORD nDespLen,LPSTR lpDriverName ,DWORD nNameLen,HMONITOR *hhMonitor);
  184. PLAYM4_API int __stdcall PlayM4_GetCapsEx(DWORD nDDrawDeviceNum);
  185. #endif
  186. PLAYM4_API BOOL __stdcall PlayM4_ThrowBFrameNum(LONG nPort,DWORD nNum);
  187. ////////////////ver 2.5 added///////////////////////////////////////
  188. PLAYM4_API BOOL __stdcall PlayM4_SetDisplayType(LONG nPort,LONG nType);
  189. PLAYM4_API long __stdcall PlayM4_GetDisplayType(LONG nPort);
  190. ////////////////ver 3.0 added///////////////////////////////////////
  191. PLAYM4_API BOOL __stdcall PlayM4_SetDecCBStream(LONG nPort,DWORD nStream);
  192. PLAYM4_API BOOL __stdcall PlayM4_SetDisplayRegion(LONG nPort,DWORD nRegionNum, RECT *pSrcRect, HWND hDestWnd, BOOL bEnable);
  193. PLAYM4_API BOOL __stdcall PlayM4_RefreshPlayEx(LONG nPort,DWORD nRegionNum);
  194. #if (WINVER > 0x0400)
  195. //Note: The funtion must be builded under win2000 or above with Microsoft Platform sdk.
  196. // You can download the sdk from http://www.microsoft.com/msdownload/platformsdk/sdkupdate/;
  197. PLAYM4_API BOOL __stdcall PlayM4_SetDDrawDeviceEx(LONG nPort,DWORD nRegionNum,DWORD nDeviceNum);
  198. #endif
  199. /////////////////v3.2 added/////////////////////////////////////////
  200. PLAYM4_API BOOL __stdcall PlayM4_GetRefValue(LONG nPort,BYTE *pBuffer, DWORD *pSize);
  201. PLAYM4_API BOOL __stdcall PlayM4_SetRefValue(LONG nPort,BYTE *pBuffer, DWORD nSize);
  202. PLAYM4_API BOOL __stdcall PlayM4_OpenStreamEx(LONG nPort,PBYTE pFileHeadBuf,DWORD nSize,DWORD nBufPoolSize);
  203. PLAYM4_API BOOL __stdcall PlayM4_CloseStreamEx(LONG nPort);
  204. PLAYM4_API BOOL __stdcall PlayM4_InputVideoData(LONG nPort,PBYTE pBuf,DWORD nSize);
  205. PLAYM4_API BOOL __stdcall PlayM4_InputAudioData(LONG nPort,PBYTE pBuf,DWORD nSize);
  206. PLAYM4_API BOOL __stdcall PlayM4_RigisterDrawFun(LONG nPort,void (CALLBACK* DrawFun)(long nPort,HDC hDc,LONG nUser),LONG nUser);
  207. //////////////////v3.4/////////////////////////////////////////////////////
  208. PLAYM4_API BOOL __stdcall PlayM4_SetTimerType(LONG nPort,DWORD nTimerType,DWORD nReserved);
  209. PLAYM4_API BOOL __stdcall PlayM4_GetTimerType(LONG nPort,DWORD *pTimerType,DWORD *pReserved);
  210. PLAYM4_API BOOL __stdcall PlayM4_ResetBuffer(LONG nPort,DWORD nBufType);
  211. PLAYM4_API DWORD __stdcall PlayM4_GetBufferValue(LONG nPort,DWORD nBufType);
  212. //////////////////V3.6/////////////////////////////////////////////////////////
  213. PLAYM4_API BOOL __stdcall PlayM4_AdjustWaveAudio(LONG nPort,LONG nCoefficient);
  214. PLAYM4_API BOOL __stdcall PlayM4_SetVerifyCallBack(LONG nPort, DWORD nBeginTime, DWORD nEndTime, void (__stdcall * funVerify)(long nPort, FRAME_POS * pFilePos, DWORD bIsVideo, DWORD nUser), DWORD nUser);
  215. PLAYM4_API BOOL __stdcall PlayM4_SetAudioCallBack(LONG nPort, void (__stdcall * funAudio)(long nPort, char * pAudioBuf, long nSize, long nStamp, long nType, long nUser), long nUser);
  216. PLAYM4_API BOOL __stdcall PlayM4_SetEncTypeChangeCallBack(LONG nPort,void(CALLBACK *funEncChange)(long nPort,long nUser),long nUser);
  217. PLAYM4_API BOOL __stdcall PlayM4_SetColor(LONG nPort, DWORD nRegionNum, int nBrightness, int nContrast, int nSaturation, int nHue);
  218. PLAYM4_API BOOL __stdcall PlayM4_GetColor(LONG nPort, DWORD nRegionNum, int *pBrightness, int *pContrast, int *pSaturation, int *pHue);
  219. PLAYM4_API BOOL __stdcall PlayM4_SetEncChangeMsg(LONG nPort,HWND hWnd,UINT nMsg);
  220. PLAYM4_API BOOL __stdcall PlayM4_GetOriginalFrameCallBack(LONG nPort, BOOL bIsChange,BOOL bNormalSpeed,long nStartFrameNum,long nStartStamp,long nFileHeader,void(CALLBACK *funGetOrignalFrame)(long nPort,FRAME_TYPE *frameType, long nUser),long nUser);
  221. PLAYM4_API BOOL __stdcall PlayM4_GetFileSpecialAttr(LONG nPort, DWORD *pTimeStamp,DWORD *pFileNum ,DWORD *pReserved);
  222. PLAYM4_API DWORD __stdcall PlayM4_GetSpecialData(LONG nPort);
  223. #endif