Skip to content

Commit b9f25c6

Browse files
start of cpp version
1 parent 9a46a88 commit b9f25c6

File tree

12 files changed

+451
-0
lines changed

12 files changed

+451
-0
lines changed
Lines changed: 91 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,91 @@
1+
#include "pch.h"
2+
#include "Class.h"
3+
#include "Class.g.cpp"
4+
5+
6+
namespace winrt::RuntimeComponent2::implementation
7+
{
8+
int32_t Class::MyProperty()
9+
{
10+
throw hresult_not_implemented();
11+
}
12+
13+
void Class::MyProperty(int32_t /* value */)
14+
{
15+
throw hresult_not_implemented();
16+
}
17+
18+
IVectorView<VideoEncodingProperties> Class::SupportedEncodingProperties() {
19+
VideoEncodingProperties encodingProperties = VideoEncodingProperties();
20+
encodingProperties.Subtype(L"ARGB32");
21+
return single_threaded_vector(std::move(std::vector<VideoEncodingProperties>{encodingProperties})).GetView();
22+
}
23+
24+
LearningModelSession Class::Session() {
25+
if (!configuration) {
26+
IInspectable val = configuration.TryLookup(L"Session");
27+
if (val) {
28+
return val.try_as<LearningModelSession>();
29+
}
30+
}
31+
return NULL;
32+
}
33+
LearningModelBinding Class::Binding() {
34+
if (!configuration) {
35+
IInspectable val = configuration.TryLookup(L"Binding");
36+
if (!configuration && val) {
37+
return val.try_as<LearningModelBinding>();
38+
}
39+
}
40+
return NULL;
41+
}
42+
43+
hstring Class::InputImageDescription() {
44+
if (!configuration) {
45+
IInspectable val = configuration.TryLookup(L"InputImageDescription");
46+
if (!configuration && val) {
47+
return unbox_value<hstring>(val);
48+
}
49+
}
50+
return L"";
51+
}
52+
hstring Class::OutputImageDescription() {
53+
if (!configuration) {
54+
IInspectable val = configuration.TryLookup(L"OutputImageDescription");
55+
if (!configuration && val) {
56+
return unbox_value<hstring>(val);
57+
}
58+
}
59+
return L"";
60+
}
61+
62+
63+
bool Class::TimeIndependent() { return true; }
64+
MediaMemoryTypes Class::SupportedMemoryTypes() { return MediaMemoryTypes::GpuAndCpu; }
65+
bool Class::IsReadOnly() { return false; }
66+
void Class::DiscardQueuedFrames() {}
67+
68+
void Class::Close(MediaEffectClosedReason) {
69+
throw hresult_not_implemented();
70+
}
71+
72+
void Class::ProcessFrame(ProcessVideoFrameContext context) {
73+
LearningModelSession _session = Session();
74+
LearningModelBinding _binding = Binding();
75+
VideoFrame inputFrame = context.InputFrame();
76+
VideoFrame outputFrame = context.OutputFrame();
77+
78+
_binding.Bind(InputImageDescription(), inputFrame);
79+
_binding.Bind(OutputImageDescription(), outputFrame);
80+
81+
auto results = _session.Evaluate(_binding, L"test");
82+
}
83+
84+
void Class::SetEncodingProperties(VideoEncodingProperties, IDirect3DDevice) {
85+
throw hresult_not_implemented();
86+
}
87+
88+
void Class::SetProperties(IPropertySet config) {
89+
configuration = config;
90+
}
91+
}
Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
#pragma once
2+
3+
#include "Class.g.h"
4+
#include "winrt\Windows.Media.Effects.h"
5+
6+
using namespace winrt::Windows::Media::Effects;
7+
using namespace winrt::Windows::Media::MediaProperties;
8+
using namespace winrt::Windows::Graphics::DirectX::Direct3D11;
9+
using namespace winrt::Windows::Foundation::Collections;
10+
using namespace winrt::Microsoft::AI::MachineLearning;
11+
using namespace winrt::Windows::Media;
12+
13+
namespace winrt::RuntimeComponent2::implementation
14+
{
15+
struct Class : ClassT<Class>
16+
{
17+
Class() = default;
18+
19+
int32_t MyProperty();
20+
IVectorView<VideoEncodingProperties> SupportedEncodingProperties();
21+
bool TimeIndependent();
22+
MediaMemoryTypes SupportedMemoryTypes();
23+
bool IsReadOnly();
24+
IPropertySet configuration;
25+
26+
void MyProperty(int32_t value);
27+
void DiscardQueuedFrames();
28+
void Close(MediaEffectClosedReason);
29+
void ProcessFrame(ProcessVideoFrameContext);
30+
void SetEncodingProperties(VideoEncodingProperties, IDirect3DDevice);
31+
void SetProperties(IPropertySet);
32+
33+
private:
34+
LearningModelSession Session();
35+
LearningModelBinding Binding();
36+
hstring InputImageDescription();
37+
hstring OutputImageDescription();
38+
39+
};
40+
}
41+
42+
namespace winrt::RuntimeComponent2::factory_implementation
43+
{
44+
struct Class : ClassT<Class, implementation::Class>
45+
{
46+
};
47+
}
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
2+
namespace RuntimeComponent2
3+
{
4+
[default_interface]
5+
runtimeclass Class : Windows.Media.Effects.IBasicVideoEffect
6+
{
7+
Class();
8+
Int32 MyProperty;
9+
void SetProperties(Windows.Foundation.Collections.IPropertySet config);
10+
}
11+
}
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
3+
<ImportGroup Label="PropertySheets" />
4+
<PropertyGroup Label="UserMacros" />
5+
<!--
6+
To customize common C++/WinRT project properties:
7+
* right-click the project node
8+
* expand the Common Properties item
9+
* select the C++/WinRT property page
10+
11+
For more advanced scenarios, and complete documentation, please see:
12+
https://github.com/Microsoft/cppwinrt/tree/master/nuget
13+
-->
14+
<PropertyGroup />
15+
<ItemDefinitionGroup />
16+
</Project>
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
EXPORTS
2+
DllCanUnloadNow = WINRT_CanUnloadNow PRIVATE
3+
DllGetActivationFactory = WINRT_GetActivationFactory PRIVATE
Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
2+
Microsoft Visual Studio Solution File, Format Version 12.00
3+
# Visual Studio Version 16
4+
VisualStudioVersion = 16.0.30204.135
5+
MinimumVisualStudioVersion = 10.0.40219.1
6+
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "RuntimeComponent2", "RuntimeComponent2.vcxproj", "{E9C60C87-553F-406B-892E-1F827A31930D}"
7+
EndProject
8+
Global
9+
GlobalSection(SolutionConfigurationPlatforms) = preSolution
10+
Debug|ARM = Debug|ARM
11+
Debug|ARM64 = Debug|ARM64
12+
Debug|x64 = Debug|x64
13+
Debug|x86 = Debug|x86
14+
Release|ARM = Release|ARM
15+
Release|ARM64 = Release|ARM64
16+
Release|x64 = Release|x64
17+
Release|x86 = Release|x86
18+
EndGlobalSection
19+
GlobalSection(ProjectConfigurationPlatforms) = postSolution
20+
{E9C60C87-553F-406B-892E-1F827A31930D}.Debug|ARM.ActiveCfg = Debug|ARM
21+
{E9C60C87-553F-406B-892E-1F827A31930D}.Debug|ARM.Build.0 = Debug|ARM
22+
{E9C60C87-553F-406B-892E-1F827A31930D}.Debug|ARM64.ActiveCfg = Debug|ARM64
23+
{E9C60C87-553F-406B-892E-1F827A31930D}.Debug|ARM64.Build.0 = Debug|ARM64
24+
{E9C60C87-553F-406B-892E-1F827A31930D}.Debug|x64.ActiveCfg = Debug|x64
25+
{E9C60C87-553F-406B-892E-1F827A31930D}.Debug|x64.Build.0 = Debug|x64
26+
{E9C60C87-553F-406B-892E-1F827A31930D}.Debug|x86.ActiveCfg = Debug|Win32
27+
{E9C60C87-553F-406B-892E-1F827A31930D}.Debug|x86.Build.0 = Debug|Win32
28+
{E9C60C87-553F-406B-892E-1F827A31930D}.Release|ARM.ActiveCfg = Release|ARM
29+
{E9C60C87-553F-406B-892E-1F827A31930D}.Release|ARM.Build.0 = Release|ARM
30+
{E9C60C87-553F-406B-892E-1F827A31930D}.Release|ARM64.ActiveCfg = Release|ARM64
31+
{E9C60C87-553F-406B-892E-1F827A31930D}.Release|ARM64.Build.0 = Release|ARM64
32+
{E9C60C87-553F-406B-892E-1F827A31930D}.Release|x64.ActiveCfg = Release|x64
33+
{E9C60C87-553F-406B-892E-1F827A31930D}.Release|x64.Build.0 = Release|x64
34+
{E9C60C87-553F-406B-892E-1F827A31930D}.Release|x86.ActiveCfg = Release|Win32
35+
{E9C60C87-553F-406B-892E-1F827A31930D}.Release|x86.Build.0 = Release|Win32
36+
EndGlobalSection
37+
GlobalSection(SolutionProperties) = preSolution
38+
HideSolutionNode = FALSE
39+
EndGlobalSection
40+
GlobalSection(ExtensibilityGlobals) = postSolution
41+
SolutionGuid = {532AD8CE-938B-49E3-BF7A-3EC67367D8B0}
42+
EndGlobalSection
43+
EndGlobal
Lines changed: 162 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,162 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<Project DefaultTargets="Build" ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
3+
<Import Project="packages\Microsoft.AI.MachineLearning.1.3.0\build\native\Microsoft.AI.MachineLearning.props" Condition="Exists('packages\Microsoft.AI.MachineLearning.1.3.0\build\native\Microsoft.AI.MachineLearning.props')" />
4+
<Import Project="packages\Microsoft.Windows.CppWinRT.2.0.200615.7\build\native\Microsoft.Windows.CppWinRT.props" Condition="Exists('packages\Microsoft.Windows.CppWinRT.2.0.200615.7\build\native\Microsoft.Windows.CppWinRT.props')" />
5+
<PropertyGroup Label="Globals">
6+
<CppWinRTOptimized>true</CppWinRTOptimized>
7+
<CppWinRTRootNamespaceAutoMerge>true</CppWinRTRootNamespaceAutoMerge>
8+
<CppWinRTGenerateWindowsMetadata>true</CppWinRTGenerateWindowsMetadata>
9+
<MinimalCoreWin>true</MinimalCoreWin>
10+
<ProjectGuid>{e9c60c87-553f-406b-892e-1f827a31930d}</ProjectGuid>
11+
<ProjectName>RuntimeComponent2</ProjectName>
12+
<RootNamespace>RuntimeComponent2</RootNamespace>
13+
<DefaultLanguage>en-US</DefaultLanguage>
14+
<MinimumVisualStudioVersion>14.0</MinimumVisualStudioVersion>
15+
<AppContainerApplication>true</AppContainerApplication>
16+
<ApplicationType>Windows Store</ApplicationType>
17+
<ApplicationTypeRevision>10.0</ApplicationTypeRevision>
18+
<WindowsTargetPlatformVersion Condition=" '$(WindowsTargetPlatformVersion)' == '' ">10.0.18362.0</WindowsTargetPlatformVersion>
19+
<WindowsTargetPlatformMinVersion>10.0.17134.0</WindowsTargetPlatformMinVersion>
20+
</PropertyGroup>
21+
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
22+
<ItemGroup Label="ProjectConfigurations">
23+
<ProjectConfiguration Include="Debug|ARM">
24+
<Configuration>Debug</Configuration>
25+
<Platform>ARM</Platform>
26+
</ProjectConfiguration>
27+
<ProjectConfiguration Include="Debug|ARM64">
28+
<Configuration>Debug</Configuration>
29+
<Platform>ARM64</Platform>
30+
</ProjectConfiguration>
31+
<ProjectConfiguration Include="Debug|Win32">
32+
<Configuration>Debug</Configuration>
33+
<Platform>Win32</Platform>
34+
</ProjectConfiguration>
35+
<ProjectConfiguration Include="Debug|x64">
36+
<Configuration>Debug</Configuration>
37+
<Platform>x64</Platform>
38+
</ProjectConfiguration>
39+
<ProjectConfiguration Include="Release|ARM">
40+
<Configuration>Release</Configuration>
41+
<Platform>ARM</Platform>
42+
</ProjectConfiguration>
43+
<ProjectConfiguration Include="Release|ARM64">
44+
<Configuration>Release</Configuration>
45+
<Platform>ARM64</Platform>
46+
</ProjectConfiguration>
47+
<ProjectConfiguration Include="Release|Win32">
48+
<Configuration>Release</Configuration>
49+
<Platform>Win32</Platform>
50+
</ProjectConfiguration>
51+
<ProjectConfiguration Include="Release|x64">
52+
<Configuration>Release</Configuration>
53+
<Platform>x64</Platform>
54+
</ProjectConfiguration>
55+
</ItemGroup>
56+
<PropertyGroup Label="Configuration">
57+
<ConfigurationType>DynamicLibrary</ConfigurationType>
58+
<PlatformToolset>v140</PlatformToolset>
59+
<PlatformToolset Condition="'$(VisualStudioVersion)' == '15.0'">v141</PlatformToolset>
60+
<PlatformToolset Condition="'$(VisualStudioVersion)' == '16.0'">v142</PlatformToolset>
61+
<CharacterSet>Unicode</CharacterSet>
62+
<GenerateManifest>false</GenerateManifest>
63+
</PropertyGroup>
64+
<PropertyGroup Condition="'$(Configuration)'=='Debug'" Label="Configuration">
65+
<UseDebugLibraries>true</UseDebugLibraries>
66+
<LinkIncremental>true</LinkIncremental>
67+
</PropertyGroup>
68+
<PropertyGroup Condition="'$(Configuration)'=='Release'" Label="Configuration">
69+
<UseDebugLibraries>false</UseDebugLibraries>
70+
<WholeProgramOptimization>true</WholeProgramOptimization>
71+
<LinkIncremental>false</LinkIncremental>
72+
</PropertyGroup>
73+
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
74+
<ImportGroup Label="ExtensionSettings">
75+
</ImportGroup>
76+
<ImportGroup Label="Shared">
77+
</ImportGroup>
78+
<ImportGroup Label="PropertySheets">
79+
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
80+
</ImportGroup>
81+
<ImportGroup Label="PropertySheets">
82+
<Import Project="PropertySheet.props" />
83+
</ImportGroup>
84+
<PropertyGroup Label="UserMacros" />
85+
<PropertyGroup />
86+
<ItemDefinitionGroup>
87+
<ClCompile>
88+
<PrecompiledHeader>Use</PrecompiledHeader>
89+
<PrecompiledHeaderFile>pch.h</PrecompiledHeaderFile>
90+
<PrecompiledHeaderOutputFile>$(IntDir)pch.pch</PrecompiledHeaderOutputFile>
91+
<WarningLevel>Level4</WarningLevel>
92+
<AdditionalOptions>%(AdditionalOptions) /bigobj</AdditionalOptions>
93+
<!--Temporarily disable cppwinrt heap enforcement to work around xaml compiler generated std::shared_ptr use -->
94+
<AdditionalOptions Condition="'$(CppWinRTHeapEnforcement)'==''">/DWINRT_NO_MAKE_DETECTION %(AdditionalOptions)</AdditionalOptions>
95+
<DisableSpecificWarnings>
96+
</DisableSpecificWarnings>
97+
<PreprocessorDefinitions>_WINRT_DLL;WIN32_LEAN_AND_MEAN;WINRT_LEAN_AND_MEAN;%(PreprocessorDefinitions)</PreprocessorDefinitions>
98+
<AdditionalUsingDirectories>$(WindowsSDK_WindowsMetadata);$(AdditionalUsingDirectories)</AdditionalUsingDirectories>
99+
</ClCompile>
100+
<Link>
101+
<SubSystem>Console</SubSystem>
102+
<GenerateWindowsMetadata>false</GenerateWindowsMetadata>
103+
<ModuleDefinitionFile>RuntimeComponent2.def</ModuleDefinitionFile>
104+
</Link>
105+
</ItemDefinitionGroup>
106+
<ItemDefinitionGroup Condition="'$(Configuration)'=='Debug'">
107+
<ClCompile>
108+
<PreprocessorDefinitions>_DEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
109+
</ClCompile>
110+
</ItemDefinitionGroup>
111+
<ItemDefinitionGroup Condition="'$(Configuration)'=='Release'">
112+
<ClCompile>
113+
<PreprocessorDefinitions>NDEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
114+
</ClCompile>
115+
<Link>
116+
<EnableCOMDATFolding>true</EnableCOMDATFolding>
117+
<OptimizeReferences>true</OptimizeReferences>
118+
</Link>
119+
</ItemDefinitionGroup>
120+
<ItemGroup>
121+
<ClInclude Include="pch.h" />
122+
<ClInclude Include="Class.h">
123+
<DependentUpon>Class.idl</DependentUpon>
124+
</ClInclude>
125+
</ItemGroup>
126+
<ItemGroup>
127+
<ClCompile Include="pch.cpp">
128+
<PrecompiledHeader>Create</PrecompiledHeader>
129+
</ClCompile>
130+
<ClCompile Include="Class.cpp">
131+
<DependentUpon>Class.idl</DependentUpon>
132+
</ClCompile>
133+
<ClCompile Include="$(GeneratedFilesDir)module.g.cpp" />
134+
</ItemGroup>
135+
<ItemGroup>
136+
<Midl Include="Class.idl" />
137+
</ItemGroup>
138+
<ItemGroup>
139+
<None Include="packages.config" />
140+
<None Include="RuntimeComponent2.def" />
141+
</ItemGroup>
142+
<ItemGroup>
143+
<None Include="PropertySheet.props" />
144+
<Text Include="readme.txt">
145+
<DeploymentContent>false</DeploymentContent>
146+
</Text>
147+
</ItemGroup>
148+
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
149+
<ImportGroup Label="ExtensionTargets">
150+
<Import Project="packages\Microsoft.Windows.CppWinRT.2.0.200615.7\build\native\Microsoft.Windows.CppWinRT.targets" Condition="Exists('packages\Microsoft.Windows.CppWinRT.2.0.200615.7\build\native\Microsoft.Windows.CppWinRT.targets')" />
151+
<Import Project="packages\Microsoft.AI.MachineLearning.1.3.0\build\native\Microsoft.AI.MachineLearning.targets" Condition="Exists('packages\Microsoft.AI.MachineLearning.1.3.0\build\native\Microsoft.AI.MachineLearning.targets')" />
152+
</ImportGroup>
153+
<Target Name="EnsureNuGetPackageBuildImports" BeforeTargets="PrepareForBuild">
154+
<PropertyGroup>
155+
<ErrorText>This project references NuGet package(s) that are missing on this computer. Use NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}.</ErrorText>
156+
</PropertyGroup>
157+
<Error Condition="!Exists('packages\Microsoft.Windows.CppWinRT.2.0.200615.7\build\native\Microsoft.Windows.CppWinRT.props')" Text="$([System.String]::Format('$(ErrorText)', 'packages\Microsoft.Windows.CppWinRT.2.0.200615.7\build\native\Microsoft.Windows.CppWinRT.props'))" />
158+
<Error Condition="!Exists('packages\Microsoft.Windows.CppWinRT.2.0.200615.7\build\native\Microsoft.Windows.CppWinRT.targets')" Text="$([System.String]::Format('$(ErrorText)', 'packages\Microsoft.Windows.CppWinRT.2.0.200615.7\build\native\Microsoft.Windows.CppWinRT.targets'))" />
159+
<Error Condition="!Exists('packages\Microsoft.AI.MachineLearning.1.3.0\build\native\Microsoft.AI.MachineLearning.props')" Text="$([System.String]::Format('$(ErrorText)', 'packages\Microsoft.AI.MachineLearning.1.3.0\build\native\Microsoft.AI.MachineLearning.props'))" />
160+
<Error Condition="!Exists('packages\Microsoft.AI.MachineLearning.1.3.0\build\native\Microsoft.AI.MachineLearning.targets')" Text="$([System.String]::Format('$(ErrorText)', 'packages\Microsoft.AI.MachineLearning.1.3.0\build\native\Microsoft.AI.MachineLearning.targets'))" />
161+
</Target>
162+
</Project>

0 commit comments

Comments
 (0)