-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdevice.h
85 lines (64 loc) · 2.16 KB
/
device.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
//////////////////////////////////////////////////////////////////////////
//
// device.h: Manages the Direct3D device
//
// THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF
// ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO
// THE IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A
// PARTICULAR PURPOSE.
//
// Copyright (c) Microsoft Corporation. All rights reserved.
//
//////////////////////////////////////////////////////////////////////////
#pragma once
// Function pointer for the function that transforms the image.
typedef void (*IMAGE_TRANSFORM_FN)(
BYTE* pDest,
LONG lDestStride,
const BYTE* pSrc,
LONG lSrcStride,
DWORD dwWidthInPixels,
DWORD dwHeightInPixels
);
// DrawDevice class
class DrawDevice
{
private:
HWND m_hwnd;
IDirect3D9 *m_pD3D;
IDirect3DDevice9 *m_pDevice;
IDirect3DSwapChain9 *m_pSwapChain;
D3DPRESENT_PARAMETERS m_d3dpp;
// Format information
D3DFORMAT m_format;
UINT m_width;
UINT m_height;
LONG m_lDefaultStride;
MFRatio m_PixelAR;
MFVideoInterlaceMode m_interlace;
RECT m_rcDest; // Destination rectangle
// Drawing
IMAGE_TRANSFORM_FN m_convertFn; // Function to convert the video to RGB32
// 保存到 bmp 文件文件名
const wchar_t *filename;
private:
HRESULT TestCooperativeLevel();
HRESULT SetConversionFunction(REFGUID subtype);
HRESULT CreateSwapChains();
void UpdateDestinationRect();
public:
DrawDevice();
virtual ~DrawDevice();
HRESULT CreateDevice(HWND hwnd);
HRESULT ResetDevice();
void DestroyDevice();
HRESULT SetVideoType(IMFMediaType *pType);
HRESULT DrawFrame(IMFMediaBuffer *pBuffer);
// What video formats we accept
BOOL IsFormatSupported(REFGUID subtype) const;
HRESULT GetFormat(DWORD index, GUID *pSubtype) const;
// 设置保存到 bmp 文件文件名
void set_filename(const wchar_t *filename) {
this->filename = filename;
};
};