コード例 #1
0
bool IisuManager::initIisu()
{
	// Iisu context.
	SK::Context& context = SK::Context::Instance();

	SK_LOGGER(LOG_INFO) << "The context instance was obtained.";

	// Iisu handle.
	char* iisuSdkDir_char = getenv("IISU_SDK_DIR");
	if (iisuSdkDir_char == 0)
	{
		SK_LOGGER(LOG_ERROR) << "Cannot find environment variable \'IISU_SDK_DIR\':";
		SK_LOGGER(LOG_ERROR) << "     -> the iisu runtime may not have been installed correctly.";
		return false;
	}

	std::string iisuSdkDir(iisuSdkDir_char);
	std::string iisuBinDir = iisuSdkDir + "\\bin";

	SK::IisuHandle::Configuration handleConf(iisuBinDir.c_str());
	SK::Return<SK::IisuHandle*> retHandle = context.createHandle(handleConf);
	if (retHandle.failed())
	{
		SK_LOGGER(LOG_ERROR) << retHandle.getDescription().ptr();
		return false;
	}
	SK::IisuHandle* handle = retHandle.get();

	SK_LOGGER(LOG_INFO) << "The application handle was obtained.";

	// Iisu device.
	SK::Device::Configuration deviceConf;
	SK::Return<SK::Device*> retDevice = handle->initializeDevice(deviceConf);
	if (retDevice.failed())
	{
		SK_LOGGER(LOG_ERROR) << retDevice.getDescription().ptr();

		SK::Result result = context.destroyHandle(*handle);
		if (result.failed())
			SK_LOGGER(LOG_ERROR) << result.getDescription().ptr();

		return false;
	}
	m_device = retDevice.get();

	SK_LOGGER(LOG_INFO) << "The iisu device was obtained.";

	// Iisu events registration.
	m_device->getEventManager().registerEventListener("SYSTEM.Error", *this, &IisuManager::iisuErrorListener);
	m_device->getEventManager().registerEventListener("DEVICE.DataFrame", *this, &IisuManager::newIisuDataFrameListener);

	SK_LOGGER(LOG_INFO) << "The event listeners were registered.";

	return true;
}
コード例 #2
0
bool IisuManager::resumeStream()
{
	// Check device.
	if (!m_device)
	{
		SK_LOGGER(LOG_ERROR) << "No iisu device available: cannot stream.";
		return false;
	}

	// Linearize PathMaps.
	linearizePathMap(m_dataBase->getPathMapsRoot());
	SK_LOGGER(LOG_INFO) << "Path maps linearization OK.";

	// Create the TypedPathMaps (depending of their type returned by iisu).
	for (uint i = 0; i < m_pathMapsLinearized.size(); ++i)
	{
		const PathMap* pathMap = m_pathMapsLinearized[i];
		assert(pathMap);

		if (pathMap->getIisuPath() == "")
			continue;

		// Check the path exists and get its type.
		SK::Return<SK::TypeInfo> retType = m_device->getDataType(pathMap->getIisuPath().c_str()) ;
		if (retType.failed())
		{
			SK_LOGGER(LOG_ERROR) << "Path \'" << pathMap->getIisuPath() << "\' does not exist.";

			continue;
		}

		std::string fullOscPaths = pathMap->findFullOscPath();

		SK::TypeInfo typeInfo = retType.get() ;
		TypedPathMap* typedPathMap = SK::TypeInfo::injectIisuType<BaseTypedPathMapFactory, TypedPathMapFactory>(typeInfo)->create(fullOscPaths, pathMap->getIisuPath());
	
		if (!typedPathMap)
		{
			SK_LOGGER(LOG_WARNING) << "Type \'" << typeInfo.name() << "\' is not handled by the OSC stream. Data \'" << pathMap->getIisuPath() << "\' will not stream.";

			continue;
		}

		m_typedPathMapsLinearized.push_back(typedPathMap);
	}

	SK_LOGGER(LOG_INFO) << "TypedPathMaps instantiated.";

	// Register data handles.
	IisuDataRegistrator iisuPathRegistrator(m_device, m_iisuDataHandles);
	for (uint i = 0; i < m_typedPathMapsLinearized.size(); ++i)
		m_typedPathMapsLinearized[i]->accept(&iisuPathRegistrator);

	// Start device.
	m_device->start();

	SK_LOGGER(LOG_INFO) << "The iisu engine is started.";
	SK_LOGGER(LOG_INFO) << "OscBridge is now streaming OSC...";

	return true;
}