XnStatus XnShiftToDepthStreamHelper::RaiseChangeEvents() { XnStatus nRetVal = XN_STATUS_OK; nRetVal = m_ShiftToDepthTable.UnsafeUpdateValue(XnGeneralBufferPack(m_ShiftToDepthTables.pShiftToDepthTable, m_ShiftToDepthTables.nShiftsCount * sizeof(OniDepthPixel))); XN_IS_STATUS_OK(nRetVal); nRetVal = m_DepthToShiftTable.UnsafeUpdateValue(XnGeneralBufferPack(m_ShiftToDepthTables.pDepthToShiftTable, m_ShiftToDepthTables.nDepthsCount * sizeof(XnUInt16))); XN_IS_STATUS_OK(nRetVal); return (XN_STATUS_OK); }
XnStatus XnServerSession::HandleGetGeneralProperty() { XnStatus nRetVal = XN_STATUS_OK; // read it XnUChar bufValue[XN_SENSOR_SERVER_MAX_REPLY_SIZE]; XnSensorServerMessageGetPropertyRequest* pRequest = (XnSensorServerMessageGetPropertyRequest*)bufValue; XnUChar* pData = bufValue + sizeof(XnSensorServerMessageGetPropertyRequest); XnUInt32 nDataSize = XN_SENSOR_SERVER_MAX_REPLY_SIZE; nRetVal = m_privateIncomingPacker.ReadCustomData(XN_SENSOR_SERVER_MESSAGE_GET_GENERAL_PROPERTY, bufValue, &nDataSize); XN_IS_STATUS_OK(nRetVal); if (nDataSize < sizeof(XnSensorServerMessageGetPropertyRequest)) { XN_LOG_WARNING_RETURN(XN_STATUS_ERROR, XN_MASK_SENSOR_SERVER, "Sensor server protocol error - invalid size!"); } // get XnGeneralBuffer gbValue = XnGeneralBufferPack(pData, pRequest->nSize); XnStatus nActionResult = GetGeneralPropertyImpl(pRequest->strModuleName, pRequest->strPropertyName, gbValue); if (nActionResult != XN_STATUS_OK) { xnLogWarning(XN_MASK_SENSOR_SERVER, "Client %u failed to get property '%s.%s': %s", m_nID, pRequest->strModuleName, pRequest->strPropertyName, xnGetStatusString(nActionResult)); } nRetVal = SendReply(XN_SENSOR_SERVER_MESSAGE_GET_GENERAL_PROPERTY, nActionResult, pRequest->nSize, pData); XN_IS_STATUS_OK(nRetVal); return (XN_STATUS_OK); }
XnStatus XnSensorDepthStream::SetAGCBin(const XnDepthAGCBin* pBin) { XnStatus nRetVal = XN_STATUS_OK; nRetVal = ValidateDepthValue(pBin->nMin); XN_IS_STATUS_OK(nRetVal); nRetVal = ValidateDepthValue(pBin->nMax); XN_IS_STATUS_OK(nRetVal); // translate to shifts XnUInt16* pDepthToShift = GetDepthToShiftTable(); XnUInt16 nMinShift = pDepthToShift[pBin->nMin]; XnUInt16 nMaxShift = pDepthToShift[pBin->nMax]; // update firmware nRetVal = XnHostProtocolSetDepthAGCBin(m_Helper.GetPrivateData(), pBin->nBin, nMinShift, nMaxShift); XN_IS_STATUS_OK(nRetVal); // update prop nRetVal = m_AGCBin.UnsafeUpdateValue(XnGeneralBufferPack((void*)pBin, sizeof(XnDepthAGCBin))); XN_IS_STATUS_OK(nRetVal); return (XN_STATUS_OK); }
XnActualGeneralProperty::XnActualGeneralProperty(const XnChar* strName, void* pData, XnUInt32 nDataSize, ReadValueFromFileFuncPtr pReadFromFileFunc /* = NULL */, const XnChar* strModule /* = "" */) : XnGeneralProperty(strName, &m_gbValue, pReadFromFileFunc, strModule), m_gbValue(XnGeneralBufferPack(pData, nDataSize)), m_bOwner(FALSE) { // set a callback for get operations UpdateGetCallback(GetCallback, this); }
XnStatus MockProductionNode::GetGeneralProperty(const XnChar* strName, XnUInt32 nBufferSize, void* pBuffer) const { XnGeneralBuffer source; XnStatus nRetVal = m_generalProps.Get(strName, source); XN_IS_STATUS_OK(nRetVal); XnGeneralBuffer dest = XnGeneralBufferPack(pBuffer, nBufferSize); nRetVal = XnGeneralBufferCopy(&dest, &source); XN_IS_STATUS_OK(nRetVal); return XN_STATUS_OK; }
XnStatus XnServerSensorInvoker::GetStreamMaxResolution(SensorInvokerStream* pStream, XnUInt32& nMaxNumPixels) { XnStatus nRetVal = XN_STATUS_OK; XnUInt64 nCount = 0; nRetVal = m_sensor.GetProperty(pStream->strType, XN_STREAM_PROPERTY_SUPPORT_MODES_COUNT, &nCount); XN_IS_STATUS_OK(nRetVal); XnCmosPreset* aPresets = XN_NEW_ARR(XnCmosPreset, nCount); nRetVal = m_sensor.GetProperty(pStream->strType, XN_STREAM_PROPERTY_SUPPORT_MODES, XnGeneralBufferPack(aPresets, nCount * sizeof(XnCmosPreset))); if (nRetVal != XN_STATUS_OK) { XN_DELETE_ARR(aPresets); return nRetVal; } XnUInt32 nMaxPixels = 0; for (XnUInt32 i = 0; i < nCount; ++i) { XnUInt32 nXRes; XnUInt32 nYRes; if (!XnDDKGetXYFromResolution((XnResolutions)aPresets[i].nResolution, &nXRes, &nYRes)) { continue; } if (nXRes * nYRes > nMaxPixels) { nMaxPixels = nXRes * nYRes; } } XN_ASSERT(nMaxPixels > 0); XN_DELETE_ARR(aPresets); nMaxNumPixels = nMaxPixels; return (XN_STATUS_OK); }
XnStatus XnServerSensorInvoker::SetStreamSharedMemory(SensorInvokerStream* pStream) { XnStatus nRetVal = XN_STATUS_OK; // give shared memory a name (to make the name unique, we'll add process ID) XN_PROCESS_ID procID; xnOSGetCurrentProcessID(&procID); XnChar strSharedMemoryName[XN_FILE_MAX_PATH]; sprintf(strSharedMemoryName, "%u_%s_%s", (XnUInt32)procID, m_sensor.GetUSBPath(), pStream->strType); nRetVal = pStream->pSharedMemoryName->UnsafeUpdateValue(strSharedMemoryName); XN_IS_STATUS_OK(nRetVal); XnUInt32 nBufferSize = 0; XnUInt32 nPixelSize = 0; if (strcmp(pStream->strType, XN_STREAM_TYPE_DEPTH) == 0) { // have space for depth and shift values nPixelSize = sizeof(XnDepthPixel) + sizeof(XnUInt16); } else if (strcmp(pStream->strType, XN_STREAM_TYPE_IMAGE) == 0) { // biggest pixel size is the RGB24 nPixelSize = sizeof(XnRGB24Pixel); } else if (strcmp(pStream->strType, XN_STREAM_TYPE_IR) == 0) { // biggest pixel size is the RGB24 nPixelSize = sizeof(XnIRPixel); } else { XN_ASSERT(FALSE); return XN_STATUS_ERROR; } // find out max resolution XnUInt32 nMaxNumPixels = 0; nRetVal = GetStreamMaxResolution(pStream, nMaxNumPixels); XN_IS_STATUS_OK(nRetVal); nBufferSize = (XnUInt32)(nMaxNumPixels * nPixelSize * m_numberOfBuffers.GetValue()); // allocate shared memory nRetVal = xnOSCreateSharedMemoryEx(strSharedMemoryName, nBufferSize, XN_OS_FILE_READ | XN_OS_FILE_WRITE, m_allowOtherUsers.GetValue() == TRUE, &pStream->hSharedMemory); XN_IS_STATUS_OK(nRetVal); nRetVal = xnOSSharedMemoryGetAddress(pStream->hSharedMemory, (void**)&pStream->pSharedMemoryAddress); XN_IS_STATUS_OK(nRetVal); // Set buffer pool for this stream XnGeneralBuffer* aBuffers = XN_NEW_ARR(XnGeneralBuffer, m_numberOfBuffers.GetValue()); XnUInt32 nSingleBufferSize = nBufferSize / m_numberOfBuffers.GetValue(); for (XnUInt32 i = 0; i < m_numberOfBuffers.GetValue(); ++i) { aBuffers[i].pData = pStream->pSharedMemoryAddress + (i * nSingleBufferSize); aBuffers[i].nDataSize = nSingleBufferSize; } nRetVal = m_sensor.SetProperty(pStream->strType, XN_STREAM_PROPERTY_EXTERNAL_BUFFER_POOL, XnGeneralBufferPack(aBuffers, m_numberOfBuffers.GetValue() * sizeof(XnGeneralBuffer))); XN_DELETE_ARR(aBuffers); XN_IS_STATUS_OK(nRetVal); return (XN_STATUS_OK); }
XnStatus XnSensorProductionNode::SetGeneralProperty(const XnChar* strName, XnUInt32 nBufferSize, const void* pBuffer) { return m_pSensor->SetProperty(m_strModule, strName, XnGeneralBufferPack((void*)pBuffer, nBufferSize)); }