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.

281 lines
10 KiB

  1. /*
  2. * File: vcmcaps.h
  3. *
  4. *
  5. * VCM implementation of Microsoft Network Video capability object.
  6. *
  7. * Additional methods supported by this implementation:
  8. *
  9. * VIDEO_FORMAT_ID AddEncodeFormat(VIDCAP_DETAILS *pFmtBuf,LPVOID lpvMappingData, UINT uSize);
  10. * VIDEO_FORMAT_ID AddDecodeFormat(VIDCAP_DETAILS *pFmtBuf,LPVOID lpvMappingData, UINT uSize);
  11. *
  12. * Revision History:
  13. *
  14. * 12/27/95 mikev created
  15. * 07/28/96 philf added support for video
  16. */
  17. #ifndef _VCMCAPS_H
  18. #define _VCMCAPS_H
  19. #include <pshpack8.h>
  20. // VCM enumeration support functions
  21. BOOL GetVideoFormatBuffer(VOID);
  22. BOOL __stdcall FormatTagEnumCallback(HVCMDRIVERID hadid, PVCMFORMATTAGDETAILS paftd,
  23. DWORD dwInstance, DWORD fdwSupport);
  24. BOOL __stdcall FormatEnumCallback(HVCMDRIVERID hadid,
  25. PVCMFORMATDETAILS pafd, DWORD_PTR dwInstance, DWORD fdwSupport);
  26. BOOL __stdcall DriverEnumCallback(HVCMDRIVERID hadid,
  27. DWORD_PTR dwInstance, DWORD fdwSupport);
  28. #ifdef __cplusplus
  29. class CVcmCapability
  30. {
  31. protected:
  32. HACMDRIVER hAcmDriver;
  33. DWORD m_dwDeviceID;
  34. public:
  35. CVcmCapability();
  36. ~CVcmCapability();
  37. BOOL FormatEnum(CVcmCapability *pCapObject, DWORD dwFlags);
  38. BOOL DriverEnum(CVcmCapability *pCapObject);
  39. HACMDRIVER GetDriverHandle() {return hAcmDriver;};
  40. virtual BOOL FormatEnumHandler(HVCMDRIVERID hadid,
  41. PVCMFORMATDETAILS pafd, VCMDRIVERDETAILS *padd, DWORD_PTR dwInstance);
  42. };
  43. #define SQCIF 0x1
  44. #define QCIF 0x2
  45. #define CIF 0x4
  46. #define UNKNOWN 0x8
  47. #define get_format(w,h) ((w == 128 && h == 96 ) ? SQCIF : ((w == 176 && h == 144 )? QCIF: ((w == 352 && h == 288 ) ? CIF :UNKNOWN)))
  48. #define NONSTD_VID_TERMCAP {H245_CAPDIR_LCLRX, H245_DATA_VIDEO,H245_CLIENT_VID_NONSTD, 0, {0}}
  49. #define STD_VID_TERMCAP(tc) {H245_CAPDIR_LCLRX, H245_DATA_VIDEO,(tc), 0, {0}}
  50. //Advertise the maximum possible rate, and assume we can do below this.
  51. //H.261 defines a max MPI of 4!
  52. #define STD_VID_PARAMS {0,0,1}
  53. typedef struct VideoParameters
  54. {
  55. BYTE RTPPayload; // RTP payload type
  56. DWORD dwFormatDescriptor; // the unique ID of this format
  57. UINT uSamplesPerSec; // the number of frames per second
  58. UINT uBitsPerSample; // the number of bits per pixel
  59. VIDEO_SIZES enumVideoSize; // enum. Use Small, Medium, Large
  60. UINT biWidth; // the frame width in pixels
  61. UINT biHeight; // the frame height in pixels
  62. }VIDEO_PARAMS;
  63. typedef struct VidCapDetails
  64. {
  65. DWORD dwFormatTag;
  66. CC_TERMCAP H245Cap;
  67. NSC_CHANNEL_VIDEO_PARAMETERS nonstd_params;
  68. VIDEO_PARAMS video_params; // this has a dependency on protocol.h
  69. DWORD dwPublicRefIndex; // index of the local capability entry that will be
  70. // advertized. Zero if this entry is the one to advertize
  71. BOOL bSendEnabled;
  72. BOOL bRecvEnabled;
  73. DWORD dwDefaultSamples; // default number of samples per packet
  74. UINT uMaxBitrate; // max bandwidth used by this format (calculated: bits per sample * sample rate)
  75. UINT uAvgBitrate; // average bandwidth used by this format (we get this from the codec)
  76. WORD wCPUUtilizationEncode;
  77. WORD wCPUUtilizationDecode;
  78. WORD wApplicationPrefOrder; // overriding preference - lower number means more preferred
  79. UINT uLocalDetailsSize; // size in bytes of what lpLocalFormatDetails points to
  80. LPVOID lpLocalFormatDetails;
  81. UINT uRemoteDetailsSize; // size in bytes of what lpRemoteFormatDetails points to
  82. LPVOID lpRemoteFormatDetails;
  83. char szFormat[VCMFORMATDETAILS_FORMAT_CHARS];
  84. } VIDCAP_DETAILS, *PVIDCAP_DETAILS;
  85. /*
  86. * VCM interface
  87. * Definitions for interfacing with VCM
  88. */
  89. typedef struct
  90. {
  91. PVIDCAP_DETAILS pVidcapDetails; // a pointer to an VIDCAP_DETAILS structure
  92. DWORD dwFlags; // misc flags...
  93. PVIDEOFORMATEX pvfx; // pointer to video format structure. used when adding formats
  94. HRESULT hr;
  95. } VCM_APP_PARAM, *PVCM_APP_PARAM;
  96. //
  97. // implementation class of the Video Interface
  98. //
  99. class CImpAppVidCap : public IAppVidCap
  100. {
  101. public:
  102. STDMETHOD_(ULONG, AddRef());
  103. STDMETHOD_(ULONG, Release());
  104. STDMETHOD(GetNumFormats(UINT *puNumFmtOut));
  105. STDMETHOD(ApplyAppFormatPrefs(PBASIC_VIDCAP_INFO pFormatPrefsBuf,
  106. UINT uNumFormatPrefs));
  107. STDMETHOD(EnumFormats(PBASIC_VIDCAP_INFO pFmtBuf, UINT uBufsize,
  108. UINT *uNumFmtOut));
  109. STDMETHOD(EnumCommonFormats(PBASIC_VIDCAP_INFO pFmtBuf, UINT uBufsize,
  110. UINT *uNumFmtOut, BOOL bTXCaps));
  111. STDMETHOD( GetBasicVidcapInfo (VIDEO_FORMAT_ID Id,
  112. PBASIC_VIDCAP_INFO pFormatPrefsBuf));
  113. STDMETHOD( AddVCMFormat (PVIDEOFORMATEX lpvfx, PVIDCAP_INFO pVidCapInfo));
  114. STDMETHOD( RemoveVCMFormat (PVIDEOFORMATEX lpvfx));
  115. STDMETHOD_ (PVIDEOFORMATEX, GetVidcapDetails(THIS_ VIDEO_FORMAT_ID Id));
  116. STDMETHOD( GetPreferredFormatId (VIDEO_FORMAT_ID *pId));
  117. STDMETHOD (SetDeviceID(DWORD dwDeviceID));
  118. void Init(class CMsivCapability * pCapObject) {m_pCapObject = pCapObject;};
  119. protected:
  120. class CMsivCapability * m_pCapObject;
  121. };
  122. class CMsivCapability : public IH323MediaCap, public CVcmCapability
  123. {
  124. protected:
  125. UINT uRef;
  126. BOOL bPublicizeTXCaps;
  127. BOOL bPublicizeTSTradeoff;
  128. //LOOKLOOK this supports a hack to disable CPU intensive codecs if not running on a pentium
  129. WORD wMaxCPU;
  130. static MEDIA_FORMAT_ID IDsByRank[MAX_CAPS_PRESORT];
  131. static UINT uNumLocalFormats; // # of active entries in pLocalFormats
  132. static UINT uStaticRef; // global ref count
  133. static UINT uCapIDBase; // rebase capability ID to index into IDsByRank
  134. static VIDCAP_DETAILS *pLocalFormats; // cached list of formats that we can receive
  135. static UINT uLocalFormatCapacity; // size of pLocalFormats (in multiples of VIDCAP_DETAILS)
  136. PVIDCAP_DETAILS pRemoteDecodeFormats; // cached list of formats that the
  137. // other end can receive/decode
  138. UINT uNumRemoteDecodeFormats; // # of entries for remote decode capabilities
  139. UINT uRemoteDecodeFormatCapacity; // size of pRemoteDecodeFormats (in multiples of VIDCAP_DETAILS)
  140. PVCM_APP_PARAM m_pAppParam; // a pointer to a PVCM_APP_PARAM structure. Used to carry
  141. // a information through the enumeration process
  142. // but can be used for other purposes
  143. //
  144. // embedded interface classes
  145. //
  146. CImpAppVidCap m_IAppVidCap;
  147. protected:
  148. // Internal functions
  149. UINT IDToIndex(MEDIA_FORMAT_ID id) {return id - uCapIDBase;};
  150. MEDIA_FORMAT_ID IndexToId(UINT uIndex){return uIndex + uCapIDBase;};
  151. LPTSTR AllocRegistryKeyName(LPTSTR lpDriverName,
  152. UINT uSampleRate, UINT uBitsPerSample, UINT uBytesPerSec,UINT uWidth,UINT uHeight);
  153. VOID FreeRegistryKeyName(LPTSTR lpszKeyName);
  154. VOID CalculateFormatProperties(VIDCAP_DETAILS *pFmtBuf, PVIDEOFORMATEX lpvfx);
  155. BOOL IsFormatSpecified(PVIDEOFORMATEX lpFormat, PVCMFORMATDETAILS pvfd,
  156. VCMDRIVERDETAILS *pvdd, VIDCAP_DETAILS *pVidcapDetails);
  157. virtual VOID SortEncodeCaps(SortMode sortmode);
  158. virtual VIDEO_FORMAT_ID AddFormat(VIDCAP_DETAILS *pFmtBuf,LPVOID lpvMappingData, UINT uSize);
  159. BOOL UpdateFormatInRegistry(VIDCAP_DETAILS *pFmt);
  160. BOOL BuildFormatName( PVIDCAP_DETAILS pVidcapDetails,
  161. WCHAR *pszDriverName,
  162. WCHAR *pszFormatName);
  163. HRESULT GetFormatName(PVIDCAP_DETAILS pVidcapDetails, PVIDEOFORMATEX pvfx);
  164. public:
  165. STDMETHOD_(BOOL, Init());
  166. STDMETHOD_(BOOL, ReInit());
  167. CMsivCapability();
  168. ~CMsivCapability();
  169. // handler for codec enumeration callback
  170. virtual BOOL FormatEnumHandler(HVCMDRIVERID hvdid,
  171. PVCMFORMATDETAILS pvfd, VCMDRIVERDETAILS *pvdd, DWORD_PTR dwInstance);
  172. //
  173. // Common interface methods
  174. //
  175. STDMETHODIMP QueryInterface(REFIID riid, LPVOID FAR * ppvObj);
  176. STDMETHOD_(ULONG, AddRef());
  177. STDMETHOD_(ULONG, Release());
  178. //
  179. // IVCapApi methods
  180. //
  181. STDMETHOD(GetNumFormats(UINT *puNumFmtOut));
  182. STDMETHOD(ApplyAppFormatPrefs(PBASIC_VIDCAP_INFO pFormatPrefsBuf,
  183. UINT uNumFormatPrefs));
  184. STDMETHOD(EnumFormats(PBASIC_VIDCAP_INFO pFmtBuf, UINT uBufsize,
  185. UINT *uNumFmtOut));
  186. STDMETHOD(EnumCommonFormats(PBASIC_VIDCAP_INFO pFmtBuf, UINT uBufsize,
  187. UINT *uNumFmtOut, BOOL bTXCaps));
  188. STDMETHOD( GetBasicVidcapInfo (VIDEO_FORMAT_ID Id,
  189. PBASIC_VIDCAP_INFO pFormatPrefsBuf));
  190. STDMETHOD( AddVCMFormat (PVIDEOFORMATEX lpvfx, PVIDCAP_INFO pVidCapInfo));
  191. STDMETHOD( RemoveVCMFormat (PVIDEOFORMATEX lpvfx));
  192. STDMETHOD( GetPreferredFormatId (VIDEO_FORMAT_ID *pId));
  193. STDMETHOD (SetDeviceID(DWORD dwDeviceID)) {m_dwDeviceID = dwDeviceID; return hrSuccess;};
  194. // support of IVCapApi methods
  195. virtual HRESULT CopyVidcapInfo (PVIDCAP_DETAILS pDetails, PVIDCAP_INFO pInfo,
  196. BOOL bDirection);
  197. //
  198. // IH323MediaCap methods
  199. //
  200. STDMETHOD_(VOID, FlushRemoteCaps());
  201. STDMETHOD( AddRemoteDecodeCaps(PCC_TERMCAPLIST pTermCapList));
  202. STDMETHOD_(VIDEO_FORMAT_ID, AddRemoteDecodeFormat(PCC_TERMCAP pCCThisCap));
  203. // Get local and remote channel parameters for a specific encode capability
  204. STDMETHOD( GetEncodeParams(LPVOID pBufOut, UINT uBufSize, LPVOID pLocalParams,
  205. UINT uLocalSize,MEDIA_FORMAT_ID idRemote,MEDIA_FORMAT_ID idLocal));
  206. STDMETHOD( GetPublicDecodeParams(LPVOID pBufOut, UINT uBufSize, VIDEO_FORMAT_ID id));
  207. STDMETHOD( GetDecodeParams(PCC_RX_CHANNEL_REQUEST_CALLBACK_PARAMS pChannelParams,
  208. VIDEO_FORMAT_ID * pFormatID, LPVOID lpvBuf, UINT uBufSize));
  209. STDMETHOD_(UINT, GetNumCaps()){return uNumLocalFormats;};
  210. STDMETHOD_(UINT, GetNumCaps(BOOL bRXCaps));
  211. STDMETHOD_(BOOL, IsHostForCapID(MEDIA_FORMAT_ID CapID));
  212. STDMETHOD_(BOOL, IsCapabilityRecognized(PCC_TERMCAP pCCThisCap));
  213. STDMETHOD(SetCapIDBase(UINT uNewBase));
  214. STDMETHOD_(UINT, GetCapIDBase()) {return uCapIDBase;};
  215. STDMETHOD (IsFormatEnabled (MEDIA_FORMAT_ID FormatID, PBOOL bRecv, PBOOL bSend));
  216. STDMETHOD_(BOOL, IsFormatPublic(MEDIA_FORMAT_ID FormatID));
  217. STDMETHOD_(MEDIA_FORMAT_ID, GetPublicID(MEDIA_FORMAT_ID FormatID));
  218. STDMETHOD_ (VOID, EnableTXCaps(BOOL bSetting)) {bPublicizeTXCaps = bSetting;};
  219. STDMETHOD_ (VOID, EnableRemoteTSTradeoff(BOOL bSetting)) {bPublicizeTSTradeoff= bSetting;};
  220. STDMETHOD (SetAudioPacketDuration( UINT durationInMs));
  221. STDMETHOD (ResolveToLocalFormat(MEDIA_FORMAT_ID FormatIDLocal,
  222. MEDIA_FORMAT_ID * pFormatIDRemote));
  223. STDMETHOD_(UINT, GetLocalSendParamSize(MEDIA_FORMAT_ID dwID));
  224. STDMETHOD_(UINT, GetLocalRecvParamSize(PCC_TERMCAP pCapability));
  225. STDMETHOD( CreateCapList(LPVOID *ppCapBuf));
  226. STDMETHOD( DeleteCapList(LPVOID pCapBuf));
  227. STDMETHOD( ResolveEncodeFormat(VIDEO_FORMAT_ID *pIDVidEncodeOut,VIDEO_FORMAT_ID * pIDVidRemoteDecode));
  228. // methods provided to the Data pump, common to H.323 and MSICCP
  229. STDMETHOD(GetDecodeFormatDetails(MEDIA_FORMAT_ID FormatID, VOID **ppFormat, UINT *puSize));
  230. STDMETHOD(GetEncodeFormatDetails(MEDIA_FORMAT_ID FormatID, VOID **ppFormat, UINT *puSize));
  231. };
  232. #endif // __cplusplus
  233. #include <poppack.h>
  234. #endif //#ifndef _VCMCAPS_H
  235.