summaryrefslogtreecommitdiff
path: root/general/SimpleMediaSource/MediaSource/SimpleFrameGenerator.h
diff options
context:
space:
mode:
authorj-leungyy <[email protected]>2021-05-25 09:06:09 -0700
committerGitHub <[email protected]>2021-05-25 09:06:09 -0700
commit4fe5787f122fdfc45253b45f9fad3983f53d86df (patch)
treea11e06f8951d4b7b847f6f5a708f86df87d637db /general/SimpleMediaSource/MediaSource/SimpleFrameGenerator.h
parent53afd12aadb8aff15097f1546d4f80c6074e0bdc (diff)
update simplemediasource sample (#614)
* update simplemediasource wrl to winrtcpp COM, add mediatype NV12 (SimpleFrameGenerator), fix Mediatype missing attribute (bitrate), add IMFActivate, IMFSampleAllocator interface and implementation, update hardcode arg with named variables, cleanup sample for StreamIndex and StreamId, add sample KSControl * address PR-it1 comments * address comment from PR-it2, replace manual define of IKSControl by ksproxy.h * remove unuse header * address comment from PR * fix sdk to latest, add driversign algorithm * remove nudget, use submodule
Diffstat (limited to 'general/SimpleMediaSource/MediaSource/SimpleFrameGenerator.h')
-rw-r--r--general/SimpleMediaSource/MediaSource/SimpleFrameGenerator.h46
1 files changed, 46 insertions, 0 deletions
diff --git a/general/SimpleMediaSource/MediaSource/SimpleFrameGenerator.h b/general/SimpleMediaSource/MediaSource/SimpleFrameGenerator.h
new file mode 100644
index 00000000..f481ab61
--- /dev/null
+++ b/general/SimpleMediaSource/MediaSource/SimpleFrameGenerator.h
@@ -0,0 +1,46 @@
+//
+// Copyright (C) Microsoft Corporation. All rights reserved.
+//
+
+#pragma once
+#ifndef SIMPLE_FRAME_GENERATOR_H
+#define SIMPLE_FRAME_GENERATOR_H
+
+class SimpleFrameGenerator
+{
+public:
+ SimpleFrameGenerator() = default;
+ ~SimpleFrameGenerator() {};
+
+ HRESULT Initialize(_In_ IMFMediaType* pMediaType);
+
+ HRESULT CreateFrame(
+ _Inout_updates_bytes_(len) BYTE* pBuf,
+ _In_ DWORD len,
+ _In_ LONG pitch,
+ _In_ ULONG rgbMask);
+
+ // pixel format converter
+ static void RGB24ToYUY2(int R, int G, int B, BYTE* pY, BYTE* pU, BYTE* pV);
+ static void RGB24ToY(int R, int G, int B, BYTE* pY);
+ static void RGB32ToNV12(BYTE RGB1[8], BYTE RGB2[8], BYTE* pY1, BYTE* pY2, BYTE* pUV);
+
+ static HRESULT RGB32ToNV12Frame(_Inout_updates_bytes_(len) BYTE* pbBuff, ULONG cbBuff, long stride, UINT width, UINT height, BYTE* pbBuffOut, ULONG cbBuffOut, long strideOut);
+
+private:
+ HRESULT _CreateRGB32Frame(
+ _Inout_updates_bytes_(len) BYTE* pBuf,
+ _In_ DWORD len,
+ _In_ LONG pitch,
+ _In_ DWORD width,
+ _In_ DWORD height,
+ _In_ ULONG rgbMask);
+
+ UINT32 m_width = 0;
+ UINT32 m_height = 0;
+ GUID m_subType = GUID_NULL;
+
+};
+
+#endif
+