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.

316 lines
9.5 KiB

  1. #include "extra.h"
  2. #include "fileshar.h"
  3. #include "aviidx.h"
  4. #include "buffer.h"
  5. /* - - - - - - - - */
  6. /*
  7. ** Copyright (C) Microsoft Corporation 1993. All rights reserved.
  8. */
  9. /* - - - - - - - - */
  10. #define CFactoryImpl CI // Can't handle long exported names
  11. #define CAVIFileImpl CF // Can't handle long exported names
  12. #define CAVIStreamImpl CS // Can't handle long exported names
  13. /* Remove warning of using object during initialization. */
  14. #pragma warning(disable:4355)
  15. /* - - - - - - - - */
  16. #define implement struct
  17. #define implementations private
  18. /*
  19. ** _StdClassImplementations
  20. ** Defines the standard implementations for a class object.
  21. */
  22. #define _StdClassImplementations(Impl) \
  23. STDMETHODIMP QueryInterface(REFIID riid, LPVOID FAR* ppv); \
  24. STDMETHODIMP_(ULONG) AddRef(); \
  25. STDMETHODIMP_(ULONG) Release()
  26. /* - - - - - - - - */
  27. class FAR CAVIFileCF {
  28. public:
  29. static HRESULT Create(const CLSID FAR& rclsid, REFIID riid, LPVOID FAR* ppv);
  30. private:
  31. CAVIFileCF(const CLSID FAR& rclsid, IUnknown FAR* FAR* ppUnknown);
  32. implementations:
  33. implement CUnknownImpl : IUnknown {
  34. public:
  35. _StdClassImplementations(CUnknownImpl);
  36. CUnknownImpl(CAVIFileCF FAR* pAVIFileCF);
  37. private:
  38. CAVIFileCF FAR* m_pAVIFileCF;
  39. ULONG m_refs;
  40. };
  41. implement CFactoryImpl : IClassFactory {
  42. public:
  43. _StdClassImplementations(CFactoryImpl);
  44. CFactoryImpl(CAVIFileCF FAR* pAVIFileCF);
  45. STDMETHODIMP CreateInstance(IUnknown FAR* pUnknownOuter, REFIID riid, LPVOID FAR* ppv);
  46. STDMETHODIMP LockServer(BOOL fLock);
  47. private:
  48. CAVIFileCF FAR* m_pAVIFileCF;
  49. };
  50. public:
  51. CUnknownImpl m_Unknown;
  52. CFactoryImpl m_Factory;
  53. public:
  54. CLSID m_clsid;
  55. };
  56. /* - - - - - - - - */
  57. class FAR CAVIFile;
  58. class FAR CAVIStream {
  59. public:
  60. CAVIStream(IUnknown FAR* pUnknownOuter, IUnknown FAR* FAR* ppUnknown);
  61. private:
  62. implementations:
  63. implement CUnknownImpl : IUnknown {
  64. public:
  65. _StdClassImplementations(CUnknownImpl);
  66. CUnknownImpl(CAVIStream FAR* pAVIStream);
  67. private:
  68. CAVIStream FAR* m_pAVIStream;
  69. ULONG m_refs;
  70. };
  71. implement CAVIStreamImpl : IAVIStream {
  72. public:
  73. _StdClassImplementations(CAVIStreamImpl);
  74. CAVIStreamImpl(CAVIStream FAR* pAVIStream);
  75. ~CAVIStreamImpl();
  76. STDMETHODIMP Create (THIS_ LPARAM lParam1, LPARAM lParam2);
  77. STDMETHODIMP Info (THIS_ AVISTREAMINFO FAR * psi, LONG lSize);
  78. STDMETHODIMP_(LONG) FindSample(THIS_ LONG lPos, LONG lFlags);
  79. STDMETHODIMP ReadFormat (THIS_ LONG lPos,
  80. LPVOID lpFormat, LONG FAR *cbFormat);
  81. STDMETHODIMP SetFormat (THIS_ LONG lPos,
  82. LPVOID lpFormat, LONG cbFormat);
  83. STDMETHODIMP Read (THIS_ LONG lStart, LONG lSamples,
  84. LPVOID lpBuffer, LONG cbBuffer,
  85. LONG FAR * plBytes, LONG FAR * plSamples);
  86. STDMETHODIMP Write (THIS_ LONG lStart, LONG lSamples,
  87. LPVOID lpBuffer, LONG cbBuffer,
  88. DWORD dwFlags,
  89. LONG FAR *plSampWritten,
  90. LONG FAR *plBytesWritten);
  91. STDMETHODIMP Delete (THIS_ LONG lStart, LONG lSamples);
  92. STDMETHODIMP ReadData (THIS_ DWORD fcc, LPVOID lp, LONG FAR *lpcb);
  93. STDMETHODIMP WriteData (THIS_ DWORD fcc, LPVOID lp, LONG cb);
  94. STDMETHODIMP Reserved1 (THIS);
  95. STDMETHODIMP Reserved2 (THIS);
  96. STDMETHODIMP Reserved3 (THIS);
  97. STDMETHODIMP Reserved4 (THIS);
  98. STDMETHODIMP Reserved5 (THIS);
  99. private:
  100. void ReadPalette(LONG lPos, LONG lPal, LPRGBQUAD prgb);
  101. // private functions here?
  102. CAVIStream FAR* m_pAVIStream;
  103. };
  104. implement CStreamingImpl : IAVIStreaming {
  105. public:
  106. _StdClassImplementations(CStreamingImpl);
  107. CStreamingImpl(CAVIStream FAR* pAVIStream);
  108. ~CStreamingImpl();
  109. STDMETHODIMP Begin (THIS_
  110. LONG lStart,
  111. LONG lEnd,
  112. LONG lRate);
  113. STDMETHODIMP End (THIS);
  114. private:
  115. // private functions here?
  116. CAVIStream FAR* m_pAVIStream;
  117. };
  118. struct CMarshalImpl : IMarshal {
  119. public:
  120. CMarshalImpl(CAVIStream FAR* pAVIStream);
  121. STDMETHODIMP QueryInterface(REFIID riid, LPVOID FAR* ppv);
  122. STDMETHODIMP_(ULONG) AddRef();
  123. STDMETHODIMP_(ULONG) Release();
  124. // *** IMarshal methods ***
  125. STDMETHODIMP GetUnmarshalClass (THIS_ REFIID riid, LPVOID pv,
  126. DWORD dwDestContext, LPVOID pvDestContext,
  127. DWORD mshlflags, LPCLSID pCid);
  128. STDMETHODIMP GetMarshalSizeMax (THIS_ REFIID riid, LPVOID pv,
  129. DWORD dwDestContext, LPVOID pvDestContext,
  130. DWORD mshlflags, LPDWORD pSize);
  131. STDMETHODIMP MarshalInterface (THIS_ LPSTREAM pStm, REFIID riid,
  132. LPVOID pv, DWORD dwDestContext, LPVOID pvDestContext,
  133. DWORD mshlflags);
  134. STDMETHODIMP UnmarshalInterface (THIS_ LPSTREAM pStm, REFIID riid,
  135. LPVOID FAR* ppv);
  136. STDMETHODIMP ReleaseMarshalData (THIS_ LPSTREAM pStm);
  137. STDMETHODIMP DisconnectObject (THIS_ DWORD dwReserved);
  138. CAVIStream FAR* m_pAVIStream;
  139. };
  140. public:
  141. CUnknownImpl m_Unknown;
  142. CAVIStreamImpl m_AVIStream;
  143. CMarshalImpl m_Marshal;
  144. CStreamingImpl m_Streaming;
  145. public:
  146. IUnknown FAR* m_pUnknownOuter;
  147. // AVIStream Instance data
  148. AVISTREAMINFO avistream; // stream info
  149. CAVIFile FAR * pfile;
  150. int iStream;
  151. PAVISTREAM paviBase;
  152. //
  153. // stream instance data
  154. //
  155. HSHFILE hshfile; // file I/O
  156. LONG lPal; // last palette change
  157. RGBQUAD argbq[256]; // current palette
  158. LPVOID lpFormat; // stream format
  159. LONG cbFormat;
  160. LPVOID lpData; // stream handler data
  161. LONG cbData;
  162. EXTRA extra;
  163. PBUFSYSTEM pb;
  164. BOOL fInit;
  165. PSTREAMINDEX psx;
  166. };
  167. /* - - - - - - - - */
  168. #define MAXSTREAMS 64
  169. class FAR CAVIFile {
  170. public:
  171. static HRESULT Create(IUnknown FAR* pUnknownOuter, REFIID riid, LPVOID FAR* ppv);
  172. private:
  173. CAVIFile(IUnknown FAR* pUnknownOuter, IUnknown FAR* FAR* ppUnknown);
  174. implementations:
  175. implement CUnknownImpl : IUnknown {
  176. public:
  177. _StdClassImplementations(CUnknownImpl);
  178. CUnknownImpl(CAVIFile FAR* pAVIFile);
  179. private:
  180. CAVIFile FAR* m_pAVIFile;
  181. ULONG m_refs;
  182. };
  183. implement CAVIFileImpl : IAVIFile {
  184. public:
  185. _StdClassImplementations(CAVIFileImpl);
  186. CAVIFileImpl(CAVIFile FAR* pAVIFile);
  187. ~CAVIFileImpl();
  188. STDMETHODIMP Open (THIS_
  189. LPCSTR szFile,
  190. UINT mode);
  191. STDMETHODIMP Info (THIS_
  192. AVIFILEINFO FAR * pfi,
  193. LONG lSize);
  194. STDMETHODIMP GetStream (THIS_
  195. PAVISTREAM FAR * ppStream,
  196. DWORD fccType,
  197. LONG lParam);
  198. STDMETHODIMP CreateStream (THIS_
  199. PAVISTREAM FAR * ppStream,
  200. AVISTREAMINFO FAR * psi);
  201. STDMETHODIMP Save (THIS_
  202. LPCSTR szFile,
  203. AVICOMPRESSOPTIONS FAR *lpOptions,
  204. AVISAVECALLBACK lpfnCallback);
  205. STDMETHODIMP WriteData (THIS_
  206. DWORD ckid,
  207. LPVOID lpData,
  208. LONG cbData);
  209. STDMETHODIMP ReadData (THIS_
  210. DWORD ckid,
  211. LPVOID lpData,
  212. LONG FAR *lpcbData);
  213. STDMETHODIMP EndRecord (THIS);
  214. STDMETHODIMP Reserved1 (THIS);
  215. STDMETHODIMP Reserved2 (THIS);
  216. STDMETHODIMP Reserved3 (THIS);
  217. STDMETHODIMP Reserved4 (THIS);
  218. STDMETHODIMP Reserved5 (THIS);
  219. private:
  220. // private functions here?
  221. CAVIFile FAR* m_pAVIFile;
  222. };
  223. struct CMarshalImpl : IMarshal {
  224. public:
  225. CMarshalImpl(CAVIFile FAR* pAVIFile);
  226. STDMETHODIMP QueryInterface(REFIID riid, LPVOID FAR* ppv);
  227. STDMETHODIMP_(ULONG) AddRef();
  228. STDMETHODIMP_(ULONG) Release();
  229. // *** IMarshal methods ***
  230. STDMETHODIMP GetUnmarshalClass (THIS_ REFIID riid, LPVOID pv,
  231. DWORD dwDestContext, LPVOID pvDestContext,
  232. DWORD mshlflags, LPCLSID pCid);
  233. STDMETHODIMP GetMarshalSizeMax (THIS_ REFIID riid, LPVOID pv,
  234. DWORD dwDestContext, LPVOID pvDestContext,
  235. DWORD mshlflags, LPDWORD pSize);
  236. STDMETHODIMP MarshalInterface (THIS_ LPSTREAM pStm, REFIID riid,
  237. LPVOID pv, DWORD dwDestContext, LPVOID pvDestContext,
  238. DWORD mshlflags);
  239. STDMETHODIMP UnmarshalInterface (THIS_ LPSTREAM pStm, REFIID riid,
  240. LPVOID FAR* ppv);
  241. STDMETHODIMP ReleaseMarshalData (THIS_ LPSTREAM pStm);
  242. STDMETHODIMP DisconnectObject (THIS_ DWORD dwReserved);
  243. CAVIFile FAR* m_pAVIFile;
  244. };
  245. public:
  246. CUnknownImpl m_Unknown;
  247. CAVIFileImpl m_AVIFile;
  248. CMarshalImpl m_Marshal;
  249. public:
  250. IUnknown FAR* m_pUnknownOuter;
  251. //
  252. // AVIFile instance data
  253. //
  254. MainAVIHeader FARSTRUCT avihdr; // file info
  255. LONG lHeaderSize;
  256. char achFile[260];
  257. UINT mode;
  258. HSHFILE hshfile; // file I/O
  259. LONG lDataListStart;
  260. BOOL fInRecord;
  261. LONG lRecordIndex;
  262. MMCKINFO ckRecord;
  263. LONG lWriteLoc;
  264. EXTRA extra;
  265. BOOL fDirty;
  266. CAVIStream FAR * ps[MAXSTREAMS];
  267. PAVIINDEX px; // the index
  268. PBUFSYSTEM pb;
  269. };
  270. /*
  271. ** The usage counter keeps track of the overall usage of objects based on
  272. ** implementations provided by the component. This allows one to determine
  273. ** when the implementation is no longer in use.
  274. */
  275. extern UINT uUseCount;
  276. extern BOOL fLocked;
  277. /* - - - - - - - - */
  278. DEFINE_AVIGUID(CLSID_AVIFile, 0x00020000, 0, 0);