OniStatus PlayerDriver::tryDevice(const char* strUri) { static XnPlayerInputStreamInterface inputInterface = { FileOpen, FileRead, NULL, NULL, FileClose, NULL, NULL, }; // Store the file path. m_filePath = strUri; XnStatus rc = PlayerNode::ValidateStream(this, &inputInterface); if (rc == XN_STATUS_OK) { OniDeviceInfo* pInfo = XN_NEW(OniDeviceInfo); xnOSMemSet(pInfo, 0, sizeof(*pInfo)); xnOSStrCopy(pInfo->uri, strUri, ONI_MAX_STR); xnOSStrCopy(pInfo->vendor, kVendorString.Data(), ONI_MAX_STR); xnOSStrCopy(pInfo->name, kDeviceName.Data(), ONI_MAX_STR); deviceConnected(pInfo); return ONI_STATUS_OK; } return DriverBase::tryDevice(strUri); }
virtual OniStatus initialize( oni::driver::DeviceConnectedCallback connectedCallback, oni::driver::DeviceDisconnectedCallback disconnectedCallback, oni::driver::DeviceStateChangedCallback deviceStateChangedCallback, void* pCookie) { oni::driver::DriverBase::initialize(connectedCallback, disconnectedCallback, deviceStateChangedCallback, pCookie); // Open Kinect v2 auto hr = ::GetDefaultKinectSensor( &kinect_ ); if ( FAILED( hr ) ) { return ONI_STATUS_NO_DEVICE; } hr = kinect_->Open(); if (FAILED(hr)) { std::cerr << "IKinectSensor::Open() failed." << std::endl; return ONI_STATUS_ERROR; } // Create device info OniDeviceInfo* pInfo = XN_NEW(OniDeviceInfo); xnOSStrCopy(pInfo->vendor, "Microsoft", ONI_MAX_STR); xnOSStrCopy(pInfo->name, "Kinect V2 Developer Preview", ONI_MAX_STR); xnOSStrCopy(pInfo->uri, "Kinect V2", ONI_MAX_STR); // internal connect device deviceConnected(pInfo); deviceStateChanged(pInfo, 0); return ONI_STATUS_OK; }
XnStatus UserSelector::TranslateStateToLabel(const UserSelectionState* pUserState, char *strLabel, XnUInt32 maxStrLen) { switch(pUserState->m_eState) { case XN_SELECTION_UNSELECTED: xnOSStrCopy(strLabel,"Not selected",maxStrLen); return XN_STATUS_OK; case XN_SELECTION_SELECTED: xnOSStrCopy(strLabel,"Selected [",maxStrLen); xnOSStrAppend(strLabel,GetCalibrationErrorString((XnCalibrationStatus)pUserState->m_subState),maxStrLen); xnOSStrAppend(strLabel,"]",maxStrLen); return XN_STATUS_OK; case XN_SELECTION_TRACKING: xnOSStrCopy(strLabel,"Tracking",maxStrLen); return XN_STATUS_OK; case XN_SELECTION_FAILED: xnOSStrCopy(strLabel,"Failed to track [",maxStrLen); xnOSStrAppend(strLabel,GetCalibrationErrorString((XnCalibrationStatus)pUserState->m_subState),maxStrLen); xnOSStrAppend(strLabel,"]",maxStrLen); return XN_STATUS_OK; default: xnOSStrCopy(strLabel,"User in illegal state!\n",maxStrLen); return XN_STATUS_ERROR; } }
void xnLogGetMasksString(XnChar* csString) { switch (g_logData.m_nLogFilteringType) { case XN_LOG_WRITE_NONE: xnOSStrCopy(csString, "NONE", XN_LOG_MASKS_STRING_LEN); return; case XN_LOG_WRITE_ALL: xnOSStrCopy(csString, "ALL", XN_LOG_MASKS_STRING_LEN); return; case XN_LOG_WRITE_MASKS: { csString[0] = '\0'; for (XnStringsHash::Iterator it = g_logData.m_LogMasks.begin(); it != g_logData.m_LogMasks.end(); ++it) { xnOSStrAppend(csString, it.Key(), XN_LOG_MASKS_STRING_LEN); xnOSStrAppend(csString, ";", XN_LOG_MASKS_STRING_LEN); } return; } default: xnOSStrCopy(csString, "UNKNOWN", XN_LOG_MASKS_STRING_LEN); return; } }
void XN_CALLBACK_TYPE PlayerDriver::EOFReached(void* pCookie, const char *strUri) { PlayerDriver* pThis = (PlayerDriver*)pCookie; OniDeviceInfo* pInfo = XN_NEW(OniDeviceInfo); xnOSMemSet(pInfo, 0, sizeof(*pInfo)); xnOSStrCopy(pInfo->uri, strUri, ONI_MAX_STR); xnOSStrCopy(pInfo->vendor, kVendorString.Data(), ONI_MAX_STR); xnOSStrCopy(pInfo->name, kDeviceName.Data(), ONI_MAX_STR); pThis->deviceStateChanged(pInfo, ONI_DEVICE_STATE_EOF); }
XnStatus PlayerImpl::SetSource(XnRecordMedium sourceType, const XnChar* strSource) { XnStatus nRetVal = XN_STATUS_OK; // NOTE: we don't want playback speed to affect getting to the first frame, so perform this // without playback speed XnDouble dPlaybackSpeed = GetPlaybackSpeed(); SetPlaybackSpeed(XN_PLAYBACK_SPEED_FASTEST); //Right now the only record medium we support is a file m_sourceType = sourceType; switch (m_sourceType) { case XN_RECORD_MEDIUM_FILE: { nRetVal = xnOSStrCopy(m_strSource, strSource, sizeof(m_strSource)); XN_IS_STATUS_OK(nRetVal); nRetVal = ModulePlayer().SetInputStream(ModuleHandle(), this, &s_fileInputStream); XN_IS_STATUS_OK(nRetVal); break; } default: XN_ASSERT(FALSE); return XN_STATUS_BAD_PARAM; } // now re-set playback speed nRetVal = SetPlaybackSpeed(dPlaybackSpeed); XN_IS_STATUS_OK(nRetVal); return XN_STATUS_OK; }
XnVMessageListener::XnVMessageListener(const XnChar* strName) : m_bInternalThreadAlive(false), m_bInternalThreadKill(false), m_bThreadProtectionQueueMode(false) { xnLogVerbose(XNV_NITE_MASK_CREATE, "Listener %s [0x%08x]: Create", strName, this); xnOSCreateCriticalSection(&m_hListenerCS); SetCurrentThread(); m_bThreadProtectionQueueMode = false; m_strListenerName = (XnChar*)xnOSCalloc(strlen(strName)+1, sizeof(XnChar)); if (m_strListenerName != NULL) { xnOSStrCopy(m_strListenerName, strName, strlen(strName)+1); } m_pMessageQueue = XN_NEW(XnVMessageQueue); m_pMessageQueue->Init(); m_pUpdateCBs = XN_NEW(XnVMessageSpecificEvent); m_pActivateCBs = XN_NEW(XnVEvent); m_pDeactivateCBs = XN_NEW(XnVEvent); } // XnVMessageListener::XnVMessageListener
//--------------------------------------------------------------------------- // Code //--------------------------------------------------------------------------- XN_DDK_API XnStatus XnStreamDataCreateNoBuffer(XnStreamData** ppStreamOutput, const XnChar* StreamName) { XN_VALIDATE_OUTPUT_PTR(ppStreamOutput); // allocate struct XN_VALIDATE_CALLOC(*ppStreamOutput, XnStreamData, 1); XnStreamData* pStreamOutput = *ppStreamOutput; // allocate internal data pStreamOutput->pInternal = (XnStreamDataInternal*)xnOSCalloc(1, sizeof(XnStreamDataInternal)); if (pStreamOutput->pInternal == NULL) { XnStreamDataDestroy(ppStreamOutput); return (XN_STATUS_ALLOC_FAILED); } // fill internal data pStreamOutput->pInternal->bAllocated = FALSE; pStreamOutput->pInternal->nAllocSize = 0; pStreamOutput->pInternal->UpdateMode = XN_STREAM_DATA_UPDATE_AUTOMATICALLY; pStreamOutput->pInternal->Callback = NULL; pStreamOutput->pInternal->pLockedBuffer = NULL; // take name xnOSStrCopy(pStreamOutput->StreamName, StreamName, XN_DEVICE_MAX_STRING_LENGTH); return (XN_STATUS_OK); }
XN_C_API XnStatus xnLogSetOutputFolder(const XnChar* strOutputFolder) { XnStatus nRetVal = XN_STATUS_OK; // check if folder exists XnBool bDirExists = FALSE; nRetVal = xnOSDoesDirecotyExist(strOutputFolder, &bDirExists); XN_IS_STATUS_OK(nRetVal); if (!bDirExists) { // create it nRetVal = xnOSCreateDirectory(strOutputFolder); XN_IS_STATUS_OK(nRetVal); } // place it in a temp buffer, just to make sure everything succeeds XnChar strDirName[XN_FILE_MAX_PATH]; nRetVal = xnOSGetFullPathName(strOutputFolder, strDirName, XN_FILE_MAX_PATH); XN_IS_STATUS_OK(nRetVal); nRetVal = xnOSStrAppend(strDirName, XN_FILE_DIR_SEP, XN_FILE_MAX_PATH); XN_IS_STATUS_OK(nRetVal); // OK. replace xnOSStrCopy(g_logData.m_strLogDir, strDirName, XN_FILE_MAX_PATH); // restart file writer xnLogStartNewFile(); return (XN_STATUS_OK); }
XN_C_API XnStatus XN_C_DECL xnOSDeleteDirectoryTree(const XnChar* strDirName) { XnStatus nRetVal = XN_STATUS_OK; XN_VALIDATE_INPUT_PTR(strDirName); // file name must be double-null terminated XnChar strDirNameDoubleNull[MAX_PATH+1]; xnOSMemSet(strDirNameDoubleNull, 0, sizeof(strDirNameDoubleNull)); nRetVal = xnOSStrCopy(strDirNameDoubleNull, strDirName, MAX_PATH); XN_IS_STATUS_OK(nRetVal); SHFILEOPSTRUCT shOp; shOp.hwnd = NULL; shOp.wFunc = FO_DELETE; shOp.pFrom = strDirNameDoubleNull; shOp.pTo = NULL; shOp.fFlags = FOF_NOCONFIRMATION | FOF_NOERRORUI | FOF_SILENT; shOp.fAnyOperationsAborted = 0; shOp.hNameMappings = NULL; shOp.lpszProgressTitle = NULL; int ret = SHFileOperation(&shOp); if (ret != 0) { return XN_STATUS_OS_FAILED_TO_DELETE_DIR; } return (XN_STATUS_OK); }
//--------------------------------------------------------------------------- // Code //--------------------------------------------------------------------------- PoseUserSelector::PoseUserSelector(xn::UserGenerator* pUserGenerator, TrackingInitializer* pTrackingInitializer, const char* poseToTrack) : UserSelector(pUserGenerator), m_pTrackingInitializer(pTrackingInitializer), m_strPoseToTrack(NULL), m_hPoseDetectCallback(NULL), m_hPoseInProgressCallback(NULL) { VALIDATE(m_bValid , "UserSelector was not initialized properly"); VALIDATE(pTrackingInitializer != NULL , "NULL tracking initializer supplied"); VALIDATE(pTrackingInitializer->IsValid() , "tracking initializer supplied is invalid"); VALIDATE(m_pUserGenerator != NULL,"NULL user generator supplied"); VALIDATE(m_pUserGenerator->IsCapabilitySupported(XN_CAPABILITY_POSE_DETECTION) , "User generator supplied does not support pose capability"); VALIDATE(poseToTrack != NULL , "NULL pose provided"); VALIDATE(m_pUserGenerator->GetPoseDetectionCap().IsPoseSupported(poseToTrack) , "Pose detection capability does not support requested pose"); XnStatus nRetVal = m_pUserGenerator->GetPoseDetectionCap().RegisterToPoseDetected(PoseDetectedCallback,this,m_hPoseDetectCallback); VALIDATE_WITH_ACTION(nRetVal == XN_STATUS_OK,"Failed to register to pose detection",m_hPoseDetectCallback = NULL); nRetVal = m_pUserGenerator->GetPoseDetectionCap().RegisterToPoseInProgress(PoseInProgressCallback,this,m_hPoseInProgressCallback); VALIDATE_WITH_ACTION(nRetVal == XN_STATUS_OK,"Failed to register to pose in progress",m_hPoseInProgressCallback = NULL); int len=strlen(poseToTrack)+1; m_strPoseToTrack=XN_NEW_ARR(char, len); // the length is +1 to accommodate the null terminator xnOSStrCopy(m_strPoseToTrack,poseToTrack,len); }
SyncSocketConnection& SyncSocketConnection::operator=(const SyncSocketConnection& other) { xnOSStrCopy(m_strIP, other.m_strIP, sizeof(m_strIP)); m_nPort = other.m_nPort; m_hSocket = NULL; //We DON'T take the socket from the other connection m_nMaxPacketSize = other.m_nMaxPacketSize; return *this; }
XnStatus PlayerImpl::GetSource(XnRecordMedium &sourceType, XnChar* strSource, XnUInt32 nBufSize) { XnStatus nRetVal = XN_STATUS_OK; sourceType = m_sourceType; nRetVal = xnOSStrCopy(strSource, m_strSource, nBufSize); XN_IS_STATUS_OK(nRetVal); return XN_STATUS_OK; }
XnStatus XnSensorProductionNode::GetStringProperty(const XnChar* strName, XnChar* csValue, XnUInt32 nBufSize) const { XnChar strValue[XN_DEVICE_MAX_STRING_LENGTH]; XnStatus nRetVal = m_pSensor->GetProperty(m_strModule, strName, strValue); XN_IS_STATUS_OK(nRetVal); nRetVal = xnOSStrCopy(csValue, strValue, nBufSize); XN_IS_STATUS_OK(nRetVal); return XN_STATUS_OK; }
virtual OniStatus tryDevice(const char* uri) { if (xnOSStrCmp(uri, "Dummy") != 0 && xnOSStrCmp(uri, "Oz") != 0 && xnOSStrCmp(uri, "PingPong") != 0) { return ONI_STATUS_ERROR; } OniDeviceInfo* pInfo = XN_NEW(OniDeviceInfo); xnOSStrCopy(pInfo->uri, uri, ONI_MAX_STR); xnOSStrCopy(pInfo->vendor, "Table Tennis", ONI_MAX_STR); m_devices[pInfo] = NULL; deviceConnected(pInfo); return ONI_STATUS_OK; }
XN_C_API XnStatus XN_C_DECL xnLogGetFileName(XnChar* strFileName, XnUInt32 nBufferSize) { LogData& logData = LogData::GetInstance(); if (!logData.fileWriter.IsRegistered()) { return XN_STATUS_INVALID_OPERATION; } return xnOSStrCopy(strFileName, logData.fileWriter.GetFileName(), nBufferSize); }
XnStatus XnSensorDepthStream::PopulateSensorCalibrationInfo() { XnDouble dPlanePixelSize; GetProperty(XN_STREAM_PROPERTY_ZERO_PLANE_PIXEL_SIZE, &dPlanePixelSize); XnUInt64 nPlaneDsr; GetProperty(XN_STREAM_PROPERTY_ZERO_PLANE_DISTANCE, &nPlaneDsr); XnDouble dDCRCDist; GetProperty(XN_STREAM_PROPERTY_DCMOS_RCMOS_DISTANCE, &dDCRCDist); m_calibrationInfo.magic = ONI_DEPTH_UTILS_CALIBRATION_INFO_MAGIC; m_calibrationInfo.version = 1; m_calibrationInfo.params1080.zpd = (int)nPlaneDsr; m_calibrationInfo.params1080.zpps = dPlanePixelSize; m_calibrationInfo.params1080.dcrcdist = dDCRCDist; xnOSStrCopy(m_calibrationInfo.deviceName, "PS1080", 80); xnOSMemSet(m_calibrationInfo.serial, 0, 80); m_calibrationInfo.params1080.rgbRegXRes = RGB_REG_X_RES; m_calibrationInfo.params1080.rgbRegYRes = RGB_REG_Y_RES; m_calibrationInfo.params1080.cmosVGAOutputXRes = XN_CMOS_VGAOUTPUT_XRES; m_calibrationInfo.params1080.sensorWinOffsetX = XN_SENSOR_WIN_OFFET_X; m_calibrationInfo.params1080.sensorWinOffsetY = XN_SENSOR_WIN_OFFET_Y; m_calibrationInfo.params1080.rgbRegXValScale = RGB_REG_X_VAL_SCALE; m_calibrationInfo.params1080.s2dPelConst = S2D_PEL_CONST; m_calibrationInfo.params1080.s2dConstOffset = S2D_CONST_OFFSET; XnStatus nRetVal = XnHostProtocolAlgorithmParams(m_Helper.GetPrivateData(), XN_HOST_PROTOCOL_ALGORITHM_REGISTRATION, &m_calibrationInfo.params1080.registrationInfo_QQVGA, sizeof(m_calibrationInfo.params1080.registrationInfo_QQVGA), XN_RESOLUTION_QQVGA, 30); if (nRetVal != XN_STATUS_OK) { xnOSMemSet(&m_calibrationInfo.params1080.registrationInfo_QQVGA, 0, sizeof(m_calibrationInfo.params1080.registrationInfo_QQVGA)); } nRetVal = XnHostProtocolAlgorithmParams(m_Helper.GetPrivateData(), XN_HOST_PROTOCOL_ALGORITHM_REGISTRATION, &m_calibrationInfo.params1080.registrationInfo_QVGA, sizeof(m_calibrationInfo.params1080.registrationInfo_QVGA), XN_RESOLUTION_QVGA, 30); XN_IS_STATUS_OK(nRetVal); nRetVal = XnHostProtocolAlgorithmParams(m_Helper.GetPrivateData(), XN_HOST_PROTOCOL_ALGORITHM_REGISTRATION, &m_calibrationInfo.params1080.registrationInfo_VGA, sizeof(m_calibrationInfo.params1080.registrationInfo_VGA), XN_RESOLUTION_VGA, 30); XN_IS_STATUS_OK(nRetVal); nRetVal = XnHostProtocolAlgorithmParams(m_Helper.GetPrivateData(), XN_HOST_PROTOCOL_ALGORITHM_PADDING, &m_calibrationInfo.params1080.padInfo_QQVGA, sizeof(m_calibrationInfo.params1080.padInfo_QQVGA), XN_RESOLUTION_QQVGA, 30); if (nRetVal != XN_STATUS_OK) { xnOSMemSet(&m_calibrationInfo.params1080.padInfo_QQVGA, 0, sizeof(m_calibrationInfo.params1080.padInfo_QQVGA)); } xnOSMemSet(&m_calibrationInfo.params1080.padInfo_QVGA, 0, sizeof(m_calibrationInfo.params1080.padInfo_QVGA)); nRetVal = XnHostProtocolAlgorithmParams(m_Helper.GetPrivateData(), XN_HOST_PROTOCOL_ALGORITHM_PADDING, &m_calibrationInfo.params1080.padInfo_QVGA, sizeof(m_calibrationInfo.params1080.padInfo_QVGA), XN_RESOLUTION_QVGA, 30); XN_IS_STATUS_OK(nRetVal); xnOSMemSet(&m_calibrationInfo.params1080.padInfo_VGA, 0, sizeof(m_calibrationInfo.params1080.padInfo_VGA)); nRetVal = XnHostProtocolAlgorithmParams(m_Helper.GetPrivateData(), XN_HOST_PROTOCOL_ALGORITHM_PADDING, &m_calibrationInfo.params1080.padInfo_VGA, sizeof(m_calibrationInfo.params1080.padInfo_VGA), XN_RESOLUTION_VGA, 30); XN_IS_STATUS_OK(nRetVal); return XN_STATUS_OK; }
//--------------------------------------------------------------------------- // Code //--------------------------------------------------------------------------- XN_C_API XnStatus xnOSGetFileList(const XnChar* cpSearchPattern, const XnChar* cpPrefixPath, XnChar cpFileList[][XN_FILE_MAX_PATH], const XnUInt32 nMaxFiles, XnUInt32* pnFoundFiles) { // Local function variables WIN32_FIND_DATA FindFileData; XN_HANDLE hFind = NULL; XnUInt32 nFoundFiles = 0; // Validate the input/output pointers (to make sure none of them is NULL) XN_VALIDATE_INPUT_PTR(cpSearchPattern); XN_VALIDATE_OUTPUT_PTR(cpFileList); XN_VALIDATE_OUTPUT_PTR(pnFoundFiles); // Reset the number of found files counter *pnFoundFiles = 0; // Get the first file matching the search pattern hFind = FindFirstFile(cpSearchPattern, &FindFileData); // Keep looking for files as long as we have enough space in the filelist and as long as we didnt reach the end (represented by Invalid Handle) while ((hFind != INVALID_HANDLE_VALUE) && (nFoundFiles < nMaxFiles)) { // Copy the file string into its place in the file list xnOSStrCopy(cpFileList[nFoundFiles], FindFileData.cFileName, XN_FILE_MAX_PATH); if (cpPrefixPath != NULL) { xnOSStrPrefix(cpPrefixPath, cpFileList[nFoundFiles], XN_FILE_MAX_PATH); } // Increase the temporary number of found files counter nFoundFiles++; // Get the next file in the list. If there are no more, FindNextFile returns FALSE and the while loop is aborted if (!FindNextFile(hFind, &FindFileData)) { FindClose(hFind); hFind = INVALID_HANDLE_VALUE; } } // Close the find file list FindClose(hFind); // Return a file not found error if no files were found... if (nFoundFiles == 0) { return (XN_STATUS_OS_FILE_NOT_FOUND); } // Write the temporary number of found files counter into the output *pnFoundFiles = nFoundFiles; // All is good... return (XN_STATUS_OK); }
// Initialize the driver // ドライバを初期化する virtual OniStatus initialize( oni::driver::DeviceConnectedCallback connectedCallback, oni::driver::DeviceDisconnectedCallback disconnectedCallback, oni::driver::DeviceStateChangedCallback deviceStateChangedCallback, void* pCookie) { oni::driver::DriverBase::initialize(connectedCallback, disconnectedCallback, deviceStateChangedCallback, pCookie); // Connect to the DepthSense device // DepthSense デバイスに接続する m_context = DepthSense::Context::create("localhost"); // Enumerate the connected devices // 接続されているデバイスの情報を作成する m_depthSenseDevices = m_context.getDevices(); int deviceIndex = 0; for ( auto it = m_depthSenseDevices.begin(); it != m_depthSenseDevices.end(); ++it ) { // Populate the device information // デバイス情報をコピーする OniDeviceInfo* pInfo = XN_NEW(OniDeviceInfo); xnOSStrCopy(pInfo->vendor, "DepthSense", ONI_MAX_STR); xnOSStrCopy(pInfo->name, DepthSense::Device::Model_toString( it->getModel() ).c_str(), ONI_MAX_STR); XnUInt32 uriLen; xnOSStrFormat(pInfo->uri, ONI_MAX_STR, &uriLen, "%s/%d", pInfo->name, deviceIndex++); // Register the device information with the map // デバイス情報を登録する m_devices[pInfo] = NULL; // Raise events // デバイスの接続を通知する deviceConnected(pInfo); deviceStateChanged(pInfo, 0); } // Create the thread for main loop // デバイスのメインループ用スレッドを生成する xnOSCreateThread(threadFunc, this, &m_threadHandle); return ONI_STATUS_OK; }
//--------------------------------------------------------------------------- // Code //--------------------------------------------------------------------------- XnStatus resolveLicensesFile(XnChar* strFileName, XnUInt32 nBufSize) { XnStatus nRetVal = XN_STATUS_OK; #if (XN_PLATFORM == XN_PLATFORM_WIN32) nRetVal = xnOSExpandEnvironmentStrings("%OPEN_NI_INSTALL_PATH%\\Data\\licenses.xml", strFileName, nBufSize); XN_IS_STATUS_OK(nRetVal); #elif (XN_PLATFORM == XN_PLATFORM_LINUX_X86 || XN_PLATFORM == XN_PLATFORM_LINUX_ARM) nRetVal = xnOSStrCopy(strFileName, "/var/lib/ni/licenses.xml", nBufSize); XN_IS_STATUS_OK(nRetVal); #elif (XN_PLATFORM == XN_PLATFORM_MAC) // @todo porting to Mac nRetVal = xnOSStrCopy(strFileName, "/var/lib/ni/licenses.xml", nBufSize); XN_IS_STATUS_OK(nRetVal); #else #error "Unsupported platform!" #endif return (XN_STATUS_OK); }
XnStatus SyncSocketConnection::Init(const XnChar* strIP, XnUInt16 nPort, XnUInt16 nMaxPacketSize) { Disconnect(); XnStatus nRetVal = xnOSStrCopy(m_strIP, strIP, sizeof(m_strIP)); XN_IS_STATUS_OK_LOG_ERROR("Copy IP", nRetVal); m_nPort = nPort; m_nMaxPacketSize = nMaxPacketSize; m_bInitialized = TRUE; return XN_STATUS_OK; }
XN_C_API XnStatus xnOSGetModulePathForProcAddress(void* procAddr, XnChar *strModulePath) { Dl_info info; if (!dladdr(procAddr, &info)) { xnLogWarning(XN_MASK_OS, "Failed to get the dl info: %s\n", dlerror()); return XN_STATUS_ERROR; } return xnOSStrCopy(strModulePath, info.dli_fname, XN_FILE_MAX_PATH); }
void LinkContInputStream::SetDumpName(const XnChar* strDumpName) { XnStatus nRetVal = XN_STATUS_OK; (void)nRetVal; nRetVal = xnOSStrCopy(m_strDumpName, strDumpName, sizeof(m_strDumpName)); if (nRetVal != XN_STATUS_OK) { xnLogWarning(XN_MASK_INPUT_STREAM, "Failed to set dump name: %s", xnGetStatusString(nRetVal)); XN_ASSERT(FALSE); } }
XN_DDK_API XnStatus XnDeviceProxyGetDeviceName(XnDeviceHandle DeviceHandle, XnChar* csDeviceName) { XnStatus nRetVal = XN_STATUS_OK; XN_VALIDATE_INPUT_PTR(DeviceHandle); XnDeviceProxyDeviceHandle* pHandle = (XnDeviceProxyDeviceHandle*)DeviceHandle; nRetVal = xnOSStrCopy(csDeviceName, pHandle->pDesc->Definition.cpName, XN_DEVICE_MAX_STRING_LENGTH); XN_IS_STATUS_OK(nRetVal); return (XN_STATUS_OK); }
XN_C_API XnStatus xnOSGetFileName(const XnChar* cpFilePath, XnChar* cpFileName, const XnUInt32 nBufferSize) { XnStatus nRetVal = XN_STATUS_OK; const XnChar* pLastPos = strrchr(cpFilePath, '/'); if (pLastPos == NULL) pLastPos = strrchr(cpFilePath, '\\'); if (pLastPos == NULL) pLastPos = cpFilePath; return xnOSStrCopy(cpFileName, pLastPos, nBufferSize); }
XnStatus SocketInConnection::Init(const XnChar* strIP, XnUInt16 nPort, XnUInt16 nMaxPacketSize) { XN_VALIDATE_INPUT_PTR(strIP); XnStatus nRetVal = XN_STATUS_OK; nRetVal = xnOSStrCopy(m_strIP, strIP, sizeof(m_strIP)); XN_IS_STATUS_OK_LOG_ERROR("Copy IP", nRetVal); m_nPort = nPort; m_nMaxPacketSize = nMaxPacketSize; m_nBufferSize = m_nMaxPacketSize * BUFFER_NUM_PACKETS; m_pBuffer = reinterpret_cast<XnUInt8*>(xnOSMallocAligned(m_nBufferSize, XN_DEFAULT_MEM_ALIGN)); XN_VALIDATE_ALLOC_PTR(m_pBuffer); nRetVal = xnOSCreateEvent(&m_hConnectEvent, FALSE); XN_IS_STATUS_OK_LOG_ERROR("Create event", nRetVal); xnLogVerbose(XN_MASK_LINK, "Event created for socket %u", m_nPort); return XN_STATUS_OK; }
PlayerNode::PlayerNode(xn::Context &context, const XnChar* strName) : m_bOpen(FALSE), m_pStreamCookie(NULL), m_pInputStream(NULL), m_pNotificationsCookie(NULL), m_pNodeNotifications(NULL), m_pRecordBuffer(NULL), m_bRepeat(TRUE), m_context(context), m_bDataBegun(FALSE), m_nTimeStamp(0), m_nGlobalMaxTimeStamp(0), m_pNodeInfoMap(NULL), m_nMaxNodes(0), m_bEOF(FALSE) { xnOSStrCopy(m_strName, strName, sizeof(m_strName)); }
XnStatus XnSensor::SetGlobalConfigFile(const XnChar* strConfigFile) { XnStatus nRetVal = XN_STATUS_OK; nRetVal = xnOSStrCopy(m_strGlobalConfigFile, strConfigFile, XN_FILE_MAX_PATH); XN_IS_STATUS_OK(nRetVal); XnBool bExists; nRetVal = xnOSDoesFileExist(m_strGlobalConfigFile, &bExists); XN_IS_STATUS_OK(nRetVal); if (!bExists) { xnLogVerbose(XN_MASK_DEVICE_SENSOR, "Global configuration file '%s' was not found.", m_strGlobalConfigFile); } return (XN_STATUS_OK); }
XnStatus PrimeClient::Connect() { XnStatus nRetVal = XN_STATUS_OK; if (!m_bConnected) { nRetVal = m_linkControlEndpoint.Connect(); XN_IS_STATUS_OK_LOG_ERROR("Connect link control endpoint", nRetVal); // Connect output data endpoint (if any) //TODO: Connect output data endpoint only on the first time we send anything to device. nRetVal = ConnectOutputDataEndpoint(); XN_IS_STATUS_OK_LOG_ERROR("Connect output data endpoint", nRetVal); nRetVal = m_linkControlEndpoint.GetSupportedProperties(m_supportedProps); XN_IS_STATUS_OK_LOG_ERROR("Get supported properties", nRetVal); // Get some versions XnLinkDetailedVersion fwVersion; nRetVal = m_linkControlEndpoint.GetFWVersion(fwVersion); XN_IS_STATUS_OK_LOG_ERROR("Get FW version", nRetVal); m_fwVersion.m_nMajor = fwVersion.m_nMajor; m_fwVersion.m_nMinor = fwVersion.m_nMinor; m_fwVersion.m_nMaintenance = fwVersion.m_nMaintenance; m_fwVersion.m_nBuild = fwVersion.m_nBuild; xnOSStrCopy(m_fwVersion.m_strModifier, fwVersion.m_strModifier, sizeof(m_fwVersion.m_strModifier)); nRetVal = m_linkControlEndpoint.GetProtocolVersion(m_protocolVersion); XN_IS_STATUS_OK_LOG_ERROR("Get protocol version", nRetVal); nRetVal = m_linkControlEndpoint.GetHardwareVersion(m_nHWVersion); XN_IS_STATUS_OK_LOG_ERROR("Get hardware version", nRetVal); nRetVal = m_linkControlEndpoint.GetSerialNumber(m_strSerialNumber, sizeof(m_strSerialNumber)); XN_IS_STATUS_OK_LOG_ERROR("Get serial number", nRetVal); xnLogInfo(XN_MASK_PRIME_CLIENT, "Prime Client is now connected."); LogVersions(); m_bConnected = TRUE; } return XN_STATUS_OK; }
XnStatus PlayerNode::HandleNodeAddedImpl(XnUInt32 nNodeID, XnProductionNodeType type, const XnChar* strName, XnCodecID compression, XnUInt32 nNumberOfFrames, XnUInt64 nMinTimestamp, XnUInt64 nMaxTimestamp) { XN_VALIDATE_INPUT_PTR(m_pNodeNotifications); XnStatus nRetVal = XN_STATUS_OK; PlayerNodeInfo* pPlayerNodeInfo = GetPlayerNodeInfo(nNodeID); XN_VALIDATE_PTR(pPlayerNodeInfo, XN_STATUS_CORRUPT_FILE); //Notify node was added nRetVal = m_pNodeNotifications->OnNodeAdded(m_pNotificationsCookie, strName, type, compression); XN_IS_STATUS_OK(nRetVal); pPlayerNodeInfo->compression = compression; nRetVal = xnOSStrCopy(pPlayerNodeInfo->strName, strName, sizeof(pPlayerNodeInfo->strName)); XN_IS_STATUS_OK(nRetVal); if (xnIsTypeGenerator(type)) { pPlayerNodeInfo->bIsGenerator = TRUE; pPlayerNodeInfo->nFrames = nNumberOfFrames; pPlayerNodeInfo->nMaxTimeStamp = nMaxTimestamp; } //Mark this player node as valid pPlayerNodeInfo->bValid = TRUE; //Loop until this node's state is ready. //TODO: Check for eof while (!pPlayerNodeInfo->bStateReady) { nRetVal = ProcessRecord(TRUE); if (nRetVal != XN_STATUS_OK) { pPlayerNodeInfo->bValid = FALSE; return nRetVal; } } return (XN_STATUS_OK); }