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.

122 lines
3.4 KiB

  1. /*
  2. * File: vcmcaps.cpp
  3. *
  4. * Base VCM implementation of Microsoft Network Audio capability object.
  5. *
  6. * Revision History:
  7. *
  8. * 12/20/95 mikev created
  9. * 06/11/96 mikev separated protocol implementation specifics into
  10. * msiacaps.cpp (the original proprietary version) and
  11. * vcmh323.cpp (H.323/H.245 implementation)
  12. * 07/28/96 philf added support for video
  13. */
  14. #include "precomp.h"
  15. //UINT uVidNumLocalFormats =0; // # of active entries in pLocalFormats
  16. //UINT uVidLocalFormatCapacity=0; // size of pLocalFormats (in multiples of VIDCAP_DETAILS)
  17. //UINT uVidStaticRef = 0; // global ref count
  18. //UINT uVidNumCustomDecodeFormats=0; // # of custom entries for decode
  19. //VIDEO_FORMAT_ID VIDsByRank[MAX_CAPS_PRESORT]; // the best 16 ranked formats, sorted (descending, best first)
  20. //AUDIO_FORMAT_ID IDsByBandwidth[MAX_CAPS_PRESORT]; // ascending, least BW reqirement first
  21. //AUDIO_FORMAT_ID IDsByLossTolerance[MAX_CAPS_PRESORT]; // descending, most tolerant first
  22. //AUDIO_FORMAT_ID IDsByCPULoad[MAX_CAPS_PRESORT]; // ascending, lightest load first
  23. //#pragma data_seg()
  24. PVCMFORMATDETAILS pvfd_g;
  25. static UINT uMaxFormatSize =0;
  26. PVIDEOFORMATEX lpScratchFormat = NULL;
  27. BOOL __stdcall VCMFormatEnumCallback(HVCMDRIVERID hvdid, PVCMDRIVERDETAILS pvdd, PVCMFORMATDETAILS pvfd, DWORD_PTR dwInstance);
  28. CVcmCapability::CVcmCapability()
  29. :m_dwDeviceID(VIDEO_MAPPER)
  30. {
  31. }
  32. CVcmCapability::~CVcmCapability()
  33. {
  34. }
  35. // FormatEnum() is the root level enumeration of VCM formats. Each permutation of
  36. // format tag, bits per sample, and sample rate is considered a unique format
  37. // and will have a unique registry entry if it is "enabled" for internet video
  38. // vcmFormatEnum() calls VCMFormatEnumCallback().
  39. BOOL CVcmCapability::FormatEnum(CVcmCapability *pCapObject, DWORD dwFlags)
  40. {
  41. MMRESULT mResult;
  42. VCMDRIVERDETAILS vdd;
  43. VCMFORMATDETAILS vfd;
  44. if(!GetVideoFormatBuffer())
  45. return FALSE;
  46. vdd.dwSize = sizeof(VCMDRIVERDETAILS);
  47. vfd.cbStruct = sizeof(VCMFORMATDETAILS);
  48. vfd.pvfx = lpScratchFormat;
  49. vfd.cbvfx = uMaxFormatSize;
  50. vfd.szFormat[0]=(WCHAR)0;
  51. mResult = vcmFormatEnum(m_dwDeviceID, VCMFormatEnumCallback, &vdd, &vfd, (DWORD_PTR)pCapObject,
  52. dwFlags | VCM_FORMATENUMF_BOTH);
  53. if(lpScratchFormat) {
  54. MemFree(lpScratchFormat);
  55. lpScratchFormat=NULL;
  56. }
  57. if(mResult != MMSYSERR_NOERROR)
  58. {
  59. return FALSE;
  60. }
  61. return TRUE;
  62. }
  63. // default implementation of FormatEnumHandler does nothing
  64. BOOL CVcmCapability::FormatEnumHandler(HVCMDRIVERID hvdid,
  65. PVCMFORMATDETAILS pvfd, VCMDRIVERDETAILS *pvdd, DWORD_PTR dwInstance)
  66. {
  67. return FALSE;
  68. }
  69. BOOL __stdcall VCMFormatEnumCallback(HVCMDRIVERID hvdid,
  70. PVCMDRIVERDETAILS pvdd, PVCMFORMATDETAILS pvfd, DWORD_PTR dwInstance)
  71. {
  72. CVcmCapability *pCapability = (CVcmCapability *)dwInstance;
  73. return pCapability->FormatEnumHandler(hvdid, pvfd, pvdd, dwInstance);
  74. }
  75. BOOL GetVideoFormatBuffer()
  76. {
  77. // Get size of largest VIDEOFORMATEX structure in the system
  78. MMRESULT mResult;
  79. if((mResult = vcmMetrics(NULL, VCM_METRIC_MAX_SIZE_FORMAT, (LPVOID) &uMaxFormatSize)) != MMSYSERR_NOERROR)
  80. {
  81. ERRORMESSAGE(("GetFormatBuffer: vcmMetrics failed:0x%08lX\r\n",mResult));
  82. return FALSE;
  83. }
  84. if(!(lpScratchFormat = (PVIDEOFORMATEX) MemAlloc(uMaxFormatSize)))
  85. {
  86. ERRORMESSAGE(("GetFormatBuffer: allocation failed\r\n"));
  87. return FALSE;
  88. }
  89. ZeroMemory(lpScratchFormat, uMaxFormatSize);
  90. return TRUE;
  91. }
  92.