Пример #1
0
XnStatus XnFileDevice::CreateCodec(xn::ProductionNode& node)
{
    XnStatus nRetVal = XN_STATUS_OK;

    XnNodeInfo* pNodeInfo = NULL;
    if (m_nodeInfoMap.Get(node.GetName(), pNodeInfo) == XN_STATUS_OK)
    {
        XnUInt64 nValue;
        nRetVal = node.GetIntProperty(XN_STREAM_PROPERTY_COMPRESSION, nValue);
        XN_IS_STATUS_OK(nRetVal);

        // create new one
        XnCodecID codecID = XnCodec::GetCodecIDFromCompressionFormat((XnCompressionFormats)nValue);
        if (codecID == XN_CODEC_NULL)
        {
            XN_LOG_WARNING_RETURN(XN_STATUS_CORRUPT_FILE, XN_MASK_FILE, "Invalid compression type: %llu", nValue);
        }

        if (pNodeInfo->pXnCodec == NULL || pNodeInfo->pXnCodec->GetCompressionFormat() != nValue)
        {
            // release old codec
            XN_DELETE(pNodeInfo->pXnCodec);
            if (pNodeInfo->codec.IsValid())
            {
                xnRemoveNeededNode(GetSelfNodeHandle(), pNodeInfo->codec);
                pNodeInfo->codec.Release();
            }

            // special case: IR recorded with JPEG. This mode is no longer allowed by OpenNI (JPEG
            // can now only be used for image). We'll have to handle it ourselves.
            if (node.GetInfo().GetDescription().Type == XN_NODE_TYPE_IR &&
                    codecID == XN_CODEC_JPEG)
            {
                xn::IRGenerator irGen(node);
                XnMapOutputMode outputMode;
                nRetVal = irGen.GetMapOutputMode(outputMode);
                XN_IS_STATUS_OK(nRetVal);

                XN_VALIDATE_NEW_AND_INIT(pNodeInfo->pXnCodec, XnJpegCodec, TRUE, outputMode.nXRes, outputMode.nYRes);
            }
            else
            {
                // normal case
                nRetVal = m_context.CreateCodec(codecID, node, pNodeInfo->codec);
                XN_IS_STATUS_OK(nRetVal);

                // we need to make the codec a needed node, so that if xnForceShutdown() is called, we will be
                // destroyed *before* it does (as we hold a reference to it).
                nRetVal = xnAddNeededNode(GetSelfNodeHandle(), pNodeInfo->codec);
                XN_IS_STATUS_OK(nRetVal);

                XN_VALIDATE_NEW(pNodeInfo->pXnCodec, XnNiCodec, pNodeInfo->codec);
            }
        }
    }

    return (XN_STATUS_OK);
}
Пример #2
0
XnStatus XnFileDevice::CheckIRCompatibility(xn::ProductionNode& node)
{
    XnStatus nRetVal = XN_STATUS_OK;

    XnNodeInfo* pNodeInfo = NULL;
    if (node.GetInfo().GetDescription().Type == XN_NODE_TYPE_IR &&
            m_nodeInfoMap.Get(node.GetName(), pNodeInfo) == XN_STATUS_OK)
    {
        XnUInt64 nValue;
        nRetVal = node.GetIntProperty(XN_STREAM_PROPERTY_OUTPUT_FORMAT, nValue);
        XN_IS_STATUS_OK(nRetVal);

        pNodeInfo->bIRisRGB = (nValue == XN_OUTPUT_FORMAT_RGB24);
    }

    return (XN_STATUS_OK);
}