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.

197 lines
7.2 KiB

  1. /*==========================================================================;
  2. *
  3. * Copyright (C) 1999 Microsoft Corporation. All Rights Reserved.
  4. *
  5. * File: dvcsplay.h
  6. * Content: Declaration of CDVCSPlayer class
  7. * History:
  8. * Date By Reason
  9. * ============
  10. * 07/22/99 rodtoll created
  11. * 10/29/99 rodtoll Bug #113726 - Integrate Voxware Codecs, updating to use new
  12. * pluggable codec architecture.
  13. * 01/14/2000 rodtoll Updated to support multiple targets
  14. * 03/27/2000 rodtoll Updated to use new base class for player record
  15. * 03/28/2000 rodtoll Updated to use new player class as base
  16. * rodtoll Moved a bunch of logic out of server into this class
  17. * 03/29/2000 rodtoll Bug #30753 - Added volatile to the class definition
  18. * 11/16/2000 rodtoll Bug #40587 - DPVOICE: Mixing server needs to use multi-processors
  19. * 09/05/2001 simonpow Bug #463972. Added constuct/destruct methods to enable
  20. * allocations and de-allocations via CFixedPool objects
  21. * 02/28/2002 rodtoll WINBUG #549959 - SECURITY: DPVOICE: Voice server trusts client's target list
  22. * - When server controlled targetting is enabled, use server's copy of client
  23. * target list instead of list specified in incoming packet.
  24. ***************************************************************************/
  25. #ifndef __DVCSPLAYER_H
  26. #define __DVCSPLAYER_H
  27. #define DPV_TARGETBUFFER_REALLOC_SIZE 10
  28. #undef DPF_SUBCOMP
  29. #define DPF_SUBCOMP DN_SUBCOMP_VOICE
  30. class CDVCSPlayer;
  31. struct CBilinkPlusObject
  32. {
  33. CDVCSPlayer* m_pPlayer;
  34. CBilink m_bl;
  35. };
  36. // CDVCSPlayer
  37. //
  38. // This class extends the CDVPlayer class for client/server servers.
  39. //
  40. volatile class CDVCSPlayer: public CVoicePlayer
  41. {
  42. public:
  43. //called from CFixedPool class to to build/destroy CDVCSPlayer's
  44. static BOOL PoolAllocFunction(void * pvItem, void * pvContext);
  45. static void PoolDeallocFunction(void * pvItem);
  46. HRESULT Initialize( const DVID dvidPlayer, const DWORD dwHostOrder, DWORD dwFlags,
  47. PVOID pvContext, DWORD dwCompressedSize, DWORD dwUnCompressedSize,
  48. CFixedPool *pCSOwner, DWORD dwNumMixingThreads );
  49. HRESULT DeInitialize();
  50. HRESULT HandleMixingReceive( PDVPROTOCOLMSG_SPEECHHEADER pdvSpeechHeader, PBYTE pbData, DWORD dwSize, PDVID pdvidTargets, DWORD dwNumTargets, BOOL fServerTargetting );
  51. HRESULT CompressOutBound( PVOID pvInputBuffer, DWORD dwInputBufferSize, PVOID pvOutputBuffer, DWORD *pdwOutputSize );
  52. inline HRESULT ResizeIfRequired( DWORD dwThreadIndex, DWORD dwNewMaxSize )
  53. {
  54. if( dwNewMaxSize > m_pdwMaxCanHear[dwThreadIndex] )
  55. {
  56. m_pdwMaxCanHear[dwThreadIndex] = dwNewMaxSize+DPV_TARGETBUFFER_REALLOC_SIZE;
  57. if( m_pppCanHear[dwThreadIndex] )
  58. {
  59. delete [] (m_pppCanHear[dwThreadIndex]);
  60. }
  61. m_pppCanHear[dwThreadIndex] = new CDVCSPlayer*[m_pdwMaxCanHear[dwThreadIndex]];
  62. if( m_pppCanHear[dwThreadIndex] == NULL )
  63. {
  64. return DVERR_OUTOFMEMORY;
  65. }
  66. }
  67. return DV_OK;
  68. };
  69. #undef DPF_MODNAME
  70. #define DPF_MODNAME "CDVCSPlayer::CreateOutBoundConverter"
  71. inline HRESULT CreateOutBoundConverter( PWAVEFORMATEX pwfxSourceFormat, const GUID &guidCT )
  72. {
  73. HRESULT hr;
  74. hr = DVCDB_CreateConverter( pwfxSourceFormat, guidCT, &m_lpOutBoundAudioConverter );
  75. if( FAILED( hr ) )
  76. {
  77. DPFX(DPFPREP, 0, "Error creating audio converter hr=0x%x" , hr );
  78. return hr;
  79. }
  80. return hr;
  81. }
  82. inline BOOL IsOutBoundConverterInitialized() const
  83. {
  84. return (m_lpOutBoundAudioConverter != NULL);
  85. }
  86. BOOL ComparePlayerMix( DWORD dwThreadIndex, const CDVCSPlayer *lpdvPlayer );
  87. void ResetForNextRun( DWORD dwThreadIndex, BOOL fDequeue );
  88. void CompleteRun( DWORD dwThreadIndex );
  89. inline void AddToMixingList( DWORD dwThreadIndex, CBilink *pblBilink )
  90. {
  91. m_pblMixingActivePlayers[dwThreadIndex].m_bl.InsertAfter( pblBilink );
  92. }
  93. inline void RemoveFromMixingList(DWORD dwThreadIndex)
  94. {
  95. m_pblMixingActivePlayers[dwThreadIndex].m_bl.RemoveFromList();
  96. }
  97. inline void AddToSpeakingList( DWORD dwThreadIndex, CBilink *pblBilink )
  98. {
  99. m_pblMixingSpeakingPlayers[dwThreadIndex].m_bl.InsertAfter( pblBilink );
  100. }
  101. inline void RemoveFromSpeakingList(DWORD dwThreadIndex)
  102. {
  103. m_pblMixingSpeakingPlayers[dwThreadIndex].m_bl.RemoveFromList();
  104. }
  105. inline void AddToHearingList( DWORD dwThreadIndex, CBilink *pblBilink )
  106. {
  107. m_pblMixingHearingPlayers[dwThreadIndex].m_bl.InsertAfter( pblBilink );
  108. }
  109. inline void RemoveFromHearingList(DWORD dwThreadIndex)
  110. {
  111. m_pblMixingHearingPlayers[dwThreadIndex].m_bl.RemoveFromList();
  112. }
  113. public: // These variables are shared between mixing threads
  114. PDPVCOMPRESSOR m_lpOutBoundAudioConverter;
  115. BOOL m_bLastSent; // Was last frame sent to this user?
  116. BYTE m_bMsgNum; // Last msg # transmitted
  117. BYTE m_bSeqNum; // Last Sequence # transmitted
  118. DWORD m_targetSize; // Tmp to hold size of compressed data (bytes)
  119. BOOL m_lost; // the queue detected that this frame was lost
  120. DWORD m_dwNumMixingThreads;
  121. public: // These variables are on a per/mixing thread basis
  122. CDVCSPlayer **m_pReuseMixFromThisPlayer;
  123. BYTE *m_pbMsgNumToSend; // Last msg # transmitted
  124. BYTE *m_pbSeqNumToSend; // Last Sequence # transmitted
  125. CBilinkPlusObject *m_pblMixingActivePlayers; // Bilink of active players (per mixing thread)
  126. CBilinkPlusObject *m_pblMixingSpeakingPlayers; // Bilink of players speaking (per mixing thread)
  127. CBilinkPlusObject *m_pblMixingHearingPlayers; // Bilink of players hearing (per mixing thread)
  128. DWORD *m_pdwHearCount; // How many people can this user hear? (per mixing thread)
  129. BOOL *m_pfDecompressed; // Has the user's frame been decompressed (per mixing thread)
  130. BOOL *m_pfSilence; // Is the latest from from user silence? (per mixing thread)
  131. BOOL *m_pfNeedsDecompression; // Does this player need decompression (per mixing thread)
  132. CDVCSPlayer ***m_pppCanHear; // Array of pointers to player records this player can hear (per mixing thread)
  133. DWORD *m_pdwMaxCanHear; // # of elements in the m_dwCanHead array (per mixing thread)
  134. CFrame **m_pSourceFrame; // Source frame (per mixing thread)
  135. BYTE *m_sourceUnCompressed; // Buffer to hold decompressed data (per mixing thread)
  136. BYTE *m_targetCompressed; // Has user's mix been created yet? (per mixing thread)
  137. BOOL *m_pfMixed; // Has the user's output been readied? (per mixing thread)
  138. DWORD *m_pdwUnCompressedBufferOffset;
  139. // Offset into uncompressed buffer for thread (per mixing thread)
  140. DWORD *m_pdwCompressedBufferOffset;
  141. // Offset into compressed buffer for thread (per mixing thread)
  142. DWORD *m_pdwResultLength; // Size of compressed data (in bytes) (per mixing thread)
  143. BOOL *m_pfMixToBeReused; // Will this player's mix be re-used by another player (per mixing thread)
  144. CFixedPool *m_pCSOwner;
  145. protected:
  146. //protected to ensure alloc/de-alloc occurs through the
  147. //fixed pool mechanism using construct/destruct calls
  148. CDVCSPlayer();
  149. ~CDVCSPlayer();
  150. };
  151. typedef CDVCSPlayer *LPDVCSPLAYER;
  152. #undef DPF_MODNAME
  153. #endif