XnStatus XnSensor::CreateStreamModule(const XnChar* StreamType, const XnChar* StreamName, XnDeviceModuleHolder** ppStreamHolder) { XnStatus nRetVal = XN_STATUS_OK; // make sure reading from streams is turned on if (!m_ReadData.GetValue()) { nRetVal = m_ReadData.SetValue(TRUE); XN_IS_STATUS_OK(nRetVal); } XnDeviceStream* pStream; XnSensorStreamHelper* pHelper; // create stream if (strcmp(StreamType, XN_STREAM_TYPE_DEPTH) == 0) { XnSensorDepthStream* pDepthStream; XN_VALIDATE_NEW(pDepthStream, XnSensorDepthStream, StreamName, &m_Objects); pStream = pDepthStream; pHelper = pDepthStream->GetHelper(); } else if (strcmp(StreamType, XN_STREAM_TYPE_IMAGE) == 0) { XnSensorImageStream* pImageStream; XN_VALIDATE_NEW(pImageStream, XnSensorImageStream, StreamName, &m_Objects); pStream = pImageStream; pHelper = pImageStream->GetHelper(); } else if (strcmp(StreamType, XN_STREAM_TYPE_IR) == 0) { XnSensorIRStream* pIRStream; XN_VALIDATE_NEW(pIRStream, XnSensorIRStream, StreamName, &m_Objects); pStream = pIRStream; pHelper = pIRStream->GetHelper(); } else if (strcmp(StreamType, XN_STREAM_TYPE_AUDIO) == 0) { if (!m_Firmware.GetInfo()->bAudioSupported) { XN_LOG_WARNING_RETURN(XN_STATUS_UNSUPPORTED_STREAM, XN_MASK_DEVICE_SENSOR, "Audio is not supported by this FW!"); } // TODO: use the allow other users property when constructing the audio stream XnSensorAudioStream* pAudioStream; XN_VALIDATE_NEW(pAudioStream, XnSensorAudioStream, GetUSBPath(), StreamName, &m_Objects, FALSE); pStream = pAudioStream; pHelper = pAudioStream->GetHelper(); } else { XN_LOG_WARNING_RETURN(XN_STATUS_UNSUPPORTED_STREAM, XN_MASK_DEVICE_SENSOR, "Unsupported stream type: %s", StreamType); } *ppStreamHolder = XN_NEW(XnSensorStreamHolder, pStream, pHelper); return (XN_STATUS_OK); }
XnStatus XnSensor::CreateStreamModule(const XnChar* StreamType, const XnChar* StreamName, XnDeviceModuleHolder** ppStreamHolder) { XnStatus nRetVal = XN_STATUS_OK; // make sure reading from streams is turned on if (!m_ReadData.GetValue()) { nRetVal = m_ReadData.SetValue(TRUE); XN_IS_STATUS_OK(nRetVal); } XnDeviceStream* pStream; XnSensorStreamHelper* pHelper; // create stream if (strcmp(StreamType, XN_STREAM_TYPE_DEPTH) == 0) { XnSensorDepthStream* pDepthStream; XN_VALIDATE_NEW(pDepthStream, XnSensorDepthStream, GetUSBPath(), StreamName, &m_Objects, m_NumberOfBuffers.GetValue()); pStream = pDepthStream; pHelper = pDepthStream->GetHelper(); } else if (strcmp(StreamType, XN_STREAM_TYPE_IMAGE) == 0) { XnSensorImageStream* pImageStream; XN_VALIDATE_NEW(pImageStream, XnSensorImageStream, GetUSBPath(), StreamName, &m_Objects, m_NumberOfBuffers.GetValue()); pStream = pImageStream; pHelper = pImageStream->GetHelper(); } else if (strcmp(StreamType, XN_STREAM_TYPE_IR) == 0) { XnSensorIRStream* pIRStream; XN_VALIDATE_NEW(pIRStream, XnSensorIRStream, GetUSBPath(), StreamName, &m_Objects, m_NumberOfBuffers.GetValue()); pStream = pIRStream; pHelper = pIRStream->GetHelper(); } else if (strcmp(StreamType, XN_STREAM_TYPE_AUDIO) == 0) { XnSensorAudioStream* pAudioStream; XN_VALIDATE_NEW(pAudioStream, XnSensorAudioStream, GetUSBPath(), StreamName, &m_Objects); pStream = pAudioStream; pHelper = pAudioStream->GetHelper(); } else { XN_LOG_WARNING_RETURN(XN_STATUS_UNSUPPORTED_STREAM, XN_MASK_DEVICE_SENSOR, "Unsupported stream type: %s", StreamType); } *ppStreamHolder = XN_NEW(XnSensorStreamHolder, pStream, pHelper); return (XN_STATUS_OK); }