XnStatus PlayerNode::OpenStream() { XN_VALIDATE_INPUT_PTR(m_pInputStream); XnStatus nRetVal = m_pInputStream->Open(m_pStreamCookie); XN_IS_STATUS_OK(nRetVal); RecordingHeader header; XnUInt32 nBytesRead = 0; nRetVal = m_pInputStream->Read(m_pStreamCookie, &header, sizeof(header), &nBytesRead); XN_IS_STATUS_OK(nRetVal); if (nBytesRead < sizeof(header)) { XN_LOG_ERROR_RETURN(XN_STATUS_CORRUPT_FILE, XN_MASK_OPEN_NI, "Not enough bytes read"); } /* Check header */ if (xnOSMemCmp(header.headerMagic, DEFAULT_RECORDING_HEADER.headerMagic, sizeof(header.headerMagic)) != 0) { XN_LOG_ERROR_RETURN(XN_STATUS_CORRUPT_FILE, XN_MASK_OPEN_NI, "Invalid header magic"); } if ((xnVersionCompare(&header.version, &OLDEST_SUPPORTED_FILE_FORMAT_VERSION) < 0) || //File format is too old (xnVersionCompare(&header.version, &DEFAULT_RECORDING_HEADER.version) > 0)) //File format is too new { XN_LOG_ERROR_RETURN(XN_STATUS_UNSUPPORTED_VERSION, XN_MASK_OPEN_NI, "Unsupported file format version: %u.%u.%u.%u", header.version.nMajor, header.version.nMinor, header.version.nMaintenance, header.version.nBuild); } m_nGlobalMaxTimeStamp = header.nGlobalMaxTimeStamp; m_nMaxNodes = header.nMaxNodeID + 1; XN_ASSERT(m_nMaxNodes > 0); XN_DELETE_ARR(m_pNodeInfoMap); xnOSFree(m_aSeekTempArray); m_pNodeInfoMap = XN_NEW_ARR(PlayerNodeInfo, m_nMaxNodes); XN_VALIDATE_ALLOC_PTR(m_pNodeInfoMap); XN_VALIDATE_CALLOC(m_aSeekTempArray, DataIndexEntry*, m_nMaxNodes); m_bOpen = TRUE; nRetVal = ProcessUntilFirstData(); if (nRetVal != XN_STATUS_OK) { XN_DELETE_ARR(m_pNodeInfoMap); m_pNodeInfoMap = NULL; xnOSFree(m_aSeekTempArray); m_aSeekTempArray = NULL; return nRetVal; } return XN_STATUS_OK; }
XnStatus PlayerNode::Rewind() { //skip recording header XnStatus nRetVal = SeekStream(XN_OS_SEEK_SET, sizeof(RecordingHeader)); XN_IS_STATUS_OK(nRetVal); //Reset all node info's for (XnUInt32 i = 0; i < m_nMaxNodes; i++) { m_pNodeInfoMap[i].Reset(); } m_bDataBegun = FALSE; m_nTimeStamp = 0; m_bEOF = FALSE; //Skip to first data nRetVal = ProcessUntilFirstData(); XN_IS_STATUS_OK(nRetVal); return XN_STATUS_OK; }