MCPcopy Create free account
hub / github.com/OpenNI/OpenNI / OnNodeNewData

Method OnNodeNewData

Source/Modules/nimRecorder/RecorderNode.cpp:286–393  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

284}
285
286XnStatus RecorderNode::OnNodeNewData(const XnChar* strNodeName, XnUInt64 nTimeStamp, XnUInt32 /*nFrame*/, const void* pData, XnUInt32 nSize)
287{
288 XnStatus nRetVal = XN_STATUS_OK;
289
290 //Find node info
291 RecordedNodeInfo* pRecordedNodeInfo = GetRecordedNodeInfo(strNodeName);
292 XN_VALIDATE_PTR(pRecordedNodeInfo, XN_STATUS_BAD_NODE_NAME);
293
294 const void* pCompressedData = pData;
295 XnUInt32 nCompressedSize = nSize;
296 XnCodecID compression = pRecordedNodeInfo->compression;
297 if (compression != XN_CODEC_UNCOMPRESSED)
298 {
299 if (!pRecordedNodeInfo->codec.IsValid())
300 {
301 xnLogWarning(XN_MASK_OPEN_NI, "Codec is not valid for node '%s'", strNodeName);
302 XN_ASSERT(FALSE);
303 return XN_STATUS_INVALID_OPERATION;
304 }
305
306 //Compress data
307 nRetVal = pRecordedNodeInfo->codec.EncodeData(pData, nSize, m_pPayloadData, PAYLOAD_DATA_SIZE, &nCompressedSize);
308 XN_IS_STATUS_OK(nRetVal);
309 pCompressedData = m_pPayloadData;
310 }
311
312 // correct timestamp according to first data recorded
313 if (m_nGlobalStartTimeStamp == XN_MAX_UINT64)
314 {
315 m_nGlobalStartTimeStamp = nTimeStamp;
316 }
317
318 if (nTimeStamp < m_nGlobalStartTimeStamp)
319 {
320 // can happen in the rare case where a node was added in the middle of recording, and this node has data
321 // which is before the starting of the recording. In this case, we'll just ignore this data
322 return XN_STATUS_OK;
323 }
324 else
325 {
326 nTimeStamp -= m_nGlobalStartTimeStamp;
327 }
328
329 if (!pRecordedNodeInfo->bGotData)
330 {
331 // write down the DataBegin record
332 nRetVal = WriteNodeDataBegin(strNodeName);
333 XN_IS_STATUS_OK(nRetVal);
334
335 pRecordedNodeInfo->bGotData = TRUE;
336 pRecordedNodeInfo->nMinTimeStamp = nTimeStamp;
337 }
338
339 pRecordedNodeInfo->nMaxTimeStamp = nTimeStamp;
340
341 XnUInt64 nUndoRecordPos = 0;
342 nRetVal = UpdateNodePropInfo(strNodeName, XN_PROP_NEWDATA, pRecordedNodeInfo, nUndoRecordPos);
343 XN_IS_STATUS_OK(nRetVal);

Callers 2

HandleNewDataRecordMethod · 0.45

Calls 10

xnGetStatusStringFunction · 0.85
SetNodeIDMethod · 0.80
SetTimeStampMethod · 0.80
SetFrameNumberMethod · 0.80
SetPayloadSizeMethod · 0.80
SetUndoRecordPosMethod · 0.80
EncodeMethod · 0.80
IsValidMethod · 0.45
EncodeDataMethod · 0.45
AddLastMethod · 0.45

Tested by

no test coverage detected