forked from microsoft/Xbox-ATG-Samples
-
Notifications
You must be signed in to change notification settings - Fork 0
/
MediaEnginePlayer.h
74 lines (54 loc) · 2.11 KB
/
MediaEnginePlayer.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
//--------------------------------------------------------------------------------------
// File: MediaEnginePlayer.h
//
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.
//-------------------------------------------------------------------------------------
#pragma once
#include <mfapi.h>
#include <mfmediaengine.h>
//-------------------------------------------------------------------------------------
class IMFNotify
{
public:
virtual ~IMFNotify() = default;
IMFNotify(const IMFNotify&) = delete;
IMFNotify& operator=(const IMFNotify&) = delete;
IMFNotify(IMFNotify&&) = delete;
IMFNotify& operator=(IMFNotify&&) = delete;
virtual void OnMediaEngineEvent(uint32_t meEvent) = 0;
protected:
IMFNotify() = default;
};
//-------------------------------------------------------------------------------------
class MediaEnginePlayer : public IMFNotify
{
public:
MediaEnginePlayer() noexcept;
~MediaEnginePlayer();
MediaEnginePlayer(const MediaEnginePlayer&) = delete;
MediaEnginePlayer& operator=(const MediaEnginePlayer&) = delete;
MediaEnginePlayer(MediaEnginePlayer&&) = default;
MediaEnginePlayer& operator=(MediaEnginePlayer&&) = default;
void Initialize(IDXGIFactory4* dxgiFactory, ID3D12Device* device, DXGI_FORMAT format);
void Shutdown();
void Play();
void SetMuted(bool muted);
void SetSource(_In_z_ const wchar_t* sourceUri);
bool TransferFrame(HANDLE textureHandle, MFVideoNormalizedRect rect, RECT rcTarget);
// Callbacks
void OnMediaEngineEvent(uint32_t meEvent) override;
// Properties
void GetNativeVideoSize(uint32_t& cx, uint32_t& cy);
bool IsPlaying() const { return m_isPlaying; }
bool IsInfoReady() const { return m_isInfoReady; }
bool IsFinished() const { return m_isFinished; }
private:
Microsoft::WRL::ComPtr<ID3D11Device1> m_device;
Microsoft::WRL::ComPtr<IMFMediaEngine> m_mediaEngine;
Microsoft::WRL::ComPtr<IMFMediaEngineEx> m_engineEx;
MFARGB m_bkgColor;
bool m_isPlaying;
bool m_isInfoReady;
bool m_isFinished;
};