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