Exemplo n.º 1
0
XnStatus XnDeviceBase::CreateStreams(const XnPropertySet* pSet)
{
    XnStatus nRetVal = XN_STATUS_OK;

    for (XnPropertySetData::ConstIterator it = pSet->pData->Begin(); it != pSet->pData->End(); ++it)
    {
        // check if this module is a stream
        XnActualPropertiesHash* pModule = it->Value();

        XnActualPropertiesHash::ConstIterator itProp = pModule->End();
        if (XN_STATUS_OK == pModule->Find(XN_STREAM_PROPERTY_TYPE, itProp))
        {
            // create a copy of the properties
            XnActualPropertiesHash streamProps(it->Key());
            nRetVal = streamProps.CopyFrom(*pModule);
            XN_IS_STATUS_OK(nRetVal);

            // remove the type property
            nRetVal = streamProps.Remove(XN_STREAM_PROPERTY_TYPE);
            XN_IS_STATUS_OK(nRetVal);

            // and create the stream
            XnActualStringProperty* pActualProp = (XnActualStringProperty*)itProp->Value();
            nRetVal = CreateStreamImpl(pActualProp->GetValue(), it->Key(), &streamProps);
            XN_IS_STATUS_OK(nRetVal);
        }
    }

    return (XN_STATUS_OK);
}
Exemplo n.º 2
0
XnStatus XnDeviceBase::BatchConfig(const XnPropertySet* pChangeSet)
{
    XnStatus nRetVal = XN_STATUS_OK;

    XN_VALIDATE_INPUT_PTR(pChangeSet);

    for (XnPropertySetData::ConstIterator itModule = pChangeSet->pData->Begin(); itModule != pChangeSet->pData->End(); ++itModule)
    {
        // find this module
        XnDeviceModule* pModule = NULL;
        nRetVal = FindModule(itModule->Key(), &pModule);
        XN_IS_STATUS_OK(nRetVal);

        nRetVal = pModule->BatchConfig(*itModule->Value());
        XN_IS_STATUS_OK(nRetVal);
    }

    return (XN_STATUS_OK);
}
Exemplo n.º 3
0
XnStatus XnDeviceBase::ValidateOnlyModule(const XnPropertySet* pSet, const XnChar* StreamName)
{
	XnPropertySetData::ConstIterator it = pSet->pData->begin();
	if (it == pSet->pData->end())
	{
		XN_LOG_WARNING_RETURN(XN_STATUS_DEVICE_BAD_PARAM, XN_MASK_DDK, "Property set did not contain any stream!");
	}

	if (strcmp(it.Key(), StreamName) != 0)
	{
		XN_LOG_WARNING_RETURN(XN_STATUS_DEVICE_BAD_PARAM, XN_MASK_DDK, "Property set module name does not match stream name!");
	}

	if (++it != pSet->pData->end())
	{
		XN_LOG_WARNING_RETURN(XN_STATUS_DEVICE_BAD_PARAM, XN_MASK_DDK, "Property set contains more than one module!");
	}
	
	return (XN_STATUS_OK);
}
Exemplo n.º 4
0
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);
}