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.

212 lines
10 KiB

  1. // Copyright (c) 1998-1999 Microsoft Corporation
  2. // DMSegObj.h : Declaration of the CSegment
  3. #ifndef __DIRECTMUSICSEGMENTOBJECT_H_
  4. #define __DIRECTMUSICSEGMENTOBJECT_H_
  5. #include "dmusici.h"
  6. #include "dmusicf.h"
  7. #include "dmime.h"
  8. #include "TrkList.h"
  9. #include "ntfylist.h"
  10. #include "dmsstobj.h"
  11. #include "..\shared\dmusicp.h"
  12. #define COMPOSE_TRANSITION1 (DMUS_TRACKCONFIG_TRANS1_FROMSEGSTART | DMUS_TRACKCONFIG_TRANS1_FROMSEGCURRENT | DMUS_TRACKCONFIG_TRANS1_TOSEGSTART)
  13. class CSegment;
  14. DEFINE_GUID(IID_CSegment,0xb06c0c21, 0xd3c7, 0x11d3, 0x9b, 0xd1, 0x44, 0x45, 0x53, 0x54, 0x0, 0x0);
  15. /////////////////////////////////////////////////////////////////////////////
  16. // CSegment
  17. class CSegment :
  18. public IDirectMusicSegment8,
  19. public IDirectMusicSegment8P,
  20. public IPersistStream,
  21. public IDirectMusicObject,
  22. public AListItem,
  23. public IDirectMusicObjectP
  24. {
  25. friend class CPerformance;
  26. friend class CSegState;
  27. friend class CSong;
  28. public:
  29. CSegment();
  30. CSegment(DMUS_IO_SEGMENT_HEADER *pHeader, CSegment *pSource);
  31. ~CSegment();
  32. CSegment* GetNext() { return (CSegment*)AListItem::GetNext();}
  33. public:
  34. // IUnknown
  35. STDMETHODIMP QueryInterface(const IID &iid, void **ppv);
  36. STDMETHODIMP_(ULONG) AddRef();
  37. STDMETHODIMP_(ULONG) Release();
  38. // IDirectMusicSegment
  39. STDMETHODIMP GetLength(MUSIC_TIME *pmtLength);
  40. STDMETHODIMP SetLength(MUSIC_TIME pmtLength);
  41. STDMETHODIMP GetRepeats(DWORD *pdwRepeats);
  42. STDMETHODIMP SetRepeats(DWORD dwRepeats);
  43. STDMETHODIMP GetDefaultResolution(DWORD *pdwResolution);
  44. STDMETHODIMP SetDefaultResolution(DWORD dwResolution);
  45. STDMETHODIMP GetTrack(REFCLSID rType,DWORD dwGroupBits,DWORD dwIndex,IDirectMusicTrack **ppTrack);
  46. STDMETHODIMP GetTrackGroup(IDirectMusicTrack* pTrack,DWORD* pdwGroupBits);
  47. STDMETHODIMP InsertTrack(IDirectMusicTrack *pTrack,DWORD dwGroupBits);
  48. STDMETHODIMP RemoveTrack(IDirectMusicTrack *pTrack);
  49. STDMETHODIMP InitPlay(IDirectMusicSegmentState **ppSegState,IDirectMusicPerformance *pPerformance,DWORD dwFlags);
  50. STDMETHODIMP GetGraph(IDirectMusicGraph** ppGraph);
  51. STDMETHODIMP SetGraph(IDirectMusicGraph* pGraph);
  52. STDMETHODIMP AddNotificationType(REFGUID rguidNotification);
  53. STDMETHODIMP RemoveNotificationType(REFGUID rguidNotification);
  54. STDMETHODIMP GetParam(REFGUID rguidDataType,DWORD dwGroupBits,
  55. DWORD dwIndex,MUSIC_TIME mtTime,
  56. MUSIC_TIME* pmtNext,void* pData);
  57. STDMETHODIMP SetParam(REFGUID rguidDataType,DWORD dwGroupBits,
  58. DWORD dwIndex,MUSIC_TIME mtTime,void* pData);
  59. STDMETHODIMP Clone(MUSIC_TIME mtStart,MUSIC_TIME mtEnd,IDirectMusicSegment** ppSegment);
  60. STDMETHODIMP GetStartPoint(MUSIC_TIME* pmtStart);
  61. STDMETHODIMP SetStartPoint(MUSIC_TIME mtStart);
  62. STDMETHODIMP GetLoopPoints(MUSIC_TIME* pmtStart,MUSIC_TIME* pmtEnd);
  63. STDMETHODIMP SetLoopPoints(MUSIC_TIME mtStart,MUSIC_TIME mtEnd);
  64. STDMETHODIMP SetPChannelsUsed(DWORD dwNumPChannels,DWORD* paPChannels);
  65. // IDirectMusicSegment8
  66. STDMETHODIMP SetTrackConfig(REFGUID rguidTrackClassID,DWORD dwGroup, DWORD dwIndex, DWORD dwFlagsOn, DWORD dwFlagsOff) ;
  67. STDMETHODIMP GetAudioPathConfig(IUnknown ** ppIAudioPathConfig);
  68. STDMETHODIMP Compose(MUSIC_TIME mtTime,
  69. IDirectMusicSegment* pFromSegment,
  70. IDirectMusicSegment* pToSegment,
  71. IDirectMusicSegment** ppComposedSegment);
  72. STDMETHODIMP Download(IUnknown *pAudioPath);
  73. STDMETHODIMP Unload(IUnknown *pAudioPath);
  74. // IDirectMusicSegment8P
  75. STDMETHODIMP GetObjectInPath(DWORD dwPChannel, /* PChannel to search. */
  76. DWORD dwStage, /* Which stage in the path. */
  77. DWORD dwBuffer,
  78. REFGUID guidObject, /* ClassID of object. */
  79. DWORD dwIndex, /* Which object of that class. */
  80. REFGUID iidInterface,/* Requested COM interface. */
  81. void ** ppObject) ; /* Pointer to interface. */
  82. STDMETHODIMP GetHeaderChunk(
  83. DWORD *pdwSize, /* Size of passed header chunk. Also, returns size written. */
  84. DMUS_IO_SEGMENT_HEADER *pHeader); /* Header chunk to fill. */
  85. STDMETHODIMP SetHeaderChunk(
  86. DWORD dwSize, /* Size of passed header chunk. */
  87. DMUS_IO_SEGMENT_HEADER *pHeader); /* Header chunk to fill. */
  88. STDMETHODIMP SetTrackPriority(
  89. REFGUID rguidTrackClassID, /* ClassID of Track. */
  90. DWORD dwGroupBits, /* Group bits. */
  91. DWORD dwIndex, /* Nth track. */
  92. DWORD dwPriority); /* Priority to set. */
  93. STDMETHODIMP SetAudioPathConfig(
  94. IUnknown *pAudioPathConfig);
  95. // IPersist
  96. STDMETHODIMP GetClassID( CLSID* pClsId );
  97. // IPersistStream
  98. STDMETHODIMP IsDirty();
  99. STDMETHODIMP Load( IStream* pIStream );
  100. STDMETHODIMP Save( IStream* pIStream, BOOL fClearDirty );
  101. STDMETHODIMP GetSizeMax( ULARGE_INTEGER FAR* pcbSize );
  102. // IDirectMusicObject
  103. STDMETHODIMP GetDescriptor(LPDMUS_OBJECTDESC pDesc);
  104. STDMETHODIMP SetDescriptor(LPDMUS_OBJECTDESC pDesc);
  105. STDMETHODIMP ParseDescriptor(LPSTREAM pStream, LPDMUS_OBJECTDESC pDesc);
  106. HRESULT GetPChannels( DWORD* pdwNumPChannels, DWORD** ppaPChannels );
  107. HRESULT CheckNotification( REFGUID );
  108. // IDirectMusicObjectP
  109. STDMETHOD_(void, Zombie)();
  110. public:
  111. HRESULT GetTrackConfig(REFGUID rguidTrackClassID,DWORD dwGroup, DWORD dwIndex, DWORD *pdwFlags) ;
  112. HRESULT AddNotificationType(REFGUID rguidNotification, BOOL fFromPerformance);
  113. HRESULT RemoveNotificationType(REFGUID rguidNotification, BOOL fFromPerformance);
  114. BOOL IsTempoSource();
  115. HRESULT CreateSegmentState(CSegState **ppSegState,CPerformance *pPerformance,
  116. IDirectMusicAudioPath *pAudioPath, DWORD dwFlags);
  117. CTrack *GetTrack(REFCLSID rType,DWORD dwGroupBits,DWORD dwIndex);
  118. CTrack * GetTrackByParam(CTrack * pCTrack,REFGUID rguidType,DWORD dwGroupBits,DWORD dwIndex, BOOL fDontCheck);
  119. HRESULT GetTrackByParam(REFGUID rgCommandGuid,DWORD dwGroupBits,
  120. DWORD dwIndex,IDirectMusicTrack **ppTrack);
  121. HRESULT LoadDirectMusicSegment(IStream* pIStream);
  122. void AddNotificationTypeToAllTracks( REFGUID rguidNotification );
  123. void RemoveNotificationTypeFromAllTracks( REFGUID rguidNotification );
  124. CNotificationItem* FindNotification( REFGUID rguidNotification );
  125. HRESULT LoadTrack(CRiffParser *pParser);
  126. HRESULT CreateTrack(DMUS_IO_TRACK_HEADER& ioDMHdr, DWORD dwFlags, DWORD dwPriority, IStream *pStream);
  127. HRESULT InsertTrack(IDirectMusicTrack *pTrack,DWORD dwGroupBits, DWORD dwFlags, DWORD dwPriority, DWORD dwPosition);
  128. HRESULT LoadGraph(CRiffParser *pParser,CGraph **ppGraph);
  129. HRESULT LoadAudioPath(IStream *pStream);
  130. HRESULT ParseSegment(IStream* pIStream, LPDMUS_OBJECTDESC pDesc);
  131. void Init();
  132. HRESULT ComposeTransition(MUSIC_TIME mtTime,
  133. IDirectMusicSegment* pFromSegment,
  134. IDirectMusicSegment* pToSegment);
  135. HRESULT ComposeInternal();
  136. HRESULT SetClockTimeDuration(REFERENCE_TIME rtDuration);
  137. HRESULT SetFlags(DWORD dwFlags);
  138. void Clear(bool fZombie);
  139. HRESULT MusicToReferenceTime(MUSIC_TIME mtTime, REFERENCE_TIME *prtTime);
  140. HRESULT ReferenceToMusicTime(REFERENCE_TIME rtTime, MUSIC_TIME *pmtTime);
  141. // Attributes
  142. protected:
  143. CRITICAL_SECTION m_CriticalSection;
  144. DWORD m_dwRepeats; // # of times to repeat the segment. 0xffffffff is infinite
  145. DWORD m_dwResolution; // the default resolution to start motifs and such.
  146. DWORD m_dwSegFlags; // Flags loaded in with segment.
  147. CTrackList m_TrackList; // list of Tracks held in this Segment
  148. CAudioPathConfig* m_pAudioPathConfig; // Optional audio path loaded from file.
  149. CGraph* m_pGraph; // Optional tool graph for segment.
  150. CNotificationList m_NotificationList;
  151. REFERENCE_TIME m_rtLength; // Optional length in reference time units.
  152. MUSIC_TIME m_mtLength;
  153. MUSIC_TIME m_mtStart;
  154. MUSIC_TIME m_mtLoopStart;
  155. MUSIC_TIME m_mtLoopEnd;
  156. DWORD m_dwNumPChannels;
  157. DWORD* m_paPChannels;
  158. long m_cRef;
  159. IUnknown * m_pUnkDispatch; // holds the controlling unknown of the scripting object that implements IDispatch
  160. // IDirectMusicObject variables
  161. DWORD m_dwValidData;
  162. GUID m_guidObject;
  163. FILETIME m_ftDate; /* Last edited date of object. */
  164. DMUS_VERSION m_vVersion; /* Version. */
  165. WCHAR m_wszName[DMUS_MAX_NAME]; /* Name of object. */
  166. WCHAR m_wszCategory[DMUS_MAX_CATEGORY]; /* Category for object */
  167. WCHAR m_wszFileName[DMUS_MAX_FILENAME]; /* File path. */
  168. DWORD m_dwVersion; // Which version of the interfaces is the app requesting?
  169. bool m_fZombie;
  170. public:
  171. DWORD m_dwLoadID; // Identifier, used when loaded as part of a song.
  172. CSong* m_pSong; // Optional parent song that segment belongs to. This is not AddRef'd.
  173. DWORD m_dwPlayID; // ID of segment, if within a song.
  174. DWORD m_dwNextPlayID; // ID of next segment, if within a song.
  175. DWORD m_dwNextPlayFlags; // DMUS_SEGF flags for playing next segment, if within a song.
  176. BOOL m_fPlayNext; // Whether the next segment should be played.
  177. };
  178. class CSegmentList : public AList
  179. {
  180. public:
  181. void Clear();
  182. void AddHead(CSegment* pSegment) { AList::AddHead((AListItem*)pSegment);}
  183. void Insert(CSegment* pSegment);
  184. BOOL IsMember(CSegment *pSegment) { return AList::IsMember((AListItem*)pSegment);}
  185. CSegment* GetHead(){return (CSegment*)AList::GetHead();}
  186. CSegment* GetItem(LONG lIndex){return (CSegment*)AList::GetItem(lIndex);}
  187. CSegment* RemoveHead() {return (CSegment *) AList::RemoveHead();}
  188. void Remove(CSegment* pSegment){AList::Remove((AListItem*)pSegment);}
  189. void AddTail(CSegment* pSegment){AList::AddTail((AListItem*)pSegment);}
  190. CSegment* GetTail(){ return (CSegment*)AList::GetTail();}
  191. };
  192. #endif //__DIRECTMUSICSEGMENTOBJECT_H_