2

I am currently designing an app with the Metro app framework which includes a live video chat feature. I am using the GrayscaleTransform MFT included in the MediaCapture sample (at this point simply copy-and-pasted from the sample).

However, when I try to add the grayscale effect to the camera's image stream, I get a "class not registered" fatal error. I understand this is because I must 'activate and register' the media extension, but I do not know how. How do I register the media extension?

All help is greatly appreciated and I always accept an answer!

UPDATE: My GrayScale IDL file is shown below:

import "Windows.Media.idl";

#include <sdkddkver.h>

namespace GrayscaleTransform
{
[version(NTDDI_WIN8), activatable(NTDDI_WIN8)]
runtimeclass GrayscaleEffect 
{
    [default] interface Windows.Media.IMediaExtension;
}
}
4

2 に答える 2

2

The media extension is specified as an <Extension> (or extensibility point) in the package manifest's Extensions section, but you need to insert it manually (i.e. open the appxmanifest as code instead of double-clicking.)

Using the GrayscaleTransform example, in the Media extensions sample, open the MediaExtensions project's package.appxmanifest (as code) and look for this in the <Extensions> section:

<Extension Category="windows.activatableClass.inProcessServer">
    <InProcessServer>
        <Path>GrayscaleTransform.dll</Path>
        <ActivatableClass ActivatableClassId="GrayscaleTransform.GrayscaleEffect" ThreadingModel="both" />
    </InProcessServer>
</Extension>

There's a bit more general info on extensions in App contracts and extensions.

于 2012-07-31T00:49:59.190 に答える
0

As Chris Bowen explains in his answer, your application's AppXManifest is missing the required Extension elements for the activatable classes in the media extensions modules. All (non-Windows-provided) activatable classes need to be listed in the AppXManifest. The solution of adding the Extension nodes to the AppXManifest yourself will work, and this is what the MediaExtensions sample applications appear to have done.

However, you should not normally need to hand-edit the list of extensions. If you add a reference to a Windows Runtime Component project, a loose WinMD file, or an extension SDK, the build should automatically generate Extension elements for each of the activatable classes in the referenced components.

The reason this is not happening is that the media extensions are not annotated with the [activatable] attribute in IDL, so they are not attributed with the ActivatableAttribute in the WinMD that is generated. Instead of hand-editing the AppXManifest, you can declare the type as activatable in its IDL definition.

For example, to update GeometricSource.GeometricSchemeHandler, you can change its definition in IDL from:

[version(NTDDI_WIN8)]
runtimeclass GeometricSchemeHandler
{
}

to:

[version(NTDDI_WIN8), activatable(NTDDI_WIN8)]
runtimeclass GeometricSchemeHandler
{
    [default] interface Windows.Media.IMediaExtension;
}

Note the added activatable attribute and the added [default] interface. If you make these changes to each of the extensions and clean/rebuild, you should not need to explicitly specify the activatable types in your AppXManifest: the build system will add them automatically.

于 2012-07-31T01:48:39.320 に答える