共用方式為


感測器群組轉換 (相機配置檔 V2)

感測器群組轉換可能會使用類似 DMFT 的機制來發佈相機配置檔。 MF_DEVICEMFT_SENSORPROFILE_COLLECTION屬性可以透過IMFSensorTransformFactory::GetTransformInformation 的IMFAttributes 參數發行,每個支援的感測器群組轉換 (SGT) 。

在 IMFSensorTransformFactory::InitializeFactory 呼叫期間,將會提供 IMSensorDevice 介面的集合,SGT Factory 可能會藉由 QI-ing IMFGetService 介面的 IMFSensorDevice 介面,從可用的裝置變更可用的相機設定檔。 從這個介面,SGT Factory 可能會要求IMFSensorProfileCollection 介面。

然後,如果 SGT Factory 選擇這麼做,SGT Factory 可能會為每個 IMFSensorDevice 新增/移除/更新可用的相機配置檔。 修改過的相機配置檔只會針對包含 SGT 的感測器群組保存。 個別裝置的相機配置檔不會以新資訊修改。

感測器群組轉換範例

IFACEMETHODIMP
SampleSensorTransformFactory::InitializeFactory(
    _In_ DWORD dwMaxTransformCount, 
    _In_ IMFCollection* sensorDevices, 
    _In_opt_ IMFAttributes* pAttributes 
    )
{
    DWORD sensorDeviceCount = 0;
    ComPtr<IUnknown> unknown;

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

    // For this example, the IHV/OEM added a SGT to a multi-camera
    // setup.  And the SGT is responsible for updating the profile
    // information available from each of the physical cameras, and
    // leave it's own profile as "blank".  This has the net effect
    // of having the SGT support any profile the physical devices
    // expose.
    RETURN_IF_FAILED (sensorDevices->GetElementCount(&sensorDeviceCount));
    for (DWORD idx = 0; idx < sensorDeviceCount; idx++)
    {
        ComPtr<IMFGetService> service;
        ComPtr<IMFSensorProfileCollection> profileCollection;
        SENSORPROFILEID sensorProfileId;

        RETURN_IF_FAILED (sensorDevices->GetElement(idx, 
                              unknown.ReleaseAndGetAddressOf()));
        RETURN_IF_FAILED (unknown.As(service.ReleaseAndGetAddressOf()));
        RETURN_IF_FAILED (service->GetService(GUID_NULL, 
                              ID_PPV_ARGS(profileCollection.ReleaseAndGetAddressOf())));

        // Let's assume that for this ISP/sensor, we cannot support
        // photo sequence but our reference driver published a single
        // photo sequence profile whose ID is hardcoded to a static
        // variable s_PhotoSequenceProfileId.
        RETURN_IF_FAILED (profileCollection->RemoveProfile(&s_PhotoSequenceProfileId));

        // Let's also assume this is a low cost ISP/sensor so our driver
        // cannot support Video HDR (VHDR) control for high frame rate
        // recording and our reference implementation published multiple
        // high frame rate recording profile.
        // 
        // Also for this combination of ISP/sensor, we cannot support
        // Face Auth (IR doesn't support alternate illumination option).
        // So we need to remove all Face Auth from our collection.
        for (DWORD profileIdx = 0; 
                   profileIdx < profileCollection->GetProfileCount();)
        {
            ComPtr<IMFSensorProfile> profile;

            RETURN_IF_FAILED (profileCollection->GetProfile(profileIdx, 
                                  profile.ReleaseAndGetAddressOf()));

            RETURN_IF_FAILED (profile->GetProfileId(&profileId));
            if (profileId.Type == KSCAMERAPROFILE_HighFrameRate)
            {
                RETURN_IF_FAILED (profile->AddBlockedControl(L"VHDR"));
            }
            if (profileId.Type == KSCAMERAPROFILE_FaceAuth_Mode)
            {
                RETURN_IF_FAILED (profileCollection->RemoveProfileByIndex(profileIdx));
            }
            else
            {
                profileIdx++;
            }
        }
    }

    // Set the profile collection to the attribute store that will be returned when
    // IMFSensorTransformFactory::GetTransformInformation is called.
    RETURN_IF_FAILED (m_spAttributes->SetUnknown(MF_DEVICEMFT_SENSORPROFILE_COLLECTION, 
                                                 spProfileCollection));

    // ... Rest of the InitializeFactory logic...
}

相機配置檔 V2 開發人員規格