summaryrefslogtreecommitdiffstats
path: root/loader/dshow/mediatype.h
blob: c58bb32e9f00bc3aaa89e89133dc9733e799f325 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
/*
-------------------------------------------------------------------
    AM_MEDIA_TYPE service functions declarations
-------------------------------------------------------------------
*/

#ifndef MPLAYER_MEDIATYPE_H
#define MPLAYER_MEDIATYPE_H

#include "guids.h"
                  
typedef struct __attribute__((__packed__)) MediaType
{
    GUID	majortype;		//0x0
    GUID	subtype;		//0x10
    int		bFixedSizeSamples;	//0x20
    int		bTemporalCompression;	//0x24
    unsigned long lSampleSize;		//0x28
    GUID	formattype;		//0x2c
    IUnknown*	pUnk;			//0x3c
    unsigned long cbFormat;		//0x40
    char*	pbFormat;		//0x44
} AM_MEDIA_TYPE;

/**
 * \brief print info from AM_MEDIA_TYPE structure
 * =param[in] label short lable for media type
 * \param[in] pmt pointer to AM_MEDIA_TYPE
 * 
 * routine used for debug purposes
 *
 */
void DisplayMediaType(const char * label,const AM_MEDIA_TYPE* pmt);
/**
 * \brief frees memory, pointed by pbFormat and pUnk members of AM_MEDIA_TYPE structure
 *
 * \param[in] pmt pointer to structure
 *
 * \note
 * routine does not frees memory allocated for AM_MEDIA_TYPE, so given pointer will be
 * valid after this routine call.
 *
 */
void FreeMediaType(AM_MEDIA_TYPE* pmt);
/**
 * \brief frees memory allocated for AM_MEDIA_TYPE structure, including pbFormat and pUnk
 *        members
 *
 * \param[in] pmt pointer to structure
 *
 * \note
 * after call to this routine, pointer to AM_MEDIA_TYPE will not be valid anymore
 *
 */
void DeleteMediaType(AM_MEDIA_TYPE* pmt);
/**
 * \brief copyies info from source to destination AM_MEDIA_TYPE structures
 *
 * \param[in] pSrc pointer to AM_MEDIA_TYPE structure to copy data from
 * \param[out] pDst pointer to AM_MEDIA_TYPE structure to copy data to
 *
 * \return S_OK - success
 * \return E_POINTER - pSrc or pDst is NULL or (pSrc->cbFormat && !pSrc->pbFormat)
 * \return E_INVALIDARG - (pSrc == pDst) 
 * \return E_OUTOFMEMORY - Insufficient memory
 *
 * \note
 * - pDst must point to existing AM_MEDIA_TYPE structure (all data will be overwritten)
 * - if pDst->pbFormat!=NULL this will cause memory leak (as described in Directshow SDK)!
 *
 */
HRESULT CopyMediaType(AM_MEDIA_TYPE* pDst,const AM_MEDIA_TYPE* pSrc);
/**
 * \brief allocates new AM_MEDIA_TYPE structure and fills it with info from given one
 *
 * \param[in] pSrc pointer to AM_MEDIA_TYPE structure to copy data from
 *
 * \return result code, returned from CopyMediaType
 *
 */
AM_MEDIA_TYPE* CreateMediaType(const AM_MEDIA_TYPE* pSrc);

/**
 * \brief compares two AM_MEDIA_TYPE structures for compatibility
 *
 * \param[in] pmt1 first  AM_MEDIA_TYPE structure for compare
 * \param[in] pmt2 second AM_MEDIA_TYPE structure for compare
 * \param[in] bWildcards 1 means that GUID_NULL of one structure will be compatible with any value of another structure
 *
 * \return 1 if structures are compatible
 * \return 0 if structures are not compatible
 *
 */
int CompareMediaTypes(const AM_MEDIA_TYPE * pmt1, const AM_MEDIA_TYPE * pmt2, int bWildcards);

#endif /* MPLAYER_MEDIA_TYPE_H */