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.

173 lines
6.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. ***************************************************************************/
  20. #ifndef __DVCSPLAYER_H
  21. #define __DVCSPLAYER_H
  22. #define DPV_TARGETBUFFER_REALLOC_SIZE 10
  23. #undef DPF_SUBCOMP
  24. #define DPF_SUBCOMP DN_SUBCOMP_VOICE
  25. // CDVCSPlayer
  26. //
  27. // This class extends the CDVPlayer class for client/server servers.
  28. //
  29. volatile class CDVCSPlayer: public CVoicePlayer
  30. {
  31. public:
  32. CDVCSPlayer();
  33. ~CDVCSPlayer();
  34. HRESULT Initialize( const DVID dvidPlayer, const DWORD dwHostOrder, DWORD dwFlags,
  35. PVOID pvContext, DWORD dwCompressedSize, DWORD dwUnCompressedSize,
  36. CLockedFixedPool<CDVCSPlayer> *pCSOwner, DWORD dwNumMixingThreads );
  37. HRESULT DeInitialize();
  38. HRESULT HandleMixingReceive( PDVPROTOCOLMSG_SPEECHHEADER pdvSpeechHeader, PBYTE pbData, DWORD dwSize, PDVID pdvidTargets, DWORD dwNumTargets );
  39. HRESULT CompressOutBound( PVOID pvInputBuffer, DWORD dwInputBufferSize, PVOID pvOutputBuffer, DWORD *pdwOutputSize );
  40. inline HRESULT ResizeIfRequired( DWORD dwThreadIndex, DWORD dwNewMaxSize )
  41. {
  42. if( dwNewMaxSize > m_pdwMaxCanHear[dwThreadIndex] )
  43. {
  44. m_pdwMaxCanHear[dwThreadIndex] = dwNewMaxSize+DPV_TARGETBUFFER_REALLOC_SIZE;
  45. if( m_pppCanHear[dwThreadIndex] )
  46. {
  47. delete [] (m_pppCanHear[dwThreadIndex]);
  48. }
  49. m_pppCanHear[dwThreadIndex] = new CDVCSPlayer*[m_pdwMaxCanHear[dwThreadIndex]];
  50. if( m_pppCanHear[dwThreadIndex] == NULL )
  51. {
  52. return DVERR_OUTOFMEMORY;
  53. }
  54. }
  55. return DV_OK;
  56. };
  57. #undef DPF_MODNAME
  58. #define DPF_MODNAME "CDVCSPlayer::CreateOutBoundConverter"
  59. inline HRESULT CreateOutBoundConverter( PWAVEFORMATEX pwfxSourceFormat, const GUID &guidCT )
  60. {
  61. HRESULT hr;
  62. hr = DVCDB_CreateConverter( pwfxSourceFormat, guidCT, &m_lpOutBoundAudioConverter );
  63. if( FAILED( hr ) )
  64. {
  65. DPFX(DPFPREP, 0, "Error creating audio converter hr=0x%x" , hr );
  66. return hr;
  67. }
  68. return hr;
  69. }
  70. inline BOOL IsOutBoundConverterInitialized()
  71. {
  72. return (m_lpOutBoundAudioConverter != NULL);
  73. }
  74. BOOL ComparePlayerMix( DWORD dwThreadIndex, CDVCSPlayer *lpdvPlayer );
  75. void ResetForNextRun( DWORD dwThreadIndex, BOOL fDequeue );
  76. void CompleteRun( DWORD dwThreadIndex );
  77. inline void AddToMixingList( DWORD dwThreadIndex, BILINK *pblBilink )
  78. {
  79. InsertAfter( &m_pblMixingActivePlayers[dwThreadIndex], pblBilink );
  80. }
  81. inline void RemoveFromMixingList(DWORD dwThreadIndex)
  82. {
  83. Delete( &m_pblMixingActivePlayers[dwThreadIndex] );
  84. }
  85. inline void AddToSpeakingList( DWORD dwThreadIndex, BILINK *pblBilink )
  86. {
  87. InsertAfter( &m_pblMixingSpeakingPlayers[dwThreadIndex], pblBilink );
  88. }
  89. inline void RemoveFromSpeakingList(DWORD dwThreadIndex)
  90. {
  91. Delete( &m_pblMixingSpeakingPlayers[dwThreadIndex] );
  92. }
  93. inline void AddToHearingList( DWORD dwThreadIndex, BILINK *pblBilink )
  94. {
  95. InsertAfter( &m_pblMixingHearingPlayers[dwThreadIndex], pblBilink );
  96. }
  97. inline void RemoveFromHearingList(DWORD dwThreadIndex)
  98. {
  99. Delete( &m_pblMixingHearingPlayers[dwThreadIndex] );
  100. }
  101. public: // These variables are shared between mixing threads
  102. PDPVCOMPRESSOR m_lpOutBoundAudioConverter;
  103. BOOL m_bLastSent; // Was last frame sent to this user?
  104. BYTE m_bMsgNum; // Last msg # transmitted
  105. BYTE m_bSeqNum; // Last Sequence # transmitted
  106. DWORD m_targetSize; // Tmp to hold size of compressed data (bytes)
  107. BOOL m_lost; // the queue detected that this frame was lost
  108. DWORD m_dwNumMixingThreads;
  109. public: // These variables are on a per/mixing thread basis
  110. CDVCSPlayer **m_pReuseMixFromThisPlayer;
  111. BYTE *m_pbMsgNumToSend; // Last msg # transmitted
  112. BYTE *m_pbSeqNumToSend; // Last Sequence # transmitted
  113. BILINK *m_pblMixingActivePlayers; // Bilink of active players (per mixing thread)
  114. BILINK *m_pblMixingSpeakingPlayers; // Bilink of players speaking (per mixing thread)
  115. BILINK *m_pblMixingHearingPlayers; // Bilink of players hearing (per mixing thread)
  116. DWORD *m_pdwHearCount; // How many people can this user hear? (per mixing thread)
  117. BOOL *m_pfDecompressed; // Has the user's frame been decompressed (per mixing thread)
  118. BOOL *m_pfSilence; // Is the latest from from user silence? (per mixing thread)
  119. BOOL *m_pfNeedsDecompression; // Does this player need decompression (per mixing thread)
  120. CDVCSPlayer ***m_pppCanHear; // Array of pointers to player records this player can hear (per mixing thread)
  121. DWORD *m_pdwMaxCanHear; // # of elements in the m_dwCanHead array (per mixing thread)
  122. CFrame **m_pSourceFrame; // Source frame (per mixing thread)
  123. BYTE *m_sourceUnCompressed; // Buffer to hold decompressed data (per mixing thread)
  124. BYTE *m_targetCompressed; // Has user's mix been created yet? (per mixing thread)
  125. BOOL *m_pfMixed; // Has the user's output been readied? (per mixing thread)
  126. DWORD *m_pdwUnCompressedBufferOffset;
  127. // Offset into uncompressed buffer for thread (per mixing thread)
  128. DWORD *m_pdwCompressedBufferOffset;
  129. // Offset into compressed buffer for thread (per mixing thread)
  130. DWORD *m_pdwResultLength; // Size of compressed data (in bytes) (per mixing thread)
  131. BOOL *m_pfMixToBeReused; // Will this player's mix be re-used by another player (per mixing thread)
  132. CLockedFixedPool<CDVCSPlayer> *m_pCSOwner;
  133. };
  134. typedef CDVCSPlayer *LPDVCSPLAYER;
  135. #undef DPF_MODNAME
  136. #endif