forked from Jack0r/OBS-DShowAudioPlugin
-
Notifications
You must be signed in to change notification settings - Fork 0
/
MediaInfoStuff.h
121 lines (93 loc) · 3.17 KB
/
MediaInfoStuff.h
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
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
/********************************************************************************
Copyright (C) 2012 Hugh Bailey <[email protected]>
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
********************************************************************************/
#pragma once
void WINAPI FreeMediaType(AM_MEDIA_TYPE& mt);
HRESULT WINAPI CopyMediaType(AM_MEDIA_TYPE *pmtTarget, const AM_MEDIA_TYPE *pmtSource);
inline void DeleteMediaType(AM_MEDIA_TYPE *pmt)
{
if(pmt != NULL)
{
FreeMediaType(*pmt);
CoTaskMemFree(pmt);
}
}
const GUID MEDIASUBTYPE_I420 = {0x30323449, 0x0000, 0x0010, {0x80, 0x00, 0x00, 0xaa, 0x00, 0x38, 0x9b, 0x71}};
enum VideoOutputType
{
VideoOutputType_None,
VideoOutputType_RGB24,
VideoOutputType_RGB32,
VideoOutputType_ARGB32,
VideoOutputType_I420,
VideoOutputType_YV12,
VideoOutputType_Y41P,
VideoOutputType_YVU9,
VideoOutputType_YVYU,
VideoOutputType_YUY2,
VideoOutputType_UYVY,
VideoOutputType_HDYC,
VideoOutputType_MPEG2_VIDEO,
VideoOutputType_H264,
VideoOutputType_dvsl,
VideoOutputType_dvsd,
VideoOutputType_dvhd,
VideoOutputType_MJPG
};
static const CTSTR EnumToName[] =
{
TEXT("None"),
TEXT("RGB24"),
TEXT("RGB32"),
TEXT("RGBA32"),
TEXT("I420"),
TEXT("YV12"),
TEXT("Y41P"),
TEXT("YVU9"),
TEXT("YVYU"),
TEXT("YUY2"),
TEXT("UYVY"),
TEXT("HDYC"),
TEXT("MPEG2_VIDEO"),
TEXT("H264"),
TEXT("dvsl"),
TEXT("dvsd"),
TEXT("dvhd"),
TEXT("MJPG"),
};
struct MediaOutputInfo
{
VideoOutputType videoType;
AM_MEDIA_TYPE *mediaType;
UINT64 minFrameInterval, maxFrameInterval;
UINT minCX, minCY;
UINT maxCX, maxCY;
UINT xGranularity, yGranularity;
bool bUsingFourCC;
inline void FreeData()
{
FreeMediaType(*mediaType);
CoTaskMemFree(mediaType);
}
};
inline BITMAPINFOHEADER* GetVideoBMIHeader(const AM_MEDIA_TYPE *pMT)
{
return (pMT->formattype == FORMAT_VideoInfo) ?
&reinterpret_cast<VIDEOINFOHEADER*>(pMT->pbFormat)->bmiHeader :
&reinterpret_cast<VIDEOINFOHEADER2*>(pMT->pbFormat)->bmiHeader;
}
VideoOutputType GetVideoOutputTypeFromFourCC(DWORD fourCC);
VideoOutputType GetVideoOutputType(const AM_MEDIA_TYPE &media_type);
bool GetVideoOutputTypes(const List<MediaOutputInfo> &outputList, UINT width, UINT height, UINT64 frameInterval, List<VideoOutputType> &types);
MediaOutputInfo* GetBestMediaOutput(const List<MediaOutputInfo> &outputList, UINT width, UINT height, UINT preferredType, UINT64 &frameInterval);