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.

303 lines
9.7 KiB

  1. #include "precomp.h"
  2. #define INTEL_PRO 1
  3. #ifdef INTEL_PRO
  4. #define WIDTH 176
  5. #define HEIGHT 144
  6. #define NUMBPP 24
  7. #ifndef _ALPHA_
  8. #define VIDEO_FORMAT VIDEO_FORMAT_MSH263
  9. #else
  10. #define VIDEO_FORMAT VIDEO_FORMAT_DECH263
  11. #endif
  12. #define SIZE_IMAGE 8192
  13. #else
  14. #define WIDTH 160
  15. #define HEIGHT 120
  16. #define NUMBPP 16
  17. #define VIDEO_FORMAT VIDEO_FORMAT_BI_RGB
  18. #define SIZE_IMAGE (WIDTHBYTES(WIDTH * NUMBPP) * HEIGHT)
  19. #endif
  20. #define NUMFPS 7
  21. #define BITRATE (SIZE_IMAGE * NUMFPS)
  22. VIDEOFORMATEX g_vfDefList[DVF_NumOfFormats] =
  23. {
  24. #if 1
  25. #if 1
  26. {
  27. VIDEO_FORMAT, // dwFormatTag
  28. NUMFPS, // nSamplesPerSec
  29. BITRATE, // nAvgBytesPerSec
  30. BITRATE, // nMinBytesPerSec
  31. BITRATE, // nMaxBytesPerSec
  32. SIZE_IMAGE,// nBlockAlign
  33. NUMBPP, // wBitsPerSample
  34. // Temporal fields
  35. 142857UL, // dwRequestMicroSecPerFrame
  36. 10UL, // dwPersentDropForError
  37. NUMFPS, // dwNumVideoRequested
  38. 1UL, // dwSupportTSTradeOff
  39. TRUE, // bLive
  40. sizeof(VIDEOFORMATEX), // dwFormatSize
  41. // Spatial fields (BITMAPINFOHEADER compatible)
  42. {
  43. sizeof(BITMAPINFOHEADER), // bih.biSize
  44. WIDTH, // bih.biWidth
  45. HEIGHT, // bih.biHeight
  46. 1, // bih.biPlanes
  47. NUMBPP, // bih.biBitCount
  48. VIDEO_FORMAT, // bih.biCompression
  49. SIZE_IMAGE,// bih.biSizeImage
  50. 0, 0, // bih.bi(X,Y)PelsPerMeter
  51. 0, // bih.biClrUsed
  52. 0 // bih.biClrImportant
  53. }
  54. }
  55. #else
  56. {
  57. VIDEO_FORMAT_BI_RGB, // dwFormatTag
  58. NUMFPS, // nSamplesPerSec
  59. BITRATE, // nAvgBytesPerSec
  60. BITRATE, // nMinBytesPerSec
  61. BITRATE, // nMaxBytesPerSec
  62. WIDTHBYTES(WIDTH * NUMBPP) * HEIGHT,// nBlockAlign
  63. NUMBPP, // wBitsPerSample
  64. // Temporal fields
  65. 142857UL, // dwRequestMicroSecPerFrame
  66. 10UL, // dwPersentDropForError
  67. NUMFPS, // dwNumVideoRequested
  68. 1UL, // dwSupportTSTradeOff
  69. TRUE, // bLive
  70. sizeof(VIDEOFORMATEX), // dwFormatSize
  71. // Spatial fields (BITMAPINFOHEADER compatible)
  72. {
  73. sizeof(BITMAPINFOHEADER), // bih.biSize
  74. WIDTH, // bih.biWidth
  75. HEIGHT, // bih.biHeight
  76. 1, // bih.biPlanes
  77. NUMBPP, // bih.biBitCount
  78. VIDEO_FORMAT_BI_RGB, // bih.biCompression
  79. WIDTHBYTES(WIDTH * NUMBPP) * HEIGHT,// bih.biSizeImage
  80. 0, 0, // bih.bi(X,Y)PelsPerMeter
  81. 0, // bih.biClrUsed
  82. 0 // bih.biClrImportant
  83. }
  84. }
  85. #endif
  86. #else
  87. {
  88. // Wave format compatibility fields
  89. (WORD)0, 7UL, 9600UL, 9600UL, 9600UL, (DWORD)1, (WORD)4,
  90. // Temporal fields
  91. 142857UL, 10UL, 2UL, 142857UL, TRUE, sizeof(VIDEOFORMATEX),
  92. // Spatial fields (BITMAPINFOHEADER compatible)
  93. sizeof(BITMAPINFOHEADER), WIDTH, HEIGHT, 1, 4, BI_RGB, (DWORD)WIDTHBYTES(WIDTH * 4) * HEIGHT, 0, 0, 16, 0
  94. }
  95. #endif
  96. };
  97. #if 0
  98. // Color information fields (Array of 256 RGBQUAD)
  99. 0, 0, 0, 0, 255, 255, 255, 0, 238, 238, 238, 0, 221, 221, 221, 0, 204, 204, 204, 0,
  100. 187, 187, 187, 0, 170, 170, 170, 0, 153, 153, 153, 0, 136, 136, 136, 0, 119, 119, 119, 0,
  101. 102, 102, 102, 0, 85, 85, 85, 0, 68, 68, 68, 0, 51, 51, 51, 0, 34, 34, 34, 0, 17, 17, 17, 0
  102. }
  103. };
  104. { 0, 0, 0, 0}, {255, 255, 255, 0}, {238, 238, 238, 0}, {221, 221, 221, 0}, {204, 204, 204, 0},
  105. {187, 187, 187, 0}, {170, 170, 170, 0}, {153, 153, 153, 0}, {136, 136, 136, 0}, {119, 119, 119, 0},
  106. {102, 102, 102, 0}, { 85, 85, 85, 0}, { 68, 68, 68, 0}, { 51, 51, 51, 0}, { 34, 34, 34, 0}, { 17, 17, 17, 0}
  107. #endif
  108. VIDEOFORMATEX * GetDefFormat ( int idx )
  109. {
  110. return ((idx < DVF_NumOfFormats) ?
  111. (VIDEOFORMATEX *) &g_vfDefList[idx] :
  112. (VIDEOFORMATEX *) NULL);
  113. }
  114. // Move all this into VideoPacket... same for AudioPacket and utils.c
  115. ULONG GetFormatSize ( PVOID pwf )
  116. {
  117. return (((VIDEOFORMATEX *) pwf)->dwFormatSize);
  118. }
  119. BOOL IsSameFormat ( PVOID pwf1, PVOID pwf2 )
  120. {
  121. UINT u1 = GetFormatSize (pwf1);
  122. UINT u2 = GetFormatSize (pwf2);
  123. BOOL fSame = FALSE;
  124. VIDEOFORMATEX *pvfx1 = (VIDEOFORMATEX *)pwf1;
  125. VIDEOFORMATEX *pvfx2 = (VIDEOFORMATEX *)pwf2;
  126. // Only compare relevant fields
  127. if (pvfx1->dwFormatTag != pvfx2->dwFormatTag)
  128. return FALSE;
  129. if (pvfx1->nSamplesPerSec != pvfx2->nSamplesPerSec)
  130. return FALSE;
  131. if (pvfx1->nAvgBytesPerSec != pvfx2->nAvgBytesPerSec)
  132. return FALSE;
  133. if (pvfx1->nMinBytesPerSec != pvfx2->nMinBytesPerSec)
  134. return FALSE;
  135. if (pvfx1->nMaxBytesPerSec != pvfx2->nMaxBytesPerSec)
  136. return FALSE;
  137. if (pvfx1->nBlockAlign != pvfx2->nBlockAlign)
  138. return FALSE;
  139. if (pvfx1->wBitsPerSample != pvfx2->wBitsPerSample)
  140. return FALSE;
  141. if (pvfx1->bih.biSize != pvfx2->bih.biSize)
  142. return FALSE;
  143. if (pvfx1->bih.biWidth != pvfx2->bih.biWidth)
  144. return FALSE;
  145. if (pvfx1->bih.biHeight != pvfx2->bih.biHeight)
  146. return FALSE;
  147. if (pvfx1->bih.biPlanes != pvfx2->bih.biPlanes)
  148. return FALSE;
  149. if (pvfx1->bih.biBitCount != pvfx2->bih.biBitCount)
  150. return FALSE;
  151. if (pvfx1->bih.biCompression != pvfx2->bih.biCompression)
  152. return FALSE;
  153. if (pvfx1->bih.biSizeImage != pvfx2->bih.biSizeImage)
  154. return FALSE;
  155. if (pvfx1->bih.biClrUsed != pvfx2->bih.biClrUsed)
  156. return FALSE;
  157. return TRUE;
  158. }
  159. // Repeat previous frame. This is probably not necessary
  160. // since it is already painted on screen
  161. void CopyPreviousBuf (VIDEOFORMATEX *pwf, PBYTE pb, ULONG cb)
  162. {
  163. return;
  164. }
  165. // similar to the above "IsSameFormat" call, but similifed to satisfy
  166. // the needs of SendVideoStream::Configure
  167. BOOL IsSimilarVidFormat(VIDEOFORMATEX *pvfx1, VIDEOFORMATEX *pvfx2)
  168. {
  169. // Only compare relevant fields
  170. if (pvfx1->bih.biWidth != pvfx2->bih.biWidth)
  171. return FALSE;
  172. if (pvfx1->bih.biHeight != pvfx2->bih.biHeight)
  173. return FALSE;
  174. if (pvfx1->bih.biCompression != pvfx2->bih.biCompression)
  175. return FALSE;
  176. return TRUE;
  177. }
  178. int GetIFrameCaps(IStreamSignal *pStreamSignal)
  179. {
  180. HRESULT hr;
  181. PCC_VENDORINFO pLocalVendorInfo, pRemoteVendorInfo;
  182. int nStringLength20, nStringLength21, nStringLength211, nStringLengthTAPI;
  183. int nStringLength21sp1;
  184. bool bIsNetMeeting = false; // contains NetMeeting in the product string
  185. char *szProductCompare=NULL;
  186. char *szVersionCompare=NULL;
  187. int nLengthProduct, nLengthVersion;
  188. int nRet = IFRAMES_CAPS_3RDPARTY;
  189. if (pStreamSignal == NULL)
  190. {
  191. return IFRAMES_CAPS_UNKNOWN;
  192. }
  193. hr = pStreamSignal->GetVersionInfo(&pLocalVendorInfo, &pRemoteVendorInfo);
  194. if (FAILED(hr) || (NULL == pRemoteVendorInfo))
  195. {
  196. return IFRAMES_CAPS_UNKNOWN;
  197. }
  198. // make sure we are dealing with a Microsoft product
  199. if ((pRemoteVendorInfo->bCountryCode != USA_H221_COUNTRY_CODE) ||
  200. (pRemoteVendorInfo->wManufacturerCode != MICROSOFT_H_221_MFG_CODE) ||
  201. (pRemoteVendorInfo->pProductNumber == NULL) ||
  202. (pRemoteVendorInfo->pVersionNumber == NULL)
  203. )
  204. {
  205. return IFRAMES_CAPS_3RDPARTY;
  206. }
  207. // strings aren't guaranteed to be NULL terminated
  208. // so let's make a quick copy of them that so that we can
  209. // do easy string comparisons
  210. nLengthProduct = pRemoteVendorInfo->pProductNumber->wOctetStringLength;
  211. nLengthVersion = pRemoteVendorInfo->pVersionNumber->wOctetStringLength;
  212. szProductCompare = new char[nLengthProduct+1];
  213. szVersionCompare = new char[nLengthVersion+1];
  214. if ((szProductCompare == NULL) || (szVersionCompare == NULL))
  215. {
  216. return IFRAMES_CAPS_3RDPARTY;
  217. }
  218. ZeroMemory(szProductCompare, nLengthProduct+1);
  219. ZeroMemory(szVersionCompare, nLengthVersion+1);
  220. CopyMemory(szProductCompare, pRemoteVendorInfo->pProductNumber->pOctetString, nLengthProduct);
  221. CopyMemory(szVersionCompare, pRemoteVendorInfo->pVersionNumber->pOctetString, nLengthVersion);
  222. // a redundant check to make sure that it is indeed a Microsoft product
  223. if (NULL == _StrStr(szProductCompare, H323_COMPANYNAME_STR))
  224. {
  225. return IFRAMES_CAPS_3RDPARTY;
  226. }
  227. // quick check to see if this is NetMeeting or something else
  228. if (NULL != _StrStr(szProductCompare, H323_PRODUCTNAME_SHORT_STR))
  229. {
  230. bIsNetMeeting = true;
  231. }
  232. // filter out NetMeeting 2.x
  233. if (bIsNetMeeting)
  234. {
  235. if (
  236. (0 == lstrcmp(szVersionCompare, H323_20_PRODUCTRELEASE_STR)) ||
  237. (0 == lstrcmp(szVersionCompare, H323_21_PRODUCTRELEASE_STR)) ||
  238. (0 == lstrcmp(szVersionCompare, H323_211_PRODUCTRELEASE_STR)) ||
  239. (0 == lstrcmp(szVersionCompare, H323_21_SP1_PRODUCTRELEASE_STR))
  240. )
  241. {
  242. delete [] szVersionCompare;
  243. delete [] szProductCompare;
  244. return IFRAMES_CAPS_NM2;
  245. }
  246. }
  247. if (bIsNetMeeting == false)
  248. {
  249. // filter out TAPI v3.0
  250. // their version string is "Version 3.0", NetMeeting is "3.0"
  251. if (0 == lstrcmp(szVersionCompare, H323_TAPI30_PRODUCTRELEASE_STR))
  252. {
  253. delete [] szVersionCompare;
  254. delete [] szProductCompare;
  255. return IFRAMES_CAPS_3RDPARTY;
  256. }
  257. // a Microsoft product that isn't TAPI 3.0 or NetMeeting ?
  258. // assume compliance with the I-Frames stuff
  259. DEBUGMSG (ZONE_IFRAME, ("Microsoft H.323 product that isn't NetMeeting !\r\n"));
  260. DEBUGMSG (ZONE_IFRAME, ("Assuming that that remote knows about I-Frames!\r\n"));
  261. }
  262. delete [] szVersionCompare;
  263. delete [] szProductCompare;
  264. // must be NetMeeting 3.0, TAPI 3.1, or later
  265. return IFRAMES_CAPS_NM3;
  266. }