设备 MFT 支持(相机配置文件 V2)

在 IHV/OEM 需要基于运行时信息发布相机配置文件(例如,用于使用不同传感器的多个 SKU 的一组驱动程序)的情况下,相机驱动程序需要实现设备 MFT 来发布相机配置文件。

在设备 MFT 的 InitializeTransform 调用过程中,DMFT 可以通过提供 IMFSensorProfileCollection 接口,利用以下属性来发布相机配置文件:

// MF_DEVICEMFT_SENSORPROFILE_COLLECTION
// Data type: IUnknown
// IMFSensorProfileCollection interface that SGT Factory can provide to indicate new
// profiles available to the SG generation.
cpp_quote("EXTERN_GUID(MF_DEVICEMFT_SENSORPROFILE_COLLECTION, 0x36EBDC44, 0xB12C, 0x441B, 0x89, 0xF4, 0x08, 0xB2, 0xF4, 0x1A, 0x9C, 0xFC );")

必须在通过 MF_DEVICEMFT_CONNECTED_FILTER_KSCONTROL 属性提供给 DMFT 的 IMFTransform 的属性存储上设置此属性。

以下代码片段说明了在 InitializeTransform 方法期间,DMFT 可能会提供一个新的相机配置文件。

对于此示例,让我们做出一些假设:

  1. 这是一个 4 引脚相机。

  2. 引脚 0 – 捕获、引脚 1 – 预览、引脚 2 – 照片和引脚 3 – IR 流。

IFACEMETHODIMP
SampleDMFT::InitializeTransform(
    _In_ IMFAttributes *pAttributes 
    )
{
    ComPtr<IMFTransform>                spTransform;
    ComPtr<IMFAttributes>               spAttributes;
    ComPtr<IMFSensorProfileCollection>  spProfileCollection;
    ComPtr<IMFSensorProfile>            spProfile;


    if (nullptr == pAttributes)
    {
        return E_INVALIDARG;
    }

    RETURN_IF_FAILED (pAttributes->GetUnknown(MF_DEVICEMFT_CONNECTED_FILTER_KSCONTROL, 
                                              IID_PPV_ARGS(&spTransform)));
    RETURN_IF_FAILED (spTransform->GetAttributes(&spAttributes));

    // Create an empty collection...
    RETURN_IF_FAILED (MFCreateSensorProfileCollection(&spProfileCollection));

    // Create various profiles we want to publish.
    // For the legacy profile, we don't want to expose the IR stream since
    // legacy apps will not be able to consume it.
    RETURN_IF_FAILED (MFCreateSensorProfile(KSCAMERAPROFILE_Legacy, 0, nullptr, &spProfile));
    RETURN_IF_FAILED (spProfile->AddProfileFilter(0, L"((RES==;FRT<=30,1;SUT==))"));
    RETURN_IF_FAILED (spProfile->AddProfileFilter(1, L"((RES==;FRT<=30,1;SUT==))"));
    RETURN_IF_FAILED (spProfile->AddProfileFilter(2, L"((RES==;FRT<=30,1;SUT==))"));
    RETURN_IF_FAILED (spProfile->AddProfileFilter(3, L"(!)"));
    RETURN_IF_FAILED (spProfileCollection->AddProfile(spProfile));
    spProfile = nullptr;

    // For the High Frame Rate recording profile, we only support 60fps or
    // higher on the record pin and any on the preview (since preview only
    // exposes 30fps).
    RETURN_IF_FAILED (MFCreateSensorProfile(KSCAMERAPROFILE_HighFrameRate, 0, nullptr, &spProfile));
    RETURN_IF_FAILED (spProfile->AddProfileFilter(0, L"((RES==;FRT>=60,1;SUT==))"));
    RETURN_IF_FAILED (spProfile->AddProfileFilter(1, L"((RES==;FRT==;SUT==))"));
    RETURN_IF_FAILED (spProfile->AddProfileFilter(2, L"(!)"));
    RETURN_IF_FAILED (spProfile->AddProfileFilter(3, L"(!)"));
    RETURN_IF_FAILED (spProfileCollection->AddProfile(spProfile));
    spProfile = nullptr;

    // For the Face Auth, we can handle any media type on the preview but we
    // want to remove the photo and record pins and allow the IR pin to only
    // expose one media type:  VGA@60fps with L8.
    RETURN_IF_FAILED (MFCreateSensorProfile(KSCAMERAPROFILE_FaceAuth_Mode, 0, nullptr, &spProfile));
    RETURN_IF_FAILED (spProfile->AddProfileFilter(0, L"(!)"));
    RETURN_IF_FAILED (spProfile->AddProfileFilter(1, L"((RES==;FRT==;SUT==))"));
    RETURN_IF_FAILED (spProfile->AddProfileFilter(2, L"(!)"));
    RETURN_IF_FAILED (spProfile->AddProfileFilter(3, L"((RES==640,480;FRT==60,1;SUT==L8))"));
    RETURN_IF_FAILED (spProfileCollection->AddProfile(spProfile));
    spProfile = nullptr;

    // Set the profile collection to the attribute store of the IMFTransform.
    RETURN_IF_FAILED (spAttributes->SetUnknown(MF_DEVICEMFT_SENSORPROFILE_COLLECTION, 
                                               spProfileCollection));

    // ... Reset of the InitializeTransform logic...
 }

在 InitializeTransform() 方法返回之前,必须将MF_DEVICEMFT_SENSORPROFILE_COLLECTION发布到连接的 IMFTransform 的属性存储中。

链条DMFT

在设备源中链接了多个 DMFT 的情况下,如果启用了平台 DMFT,则负责发布相机配置文件的 DMFT 必须由 IHV/OEM 配置为以下链中的第一个转换。

例如,支持在以下拓扑中从 IHV/OEM DMFT1 发布相机配置文件:

串联 D M F T。

在拓扑 1 和 2 中,只有 DMFT1 可以发布相机配置文件。 将忽略 DMFT2 发布的任何相机配置文件。

M-in、N-out 设备 MFT

设备 MFT 支持的功能之一是能够采用任意数量的输入流并公开不同数量的输出流。

由于配置文件逻辑要求引脚 ID 来标识配置文件筛选器信息,因此引脚映射必须一致。

设备 MFT 发布的 IMFSensorProfileCollection 必须基于 DMFT 的输出引脚来使用引脚编号。 在这种情况下,Pin ID 必须与输出引脚的属性存储中显示的MF_DEVICESTREAM_STREAM_ID属性匹配。

为了避免可能的引脚 ID 冲突,DMFT 必须删除MF_DEVICESTREAM_TRANSFORM_STREAM_ID。 MF_DEVICESTREAM_TRANSFORM_STREAM_ID仅由 DevProxy 呈现,并且仅在 DevProxy 上下文中有意义。 对于 M-in、N-out DMFT,MF_DEVICESTREAM_TRANSFORM_STREAM_ID 未定义。

相机配置文件 V2 开发人员规范