XnStatus XnServerSensorInvoker::RegisterToProps(XnPropertySet* pProps)
{
	XnStatus nRetVal = XN_STATUS_OK;
	XnCallbackHandle hDummy = NULL;

	for (XnPropertySetData::Iterator itMod = pProps->pData->Begin(); itMod != pProps->pData->End(); ++itMod)
	{
		XnActualPropertiesHash* pHash = itMod->Value();

		XnDeviceModule* pModule;
		nRetVal = m_sensor.FindModule(itMod->Key(), &pModule);
		XN_IS_STATUS_OK(nRetVal);

		for (XnActualPropertiesHash::Iterator itProp = pHash->Begin(); itProp != pHash->End(); ++itProp)
		{
			XnProperty* pProp;
			nRetVal = pModule->GetProperty(itProp->Key(), &pProp);
			XN_IS_STATUS_OK(nRetVal);

			// no need to keep the handle. We only want to unregister when the stream is destroyed, and then
			// it happens anyway.
			nRetVal = pProp->OnChangeEvent().Register(PropertyChangedCallback, this, hDummy);
			XN_IS_STATUS_OK(nRetVal);
		}
	}

	return (XN_STATUS_OK);
}
Example #2
0
XN_DDK_API XnStatus XnPropertySetFindProperty(const XnPropertySet* pSet, const XnChar* strModule, const XnChar* strProp, XnPropertySetEnumerator** ppEnumerator)
{
	XnStatus nRetVal = XN_STATUS_OK;

	XN_VALIDATE_INPUT_PTR(pSet);
	XN_VALIDATE_INPUT_PTR(strModule);
	XN_VALIDATE_INPUT_PTR(strProp);
	XN_VALIDATE_OUTPUT_PTR(ppEnumerator);

	// find module
	XnPropertySetData::Iterator itModule = pSet->pData->End();
	nRetVal = pSet->pData->Find(strModule, itModule);
	XN_IS_STATUS_OK(nRetVal);

	XnActualPropertiesHash* pModule = itModule->Value();

	// find property
	XnActualPropertiesHash::Iterator itProp = pModule->End();
	nRetVal = pModule->Find(strProp, itProp);
	XN_IS_STATUS_OK(nRetVal);

	// create enumerator
	XnPropertySetEnumerator* pEnumer;
	XN_VALIDATE_NEW(pEnumer, XnPropertySetEnumerator);

	pEnumer->itModule = itModule;
	pEnumer->itProp = itProp;
	pEnumer->pModules = pSet->pData;
	pEnumer->strModule[0] = '\0';
	pEnumer->bFirst = FALSE;

	*ppEnumerator = pEnumer;

	return XN_STATUS_OK;
}
Example #3
0
XnStatus XnDataPacker::WritePropertySetProperties(const XnPropertySet* pSet)
{
    XnStatus nRetVal = XN_STATUS_OK;

    for (XnPropertySetData::Iterator it = pSet->pData->Begin(); it != pSet->pData->End(); ++it)
    {
        XnActualPropertiesHash* pModule = it->Value();
        for (XnActualPropertiesHash::ConstIterator itProp = pModule->Begin(); itProp != pModule->End(); ++itProp)
        {
            switch (itProp->Value()->GetType())
            {
            case XN_PROPERTY_TYPE_INTEGER:
            {
                XnActualIntProperty* pProp = (XnActualIntProperty*)itProp->Value();
                nRetVal = WritePropertyImpl(pProp->GetModule(), pProp->GetName(), pProp->GetValue());
                XN_IS_STATUS_OK(nRetVal);
                break;
            }
            case XN_PROPERTY_TYPE_REAL:
            {
                XnActualRealProperty* pProp = (XnActualRealProperty*)itProp->Value();
                nRetVal = WritePropertyImpl(pProp->GetModule(), pProp->GetName(), pProp->GetValue());
                XN_IS_STATUS_OK(nRetVal);
                break;
            }
            case XN_PROPERTY_TYPE_STRING:
            {
                XnActualStringProperty* pProp = (XnActualStringProperty*)itProp->Value();
                nRetVal = WritePropertyImpl(pProp->GetModule(), pProp->GetName(), pProp->GetValue());
                XN_IS_STATUS_OK(nRetVal);
                break;
            }
            case XN_PROPERTY_TYPE_GENERAL:
            {
                XnActualGeneralProperty* pProp = (XnActualGeneralProperty*)itProp->Value();
                nRetVal = WritePropertyImpl(pProp->GetModule(), pProp->GetName(), pProp->GetValue());
                XN_IS_STATUS_OK(nRetVal);
                break;
            }
            default:
                XN_LOG_WARNING_RETURN(XN_STATUS_ERROR, XN_MASK_DDK, "Unknown property type: %d", itProp->Value()->GetType());
            }
        }
    }

    StartWritingIntenalObject(XN_PACKED_PROPERTY_SET_PROPERTIES_END_MARKER);
    EndWritingInternalObject();

    return (XN_STATUS_OK);
}
Example #4
0
XnStatus XnServerSession::BatchConfigImpl(const XnPropertySet* pProps)
{
	XnStatus nRetVal = XN_STATUS_OK;
	
	xnLogVerbose(XN_MASK_SENSOR_SERVER, "Client %u requested a batch config", m_nID);

	XN_PROPERTY_SET_CREATE_ON_STACK(serverProps);
	for (XnPropertySetData::Iterator it = pProps->pData->Begin(); it != pProps->pData->End(); ++it)
	{
		SessionStream* pStream = NULL;
		nRetVal = m_streamsHash.Get(it->Key(), pStream);
		XN_IS_STATUS_OK(nRetVal);

		nRetVal = XnPropertySetCloneModule(pProps, &serverProps, it->Key(), pStream->strStreamName);
		XN_IS_STATUS_OK(nRetVal);
	}

	nRetVal = m_pSensor->BatchConfig(&serverProps);
	XN_IS_STATUS_OK(nRetVal);
	
	return (XN_STATUS_OK);
}
Example #5
0
XnStatus XnDataPacker::WritePropertySetImpl(const XnPropertySet* pPropertySet)
{
    XnStatus nRetVal = XN_STATUS_OK;

    StartWritingIntenalObject(XN_PACKED_PROPERTY_SET);

    // Write module names
    for (XnPropertySetData::Iterator it = pPropertySet->pData->Begin(); it != pPropertySet->pData->End(); ++it)
    {
        nRetVal = WriteString(it->Key());
        XN_IS_STATUS_OK(nRetVal);
    }

    StartWritingIntenalObject(XN_PACKED_PROPERTY_SET_MODULES_END_MARKER);
    EndWritingInternalObject();

    // write properties
    nRetVal = WritePropertySetProperties(pPropertySet);
    XN_IS_STATUS_OK(nRetVal);

    return (XN_STATUS_OK);
}
XnStatus XnDeviceFileReader::Rewind()
{
	XnStatus nRetVal = XN_STATUS_OK;
	
	// go back to start of stream
	nRetVal = GetIOStream()->Seek(XN_DEVICE_FILE_MAGIC_LEN);
	XN_IS_STATUS_OK(nRetVal);

	// read initial state
	XN_PROPERTY_SET_CREATE_ON_STACK(state);
	nRetVal = ReadInitialState(&state);
	XN_IS_STATUS_OK(nRetVal);

	// first handle current streams. remove or reset them
	XnDeviceModuleHolderList streams;
	nRetVal = GetStreamsList(streams);
	XN_IS_STATUS_OK(nRetVal);

	for (XnDeviceModuleHolderList::Iterator it = streams.Begin(); it != streams.End(); ++it)
	{
		XnDeviceModuleHolder* pHolder = *it;

		if (m_bStreamsCollectionChanged)
		{
			// we need to destroy all streams, and recreate them later
			nRetVal = DestroyStream(pHolder->GetModule()->GetName());
			XN_IS_STATUS_OK(nRetVal);
		}
		else
		{
			// just reset frame ID
			XnStreamReaderStream* pStream = (XnStreamReaderStream*)pHolder->GetModule();
			pStream->Reset();
		}
	}

	// if we need, recreate streams
	if (m_bStreamsCollectionChanged)
	{
		nRetVal = CreateStreams(&state);
		XN_IS_STATUS_OK(nRetVal);
	}

	// now set state.
	for (XnPropertySetData::Iterator it = state.pData->Begin(); it != state.pData->End(); ++it)
	{
		const XnChar* strName = it->Key();
		XnActualPropertiesHash* pHash = it->Value();

		// fix it first
		if (strcmp(strName, XN_MODULE_NAME_DEVICE) == 0)
		{
			pHash->Remove(XN_MODULE_PROPERTY_READ_WRITE_MODE);
			pHash->Remove(XN_MODULE_PROPERTY_PRIMARY_STREAM);
		}

		XnDeviceModule* pModule;
		nRetVal = FindModule(strName, &pModule);
		XN_IS_STATUS_OK(nRetVal);

		nRetVal = pModule->UnsafeBatchConfig(*pHash);
		XN_IS_STATUS_OK(nRetVal);
	}

	ResetLastTimestampAndFrame();
	m_nReferenceTimestamp = 0;
	m_nReferenceTime = 0;
	m_bStreamsCollectionChanged = FALSE;

	return (XN_STATUS_OK);
}