Beispiel #1
0
void MockGenerator::OnNodeCreation(xn::ProductionNode& createdNode)
{
	if (strcmp(createdNode.GetName(), m_strFrameSyncWith) == 0)
	{
		m_bFrameSyncWithExists = TRUE;
		m_frameSyncChangeEvent.Raise();
	}
}
Beispiel #2
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);
}
Beispiel #3
0
XnStatus MockGenerator::FrameSyncWith(xn::ProductionNode& other)
{
	XnStatus nRetVal = XN_STATUS_OK;

	if (!other.IsValid())
	{
		return XN_STATUS_BAD_PARAM;
	}

	nRetVal = SetFrameSyncNode(other.GetName());
	XN_IS_STATUS_OK(nRetVal);
	
	return (XN_STATUS_OK);
}
Beispiel #4
0
XnBool MockGenerator::CanFrameSyncWith(xn::ProductionNode& other)
{
	if (!m_bFrameSyncCap)
	{
		return FALSE;
	}

	if (!other.IsValid())
	{
		return XN_STATUS_BAD_PARAM;
	}

	return (strcmp(other.GetName(), m_strFrameSyncWith) == 0);
}
Beispiel #5
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);
}
Beispiel #6
0
XnStatus MockGenerator::StopFrameSyncWith(xn::ProductionNode& other)
{
	XnStatus nRetVal = XN_STATUS_OK;
	
	if (!other.IsValid())
	{
		return XN_STATUS_BAD_PARAM;
	}

	if (strcmp(other.GetName(), m_strFrameSyncWith) != 0)
	{
		// not synced right now with this node
		return XN_STATUS_BAD_PARAM;
	}

	nRetVal = SetFrameSyncNode("");
	XN_IS_STATUS_OK(nRetVal);

	return (XN_STATUS_OK);	
}
Beispiel #7
0
XnBool MockGenerator::IsFrameSyncedWith(xn::ProductionNode& other)
{
	return other.IsValid() && (strcmp(other.GetName(), m_strFrameSyncWith) == 0);
}