XnStatus XnFileDevice::ReadNewStream() { XnStatus nRetVal = XN_STATUS_OK; XnChar strType[XN_DEVICE_MAX_STRING_LENGTH]; XnChar strName[XN_DEVICE_MAX_STRING_LENGTH]; // create property set XnPropertySet* pPropertySet = NULL; nRetVal = XnPropertySetCreate(&pPropertySet); XN_IS_STATUS_OK(nRetVal); // read from stream nRetVal = m_pDataPacker->ReadNewStream(strType, strName, pPropertySet); if (nRetVal == XN_STATUS_OK) { // create it nRetVal = HandleNewStream(strType, strName, pPropertySet->pData->Begin()->Value()); } XnPropertySetDestroy(&pPropertySet); return (nRetVal); }
XnStatus XnFileDevice::SetInitialState(XnPropertySet* pSet) { XnStatus nRetVal = XN_STATUS_OK; // Fix state (remove some properties that we don't wish to reflect in reader device) XnActualPropertiesHash* pDeviceModule = NULL; if (XN_STATUS_OK == pSet->pData->Get(XN_MODULE_NAME_DEVICE, pDeviceModule)) { pDeviceModule->Remove(XN_MODULE_PROPERTY_READ_WRITE_MODE); pDeviceModule->Remove(XN_MODULE_PROPERTY_PRIMARY_STREAM); // check for timestamps resolution XnActualIntProperty* pIntProp = NULL; if (XN_STATUS_OK == pDeviceModule->Get(XN_MODULE_PROPERTY_HIGH_RES_TIMESTAMPS, (XnProperty*&)pIntProp)) { m_bHighresTimestamps = (pIntProp->GetValue() == TRUE); } } // TODO: create DEVICE node // now create the rest of the modules and streams (DEVICE was already created) XnPropertySetData* pPropSetData = pSet->pData; for (XnPropertySetData::ConstIterator it = pPropSetData->Begin(); it != pPropSetData->End(); ++it) { // ignore module DEVICE if (strcmp(XN_MODULE_NAME_DEVICE, it->Key()) == 0) { continue; } // check if this is a stream XnActualPropertiesHash::ConstIterator itProp = it->Value()->End(); if (XN_STATUS_OK == it->Value()->Find(XN_STREAM_PROPERTY_TYPE, itProp)) { XnActualStringProperty* pTypeProp = (XnActualStringProperty*)itProp->Value(); nRetVal = HandleNewStream(pTypeProp->GetValue(), it->Key(), it->Value()); XN_IS_STATUS_OK(nRetVal); } } // modules loop return (XN_STATUS_OK); }
XnStatus XnStreamReaderDevice::SetInitialState(const XnDeviceConfig* pDeviceConfig, XnPropertySet* pSet) { XnStatus nRetVal = XN_STATUS_OK; // Fix state (remove some properties that we don't wish to reflect in reader device) XnActualPropertiesHash* pDeviceModule = NULL; if (XN_STATUS_OK == pSet->pData->Get(XN_MODULE_NAME_DEVICE, pDeviceModule)) { pDeviceModule->Remove(XN_MODULE_PROPERTY_READ_WRITE_MODE); pDeviceModule->Remove(XN_MODULE_PROPERTY_PRIMARY_STREAM); } // now init base using this state (this will also create module DEVICE) XnDeviceConfig initConfig; initConfig.cpConnectionString = pDeviceConfig->cpConnectionString; initConfig.DeviceMode = pDeviceConfig->DeviceMode; initConfig.pInitialValues = pSet; initConfig.SharingMode = pDeviceConfig->SharingMode; nRetVal = XnStreamDevice::InitImpl(&initConfig); XN_IS_STATUS_OK(nRetVal); // now create the rest of the modules and streams (DEVICE was already created) XnPropertySetData* pPropSetData = pSet->pData; for (XnPropertySetData::ConstIterator it = pPropSetData->begin(); it != pPropSetData->end(); ++it) { // ignore module DEVICE if (strcmp(XN_MODULE_NAME_DEVICE, it.Key()) == 0) { continue; } // check if this is a stream XnActualPropertiesHash::ConstIterator itProp = it.Value()->end(); if (XN_STATUS_OK == it.Value()->Find(XN_STREAM_PROPERTY_TYPE, itProp)) { XnActualStringProperty* pTypeProp = (XnActualStringProperty*)itProp.Value(); nRetVal = HandleNewStream(pTypeProp->GetValue(), it.Key(), it.Value()); XN_IS_STATUS_OK(nRetVal); } else { // this is module. create it XnDeviceModuleHolder* pHolder = NULL; nRetVal = CreateModule(it.Key(), &pHolder); XN_IS_STATUS_OK(nRetVal); // set its props nRetVal = pHolder->Init(it.Value()); if (nRetVal != XN_STATUS_OK) { DestroyModule(pHolder); return (nRetVal); } // and add it nRetVal = AddModule(pHolder); if (nRetVal != XN_STATUS_OK) { DestroyModule(pHolder); return (nRetVal); } } } // modules loop return (XN_STATUS_OK); }
XnStatus XnServerSession::HandleSingleRequest() { XnStatus nRetVal = XN_STATUS_OK; XnUInt32 nType; nRetVal = m_privateIncomingPacker.ReadNextObject(&nType); XN_IS_STATUS_OK(nRetVal); switch (nType) { case XN_SENSOR_SERVER_MESSAGE_OPEN_SENSOR: { nRetVal = HandleOpenSensor(); XN_IS_STATUS_OK(nRetVal); break; } case XN_PACKED_INT_PROPERTY: { nRetVal = HandleSetIntProperty(); XN_IS_STATUS_OK(nRetVal); break; } case XN_PACKED_REAL_PROPERTY: { nRetVal = HandleSetRealProperty(); XN_IS_STATUS_OK(nRetVal); break; } case XN_PACKED_STRING_PROPERTY: { nRetVal = HandleSetStringProperty(); XN_IS_STATUS_OK(nRetVal); break; } case XN_PACKED_GENERAL_PROPERTY: { nRetVal = HandleSetGeneralProperty(); XN_IS_STATUS_OK(nRetVal); break; } case XN_SENSOR_SERVER_MESSAGE_GET_INT_PROPERTY: { nRetVal = HandleGetIntProperty(); XN_IS_STATUS_OK(nRetVal); break; } case XN_SENSOR_SERVER_MESSAGE_GET_REAL_PROPERTY: { nRetVal = HandleGetRealProperty(); XN_IS_STATUS_OK(nRetVal); break; } case XN_SENSOR_SERVER_MESSAGE_GET_STRING_PROPERTY: { nRetVal = HandleGetStringProperty(); XN_IS_STATUS_OK(nRetVal); break; } case XN_SENSOR_SERVER_MESSAGE_GET_GENERAL_PROPERTY: { nRetVal = HandleGetGeneralProperty(); XN_IS_STATUS_OK(nRetVal); break; } case XN_SENSOR_SERVER_MESSAGE_INI_FILE: { nRetVal = HandleConfigFromINIFile(); XN_IS_STATUS_OK(nRetVal); break; } case XN_PACKED_PROPERTY_SET: { nRetVal = HandleBatchConfig(); XN_IS_STATUS_OK(nRetVal); break; } case XN_PACKED_NEW_STREAM: { nRetVal = HandleNewStream(); XN_IS_STATUS_OK(nRetVal); break; } case XN_PACKED_STREAM_REMOVED: { nRetVal = HandleRemoveStream(); XN_IS_STATUS_OK(nRetVal); break; } case XN_SENSOR_SERVER_MESSAGE_READ_STREAM: { nRetVal = HandleReadStream(); XN_IS_STATUS_OK(nRetVal); break; } case XN_SENSOR_SERVER_MESSAGE_OPEN_STREAM: { nRetVal = HandleOpenStream(); XN_IS_STATUS_OK(nRetVal); break; } case XN_SENSOR_SERVER_MESSAGE_CLOSE_STREAM: { nRetVal = HandleCloseStream(); XN_IS_STATUS_OK(nRetVal); break; } case XN_SENSOR_SERVER_MESSAGE_BYE: { nRetVal = HandleCloseSession(); XN_IS_STATUS_OK(nRetVal); break; } default: xnLogWarning(XN_MASK_SENSOR_SERVER, "Unknown client request: %u", nType); nRetVal = SendReply(XN_SENSOR_SERVER_MESSAGE_GENERAL_OP_RESPOND, XN_STATUS_ERROR); XN_IS_STATUS_OK(nRetVal); return XN_STATUS_ERROR; } return (XN_STATUS_OK); }