| 481 | } |
| 482 | |
| 483 | XnStatus PlayerImpl::AddNode(const XnChar* strNodeName, XnProductionNodeType type, XnCodecID /*compression*/) |
| 484 | { |
| 485 | XnStatus nRetVal = XN_STATUS_OK; |
| 486 | |
| 487 | PlayedNodeInfo playedNodeInfo = {0}; |
| 488 | |
| 489 | if (m_playedNodes.Get(strNodeName, playedNodeInfo) == XN_STATUS_OK) |
| 490 | { |
| 491 | // already in the list, just return OK. |
| 492 | return (XN_STATUS_OK); |
| 493 | } |
| 494 | |
| 495 | // check if we need to create it (maybe it's a rewind...) |
| 496 | if (xnGetRefNodeHandleByName(m_hPlayer->pContext, strNodeName, &playedNodeInfo.hNode) != XN_STATUS_OK) |
| 497 | { |
| 498 | XnStatus nRetVal = xnCreateMockNode(m_hPlayer->pContext, type, strNodeName, &playedNodeInfo.hNode); |
| 499 | XN_IS_STATUS_OK(nRetVal); |
| 500 | |
| 501 | // mark this node as needed node. We need this in order to make sure if xnForceShutdown() is called, |
| 502 | // the player will be destroyed *before* mock node is (so we can release it). |
| 503 | nRetVal = xnAddNeededNode(m_hPlayer, playedNodeInfo.hNode); |
| 504 | if (nRetVal != XN_STATUS_OK) |
| 505 | { |
| 506 | xnProductionNodeRelease(playedNodeInfo.hNode); |
| 507 | return (nRetVal); |
| 508 | } |
| 509 | } |
| 510 | |
| 511 | // lock it, so no one can change configuration (this is a file recording) |
| 512 | nRetVal = xnLockNodeForChanges(playedNodeInfo.hNode, &playedNodeInfo.hLock); |
| 513 | if (nRetVal != XN_STATUS_OK) |
| 514 | { |
| 515 | xnProductionNodeRelease(playedNodeInfo.hNode); |
| 516 | return (nRetVal); |
| 517 | } |
| 518 | |
| 519 | nRetVal = m_playedNodes.Set(strNodeName, playedNodeInfo); |
| 520 | if (nRetVal != XN_STATUS_OK) |
| 521 | { |
| 522 | xnProductionNodeRelease(playedNodeInfo.hNode); |
| 523 | return (nRetVal); |
| 524 | } |
| 525 | |
| 526 | return XN_STATUS_OK; |
| 527 | } |
| 528 | |
| 529 | XnStatus PlayerImpl::RemoveNode(const XnChar* strNodeName) |
| 530 | { |
no test coverage detected