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.

275 lines
6.8 KiB

  1. /*==========================================================================
  2. *
  3. * Copyright (C) 1999 - 1999 Microsoft Corporation. All Rights Reserved.
  4. *
  5. * File: vplayer.h
  6. * Content: Voice Player Entry
  7. *
  8. * History:
  9. * Date By Reason
  10. * ==== == ======
  11. * 03/26/00 rodtoll Created
  12. * 03/29/2000 rodtoll Bug #30753 - Added volatile to the class definition
  13. * 07/09/2000 rodtoll Added signature bytes
  14. * 11/28/2000 rodtoll Bug #47333 - DPVOICE: Server controlled targetting - invalid targets are not removed automatically
  15. ***************************************************************************/
  16. #ifndef __VPLAYER_H
  17. #define __VPLAYER_H
  18. #define VOICEPLAYER_FLAGS_DISCONNECTED 0x00000001 // Player has disconnected
  19. #define VOICEPLAYER_FLAGS_INITIALIZED 0x00000002 // Player is initialized
  20. #define VOICEPLAYER_FLAGS_ISRECEIVING 0x00000004 // Player is currently receiving audio
  21. #define VOICEPLAYER_FLAGS_ISSERVERPLAYER 0x00000008 // Player is the server player
  22. #define VOICEPLAYER_FLAGS_TARGETIS8BIT 0x00000010 // Is the target 8-bit?
  23. #define VOICEPLAYER_FLAGS_ISAVAILABLE 0x00000020 // Is player available
  24. typedef struct _VOICEPLAYER_STATISTICS
  25. {
  26. DWORD dwNumSilentFrames;
  27. DWORD dwNumSpeechFrames;
  28. DWORD dwNumReceivedFrames;
  29. DWORD dwNumLostFrames;
  30. QUEUE_STATISTICS queueStats;
  31. } VOICEPLAYER_STATISTICS, *PVOICEPLAYER_STATISTICS;
  32. #define VSIG_VOICEPLAYER 'YLPV'
  33. #define VSIG_VOICEPLAYER_FREE 'YLP_'
  34. volatile class CVoicePlayer
  35. {
  36. public: // Init / destruct
  37. CVoicePlayer();
  38. virtual ~CVoicePlayer();
  39. HRESULT Initialize( const DVID dvidPlayer, const DWORD dwHostOrder, DWORD dwFlags,
  40. PVOID pvContext, CLockedFixedPool<CVoicePlayer> *pOwner );
  41. HRESULT CreateQueue( PQUEUE_PARAMS pQueueParams );
  42. HRESULT CreateInBoundConverter( const GUID &guidCT, PWAVEFORMATEX pwfxTargetFormat );
  43. virtual HRESULT DeInitialize();
  44. void FreeResources();
  45. HRESULT SetPlayerTargets( PDVID pdvidTargets, DWORD dwNumTargets );
  46. BOOL FindAndRemovePlayerTarget( DVID dvidTargetToRemove );
  47. inline void AddRef()
  48. {
  49. InterlockedIncrement( &m_lRefCount );
  50. }
  51. inline void Release()
  52. {
  53. if( InterlockedDecrement( &m_lRefCount ) == 0 )
  54. {
  55. DeInitialize();
  56. }
  57. }
  58. public: // Speech Handling
  59. HRESULT HandleReceive( PDVPROTOCOLMSG_SPEECHHEADER pdvSpeechHeader, PBYTE pbData, DWORD dwSize );
  60. HRESULT GetNextFrameAndDecompress( PVOID pvBuffer, PDWORD pdwBufferSize, BOOL *pfLost, BOOL *pfSilence, DWORD *pdwSeqNum, DWORD *pdwMsgNum );
  61. HRESULT DeCompressInBound( CFrame *frCurrentFrame, PVOID pvBuffer, PDWORD pdwBufferSize );
  62. CFrame *Dequeue(BOOL *pfLost, BOOL *pfSilence);
  63. void GetStatistics( PVOICEPLAYER_STATISTICS pStats );
  64. inline DVID GetPlayerID()
  65. {
  66. return m_dvidPlayer;
  67. }
  68. inline DWORD GetFlags()
  69. {
  70. return m_dwFlags;
  71. }
  72. inline BOOL IsInBoundConverterInitialized()
  73. {
  74. return (m_lpInBoundAudioConverter != NULL);
  75. }
  76. inline BOOL Is8BitUnCompressed()
  77. {
  78. return (m_dwFlags & VOICEPLAYER_FLAGS_TARGETIS8BIT );
  79. }
  80. inline BOOL IsReceiving()
  81. {
  82. return (m_dwFlags & VOICEPLAYER_FLAGS_ISRECEIVING);
  83. }
  84. inline void SetReceiving( const BOOL fReceiving )
  85. {
  86. Lock();
  87. if( fReceiving )
  88. m_dwFlags |= VOICEPLAYER_FLAGS_ISRECEIVING;
  89. else
  90. m_dwFlags &= ~VOICEPLAYER_FLAGS_ISRECEIVING;
  91. UnLock();
  92. }
  93. inline void SetAvailable( const BOOL fAvailable )
  94. {
  95. Lock();
  96. if( fAvailable )
  97. m_dwFlags |= VOICEPLAYER_FLAGS_ISAVAILABLE;
  98. else
  99. m_dwFlags &= ~VOICEPLAYER_FLAGS_ISAVAILABLE;
  100. UnLock();
  101. }
  102. inline BOOL IsAvailable()
  103. {
  104. return (m_dwFlags & VOICEPLAYER_FLAGS_ISAVAILABLE);
  105. }
  106. inline BOOL IsInitialized()
  107. {
  108. return (m_dwFlags & VOICEPLAYER_FLAGS_INITIALIZED);
  109. }
  110. inline BOOL IsServerPlayer()
  111. {
  112. return (m_dwFlags & VOICEPLAYER_FLAGS_ISSERVERPLAYER);
  113. }
  114. inline void SetServerPlayer()
  115. {
  116. Lock();
  117. m_dwFlags |= VOICEPLAYER_FLAGS_ISSERVERPLAYER;
  118. UnLock();
  119. }
  120. inline BOOL IsDisconnected()
  121. {
  122. return (m_dwFlags & VOICEPLAYER_FLAGS_DISCONNECTED);
  123. }
  124. inline void SetDisconnected()
  125. {
  126. Lock();
  127. m_dwFlags |= VOICEPLAYER_FLAGS_DISCONNECTED;
  128. UnLock();
  129. }
  130. inline void SetHostOrder( const DWORD dwHostOrder )
  131. {
  132. Lock();
  133. m_dwHostOrderID = dwHostOrder;
  134. UnLock();
  135. }
  136. inline DWORD GetHostOrder()
  137. {
  138. return m_dwHostOrderID;
  139. }
  140. inline void Lock()
  141. {
  142. DNEnterCriticalSection( &m_csLock );
  143. }
  144. inline void UnLock()
  145. {
  146. DNLeaveCriticalSection( &m_csLock );
  147. }
  148. inline void *GetContext()
  149. {
  150. return m_pvPlayerContext;
  151. }
  152. inline void SetContext( void *pvContext )
  153. {
  154. Lock();
  155. m_pvPlayerContext = pvContext;
  156. UnLock();
  157. }
  158. inline BYTE GetLastPeak()
  159. {
  160. return m_bLastPeak;
  161. }
  162. inline DWORD GetTransportFlags()
  163. {
  164. return m_dwTransportFlags;
  165. }
  166. inline void AddToPlayList( BILINK *pblBilink )
  167. {
  168. InsertAfter( &m_blPlayList, pblBilink );
  169. }
  170. inline void AddToNotifyList( BILINK *pblBilink )
  171. {
  172. InsertAfter( &m_blNotifyList, pblBilink );
  173. }
  174. inline void RemoveFromNotifyList()
  175. {
  176. Delete( &m_blNotifyList );
  177. }
  178. inline void RemoveFromPlayList()
  179. {
  180. Delete( &m_blPlayList );
  181. }
  182. inline DWORD_PTR GetLastPlayback()
  183. {
  184. return m_dwLastPlayback;
  185. }
  186. inline DWORD GetNumTargets()
  187. {
  188. return m_dwNumTargets;
  189. }
  190. inline PDVID GetTargetList()
  191. {
  192. return m_pdvidTargets;
  193. }
  194. DWORD m_dwSignature;
  195. BILINK m_blNotifyList;
  196. BILINK m_blPlayList;
  197. protected:
  198. virtual void Reset();
  199. PDVID m_pdvidTargets; // The player's current target
  200. DWORD m_dwNumTargets;
  201. DWORD m_dwTransportFlags;
  202. DWORD m_dwFlags;
  203. DWORD m_dwNumSilentFrames;
  204. DWORD m_dwNumSpeechFrames;
  205. DWORD m_dwNumReceivedFrames;
  206. DWORD m_dwNumLostFrames;
  207. DVID m_dvidPlayer; // Player's ID
  208. DWORD m_dwHostOrderID; // Host ORDER ID
  209. LONG m_lRefCount; // Reference count on the player
  210. PDPVCOMPRESSOR m_lpInBoundAudioConverter; // Converter for this player's audio
  211. CInputQueue2 *m_lpInputQueue; // Input queue for this player's audio
  212. PVOID m_pvPlayerContext;
  213. CLockedFixedPool<CVoicePlayer> *m_pOwner;
  214. DWORD_PTR m_dwLastData; // GetTickCount() value when last data received
  215. DWORD_PTR m_dwLastPlayback; // GetTickCount() when last non-silence from this player
  216. DNCRITICAL_SECTION m_csLock;
  217. BYTE m_bLastPeak; // Last peak value for this player.
  218. };
  219. #endif