Custom media effect in Win10 Universal App

602 views Asked by At

I'm developing an Universal Windows App that uses the camera and I need to create a custom effect for the camera. The app is written in C# and the effect is a C++ DLL that uses Media Foundation and an IDL to define a custom WinRT component.

I already successfully do this several times on Windows 8.1 with the following trick documented here, or here.

I now want to port this on Windows 10 UWP. I'm aware there is a known issue on Windows 10 which make the compiler fail with the error "Failed to load a dependency file. Windows.winmd" (see here). But even with that fix, I'm not able to successfully build the component.

Here is the IDL:

import "Windows.Media.idl";

#include <sdkddkver.h>

namespace MyEffect
{
    [version(NTDDI_WIN10), activatable(NTDDI_WIN10)]
    runtimeclass MyEffect
    {
        [default] interface Windows.Media.IMediaExtension;
    }
}

The MIDL command line (formatted for better readability):

/env win32 /h "MyEffect_h.h" /W1 /char signed /enum_class 
/tlb "$(OutDir)\MyEffect.tlb" /ns_prefix 
/metadata_dir "$(WindowsSDK_MetadataFoundationPath)" 
/nologo /winrt 
/winmd "$(OutDir)\MyEffect.winmd" 

This command succeeds. Then I add the following custom build step:

mdmerge -metadata_dir “<metadata_dir>” 
        -i “$(OutDir).” 
        -o “$(OutDir)merged” 
        -partial 
        -v

and this command fails always with different errors according to the following :

If I put $(WindowsSDK_MetadataFoundationPath), which resolves to c:\Program Files (x86)\Windows Kits\10\References\windows.foundation.foundationcontract\1.0.0.0, or $(WindowsSDK_MetadataPath), which resolves to c:\Program Files (x86)\Windows Kits\10\References it returns the error:

MDMERGE : error MDM2002: The type "Windows.Media.IMediaExtension" defined in file <...>\MyEffect.winmd was referenced by type MyEffect.MyEffect but could not be found.

If I put $(TargetPlatformSdkMetadataLocation), which resolves to c:\Program Files (x86)\Windows Kits\10\References\CommonConfiguration\Neutral, it returns the error:

MDMERGE : error MDM2012: Error 3 has occured while enumerating files in C:\Program Files (x86)\Windows Kits\10\References\CommonConfiguration\Neutral\*.winmd.

Does anyone figured out how to compile a custom Windows Media effect for UWP ?

1

There are 1 answers

0
Ianier Munoz On BEST ANSWER

Setting -metadata_dir to "C:\Program Files (x86)\Windows Kits\10\UnionMetadata" worked for me.