XnStatus PlayerImpl::AddNode(const XnChar* strNodeName, XnProductionNodeType type, XnCodecID compression) { XnStatus nRetVal = XN_STATUS_OK; PlayedNodeInfo playedNodeInfo = {0}; if (m_playedNodes.Get(strNodeName, playedNodeInfo) == XN_STATUS_OK) { // already in the list, just return OK. return (XN_STATUS_OK); } // check if we need to create it (maybe it's a rewind...) if (xnGetNodeHandleByName(m_hPlayer->pContext, strNodeName, &playedNodeInfo.hNode) != XN_STATUS_OK) { XnStatus nRetVal = xnCreateMockNode(m_hPlayer->pContext, type, strNodeName, &playedNodeInfo.hNode); XN_IS_STATUS_OK(nRetVal); } // lock it, so no one can change configuration (this is a file recording) nRetVal = xnLockNodeForChanges(playedNodeInfo.hNode, &playedNodeInfo.hLock); XN_IS_STATUS_OK(nRetVal); nRetVal = m_playedNodes.Set(strNodeName, playedNodeInfo); XN_IS_STATUS_OK(nRetVal); return XN_STATUS_OK; }
XnStatus PlayerImpl::AddNode(const XnChar* strNodeName, XnProductionNodeType type, XnCodecID compression) { XnStatus nRetVal = XN_STATUS_OK; PlayedNodeInfo playedNodeInfo = {0}; if (m_playedNodes.Get(strNodeName, playedNodeInfo) == XN_STATUS_OK) { // already in the list, just return OK. return (XN_STATUS_OK); } // check if we need to create it (maybe it's a rewind...) if (xnGetRefNodeHandleByName(m_hPlayer->pContext, strNodeName, &playedNodeInfo.hNode) != XN_STATUS_OK) { XnStatus nRetVal = xnCreateMockNode(m_hPlayer->pContext, type, strNodeName, &playedNodeInfo.hNode); XN_IS_STATUS_OK(nRetVal); // mark this node as needed node. We need this in order to make sure if xnForceShutdown() is called, // the player will be destroyed *before* mock node is (so we can release it). nRetVal = xnAddNeededNode(m_hPlayer, playedNodeInfo.hNode); if (nRetVal != XN_STATUS_OK) { xnProductionNodeRelease(playedNodeInfo.hNode); return (nRetVal); } } // lock it, so no one can change configuration (this is a file recording) nRetVal = xnLockNodeForChanges(playedNodeInfo.hNode, &playedNodeInfo.hLock); if (nRetVal != XN_STATUS_OK) { xnProductionNodeRelease(playedNodeInfo.hNode); return (nRetVal); } nRetVal = m_playedNodes.Set(strNodeName, playedNodeInfo); if (nRetVal != XN_STATUS_OK) { xnProductionNodeRelease(playedNodeInfo.hNode); return (nRetVal); } return XN_STATUS_OK; }
XnStatus xnConfigureNodeFromXml(XnNodeHandle hNode, const TiXmlElement* pNode) { XnStatus nRetVal = XN_STATUS_OK; const TiXmlElement* pConfig = pNode->FirstChildElement("Configuration"); if (pConfig == NULL) { return (XN_STATUS_OK); } XnBool bLock = FALSE; const XnChar* strLock = pConfig->Attribute("lock"); if (strLock != NULL) { xnXmlReadBoolAttribute(pConfig, "lock", &bLock); } XnLockHandle hLock = 0; if (bLock) { nRetVal = xnLockNodeForChanges(hNode, &hLock); XN_IS_STATUS_OK(nRetVal); nRetVal = xnLockedNodeStartChanges(hNode, hLock); XN_IS_STATUS_OK(nRetVal); } const TiXmlElement* pOpcode = pConfig->FirstChildElement(); while (pOpcode != NULL) { nRetVal = xnConfigureSetOpcode(hNode, pOpcode); XN_IS_STATUS_OK(nRetVal); pOpcode = pOpcode->NextSiblingElement(); } if (bLock) { nRetVal = xnLockedNodeEndChanges(hNode, hLock); } return (XN_STATUS_OK); }