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.

81 lines
2.4 KiB

  1. // Copyright (c) 1997 - 1998 Microsoft Corporation. All Rights Reserved.
  2. #ifndef __UTIL_H_INC__
  3. #define __UTIL_H_INC__
  4. bool IsSameObject(IUnknown *pUnk1, IUnknown *pUnk2);
  5. STDAPI_(void) TStringFromGUID(const GUID* pguid, LPTSTR pszBuf);
  6. #ifdef UNICODE
  7. #define WStringFromGUID TStringFromGUID
  8. #else
  9. STDAPI_(void) WStringFromGUID(const GUID* pguid, LPWSTR pszBuf);
  10. #endif
  11. void InitMediaType(AM_MEDIA_TYPE *pmt);
  12. void DeleteMediaType(AM_MEDIA_TYPE *pmt);
  13. bool IsEqualMediaType(AM_MEDIA_TYPE const & mt1, AM_MEDIA_TYPE const & mt2);
  14. void CopyMediaType(AM_MEDIA_TYPE *pmtTarget, const AM_MEDIA_TYPE *pmtSource);
  15. AM_MEDIA_TYPE * CreateMediaType(AM_MEDIA_TYPE *pSrc);
  16. void FreeMediaType(AM_MEDIA_TYPE& mt);
  17. AM_MEDIA_TYPE * WINAPI AllocVideoMediaType(const AM_MEDIA_TYPE * pmtSource);
  18. HRESULT ConvertMediaTypeToSurfaceDesc(const AM_MEDIA_TYPE *pmt,
  19. IDirectDraw *pDD,
  20. IDirectDrawPalette **ppPalette,
  21. LPDDSURFACEDESC pSurfaceDesc);
  22. HRESULT ConvertSurfaceDescToMediaType(
  23. const DDSURFACEDESC *pSurfaceDesc, IDirectDrawPalette *pPalette, const RECT *pRect,
  24. BOOL bInvertSize, AM_MEDIA_TYPE **ppMediaType,
  25. AM_MEDIA_TYPE *pmtTemplate = 0 // preserve any type information
  26. );
  27. const DDPIXELFORMAT * GetDefaultPixelFormatPtr(IDirectDraw *pDirectDraw);
  28. bool VideoSubtypeFromPixelFormat(const DDPIXELFORMAT *pPixelFormat, GUID *pSubType);
  29. bool IsSupportedType(const DDPIXELFORMAT *pPixelFormat);
  30. bool ComparePixelFormats(const DDPIXELFORMAT *pFormat1,
  31. const DDPIXELFORMAT *pFormat2);
  32. /* Class to track timestamps for fixed bitrate data */
  33. class CTimeStamp
  34. {
  35. public:
  36. CTimeStamp()
  37. {
  38. Reset();
  39. }
  40. void Reset()
  41. {
  42. m_lBytesSinceTimeStamp = 0;
  43. m_rt = 0;
  44. }
  45. void SetTime(REFERENCE_TIME rt)
  46. {
  47. m_rt = rt;
  48. m_lBytesSinceTimeStamp = 0;
  49. }
  50. void AccumulateBytes(LONG lBytes)
  51. {
  52. m_lBytesSinceTimeStamp += lBytes;
  53. }
  54. REFERENCE_TIME TimeStamp(LONG lOffset, LONG lByteRate) const
  55. {
  56. _ASSERTE(lByteRate > 0);
  57. // Do the conversion
  58. return m_rt + MulDiv(m_lBytesSinceTimeStamp + lOffset,
  59. 10000000L,
  60. lByteRate);
  61. }
  62. private:
  63. LONG m_lBytesSinceTimeStamp;
  64. REFERENCE_TIME m_rt;
  65. };
  66. #endif __UTIL_H_INC__