SensorType MediaFrameSourceGroup::GetSensorType()

in Shared/HoloLensForCV/MediaFrameSourceGroup.cpp [392:485]


    SensorType MediaFrameSourceGroup::GetSensorType(
        Windows::Media::Capture::Frames::MediaFrameSource^ source)
    {
        //
        // First check if the request is concerning the PV camera.
        //
        if (MediaFrameSourceGroupType::PhotoVideoCamera == _mediaFrameSourceGroupType)
        {
#if DBG_ENABLE_INFORMATIONAL_LOGGING
            dbg::trace(
                L"MediaFrameSourceGroup::GetSensorType:: assuming SensorType::PhotoVideo per _mediaFrameSourceGroupType check (source id is '%s')",
                source->Info->Id->Data());
#endif /* DBG_ENABLE_INFORMATIONAL_LOGGING */

            return SensorType::PhotoVideo;
        }

        //
        // The sensor streaming DMFT exposes the sensor names through the MF_MT_USER_DATA
        // property (GUID for that property is {b6bc765f-4c3b-40a4-bd51-2535b66fe09d}).
        //
        if (!source->Info->Properties->HasKey(c_MF_MT_USER_DATA))
        {
#if DBG_ENABLE_INFORMATIONAL_LOGGING
            dbg::trace(
                L"MediaFrameSourceGroup::GetSensorType:: assuming SensorType::Undefined given missing MF_MT_USER_DATA");
#endif /* DBG_ENABLE_INFORMATIONAL_LOGGING */

            return SensorType::Undefined;
        }

        Platform::Object^ mfMtUserData =
            source->Info->Properties->Lookup(
                c_MF_MT_USER_DATA);

        Platform::Array<byte>^ sensorNameAsPlatformArray =
            safe_cast<Platform::IBoxArray<byte>^>(
                mfMtUserData)->Value;

        const wchar_t* sensorName =
            reinterpret_cast<wchar_t*>(
                sensorNameAsPlatformArray->Data);

#if DBG_ENABLE_INFORMATIONAL_LOGGING
        dbg::trace(
            L"MediaFrameSourceGroup::GetSensorType:: found sensor name '%s' in MF_MT_USER_DATA (blob has %i bytes)",
            sensorName,
            sensorNameAsPlatformArray->Length);
#endif /* DBG_ENABLE_INFORMATIONAL_LOGGING */

#if ENABLE_HOLOLENS_RESEARCH_MODE_SENSORS
        if (0 == wcscmp(sensorName, L"Short Throw ToF Depth"))
        {
            return SensorType::ShortThrowToFDepth;
        }
        else if (0 == wcscmp(sensorName, L"Short Throw ToF Reflectivity"))
        {
            return SensorType::ShortThrowToFReflectivity;
        }
        if (0 == wcscmp(sensorName, L"Long Throw ToF Depth"))
        {
            return SensorType::LongThrowToFDepth;
        }
        else if (0 == wcscmp(sensorName, L"Long Throw ToF Reflectivity"))
        {
            return SensorType::LongThrowToFReflectivity;
        }
        else if (0 == wcscmp(sensorName, L"Visible Light Left-Left"))
        {
            return SensorType::VisibleLightLeftLeft;
        }
        else if (0 == wcscmp(sensorName, L"Visible Light Left-Front"))
        {
            return SensorType::VisibleLightLeftFront;
        }
        else if (0 == wcscmp(sensorName, L"Visible Light Right-Front"))
        {
            return SensorType::VisibleLightRightFront;
        }
        else if (0 == wcscmp(sensorName, L"Visible Light Right-Right"))
        {
            return SensorType::VisibleLightRightRight;
        }
        else
#endif /* ENABLE_HOLOLENS_RESEARCH_MODE_SENSORS */
        {
#if DBG_ENABLE_INFORMATIONAL_LOGGING
            dbg::trace(
                L"MediaFrameSourceGroup::GetSensorType:: could not match sensor name to SensorType enumeration");
#endif /* DBG_ENABLE_INFORMATIONAL_LOGGING */

            return SensorType::Undefined;
        }
    }