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.

202 lines
4.8 KiB

  1. /*++
  2. Copyright (c) 1995-1996 Microsoft Corporation
  3. Module Name:
  4. medictrl.h
  5. Abstract:
  6. Defines the MediaControl class which encapsulates the multimedia devices, in particular
  7. WaveIn and WaveOut.
  8. --*/
  9. #ifndef _MEDICTRL_H_
  10. #define _MEDICTRL_H_
  11. #include <pshpack8.h> /* Assume 8 byte packing throughout */
  12. #define MC_USING_DEFAULT ((UINT) -1)
  13. // #define MC_DEF_SILENCE_LEVEL 110 // about 10%
  14. // #define MC_DEF_SILENCE_LEVEL 20 // about 2%
  15. #define MC_DEF_SILENCE_LEVEL 60 // about 6%
  16. #define MC_DEF_SILENCE_DURATION 600 // 600ms
  17. #define MC_DEF_DURATION 40 // 40ms
  18. #define MC_DEF_VOLUME 50 // 50%
  19. #define MC_DEF_RECORD_TIMEOUT 2000 // 1000ms
  20. #define MC_DEF_PLAY_TIMEOUT 2000 // 1000ms
  21. #define MC_DEF_RECORD_BUFS 4
  22. #define MC_DEF_PLAY_BUFS 4
  23. typedef struct tagMediaCtrlInitStruct
  24. {
  25. DWORD dwFlags;
  26. HWND hAppWnd; // handle to window that owns the NAVC
  27. HINSTANCE hAppInst; // handle to instance of app
  28. }
  29. MEDIACTRLINIT;
  30. typedef struct tagMediaCtrlConfigStruct
  31. {
  32. ULONG cbSamplesPerPkt; // samples per buffer (only needed if duration is not specified)
  33. DPHANDLE hStrm; // Rx/Tx audio stream
  34. UINT uDevId;
  35. PVOID pDevFmt;
  36. UINT uDuration; // buffer duration in units of ms, usually 20ms or 30ms
  37. }MEDIACTRLCONFIG;
  38. class MediaControl
  39. {
  40. protected:
  41. // flags
  42. DWORD m_dwFlags; // compatible to that of class AudioPacket
  43. // ptr to stream object
  44. DPHANDLE m_hStrm; // Rx/Tx queue
  45. // device id
  46. UINT m_uDevId;
  47. // device of mm io
  48. DPHANDLE m_hDev;
  49. PVOID m_pDevFmt;
  50. ULONG m_cbSizeDevData; // ATT: the sender must agree on this size
  51. // this should be done in format negotiation
  52. // need to talk to MikeV about this!!!
  53. // properties
  54. UINT m_uState; // state: idle, start, pause, stop
  55. UINT m_uDuration; // duration per frame, in units of 10ms
  56. BOOL volatile m_fJammed; // is the device allocated elsewhere
  57. // notification event
  58. HANDLE m_hEvent;
  59. // references to audio packets
  60. MediaPacket **m_ppMediaPkt;
  61. ULONG m_cMediaPkt;
  62. protected:
  63. void _Construct ( void );
  64. void _Destruct ( void );
  65. public:
  66. MediaControl ( void );
  67. ~MediaControl ( void );
  68. virtual HRESULT Initialize ( MEDIACTRLINIT * p );
  69. virtual HRESULT Configure ( MEDIACTRLCONFIG * p ) = 0;
  70. virtual HRESULT FillMediaPacketInit ( MEDIAPACKETINIT * p );
  71. virtual HRESULT SetProp ( DWORD dwPropId, DWORD_PTR dwPropVal );
  72. virtual HRESULT GetProp ( DWORD dwPropId, PDWORD_PTR pdwPropVal );
  73. virtual HRESULT Open ( void ) = 0;
  74. virtual HRESULT Start ( void ) = 0;
  75. virtual HRESULT Stop ( void ) = 0;
  76. virtual HRESULT Reset ( void ) = 0;
  77. virtual HRESULT Close ( void ) = 0;
  78. virtual HRESULT RegisterData ( PVOID pDataPtrArray, ULONG cElements );
  79. virtual HRESULT PrepareHeaders ( void );
  80. virtual HRESULT UnprepareHeaders ( void );
  81. virtual HRESULT Release ( void );
  82. };
  83. class WaveInControl : public MediaControl {
  84. private:
  85. UINT m_uTimeout; // timeout in notification wait
  86. UINT m_uPrefeed; // num of buffers prefed to device
  87. UINT m_uSilenceDuration; // continuous silence before cutoff
  88. public:
  89. WaveInControl ( void );
  90. ~WaveInControl ( void );
  91. HRESULT Initialize ( MEDIACTRLINIT * p );
  92. HRESULT Configure ( MEDIACTRLCONFIG * p );
  93. HRESULT SetProp ( DWORD dwPropId, DWORD_PTR dwPropVal );
  94. HRESULT GetProp ( DWORD dwPropId, PDWORD_PTR pdwPropVal );
  95. HRESULT Open ( void );
  96. HRESULT Start ( void );
  97. HRESULT Stop ( void );
  98. HRESULT Reset ( void );
  99. HRESULT Close ( void );
  100. };
  101. class WaveOutControl : public MediaControl {
  102. private:
  103. UINT m_uVolume; // volume of the sound
  104. UINT m_uTimeout; // timeout in notification wait
  105. UINT m_uPrefeed; // num of buffers prefed to device
  106. UINT m_uPosition; // position of the playback stream
  107. public:
  108. WaveOutControl ( void );
  109. ~WaveOutControl ( void );
  110. HRESULT Initialize ( MEDIACTRLINIT * p );
  111. HRESULT Configure ( MEDIACTRLCONFIG * p );
  112. HRESULT SetProp ( DWORD dwPropId, DWORD_PTR dwPropVal );
  113. HRESULT GetProp ( DWORD dwPropId, PDWORD_PTR pdwPropVal );
  114. HRESULT Open ( void );
  115. HRESULT Start ( void );
  116. HRESULT Stop ( void );
  117. HRESULT Reset ( void );
  118. HRESULT Close ( void );
  119. };
  120. enum
  121. {
  122. MC_PROP_MEDIA_STREAM,
  123. MC_PROP_MEDIA_DEV_HANDLE,
  124. MC_PROP_MEDIA_FORMAT,
  125. MC_PROP_SIZE,
  126. MC_PROP_PLATFORM,
  127. MC_PROP_VOLUME,
  128. MC_PROP_SILENCE_LEVEL,
  129. MC_PROP_SILENCE_DURATION,
  130. MC_PROP_TIMEOUT,
  131. MC_PROP_PREFEED,
  132. MC_PROP_DURATION,
  133. MC_PROP_DUPLEX_TYPE,
  134. MC_PROP_EVENT_HANDLE,
  135. MC_PROP_SPP,
  136. MC_PROP_SPS,
  137. MC_PROP_STATE,
  138. MC_PROP_VOICE_SWITCH,
  139. MC_PROP_AUDIO_STRENGTH,
  140. MC_PROP_MEDIA_DEV_ID,
  141. MC_PROP_AUDIO_JAMMED,
  142. MC_PROP_NumOfProps
  143. };
  144. enum
  145. {
  146. MC_TYPE_AUDIO,
  147. MC_TYPE_NumOfTypes
  148. };
  149. enum
  150. {
  151. MC_STATE_IDLE,
  152. MC_STATE_START,
  153. MC_STATE_PAUSE,
  154. MC_STATE_STOP,
  155. MC_STATE_NumOfStates
  156. };
  157. #include <poppack.h> /* End byte packing */
  158. #endif // _MEDICTRL_H_
  159.