Source code of Windows XP (NT5)
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.

101 lines
4.1 KiB

  1. //
  2. // dmstrm.h
  3. //
  4. // Copyright (c) 1995-1998 Microsoft Corporation. All rights reserved.
  5. //
  6. #ifndef DMSTRM_H
  7. #define DMSTRM_H
  8. DEFINE_GUID(IID_IDMStream, 0x1894c260, 0xaa21, 0x11d1, 0x86, 0xbc, 0x0, 0xc0, 0x4f, 0xbf, 0x8f, 0xef);
  9. DECLARE_INTERFACE_(IDMStream, IUnknown)
  10. {
  11. // IUnknown
  12. STDMETHOD(QueryInterface) (THIS_ REFIID, LPVOID FAR *) PURE;
  13. STDMETHOD_(ULONG,AddRef) (THIS) PURE;
  14. STDMETHOD_(ULONG,Release) (THIS) PURE;
  15. // IDMStream
  16. STDMETHOD(Init) (THIS_ IStream* pStream) PURE;
  17. STDMETHOD(Descend) (THIS_ LPMMCKINFO lpck, LPMMCKINFO lpckParent, UINT wFlags) PURE;
  18. STDMETHOD(Ascend) (THIS_ LPMMCKINFO lpck, UINT wFlags) PURE;
  19. STDMETHOD(CreateChunk) (THIS_ LPMMCKINFO lpck, UINT wFlags) PURE;
  20. STDMETHOD(SetStream) (THIS_ IStream* pIStream) PURE;
  21. STDMETHOD_(IStream*, GetStream) (THIS) PURE;
  22. };
  23. STDAPI AllocDirectMusicStream(IStream* pIStream, IDMStream** ppIDMStream);
  24. class CDirectMusicStream : public IDMStream
  25. {
  26. public:
  27. CDirectMusicStream();
  28. ~CDirectMusicStream();
  29. STDMETHODIMP Init(IStream* pStream);
  30. // IUnknown
  31. STDMETHODIMP QueryInterface(REFIID riid, LPVOID *ppvObj);
  32. STDMETHODIMP_(ULONG) AddRef();
  33. STDMETHODIMP_(ULONG) Release();
  34. // IDMStream
  35. STDMETHODIMP Descend(LPMMCKINFO lpck, LPMMCKINFO lpckParent, UINT wFlags);
  36. STDMETHODIMP Ascend(LPMMCKINFO lpck, UINT wFlags);
  37. STDMETHODIMP CreateChunk(LPMMCKINFO lpck, UINT wFlags);
  38. STDMETHODIMP SetStream(IStream* pStream);
  39. STDMETHODIMP_(IStream*) GetStream();
  40. private:
  41. long m_cRef; // object reference count
  42. IStream* m_pStream; // stream to operate on
  43. };
  44. // Macro to round up an odd size to RIFF 16 bit boundary.
  45. #define RIFF_ALIGN(dwSize) (dwSize + (dwSize & 1))
  46. typedef struct _RIFFIO
  47. {
  48. FOURCC ckid; /* chunk ID */
  49. long cksize; /* chunk size */
  50. FOURCC fccType; /* form type or list type */
  51. long lRead; /* How much of this chunk has been read so far. */
  52. _RIFFIO * pParent; /* pointer to parent chunk */
  53. LARGE_INTEGER liPosition; /* Filled in by MarkPosition() when handing stream to another component. */
  54. } RIFFIO;
  55. class CRiffParser
  56. {
  57. public:
  58. CRiffParser(IStream *pStream);
  59. void DebugOn() { m_fDebugOn = TRUE; } // Turns on tracing of parsing. Only available in debug builds.
  60. BOOL NextChunk(HRESULT * pHr); // Does the work of LeaveChunk, MoreChunks, and EnterChunk in one call.
  61. void EnterList(RIFFIO *pChunk); // Descend into a new list.
  62. void LeaveList(); // Pop out of the current list.
  63. BOOL MoreChunks(); // Returns true if there are more chunks to process in this LIST or RIFF.
  64. HRESULT EnterChunk(); // Reads header of next chunk in this LIST or RIFF container.
  65. HRESULT LeaveChunk(); // Move to the end of the current chunk in the LIST or RIFF.
  66. void MarkPosition(); // Stores the absolute position of the start of the current chunk.
  67. HRESULT SeekBack(); // Scan back to the beginning of the current chunk.
  68. HRESULT SeekForward(); // Scan forward to the end of the current chunk.
  69. HRESULT Read(void *pv,ULONG cb); // Reads data from stream.
  70. HRESULT Skip(ULONG ulBytes); // Seeks forward ulBytes.
  71. void EnteringComponent() { m_fInComponent = true; }
  72. BOOL ComponentFailed() { return m_fComponentFailed; }
  73. IStream * GetStream() { return m_pStream; }
  74. private:
  75. BOOL m_fDebugOn; // Set true to turn tracing of parsing on.
  76. BOOL m_fFirstPass; // Used by NextChunk to understand whether this is the first time in the list.
  77. IStream * m_pStream; // Stream to operate on.
  78. RIFFIO * m_pChunk; // Current chunk that we are in.
  79. RIFFIO * m_pParent; // Parent chunk of current chunk.
  80. long m_lRead; // How far we've read in the current chunk.
  81. BOOL m_fComponentFailed; // Set true if a component failed to load, yet the file is okay.
  82. BOOL m_fInComponent; // Set to true when inside a component's chunk.
  83. };
  84. #endif // #ifndef DMSTRM_H