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.

204 lines
8.8 KiB

  1. // Copyright (c) 1998-1999 Microsoft Corporation
  2. // DMSegObj.h : Declaration of the CSegment
  3. #ifndef __DIRECTMUSICSONGOBJECT_H_
  4. #define __DIRECTMUSICSONGOBJECT_H_
  5. #include "dmusici.h"
  6. #include "dmusicf.h"
  7. #include "dmime.h"
  8. #include "TrkList.h"
  9. #include "dmgraph.h"
  10. #include "dmsegobj.h"
  11. #include "tlist.h"
  12. #include "..\shared\dmusicp.h"
  13. class CVirtualSegment : public AListItem
  14. {
  15. friend class CSong;
  16. friend class ComposingTrack;
  17. public:
  18. CVirtualSegment();
  19. ~CVirtualSegment();
  20. CVirtualSegment* GetNext() { return (CVirtualSegment*)AListItem::GetNext();}
  21. CTrack * GetTrackByParam( CTrack * pCTrack,
  22. REFGUID rguidType,DWORD dwGroupBits,DWORD dwIndex);
  23. private:
  24. CTrackList m_TrackList; // List of tracks that this segment uses.
  25. CSegment * m_pSourceSegment; // Segment that is used as basis for this segment.
  26. CSegment * m_pPlaySegment; // Resulting segment that will be played.
  27. CGraph * m_pGraph; // Optional tool graph.
  28. DWORD m_dwFlags; // Various control flags.
  29. DWORD m_dwID; // Unique ID.
  30. DWORD m_dwNextPlayID; // ID of next segment, to chain segments into a song.
  31. DWORD m_dwNextPlayFlags; // DMUS_SEGF flags for playing next segment, when chaining a song.
  32. DMUS_IO_SEGMENT_HEADER m_SegHeader; // Segment header, used to define the segment that it creates, or change the one it references.
  33. MUSIC_TIME m_mtTime; // Start time of this segment.
  34. DWORD m_dwTransitionCount;// How many transitions are defined.
  35. DMUS_IO_TRANSITION_DEF *m_pTransitions; // Array of transitions from other segments.
  36. WCHAR m_wszName[DMUS_MAX_NAME];// Name of generated segment.
  37. };
  38. class CVirtualSegmentList : public AList
  39. {
  40. public:
  41. void Clear();
  42. void AddHead(CVirtualSegment* pVirtualSegment) { AList::AddHead((AListItem*)pVirtualSegment);}
  43. void Insert(CVirtualSegment* pVirtualSegment);
  44. CVirtualSegment* GetHead(){return (CVirtualSegment*)AList::GetHead();}
  45. CVirtualSegment* GetItem(LONG lIndex){return (CVirtualSegment*)AList::GetItem(lIndex);}
  46. CVirtualSegment* RemoveHead() { return (CVirtualSegment *)AList::RemoveHead();};
  47. void Remove(CVirtualSegment* pVirtualSegment){AList::Remove((AListItem*)pVirtualSegment);}
  48. void AddTail(CVirtualSegment* pVirtualSegment){AList::AddTail((AListItem*)pVirtualSegment);}
  49. CVirtualSegment* GetTail(){ return (CVirtualSegment*)AList::GetTail();}
  50. };
  51. class CSongSegment : public AListItem
  52. {
  53. public:
  54. CSongSegment();
  55. ~CSongSegment();
  56. CSongSegment* GetNext() { return (CSongSegment*)AListItem::GetNext();}
  57. CSegment * m_pSegment;
  58. DWORD m_dwLoadID;
  59. };
  60. class CSongSegmentList : public AList
  61. {
  62. public:
  63. HRESULT AddSegment(CSegment *pSegment, DWORD dwLoadID);
  64. void Clear();
  65. void AddHead(CSongSegment* pSongSegment) { AList::AddHead((AListItem*)pSongSegment);}
  66. void Insert(CSongSegment* pSongSegment);
  67. CSongSegment* GetHead(){return (CSongSegment*)AList::GetHead();}
  68. CSongSegment* GetItem(LONG lIndex){return (CSongSegment*)AList::GetItem(lIndex);}
  69. CSongSegment* RemoveHead() { return (CSongSegment *)AList::RemoveHead();};
  70. void Remove(CSongSegment* pSongSegment){AList::Remove((AListItem*)pSongSegment);}
  71. void AddTail(CSongSegment* pSongSegment){AList::AddTail((AListItem*)pSongSegment);}
  72. CSongSegment* GetTail(){ return (CSongSegment*)AList::GetTail();}
  73. };
  74. class CSong;
  75. DEFINE_GUID(IID_CSong,0xb06c0c22, 0xd3c7, 0x11d3, 0x9b, 0xd1, 0x44, 0x45, 0x53, 0x54, 0x0, 0x0);
  76. /////////////////////////////////////////////////////////////////////////////
  77. // CSong
  78. class CSong :
  79. public IDirectMusicSong,
  80. public IPersistStream,
  81. public IDirectMusicObject,
  82. public IDirectMusicObjectP
  83. {
  84. public:
  85. CSong();
  86. ~CSong();
  87. public:
  88. // IUnknown
  89. STDMETHODIMP QueryInterface(const IID &iid, void **ppv);
  90. STDMETHODIMP_(ULONG) AddRef();
  91. STDMETHODIMP_(ULONG) Release();
  92. // IDirectMusicSong
  93. STDMETHODIMP Compose( );
  94. STDMETHODIMP GetParam( REFGUID rguidType,
  95. DWORD dwGroupBits,
  96. DWORD dwIndex,
  97. MUSIC_TIME mtTime,
  98. MUSIC_TIME* pmtNext,
  99. void* pParam) ;
  100. STDMETHODIMP GetSegment( WCHAR *wszName,IDirectMusicSegment **ppSegment) ;
  101. STDMETHODIMP EnumSegment( DWORD dwIndex,IDirectMusicSegment **ppSegment) ;
  102. STDMETHODIMP GetAudioPathConfig(IUnknown ** ppAudioPathConfig);
  103. STDMETHODIMP Download(IUnknown *pAudioPath);
  104. STDMETHODIMP Unload(IUnknown *pAudioPath);
  105. // IPersist
  106. STDMETHODIMP GetClassID( CLSID* pClsId );
  107. // IPersistStream
  108. STDMETHODIMP IsDirty();
  109. STDMETHODIMP Load( IStream* pIStream );
  110. STDMETHODIMP Save( IStream* pIStream, BOOL fClearDirty );
  111. STDMETHODIMP GetSizeMax( ULARGE_INTEGER FAR* pcbSize );
  112. // IDirectMusicObject
  113. STDMETHODIMP GetDescriptor(LPDMUS_OBJECTDESC pDesc);
  114. STDMETHODIMP SetDescriptor(LPDMUS_OBJECTDESC pDesc);
  115. STDMETHODIMP ParseDescriptor(LPSTREAM pStream, LPDMUS_OBJECTDESC pDesc);
  116. // IDirectMusicObjectP
  117. STDMETHOD_(void, Zombie)();
  118. public:
  119. HRESULT GetTransitionSegment(CSegment *pSource, CSegment *pDestination,
  120. DMUS_IO_TRANSITION_DEF *pTransDef);
  121. HRESULT GetPlaySegment( DWORD dwIndex,CSegment **ppSegment) ;
  122. private:
  123. void Clear();
  124. HRESULT Instantiate() ;
  125. HRESULT LoadReferencedSegment(CSegment **ppSegment, CRiffParser *pParser);
  126. HRESULT LoadSegmentList(CRiffParser *pParser);
  127. HRESULT LoadGraphList(CRiffParser *pParser);
  128. HRESULT LoadVirtualSegmentList(CRiffParser *pParser);
  129. HRESULT LoadTrackRefList(CRiffParser *pParser, CVirtualSegment *pVirtualSegment);
  130. HRESULT LoadAudioPath(IStream *pStream);
  131. void GetGraph(CGraph **ppGraph,DWORD dwGraphID);
  132. void GetSourceSegment(CSegment **ppSegment,DWORD dwSegmentID);
  133. BOOL GetSegmentTrack(IDirectMusicTrack **ppTrack,DWORD dwSegmentID,DWORD dwGroupBits,DWORD dwIndex,REFGUID guidClassID);
  134. CAudioPathConfig* m_pAudioPathConfig; // Optional audio path loaded from file.
  135. CGraphList m_GraphList; // List of graphs for use by segments in the song.
  136. CSongSegmentList m_SegmentList; // List of source segments.
  137. CSegmentList m_PlayList; // List of composed segments.
  138. CVirtualSegmentList m_VirtualSegmentList; // List of segment references. This is what is used to compose the finished song.
  139. CRITICAL_SECTION m_CriticalSection;
  140. DWORD m_fPartialLoad;
  141. DWORD m_dwFlags;
  142. DWORD m_dwStartSegID; // ID of first segment, in play list, that should play.
  143. long m_cRef;
  144. // IDirectMusicObject variables
  145. DWORD m_dwValidData;
  146. GUID m_guidObject;
  147. FILETIME m_ftDate; /* Last edited date of object. */
  148. DMUS_VERSION m_vVersion; /* Version. */
  149. WCHAR m_wszName[DMUS_MAX_NAME]; /* Name of object. */
  150. WCHAR m_wszCategory[DMUS_MAX_CATEGORY]; /* Category for object */
  151. WCHAR m_wszFileName[DMUS_MAX_FILENAME]; /* File path. */
  152. DWORD m_dwVersion; // Which version of the interfaces is the app requesting?
  153. IUnknown * m_pUnkDispatch; // holds the controlling unknown of the scripting object that implements IDispatch
  154. bool m_fZombie;
  155. };
  156. struct CompositionComponent
  157. {
  158. CVirtualSegment* pVirtualSegment; // composing track came from here
  159. CTrack* pComposingTrack; // used for composition
  160. MUSIC_TIME mtTime;
  161. };
  162. class ComposingTrack
  163. {
  164. public:
  165. ComposingTrack();
  166. ~ComposingTrack();
  167. DWORD GetTrackGroup() { return m_dwTrackGroup; }
  168. GUID GetTrackID() { return m_guidClassID; }
  169. DWORD GetPriority() { return m_dwPriority; }
  170. void SetPriority(DWORD dwPriority) { m_dwPriority = dwPriority; }
  171. void SetTrackGroup(DWORD dwTrackGroup) { m_dwTrackGroup = dwTrackGroup; }
  172. void SetTrackID(GUID& rguidClassID) { m_guidClassID = rguidClassID; }
  173. HRESULT AddTrack(CVirtualSegment* pVirtualSegment, CTrack* pTrack);
  174. HRESULT Compose(IDirectMusicSong* pSong);
  175. private:
  176. GUID m_guidClassID; // composing track's class id
  177. DWORD m_dwTrackGroup; // track will be composed from these groups
  178. DWORD m_dwPriority; // Track priority, to order the composition process.
  179. TList<CompositionComponent> m_Components; // list of components making up the master
  180. };
  181. #endif //__DIRECTMUSICSONGOBJECT_H_