设备 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,则 IHV/OEM 必须将负责发布相机配置文件的 DMFT 配置为继 DevProxy 或 Platform DMFT 之后的链中的第一个转换。

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

chained D M F T.

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

m-in、N-out Device MFT

设备 MCT 支持的一项功能是能够接受任意数量的输入流并公开不同数量的输出流。

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

设备 MFT 发布的 IMFSensorProfileCollection 必须使用基于 DMFT 输出引脚的引脚编号。 在这种情况下,固定 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 开发人员规范