mtype.h 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104
  1. //------------------------------------------------------------------------------
  2. // File: MtType.h
  3. //
  4. // Desc: DirectShow base classes - defines a class that holds and manages
  5. // media type information.
  6. //
  7. // Copyright (c) 1992-2001 Microsoft Corporation. All rights reserved.
  8. //------------------------------------------------------------------------------
  9. #ifndef __MTYPE__
  10. #define __MTYPE__
  11. /* Helper class that derived pin objects can use to compare media
  12. types etc. Has same data members as the struct AM_MEDIA_TYPE defined
  13. in the streams IDL file, but also has (non-virtual) functions */
  14. class CMediaType : public _AMMediaType
  15. {
  16. public:
  17. ~CMediaType();
  18. CMediaType();
  19. CMediaType(const GUID * majortype);
  20. CMediaType(const AM_MEDIA_TYPE&, __out_opt HRESULT* phr = NULL);
  21. CMediaType(const CMediaType&, __out_opt HRESULT* phr = NULL);
  22. CMediaType& operator=(const CMediaType&);
  23. CMediaType& operator=(const AM_MEDIA_TYPE&);
  24. BOOL operator == (const CMediaType&) const;
  25. BOOL operator != (const CMediaType&) const;
  26. HRESULT Set(const CMediaType& rt);
  27. HRESULT Set(const AM_MEDIA_TYPE& rt);
  28. BOOL IsValid() const;
  29. const GUID *Type() const {
  30. return &majortype;
  31. } ;
  32. void SetType(const GUID *);
  33. const GUID *Subtype() const {
  34. return &subtype;
  35. } ;
  36. void SetSubtype(const GUID *);
  37. BOOL IsFixedSize() const {
  38. return bFixedSizeSamples;
  39. };
  40. BOOL IsTemporalCompressed() const {
  41. return bTemporalCompression;
  42. };
  43. ULONG GetSampleSize() const;
  44. void SetSampleSize(ULONG sz);
  45. void SetVariableSize();
  46. void SetTemporalCompression(BOOL bCompressed);
  47. // read/write pointer to format - can't change length without
  48. // calling SetFormat, AllocFormatBuffer or ReallocFormatBuffer
  49. BYTE* Format() const {
  50. return pbFormat;
  51. };
  52. ULONG FormatLength() const {
  53. return cbFormat;
  54. };
  55. void SetFormatType(const GUID *);
  56. const GUID *FormatType() const {
  57. return &formattype;
  58. };
  59. BOOL SetFormat(__in_bcount(length) BYTE *pFormat, ULONG length);
  60. void ResetFormatBuffer();
  61. BYTE* AllocFormatBuffer(ULONG length);
  62. BYTE* ReallocFormatBuffer(ULONG length);
  63. void InitMediaType();
  64. BOOL MatchesPartial(const CMediaType* ppartial) const;
  65. BOOL IsPartiallySpecified(void) const;
  66. };
  67. /* General purpose functions to copy and delete a task allocated AM_MEDIA_TYPE
  68. structure which is useful when using the IEnumMediaFormats interface as
  69. the implementation allocates the structures which you must later delete */
  70. void WINAPI DeleteMediaType(__inout_opt AM_MEDIA_TYPE *pmt);
  71. AM_MEDIA_TYPE * WINAPI CreateMediaType(AM_MEDIA_TYPE const *pSrc);
  72. HRESULT WINAPI CopyMediaType(__out AM_MEDIA_TYPE *pmtTarget, const AM_MEDIA_TYPE *pmtSource);
  73. void WINAPI FreeMediaType(__inout AM_MEDIA_TYPE& mt);
  74. // Initialize a media type from a WAVEFORMATEX
  75. STDAPI CreateAudioMediaType(
  76. const WAVEFORMATEX *pwfx,
  77. __out AM_MEDIA_TYPE *pmt,
  78. BOOL bSetFormat);
  79. #endif /* __MTYPE__ */