blob: fc2fe53eedab6555d3300a011f29f794510052a1 [file] [log] [blame]
Alexandre Lision8af73cb2013-12-10 14:11:20 -05001//------------------------------------------------------------------------------
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
10
11#ifndef __MTYPE__
12#define __MTYPE__
13
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 */
17
18class CMediaType : public _AMMediaType {
19
20public:
21
22 ~CMediaType();
23 CMediaType();
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);
27
28 CMediaType& operator=(const CMediaType&);
29 CMediaType& operator=(const AM_MEDIA_TYPE&);
30
31 BOOL operator == (const CMediaType&) const;
32 BOOL operator != (const CMediaType&) const;
33
34 HRESULT Set(const CMediaType& rt);
35 HRESULT Set(const AM_MEDIA_TYPE& rt);
36
37 BOOL IsValid() const;
38
39 const GUID *Type() const { return &majortype;} ;
40 void SetType(const GUID *);
41 const GUID *Subtype() const { return &subtype;} ;
42 void SetSubtype(const GUID *);
43
44 BOOL IsFixedSize() const {return bFixedSizeSamples; };
45 BOOL IsTemporalCompressed() const {return bTemporalCompression; };
46 ULONG GetSampleSize() const;
47
48 void SetSampleSize(ULONG sz);
49 void SetVariableSize();
50 void SetTemporalCompression(BOOL bCompressed);
51
52 // read/write pointer to format - can't change length without
53 // calling SetFormat, AllocFormatBuffer or ReallocFormatBuffer
54
55 BYTE* Format() const {return pbFormat; };
56 ULONG FormatLength() const { return cbFormat; };
57
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);
64
65 void InitMediaType();
66
67 BOOL MatchesPartial(const CMediaType* ppartial) const;
68 BOOL IsPartiallySpecified(void) const;
69};
70
71
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 */
75
76void WINAPI DeleteMediaType(__inout_opt AM_MEDIA_TYPE *pmt);
77AM_MEDIA_TYPE * WINAPI CreateMediaType(AM_MEDIA_TYPE const *pSrc);
78HRESULT WINAPI CopyMediaType(__out AM_MEDIA_TYPE *pmtTarget, const AM_MEDIA_TYPE *pmtSource);
79void WINAPI FreeMediaType(__inout AM_MEDIA_TYPE& mt);
80
81// Initialize a media type from a WAVEFORMATEX
82
83STDAPI CreateAudioMediaType(
84 const WAVEFORMATEX *pwfx,
85 __out AM_MEDIA_TYPE *pmt,
86 BOOL bSetFormat);
87
88#endif /* __MTYPE__ */
89