Leaked source code of windows server 2003
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

752 lines
24 KiB

  1. // Copyright (c) 1996 - 1999 Microsoft Corporation. All Rights Reserved.
  2. #ifndef __DYNLINK_H__
  3. #define __DYNLINK_H__
  4. // Add DYNLINKAVI to the class definition statement
  5. // for all classes that use AVI/VFW function
  6. // to enable dynamic linking to AVI. That, and #includ'ing this file
  7. // should be the only thing you need to do
  8. //
  9. // For example:
  10. // class CAVIDec : public CTransformFilter DYNLINKAVI DYNLINKVFW
  11. //
  12. // In the case where the filter is being built into its own DLL dynamic
  13. // linking is not enabled and DYNLINKAVI is #define'd to nothing.
  14. //
  15. // If the class in which you want to use dynamic linking does not
  16. // inherit from anything else use _DYNLINKAVI or _DYNLINKVFW
  17. //
  18. // For example:
  19. // class CNoInherit : _DYNLINKAVI
  20. // or
  21. // class CNoInherit : _DYNLINKVFW
  22. // or
  23. // class CNoInterit : _DYNLINKVFW DYNLINKAVI //etc...
  24. //
  25. #define NODRAWDIB
  26. #define NOAVIFMT
  27. #include <vfw.h> // we need the avi definitions
  28. #include <urlmon.h>
  29. #ifdef FILTER_DLL
  30. #define DYNLINKAVI
  31. #define DYNLINKVFW
  32. #define DYNLINKACM
  33. #define DYNLINKURLMON
  34. #define _DYNLINKAVI
  35. #define _DYNLINKVFW
  36. #define _DYNLINKACM
  37. #define _DYNLINKURLMON
  38. #else
  39. // Add DYNLINKAVI at the end of the class definition statement
  40. // for all classes that use AVI/VFW function
  41. // to enable dynamic linking to AVI. That, and #includ'ing this file
  42. // should be the only thing you need to do
  43. // define string that will bind dynamic linking to the class definition
  44. #define DYNLINKAVI , CAVIDynLink
  45. #define DYNLINKVFW , CVFWDynLink
  46. #define DYNLINKACM , CACMDynLink
  47. #define DYNLINKURLMON , CURLMonDynLink
  48. // for those classes that have no inheritance and still want dynamic linking
  49. #define _DYNLINKAVI CAVIDynLink
  50. #define _DYNLINKVFW CVFWDynLink
  51. #define _DYNLINKACM CACMDynLink
  52. #define _DYNLINKURLMON CURLMonDynLink
  53. //
  54. // typedef the AVIFILE API set that we redirect
  55. //
  56. typedef HRESULT (STDAPICALLTYPE *pAVIFileOpenW )(PAVIFILE FAR * ppfile, LPCWSTR szFile, UINT uMode, LPCLSID lpHandler);
  57. typedef HRESULT (STDAPICALLTYPE *pAVIStreamRead)(PAVISTREAM pavi, LONG lStart, LONG lSamples, LPVOID lpBuffer, LONG cbBuffer, LONG FAR * plBytes, LONG FAR * plSamples);
  58. typedef LONG (STDAPICALLTYPE *pAVIStreamStart) (PAVISTREAM pavi);
  59. typedef LONG (STDAPICALLTYPE *pAVIStreamLength) (PAVISTREAM pavi);
  60. typedef LONG (STDAPICALLTYPE *pAVIStreamTimeToSample)(PAVISTREAM pavi, LONG lTime);
  61. typedef LONG (STDAPICALLTYPE *pAVIStreamSampleToTime)(PAVISTREAM pavi, LONG lSample);
  62. typedef HRESULT (STDAPICALLTYPE *pAVIStreamBeginStreaming)(PAVISTREAM pavi, LONG lStart, LONG lEnd, LONG lRate);
  63. typedef HRESULT (STDAPICALLTYPE *pAVIStreamEndStreaming)(PAVISTREAM pavi);
  64. typedef LONG (STDAPICALLTYPE *pAVIStreamFindSample)(PAVISTREAM pavi, LONG lPos, LONG lFlags);
  65. #undef AVIStreamEnd // sigh... nasty AVI macro
  66. //
  67. // Class to link dynamically to AVIFIL32.DLL entry points
  68. //
  69. class CAVIDynLink {
  70. private:
  71. static HMODULE m_hAVIFile32; // handle to AVIFIL32
  72. static LONG m_dynlinkCount; // instance count for this process
  73. static CRITICAL_SECTION m_LoadAVILock; // serialise constructor/destructor
  74. public:
  75. static void CAVIDynLinkLoad() {
  76. InitializeCriticalSection(&CAVIDynLink::m_LoadAVILock); // serialise constructor/destructor
  77. }
  78. static void CAVIDynLinkUnload() {
  79. DeleteCriticalSection(&CAVIDynLink::m_LoadAVILock); // serialise constructor/destructor
  80. }
  81. static void AVIFileInit(void);
  82. static void AVIFileExit(void);
  83. static HRESULT AVIFileOpenW (PAVIFILE FAR * ppfile, LPCWSTR szFile,
  84. UINT uMode, LPCLSID lpHandler);
  85. static HRESULT AVIStreamRead(PAVISTREAM pavi,
  86. LONG lStart,
  87. LONG lSamples,
  88. LPVOID lpBuffer,
  89. LONG cbBuffer,
  90. LONG FAR * plBytes,
  91. LONG FAR * plSamples)
  92. {
  93. return(pavi->Read(lStart, lSamples, lpBuffer, cbBuffer, plBytes, plSamples));
  94. }
  95. static LONG AVIStreamStart(PAVISTREAM pavi)
  96. {
  97. AVISTREAMINFOW aviStreamInfo;
  98. HRESULT hr;
  99. hr = pavi->Info(&aviStreamInfo, sizeof(aviStreamInfo));
  100. if (hr!=NOERROR) {
  101. aviStreamInfo.dwStart=0;
  102. }
  103. return(LONG)aviStreamInfo.dwStart;
  104. //return(((pAVIStreamStart)aAVIEntries[indxAVIStreamStart])(pavi));
  105. }
  106. static LONG AVIStreamLength(PAVISTREAM pavi)
  107. {
  108. AVISTREAMINFOW aviStreamInfo;
  109. HRESULT hr;
  110. hr = pavi->Info(&aviStreamInfo, sizeof(aviStreamInfo));
  111. if (hr!=NOERROR) {
  112. aviStreamInfo.dwLength=1;
  113. }
  114. return (LONG)aviStreamInfo.dwLength;
  115. //return(((pAVIStreamLength)aAVIEntries[indxAVIStreamLength])(pavi));
  116. }
  117. /*static*/ LONG AVIStreamTimeToSample (PAVISTREAM pavi, LONG lTime);
  118. /*static*/ LONG AVIStreamSampleToTime (PAVISTREAM pavi, LONG lSample);
  119. /*static*/ HRESULT AVIStreamBeginStreaming(PAVISTREAM pavi, LONG lStart, LONG lEnd, LONG lRate);
  120. /*static*/ HRESULT AVIStreamEndStreaming(PAVISTREAM pavi);
  121. static LONG AVIStreamFindSample(PAVISTREAM pavi, LONG lPos, LONG lFlags)
  122. {
  123. // The use of AVIStreamFindSample within Quartz ALWAYS set the type
  124. // and direction
  125. ASSERT(lFlags & FIND_TYPE);
  126. ASSERT(lFlags & FIND_DIR);
  127. return(pavi->FindSample(lPos, lFlags));
  128. //return(((pAVIStreamFindSample)aAVIEntries[indxAVIStreamFindSample])(pavi));
  129. }
  130. static LONG AVIStreamEnd(PAVISTREAM pavi)
  131. {
  132. AVISTREAMINFOW aviStreamInfo;
  133. HRESULT hr;
  134. hr = pavi->Info(&aviStreamInfo, sizeof(aviStreamInfo));
  135. if (hr!=NOERROR) {
  136. aviStreamInfo.dwStart=0;
  137. aviStreamInfo.dwLength=1;
  138. }
  139. return (LONG)aviStreamInfo.dwLength + (LONG)aviStreamInfo.dwStart;
  140. //return(((pAVIStreamStart)aAVIEntries[indxAVIStreamStart])(pavi)
  141. // + ((pAVIStreamLength)aAVIEntries[indxAVIStreamLength])(pavi));
  142. }
  143. CAVIDynLink();
  144. ~CAVIDynLink();
  145. private:
  146. // make copy and assignment inaccessible
  147. CAVIDynLink(const CAVIDynLink &refAVIDynLink);
  148. CAVIDynLink &operator=(const CAVIDynLink &refAVIDynLink);
  149. };
  150. //
  151. // Class for dynamic linking to MSVFW32.DLL
  152. //
  153. // Most of the IC API set are macros that call ICSendMessage. There are
  154. // a couple of awkward ones that we expand inline.
  155. //
  156. //
  157. // Dynamically loaded array of entry points
  158. //
  159. extern FARPROC aVFWEntries[];
  160. //
  161. // List of index entries into the array for each redirected API
  162. //
  163. #define indxICClose 0
  164. #define indxICSendMessage 1
  165. #define indxICLocate 2
  166. #define indxICOpen 3
  167. #define indxICInfo 4
  168. #define indxICGetInfo 5
  169. //
  170. // typedef the API set that we redirect
  171. //
  172. typedef LRESULT (WINAPI *pICClose)(HIC hic);
  173. typedef HIC (WINAPI *pICLocate)(DWORD fccType, DWORD fccHandler, LPBITMAPINFOHEADER lpbiIn, LPBITMAPINFOHEADER lpbiOut, WORD wFlags);
  174. typedef LRESULT (WINAPI *pICSendMessage)(HIC hic, UINT msg, DWORD_PTR dw1, DWORD_PTR dw2);
  175. typedef HIC (VFWAPI *pICOpen)(DWORD fccType, DWORD fccHandler, UINT wMode);
  176. typedef BOOL (VFWAPI *pICInfo)(DWORD fccType, DWORD fccHandler, ICINFO FAR* lpicinfo);
  177. typedef BOOL (VFWAPI *pICGetInfo)(HIC hic, ICINFO FAR* lpicinfo, DWORD cb);
  178. class CVFWDynLink {
  179. private:
  180. static HMODULE m_hVFW; // handle to MSVFW32
  181. static LONG m_vfwlinkCount; // instance count for this process
  182. static CRITICAL_SECTION m_LoadVFWLock; // serialise constructor/destructor
  183. public:
  184. static void CVFWDynLinkLoad()
  185. {
  186. InitializeCriticalSection(&m_LoadVFWLock); // serialise constructor/destructor
  187. }
  188. static void CVFWDynLinkUnload()
  189. {
  190. DeleteCriticalSection(&m_LoadVFWLock); // serialise constructor/destructor
  191. }
  192. static DWORD_PTR ICDecompress(
  193. HIC hic,
  194. DWORD dwFlags, // flags (from AVI index...)
  195. LPBITMAPINFOHEADER lpbiFormat, // BITMAPINFO of compressed data
  196. // biSizeImage has the chunk size
  197. // biCompression has the ckid (AVI only)
  198. LPVOID lpData, // data
  199. LPBITMAPINFOHEADER lpbi, // DIB to decompress to
  200. LPVOID lpBits)
  201. {
  202. ICDECOMPRESS icd;
  203. icd.dwFlags = dwFlags;
  204. icd.lpbiInput = lpbiFormat;
  205. icd.lpInput = lpData;
  206. icd.lpbiOutput = lpbi;
  207. icd.lpOutput = lpBits;
  208. icd.ckid = 0;
  209. return ICSendMessage(hic, ICM_DECOMPRESS, (DWORD_PTR)(LPVOID)&icd, sizeof(ICDECOMPRESS));
  210. }
  211. static LRESULT CVFWDynLink::ICClose(HIC hic)
  212. {
  213. return((((pICClose)aVFWEntries[indxICClose]))(hic));
  214. }
  215. static HIC ICLocate(DWORD fccType, DWORD fccHandler, LPBITMAPINFOHEADER lpbiIn, LPBITMAPINFOHEADER lpbiOut, WORD wFlags)
  216. {
  217. return((((pICLocate)aVFWEntries[indxICLocate]))(fccType, fccHandler, lpbiIn, lpbiOut, wFlags));
  218. }
  219. static LRESULT ICSendMessage(HIC hic, UINT msg, DWORD_PTR dw1, DWORD_PTR dw2)
  220. {
  221. return((((pICSendMessage)aVFWEntries[indxICSendMessage]))(hic, msg, dw1, dw2));
  222. }
  223. static HIC ICOpen(DWORD fccType, DWORD fccHandler, UINT wMode)
  224. {
  225. return((((pICOpen)aVFWEntries[indxICOpen]))(fccType, fccHandler, wMode));
  226. }
  227. static BOOL ICInfo(DWORD fccType, DWORD fccHandler, ICINFO* lpicinfo)
  228. {
  229. return((((pICInfo)aVFWEntries[indxICInfo]))(fccType, fccHandler, lpicinfo));
  230. }
  231. static BOOL ICGetInfo(HIC hic, ICINFO* lpicinfo, DWORD cb)
  232. {
  233. return((((pICGetInfo)aVFWEntries[indxICGetInfo]))(hic, lpicinfo, cb));
  234. }
  235. static LRESULT ICDecompressEx(
  236. HIC hic,
  237. DWORD dwFlags,
  238. LPBITMAPINFOHEADER lpbiSrc,
  239. LPVOID lpSrc,
  240. int xSrc,int ySrc,int dxSrc,int dySrc,LPBITMAPINFOHEADER lpbiDst,
  241. LPVOID lpDst,
  242. int xDst,int yDst,int dxDst,int dyDst)
  243. {
  244. ICDECOMPRESSEX ic;
  245. ic.dwFlags = dwFlags;
  246. ic.lpbiSrc = lpbiSrc;
  247. ic.lpSrc = lpSrc;
  248. ic.xSrc = xSrc;
  249. ic.ySrc = ySrc;
  250. ic.dxSrc = dxSrc;
  251. ic.dySrc = dySrc;
  252. ic.lpbiDst = lpbiDst;
  253. ic.lpDst = lpDst;
  254. ic.xDst = xDst;
  255. ic.yDst = yDst;
  256. ic.dxDst = dxDst;
  257. ic.dyDst = dyDst;
  258. // note that ICM swaps round the length and pointer
  259. // length in lparam2, pointer in lparam1
  260. return ICSendMessage(hic, ICM_DECOMPRESSEX, (DWORD_PTR)&ic, sizeof(ic));
  261. }
  262. static LRESULT ICDecompressExQuery(
  263. HIC hic,
  264. DWORD dwFlags,
  265. LPBITMAPINFOHEADER lpbiSrc,
  266. LPVOID lpSrc,
  267. int xSrc,int ySrc,int dxSrc,int dySrc,
  268. LPBITMAPINFOHEADER lpbiDst,
  269. LPVOID lpDst,
  270. int xDst,int yDst,int dxDst,int dyDst)
  271. {
  272. ICDECOMPRESSEX ic;
  273. ic.dwFlags = dwFlags;
  274. ic.lpbiSrc = lpbiSrc;
  275. ic.lpSrc = lpSrc;
  276. ic.xSrc = xSrc;
  277. ic.ySrc = ySrc;
  278. ic.dxSrc = dxSrc;
  279. ic.dySrc = dySrc;
  280. ic.lpbiDst = lpbiDst;
  281. ic.lpDst = lpDst;
  282. ic.xDst = xDst;
  283. ic.yDst = yDst;
  284. ic.dxDst = dxDst;
  285. ic.dyDst = dyDst;
  286. // note that ICM swaps round the length and pointer
  287. // length in lparam2, pointer in lparam1
  288. return ICSendMessage(hic, ICM_DECOMPRESSEX_QUERY, (DWORD_PTR)&ic, sizeof(ic));
  289. }
  290. static LRESULT ICDecompressExBegin(
  291. HIC hic,
  292. DWORD dwFlags,
  293. LPBITMAPINFOHEADER lpbiSrc,
  294. LPVOID lpSrc,
  295. int xSrc,int ySrc,int dxSrc,int dySrc,
  296. LPBITMAPINFOHEADER lpbiDst,
  297. LPVOID lpDst,
  298. int xDst,int yDst,int dxDst,int dyDst)
  299. {
  300. ICDECOMPRESSEX ic;
  301. ic.dwFlags = dwFlags;
  302. ic.lpbiSrc = lpbiSrc;
  303. ic.lpSrc = lpSrc;
  304. ic.xSrc = xSrc;
  305. ic.ySrc = ySrc;
  306. ic.dxSrc = dxSrc;
  307. ic.dySrc = dySrc;
  308. ic.lpbiDst = lpbiDst;
  309. ic.lpDst = lpDst;
  310. ic.xDst = xDst;
  311. ic.yDst = yDst;
  312. ic.dxDst = dxDst;
  313. ic.dyDst = dyDst;
  314. // note that ICM swaps round the length and pointer
  315. // length in lparam2, pointer in lparam1
  316. return ICSendMessage(hic, ICM_DECOMPRESSEX_BEGIN, (DWORD_PTR)&ic, sizeof(ic));
  317. }
  318. static DWORD_PTR VFWAPIV ICDrawBegin(
  319. HIC hic,
  320. DWORD dwFlags, // flags
  321. HPALETTE hpal, // palette to draw with
  322. HWND hwnd, // window to draw to
  323. HDC hdc, // HDC to draw to
  324. int xDst, // destination rectangle
  325. int yDst,
  326. int dxDst,
  327. int dyDst,
  328. LPBITMAPINFOHEADER lpbi, // format of frame to draw
  329. int xSrc, // source rectangle
  330. int ySrc,
  331. int dxSrc,
  332. int dySrc,
  333. DWORD dwRate, // frames/second = (dwRate/dwScale)
  334. DWORD dwScale)
  335. {
  336. ICDRAWBEGIN icdraw;
  337. icdraw.dwFlags = dwFlags;
  338. icdraw.hpal = hpal;
  339. icdraw.hwnd = hwnd;
  340. icdraw.hdc = hdc;
  341. icdraw.xDst = xDst;
  342. icdraw.yDst = yDst;
  343. icdraw.dxDst = dxDst;
  344. icdraw.dyDst = dyDst;
  345. icdraw.lpbi = lpbi;
  346. icdraw.xSrc = xSrc;
  347. icdraw.ySrc = ySrc;
  348. icdraw.dxSrc = dxSrc;
  349. icdraw.dySrc = dySrc;
  350. icdraw.dwRate = dwRate;
  351. icdraw.dwScale = dwScale;
  352. return ICSendMessage(hic, ICM_DRAW_BEGIN, (DWORD_PTR)(LPVOID)&icdraw, sizeof(ICDRAWBEGIN));
  353. }
  354. static DWORD_PTR VFWAPIV ICDraw(
  355. HIC hic,
  356. DWORD dwFlags, // flags
  357. LPVOID lpFormat, // format of frame to decompress
  358. LPVOID lpData, // frame data to decompress
  359. DWORD cbData, // size in bytes of data
  360. LONG lTime) // time to draw this frame (see drawbegin dwRate and dwScale)
  361. {
  362. ICDRAW icdraw;
  363. icdraw.dwFlags = dwFlags;
  364. icdraw.lpFormat = lpFormat;
  365. icdraw.lpData = lpData;
  366. icdraw.cbData = cbData;
  367. icdraw.lTime = lTime;
  368. return ICSendMessage(hic, ICM_DRAW, (DWORD_PTR)(LPVOID)&icdraw, sizeof(ICDRAW));
  369. }
  370. CVFWDynLink();
  371. ~CVFWDynLink();
  372. private:
  373. // make copy and assignment inaccessible
  374. CVFWDynLink(const CVFWDynLink &refVFWDynLink);
  375. CVFWDynLink &operator=(const CVFWDynLink &refVFWDynLink);
  376. };
  377. //
  378. // Class for dynamic linking to MSACM32.DLL
  379. //
  380. //
  381. // Dynamically loaded array of entry points
  382. //
  383. extern FARPROC aACMEntries[];
  384. //
  385. // List of index entries into the array for each redirected API
  386. //
  387. #define indxacmStreamConvert 0
  388. #define indxacmStreamSize 1
  389. #define indxacmStreamPrepareHeader 2
  390. #define indxacmMetrics 3
  391. #define indxacmStreamUnprepareHeader 4
  392. #define indxacmStreamOpen 5
  393. #define indxacmFormatSuggest 6
  394. #define indxacmStreamClose 7
  395. #ifdef UNICODE
  396. # define indxacmFormatEnumW 8
  397. #else
  398. # define indxacmFormatEnumA 8
  399. #endif
  400. //
  401. // typedef the API set that we redirect
  402. //
  403. typedef MMRESULT (ACMAPI *pacmStreamConvert)(HACMSTREAM has, LPACMSTREAMHEADER pash, DWORD fdwConvert);
  404. typedef MMRESULT (ACMAPI *pacmStreamSize)
  405. (
  406. HACMSTREAM has,
  407. DWORD cbInput,
  408. LPDWORD pdwOutputBytes,
  409. DWORD fdwSize
  410. );
  411. typedef MMRESULT (ACMAPI *pacmStreamPrepareHeader)
  412. (
  413. HACMSTREAM has,
  414. LPACMSTREAMHEADER pash,
  415. DWORD fdwPrepare
  416. );
  417. typedef MMRESULT (ACMAPI *pacmMetrics)
  418. (
  419. HACMOBJ hao,
  420. UINT uMetric,
  421. LPVOID pMetric
  422. );
  423. typedef MMRESULT (ACMAPI *pacmStreamUnprepareHeader)
  424. (
  425. HACMSTREAM has,
  426. LPACMSTREAMHEADER pash,
  427. DWORD fdwUnprepare
  428. );
  429. typedef MMRESULT (ACMAPI *pacmStreamOpen)
  430. (
  431. LPHACMSTREAM phas, // pointer to stream handle
  432. HACMDRIVER had, // optional driver handle
  433. LPWAVEFORMATEX pwfxSrc, // source format to convert
  434. LPWAVEFORMATEX pwfxDst, // required destination format
  435. LPWAVEFILTER pwfltr, // optional filter
  436. DWORD_PTR dwCallback, // callback
  437. DWORD_PTR dwInstance, // callback instance data
  438. DWORD fdwOpen // ACM_STREAMOPENF_* and CALLBACK_*
  439. );
  440. typedef MMRESULT (ACMAPI *pacmFormatSuggest)
  441. (
  442. HACMDRIVER had,
  443. LPWAVEFORMATEX pwfxSrc,
  444. LPWAVEFORMATEX pwfxDst,
  445. DWORD cbwfxDst,
  446. DWORD fdwSuggest
  447. );
  448. typedef MMRESULT (ACMAPI *pacmStreamClose)
  449. (
  450. HACMSTREAM has,
  451. DWORD fdwClose
  452. );
  453. typedef MMRESULT (ACMAPI *pacmFormatEnumA)
  454. (
  455. HACMDRIVER had,
  456. LPACMFORMATDETAILSA pafd,
  457. ACMFORMATENUMCBA fnCallback,
  458. DWORD_PTR dwInstance,
  459. DWORD fdwEnum
  460. );
  461. typedef MMRESULT (ACMAPI *pacmFormatEnumW)
  462. (
  463. HACMDRIVER had,
  464. LPACMFORMATDETAILSW pafd,
  465. ACMFORMATENUMCBW fnCallback,
  466. DWORD_PTR dwInstance,
  467. DWORD fdwEnum
  468. );
  469. class CACMDynLink {
  470. private:
  471. static HMODULE m_hACM; // handle to MSVFW32
  472. static LONG m_ACMlinkCount; // instance count for this process
  473. static CRITICAL_SECTION m_LoadACMLock; // serialise constructor/destructor
  474. public:
  475. static void CACMDynLinkLoad()
  476. {
  477. InitializeCriticalSection(&m_LoadACMLock); // serialise constructor/destructor
  478. }
  479. static void CACMDynLinkUnload()
  480. {
  481. DeleteCriticalSection(&m_LoadACMLock); // serialise constructor/destructor
  482. }
  483. static MMRESULT ACMAPI acmStreamConvert(HACMSTREAM has, LPACMSTREAMHEADER pash, DWORD fdwConvert)
  484. {
  485. return((((pacmStreamConvert)aACMEntries[indxacmStreamConvert]))(has, pash, fdwConvert));
  486. }
  487. static MMRESULT ACMAPI acmStreamSize
  488. (
  489. HACMSTREAM has,
  490. DWORD cbInput,
  491. LPDWORD pdwOutputBytes,
  492. DWORD fdwSize
  493. )
  494. {
  495. return((((pacmStreamSize)aACMEntries[indxacmStreamSize]))(has, cbInput, pdwOutputBytes, fdwSize));
  496. }
  497. static MMRESULT ACMAPI acmStreamPrepareHeader
  498. (
  499. HACMSTREAM has,
  500. LPACMSTREAMHEADER pash,
  501. DWORD fdwPrepare
  502. )
  503. {
  504. return((((pacmStreamPrepareHeader)aACMEntries[indxacmStreamPrepareHeader]))(has, pash, fdwPrepare));
  505. }
  506. static MMRESULT ACMAPI acmMetrics
  507. (
  508. HACMOBJ hao,
  509. UINT uMetric,
  510. LPVOID pMetric
  511. )
  512. {
  513. return((((pacmMetrics)aACMEntries[indxacmMetrics]))(hao, uMetric, pMetric));
  514. }
  515. static MMRESULT ACMAPI acmStreamUnprepareHeader
  516. (
  517. HACMSTREAM has,
  518. LPACMSTREAMHEADER pash,
  519. DWORD fdwUnprepare
  520. )
  521. {
  522. return((((pacmStreamUnprepareHeader)aACMEntries[indxacmStreamUnprepareHeader]))(has, pash, fdwUnprepare));
  523. }
  524. static MMRESULT ACMAPI acmStreamOpen
  525. (
  526. LPHACMSTREAM phas, // pointer to stream handle
  527. HACMDRIVER had, // optional driver handle
  528. LPWAVEFORMATEX pwfxSrc, // source format to convert
  529. LPWAVEFORMATEX pwfxDst, // required destination format
  530. LPWAVEFILTER pwfltr, // optional filter
  531. DWORD_PTR dwCallback, // callback
  532. DWORD_PTR dwInstance, // callback instance data
  533. DWORD fdwOpen // ACM_STREAMOPENF_* and CALLBACK_*
  534. )
  535. {
  536. return((((pacmStreamOpen)aACMEntries[indxacmStreamOpen]))(phas,had,pwfxSrc,pwfxDst,pwfltr,dwCallback,dwInstance,fdwOpen));
  537. }
  538. static MMRESULT ACMAPI acmFormatSuggest
  539. (
  540. HACMDRIVER had,
  541. LPWAVEFORMATEX pwfxSrc,
  542. LPWAVEFORMATEX pwfxDst,
  543. DWORD cbwfxDst,
  544. DWORD fdwSuggest
  545. )
  546. {
  547. return((((pacmFormatSuggest)aACMEntries[indxacmFormatSuggest]))(had, pwfxSrc, pwfxDst, cbwfxDst, fdwSuggest));
  548. }
  549. static MMRESULT ACMAPI acmStreamClose
  550. (
  551. HACMSTREAM has,
  552. DWORD fdwClose
  553. )
  554. {
  555. return((((pacmStreamClose)aACMEntries[indxacmStreamClose]))(has, fdwClose));
  556. }
  557. #ifdef UNICODE
  558. static MMRESULT ACMAPI acmFormatEnumW
  559. (
  560. HACMDRIVER had,
  561. LPACMFORMATDETAILSW pafd,
  562. ACMFORMATENUMCBW fnCallback,
  563. DWORD_PTR dwInstance,
  564. DWORD fdwEnum
  565. )
  566. {
  567. return((((pacmFormatEnumW)aACMEntries[indxacmFormatEnumW]))(had,pafd,fnCallback,dwInstance,fdwEnum));
  568. }
  569. #else
  570. static MMRESULT ACMAPI acmFormatEnumA
  571. (
  572. HACMDRIVER had,
  573. LPACMFORMATDETAILSA pafd,
  574. ACMFORMATENUMCBA fnCallback,
  575. DWORD_PTR dwInstance,
  576. DWORD fdwEnum
  577. )
  578. {
  579. return((((pacmFormatEnumA)aACMEntries[indxacmFormatEnumA]))(had,pafd,fnCallback,dwInstance,fdwEnum));
  580. }
  581. #endif
  582. CACMDynLink();
  583. ~CACMDynLink();
  584. private:
  585. // make copy and assignment inaccessible
  586. CACMDynLink(const CVFWDynLink &refVFWDynLink);
  587. CACMDynLink &operator=(const CVFWDynLink &refVFWDynLink);
  588. };
  589. //
  590. // Class for dynamic linking to URLMON.DLL
  591. //
  592. //
  593. // Dynamically loaded array of entry points
  594. //
  595. extern FARPROC aURLMonEntries[];
  596. //
  597. // List of index entries into the array for each redirected API
  598. //
  599. #define indxurlmonCreateURLMoniker 0
  600. #define indxurlmonRegisterCallback 1
  601. #define indxurlmonRevokeCallback 2
  602. //
  603. // typedef the API set that we redirect
  604. //
  605. typedef HRESULT (STDAPICALLTYPE * pCreateURLMoniker) (LPMONIKER pMkCtx, LPCWSTR szURL, LPMONIKER FAR * ppmk);
  606. typedef HRESULT (STDAPICALLTYPE * pRegisterBindStatusCallback)(LPBC pBC, IBindStatusCallback *pBSCb,
  607. IBindStatusCallback** ppBSCBPrev, DWORD dwReserved);
  608. typedef HRESULT (STDAPICALLTYPE * pRevokeBindStatusCallback)(LPBC pBC, IBindStatusCallback *pBSCb);
  609. class CURLMonDynLink {
  610. private:
  611. static HMODULE m_hURLMon; // handle to URLMON
  612. static LONG m_URLMonlinkCount; // instance count for this process
  613. static CRITICAL_SECTION m_LoadURLMonLock; // serialise constructor/destructor
  614. public:
  615. static void CURLMonDynLinkLoad()
  616. {
  617. InitializeCriticalSection(&m_LoadURLMonLock); // serialise constructor/destructor
  618. }
  619. static void CURLMonDynLinkUnload()
  620. {
  621. DeleteCriticalSection(&m_LoadURLMonLock); // serialise constructor/destructor
  622. }
  623. static HRESULT STDAPICALLTYPE CreateURLMoniker (LPMONIKER pMkCtx, LPCWSTR szURL, LPMONIKER FAR * ppmk)
  624. {
  625. return((((pCreateURLMoniker)aURLMonEntries[indxurlmonCreateURLMoniker]))
  626. (pMkCtx, szURL, ppmk));
  627. }
  628. static HRESULT STDAPICALLTYPE RegisterBindStatusCallback (LPBC pBC, IBindStatusCallback *pBSCb,
  629. IBindStatusCallback** ppBSCBPrev, DWORD dwReserved)
  630. {
  631. return((((pRegisterBindStatusCallback)aURLMonEntries[indxurlmonRegisterCallback]))
  632. (pBC, pBSCb, ppBSCBPrev, dwReserved));
  633. }
  634. static HRESULT STDAPICALLTYPE RevokeBindStatusCallback (LPBC pBC, IBindStatusCallback *pBSCb)
  635. {
  636. return((((pRevokeBindStatusCallback)aURLMonEntries[indxurlmonRevokeCallback]))
  637. (pBC, pBSCb));
  638. }
  639. CURLMonDynLink();
  640. ~CURLMonDynLink();
  641. private:
  642. // make copy and assignment inaccessible
  643. CURLMonDynLink(const CVFWDynLink &refVFWDynLink);
  644. CURLMonDynLink &operator=(const CVFWDynLink &refVFWDynLink);
  645. };
  646. #endif // FILTER_DLL
  647. #endif // __DYNLINK_H__