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.

316 lines
11 KiB

  1. /*
  2. * File: acmcaps.h
  3. *
  4. *
  5. * ACM implementation of Microsoft Network Audio capability object.
  6. *
  7. * Additional methods supported by this implementation:
  8. * BOOL OpenACMDriver(HACMDRIVERID hadid); // (internal)
  9. * VOID CloseACMDriver(); // (internal)
  10. * HACMDRIVER GetDriverHandle(); // (internal)
  11. *
  12. * AUDIO_FORMAT_ID AddEncodeFormat(AUDCAP_DETAILS *pFmtBuf,LPVOID lpvMappingData, UINT uSize);
  13. * AUDIO_FORMAT_ID AddDecodeFormat(AUDCAP_DETAILS *pFmtBuf,LPVOID lpvMappingData, UINT uSize);
  14. *
  15. * Revision History:
  16. *
  17. * 12/27/95 mikev created
  18. */
  19. #ifndef _ACMCAPS_H
  20. #define _ACMCAPS_H
  21. // ACM enumeration support functions
  22. BOOL GetFormatBuffer(VOID);
  23. BOOL __stdcall ACMFormatTagEnumCallback(HACMDRIVERID hadid, LPACMFORMATTAGDETAILS paftd,
  24. DWORD_PTR dwInstance, DWORD fdwSupport);
  25. BOOL __stdcall ACMFormatEnumCallback(HACMDRIVERID hadid,
  26. LPACMFORMATDETAILS pafd, DWORD_PTR dwInstance, DWORD fdwSupport);
  27. BOOL __stdcall ACMDriverEnumCallback(HACMDRIVERID hadid,
  28. DWORD_PTR dwInstance, DWORD fdwSupport);
  29. #ifdef __cplusplus
  30. class CAcmCapability
  31. {
  32. protected:
  33. HACMDRIVER hAcmDriver;
  34. public:
  35. CAcmCapability();
  36. ~CAcmCapability();
  37. BOOL DriverEnum(DWORD_PTR pAppParam);
  38. HACMDRIVER GetDriverHandle() {return hAcmDriver;};
  39. virtual BOOL FormatEnumHandler(HACMDRIVERID hadid,
  40. LPACMFORMATDETAILS pafd, DWORD_PTR dwInstance, DWORD fdwSupport);
  41. virtual BOOL OpenACMDriver(HACMDRIVERID hadid);
  42. virtual VOID CloseACMDriver();
  43. };
  44. #define PREF_ORDER_UNASSIGNED 0xffff
  45. typedef enum {
  46. SortByAppPref=0
  47. }SortMode;
  48. typedef struct AudioParameters
  49. {
  50. BYTE RTPPayload; // RTP payload type
  51. DWORD dwFormatDescriptor; // the unique ID of this format
  52. UINT uSamplesPerSec;
  53. UINT uBitsPerSample;
  54. }AUDIO_PARAMS;
  55. typedef struct H245AudCaps
  56. {
  57. H245_CAPDIR_T Dir;
  58. H245_DATA_T DataType;
  59. H245_CLIENT_T ClientType;
  60. H245_CAPID_T CapId;
  61. H245_CAP_NONSTANDARD_T H245_NonStd;
  62. H245_CAP_NONSTANDARD_T H245Aud_NONSTD;
  63. unsigned short H245Aud_G711_ALAW64;
  64. unsigned short H245Aud_G711_ULAW64;
  65. H245_CAP_G723_T H245Aud_G723;
  66. } H245_TERMCAP;
  67. // default initializer for NSC_CHANNEL_PARAMETERS
  68. #define STD_CHAN_PARAMS {0, 0,0,0,0,0,0,0,0}
  69. // initializers for CC_TERMCAP
  70. #define NONSTD_TERMCAP {H245_CAPDIR_LCLRX, H245_DATA_AUDIO,H245_CLIENT_AUD_NONSTD, 0, {0}}
  71. #define STD_TERMCAP(tc) {H245_CAPDIR_LCLRX, H245_DATA_AUDIO,(tc), 0, {0}}
  72. // Capability cache structure. This contains local capabilities, public versions of
  73. // those capabilities, parameters for capabilities, plus other information
  74. // that is used to affect how the local machine proritizes or selects a format
  75. //
  76. typedef struct AudCapDetails
  77. {
  78. WORD wFormatTag;
  79. H245_TERMCAP H245TermCap;
  80. NSC_CHANNEL_PARAMETERS nonstd_params;
  81. AUDIO_PARAMS audio_params;
  82. DWORD dwPublicRefIndex; // index of the local capability entry that will be
  83. // advertized. Zero if this entry is the one to advertize
  84. BOOL bSendEnabled;
  85. BOOL bRecvEnabled;
  86. DWORD dwDefaultSamples; // default number of samples per packet
  87. UINT uMaxBitrate; // max bandwidth used by this format (calculated: bits per sample * sample rate)
  88. UINT uAvgBitrate; // average bandwidth used by this format (we get this from the codec)
  89. WORD wCPUUtilizationEncode;
  90. WORD wCPUUtilizationDecode;
  91. WORD wApplicationPrefOrder; // overriding preference - lower number means more preferred
  92. UINT uLocalDetailsSize; // size in bytes of what lpLocalFormatDetails points to
  93. LPVOID lpLocalFormatDetails;
  94. UINT uRemoteDetailsSize; // size in bytes of what lpRemoteFormatDetails points to
  95. LPVOID lpRemoteFormatDetails;
  96. char szFormat[ACMFORMATDETAILS_FORMAT_CHARS];
  97. }AUDCAP_DETAILS, *PAUDCAP_DETAILS;
  98. //Registry Format Cache Structure
  99. //Use In the ACM routines. They build a list of format names, and a list of format data blocks.
  100. //rrf_nFormats is the number of formats we read from the registry.
  101. typedef struct rrfCache {
  102. char **pNames;
  103. BYTE **pData;
  104. UINT nFormats;
  105. } RRF_INFO, *PRRF_INFO;
  106. /*
  107. * ACM interface
  108. * Definitions for interfacing with ACM
  109. */
  110. #define ACMAPP_FORMATENUMHANDLER_MASK 0x3
  111. #define ACMAPP_FORMATENUMHANDLER_ENUM 0x0
  112. #define ACMAPP_FORMATENUMHANDLER_ADD 0x1
  113. typedef struct
  114. {
  115. CAcmCapability *pCapObject; // the "calling" capability object
  116. PAUDCAP_DETAILS pAudcapDetails; // a pointer to an AUDCAP_DETAILS structure
  117. DWORD dwFlags; // misc flags...
  118. LPWAVEFORMATEX lpwfx; // pointer to wave format structure. used when adding formats
  119. LPACMFORMATTAGDETAILS paftd; // pointer to an ACM format tag details.
  120. // is filled in during DriverEnum
  121. HRESULT hr;
  122. PRRF_INFO pRegCache;
  123. } ACM_APP_PARAM, *PACM_APP_PARAM;
  124. //
  125. // implementation class of the audio interface
  126. //
  127. class CImpAppAudioCap : public IAppAudioCap
  128. {
  129. public:
  130. STDMETHOD_(ULONG, AddRef());
  131. STDMETHOD_(ULONG, Release());
  132. STDMETHOD(GetNumFormats(UINT *puNumFmtOut));
  133. STDMETHOD(ApplyAppFormatPrefs(PBASIC_AUDCAP_INFO pFormatPrefsBuf,
  134. UINT uNumFormatPrefs));
  135. STDMETHOD(EnumFormats(PBASIC_AUDCAP_INFO pFmtBuf, UINT uBufsize,
  136. UINT *uNumFmtOut));
  137. STDMETHOD(EnumCommonFormats(PBASIC_AUDCAP_INFO pFmtBuf, UINT uBufsize,
  138. UINT *uNumFmtOut, BOOL bTXCaps));
  139. STDMETHOD( GetBasicAudcapInfo (AUDIO_FORMAT_ID Id,
  140. PBASIC_AUDCAP_INFO pFormatPrefsBuf));
  141. STDMETHOD( AddACMFormat (LPWAVEFORMATEX lpwfx, PBASIC_AUDCAP_INFO pAudCapInfo));
  142. STDMETHOD( RemoveACMFormat (LPWAVEFORMATEX lpwfx));
  143. STDMETHOD_ (LPVOID, GetFormatDetails) (AUDIO_FORMAT_ID Id) ;
  144. void Init(class CMsiaCapability * pCapObject) {m_pCapObject = pCapObject;};
  145. protected:
  146. class CMsiaCapability * m_pCapObject;
  147. };
  148. class CMsiaCapability : public IH323MediaCap, public CAcmCapability
  149. {
  150. protected:
  151. UINT uRef;
  152. BOOL bPublicizeTXCaps;
  153. BOOL bPublicizeTSTradeoff;
  154. PRRF_INFO pRegFmts; //Registry cache info structure
  155. // LOOKLOOK this supports a hack to disable CPU intensive codecs if not running on a pentium
  156. WORD wMaxCPU;
  157. UINT m_uPacketDuration; // packet duration in millisecs
  158. static MEDIA_FORMAT_ID IDsByRank[MAX_CAPS_PRESORT];
  159. static UINT uNumLocalFormats; // # of active entries in pLocalFormats
  160. static UINT uCapIDBase; // rebase capability ID to index into IDsByRank
  161. static AUDCAP_DETAILS *pLocalFormats; // cached list of formats that we can receive
  162. static UINT uLocalFormatCapacity; // size of pLocalFormats (in multiples of AUDCAP_DETAILS)
  163. static UINT uStaticRef; // global ref count for all instances of CMsiaCapability
  164. AUDCAP_DETAILS *pRemoteDecodeFormats; // cached list of formats that the
  165. UINT uNumRemoteDecodeFormats; // # of entries for remote decode capabilities
  166. UINT uRemoteDecodeFormatCapacity; // size of pRemoteDecodeFormats (in multiples of VIDCAP_DETAILS)
  167. // other end can receive/decode
  168. // embedded interface classes
  169. CImpAppAudioCap m_IAppCap;
  170. public:
  171. protected:
  172. // Internal functions
  173. UINT IDToIndex(MEDIA_FORMAT_ID id) {return id - uCapIDBase;};
  174. MEDIA_FORMAT_ID IndexToId(UINT uIndex){return uIndex + uCapIDBase;};
  175. LPTSTR AllocRegistryKeyName(LPTSTR lpDriverName,
  176. UINT uSampleRate, UINT uBitsPerSample, UINT uBytesPerSec);
  177. VOID FreeRegistryKeyName(LPTSTR lpszKeyName);
  178. virtual VOID CalculateFormatProperties(AUDCAP_DETAILS *pFmtBuf,LPWAVEFORMATEX lpwfx);
  179. virtual BOOL IsFormatSpecified(LPWAVEFORMATEX lpFormat, LPACMFORMATDETAILS pafd,
  180. LPACMFORMATTAGDETAILS paftd, AUDCAP_DETAILS *pAudcapDetails);
  181. virtual VOID SortEncodeCaps(SortMode sortmode);
  182. BOOL UpdateFormatInRegistry(AUDCAP_DETAILS *pFmt);
  183. BOOL BuildFormatName( AUDCAP_DETAILS *pAudcapDetails,
  184. char *pszFormatTagName,
  185. char *pszFormatName);
  186. virtual AUDIO_FORMAT_ID AddFormat(AUDCAP_DETAILS *pFmtBuf,LPVOID lpvMappingData, UINT uSize);
  187. DWORD MaxFramesPerPacket(WAVEFORMATEX *pwf);
  188. DWORD MinFramesPerPacket(WAVEFORMATEX *pwf);
  189. UINT MinSampleSize(WAVEFORMATEX *pwf);
  190. public:
  191. STDMETHOD_(BOOL, Init());
  192. STDMETHOD_(BOOL, ReInit());
  193. CMsiaCapability();
  194. ~CMsiaCapability();
  195. // handler for codec enumeration callback
  196. virtual BOOL FormatEnumHandler(HACMDRIVERID hadid,
  197. LPACMFORMATDETAILS pafd, DWORD_PTR dwInstance, DWORD fdwSupport);
  198. virtual BOOL AddFormatEnumHandler(HACMDRIVERID hadid,
  199. LPACMFORMATDETAILS pafd, DWORD_PTR dwInstance, DWORD fdwSupport);
  200. //
  201. // Common interface methods
  202. //
  203. STDMETHODIMP QueryInterface(REFIID riid, LPVOID FAR * ppvObj);
  204. STDMETHOD_(ULONG, AddRef());
  205. STDMETHOD_(ULONG, Release());
  206. //
  207. // IACapApi methods
  208. //
  209. STDMETHOD(GetNumFormats(UINT *puNumFmtOut));
  210. STDMETHOD(ApplyAppFormatPrefs(PBASIC_AUDCAP_INFO pFormatPrefsBuf,
  211. UINT uNumFormatPrefs));
  212. STDMETHOD(EnumFormats(PBASIC_AUDCAP_INFO pFmtBuf, UINT uBufsize,
  213. UINT *uNumFmtOut));
  214. STDMETHOD(EnumCommonFormats(PBASIC_AUDCAP_INFO pFmtBuf, UINT uBufsize,
  215. UINT *uNumFmtOut, BOOL bTXCaps));
  216. STDMETHOD( GetBasicAudcapInfo (AUDIO_FORMAT_ID Id,
  217. PBASIC_AUDCAP_INFO pFormatPrefsBuf));
  218. STDMETHOD( AddACMFormat (LPWAVEFORMATEX lpwfx, PAUDCAP_INFO pAudCapInfo));
  219. STDMETHOD( RemoveACMFormat (LPWAVEFORMATEX lpwfx));
  220. // support of IACapApi
  221. virtual HRESULT CopyAudcapInfo (PAUDCAP_DETAILS pDetails, PAUDCAP_INFO pInfo,
  222. BOOL bDirection);
  223. //
  224. // H.323 method implementations
  225. //
  226. STDMETHOD_(VOID, FlushRemoteCaps());
  227. STDMETHOD( AddRemoteDecodeCaps(PCC_TERMCAPLIST pTermCapList));
  228. STDMETHOD_(MEDIA_FORMAT_ID, AddRemoteDecodeFormat(PCC_TERMCAP pCCThisCap));
  229. STDMETHOD( CreateCapList(LPVOID *ppCapBuf));
  230. STDMETHOD( DeleteCapList(LPVOID pCapBuf));
  231. STDMETHOD( ResolveEncodeFormat(AUDIO_FORMAT_ID *pIDEncodeOut,
  232. AUDIO_FORMAT_ID *pIDRemoteDecode));
  233. STDMETHOD_(UINT, GetLocalSendParamSize(MEDIA_FORMAT_ID dwID));
  234. STDMETHOD_(UINT, GetLocalRecvParamSize(PCC_TERMCAP pCapability));
  235. STDMETHOD( GetEncodeParams(LPVOID pBufOut, UINT uBufSize,LPVOID pLocalParams, UINT uSizeLocal,
  236. AUDIO_FORMAT_ID idRemote, AUDIO_FORMAT_ID idLocal));
  237. STDMETHOD( GetLocalDecodeParams(LPVOID lpvBuf, UINT uBufSize, AUDIO_FORMAT_ID id));
  238. STDMETHOD( GetPublicDecodeParams(LPVOID pBufOut, UINT uBufSize, AUDIO_FORMAT_ID id));
  239. STDMETHOD( GetDecodeParams(PCC_RX_CHANNEL_REQUEST_CALLBACK_PARAMS pChannelParams,
  240. AUDIO_FORMAT_ID * pFormatID, LPVOID lpvBuf, UINT uBufSize));
  241. STDMETHOD_(BOOL, IsCapabilityRecognized(PCC_TERMCAP pCCThisCap));
  242. STDMETHOD_(BOOL, IsFormatPublic(MEDIA_FORMAT_ID FormatID));
  243. STDMETHOD_(MEDIA_FORMAT_ID, GetPublicID(MEDIA_FORMAT_ID FormatID));
  244. STDMETHOD_ (VOID, EnableTXCaps(BOOL bSetting)) {bPublicizeTXCaps = bSetting;};
  245. STDMETHOD_ (VOID, EnableRemoteTSTradeoff(BOOL bSetting)) {bPublicizeTSTradeoff= bSetting;};
  246. STDMETHOD (SetAudioPacketDuration( UINT durationInMs));
  247. STDMETHOD (ResolveToLocalFormat(MEDIA_FORMAT_ID FormatIDLocal,
  248. MEDIA_FORMAT_ID * pFormatIDRemote));
  249. // Methods common to H.323 and MSICCP
  250. STDMETHOD_(UINT, GetNumCaps()){return uNumLocalFormats;};
  251. STDMETHOD_(UINT, GetNumCaps(BOOL bRXCaps));
  252. STDMETHOD_(BOOL, IsHostForCapID(MEDIA_FORMAT_ID CapID));
  253. STDMETHOD(SetCapIDBase(UINT uNewBase));
  254. STDMETHOD_(UINT, GetCapIDBase()) {return uCapIDBase;};
  255. STDMETHOD (IsFormatEnabled (MEDIA_FORMAT_ID FormatID, PBOOL bRecv, PBOOL bSend));
  256. // methods provided to the Data pump, common to H.323 and MSICCP
  257. STDMETHOD(GetEncodeFormatDetails(MEDIA_FORMAT_ID FormatID, VOID **ppFormat, UINT *puSize));
  258. STDMETHOD(GetDecodeFormatDetails(MEDIA_FORMAT_ID FormatID, VOID **ppFormat, UINT *puSize));
  259. };
  260. #endif // __cplusplus
  261. #endif //#ifndef _ACMCAPS_H
  262.