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); }
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); }
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); }
XnBool XnSensorDepthGenerator::IsSensorImageNode(xn::ProductionNode& OtherNode) { xn::NodeInfo info = OtherNode.GetInfo(); XnVersion Version; Version.nMajor = XN_PS_MAJOR_VERSION; Version.nMinor = XN_PS_MINOR_VERSION; Version.nMaintenance = XN_PS_MAINTENANCE_VERSION; Version.nBuild = XN_PS_BUILD_VERSION; // check if this view point is image from this DLL if (info.GetDescription().Type != XN_NODE_TYPE_IMAGE || strcmp(info.GetDescription().strName, XN_DEVICE_NAME) != 0 || strcmp(info.GetDescription().strVendor, XN_VENDOR_PRIMESENSE) != 0 || xnVersionCompare(&info.GetDescription().Version, &Version) != 0) { return FALSE; } // check if it uses the same device xn::NodeInfoList needed = info.GetNeededNodes(); for (xn::NodeInfoList::Iterator it = needed.Begin(); it != needed.End(); ++it) { if ((*it).GetDescription().Type == XN_NODE_TYPE_DEVICE && strcmp((*it).GetCreationInfo(), m_device.GetInfo().GetCreationInfo()) == 0) { return TRUE; } } return FALSE; }
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); }
void MockGenerator::OnNodeCreation(xn::ProductionNode& createdNode) { if (strcmp(createdNode.GetName(), m_strFrameSyncWith) == 0) { m_bFrameSyncWithExists = TRUE; m_frameSyncChangeEvent.Raise(); } }
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); }
XnBool MockGenerator::IsFrameSyncedWith(xn::ProductionNode& other) { return other.IsValid() && (strcmp(other.GetName(), m_strFrameSyncWith) == 0); }