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