Ejemplo n.º 1
0
void Animation::setXML(std::string scenefile) {
	if (rData->settingsXml != NULL)
		delete rData->settingsXml;

	rData->settingsXml = new TiXmlDocument(scenefile.c_str());
	if (!(rData->settingsXml->LoadFile())) {
		delete rData->settingsXml;
		rData->settingsXml = NULL;
	}

	int w = getSettingInt(rData->settingsXml, "windowwidth");
	int h = getSettingInt(rData->settingsXml, "windowheight");
	fullScreen = getSettingInt(rData->settingsXml, "fullscreen");
	this->w = w ? w : DEFAULT_W;
	this->h = h ? h : DEFAULT_H;
	this->rData->windowRatio = this->w / this->h;
	this->rData->fpsEnabled = getSettingBool(rData->settingsXml, "fpsmode");
}
Ejemplo n.º 2
0
int FPD_IsConfigured(void) {
	LogDebug(VB_CHANNELOUT, "FPD_IsConfigured()\n");

	if (!getSettingInt("FPDEnabled"))
		return 0;

  pixelnetDMXactive = 1;
	return pixelnetDMXactive;
}
Ejemplo n.º 3
0
Archivo: Player.cpp Proyecto: dkulp/fpp
int Player::StartMedia(std::string mediaName, int newMediaOffset)
{
	int mediaOffsetInt = getSettingInt("mediaOffset");

	if (mediaOffsetInt || newMediaOffset)
		m_mediaOffset = (float)(mediaOffsetInt + newMediaOffset) * 0.001;
	else
		m_mediaOffset = 0.0;

	OpenMediaOutput(mediaName.c_str());
}
Ejemplo n.º 4
0
/*
 * Initialize effects constructs
 */
int InitEffects(void)
{
    std::string localFilename = getEffectDirectory();
    localFilename += "/background.eseq";

	if ((getFPPmode() == REMOTE_MODE) &&
		CheckForHostSpecificFile(getSetting("HostName"), localFilename)) {
        localFilename = "background_";
		localFilename += getSetting("HostName");

		LogInfo(VB_EFFECT, "Automatically starting background effect "
			"sequence %s\n", localFilename.c_str());

		StartEffect(localFilename.c_str(), 0, 1);
	} else if (FileExists(localFilename)) {
		LogInfo(VB_EFFECT, "Automatically starting background effect sequence "
			"background.eseq\n");
		StartEffect("background", 0, 1);
	}

	pauseBackgroundEffects = getSettingInt("pauseBackgroundEffects");
	return 1;
}
Ejemplo n.º 5
0
void MainLoop(void)
{
	int            commandSock = 0;
	int            controlSock = 0;
	int            bridgeSock = 0;
	int            prevFPPstatus = FPPstatus;
	int            sleepms = 50000;
	fd_set         active_fd_set;
	fd_set         read_fd_set;
	struct timeval timeout;
	int            selectResult;

	LogDebug(VB_GENERAL, "MainLoop()\n");

	FD_ZERO (&active_fd_set);

	CheckExistanceOfDirectoriesAndFiles();

	piFaceSetup(200); // PiFace inputs 1-8 == wiringPi 200-207

	if (getFPPmode() == BRIDGE_MODE)
	{
		bridgeSock = Bridge_Initialize();
		if (bridgeSock)
			FD_SET (bridgeSock, &active_fd_set);
	}
	else
	{
		InitMediaOutput();
	}

	pluginCallbackManager.init();

	InitializeChannelOutputs();
	sequence->SendBlankingData();

	InitEffects();
	InitializeChannelDataMemoryMap();

	commandSock = Command_Initialize();
	if (commandSock)
		FD_SET (commandSock, &active_fd_set);

#ifdef USEHTTPAPI
	APIServer apiServer;
	apiServer.Init();
#endif

	controlSock = InitControlSocket();
	FD_SET (controlSock, &active_fd_set);

	SetupGPIOInput();

	if (getFPPmode() & PLAYER_MODE)
	{
		if (getFPPmode() == MASTER_MODE)
			InitSyncMaster();

		scheduler->CheckIfShouldBePlayingNow();

		if (getAlwaysTransmit())
			StartChannelOutputThread();
	}

	LogInfo(VB_GENERAL, "Starting main processing loop\n");

	while (runMainFPPDLoop)
	{
		timeout.tv_sec  = 0;
		timeout.tv_usec = sleepms;

		read_fd_set = active_fd_set;


		selectResult = select(FD_SETSIZE, &read_fd_set, NULL, NULL, &timeout);
		if (selectResult < 0)
		{
			if (errno == EINTR)
			{
				// We get interrupted when media players finish
				continue;
			}
			else
			{
				LogErr(VB_GENERAL, "Main select() failed: %s\n",
					strerror(errno));
				runMainFPPDLoop = 0;
				continue;
			}
		}

		if (commandSock && FD_ISSET(commandSock, &read_fd_set))
			CommandProc();

		if (bridgeSock && FD_ISSET(bridgeSock, &read_fd_set))
			Bridge_ReceiveData();

		if (controlSock && FD_ISSET(controlSock, &read_fd_set))
			ProcessControlPacket();

		// Check to see if we need to start up the output thread.
		// FIXME, possibly trigger this via a fpp command to fppd
		if ((!ChannelOutputThreadIsRunning()) &&
			(getFPPmode() != BRIDGE_MODE) &&
			((UsingMemoryMapInput()) ||
			 (channelTester->Testing()) ||
			 (getAlwaysTransmit()))) {
			int E131BridgingInterval = getSettingInt("E131BridgingInterval");
			if (!E131BridgingInterval)
				E131BridgingInterval = 50;
			SetChannelOutputRefreshRate(1000 / E131BridgingInterval);
			StartChannelOutputThread();
		}

		if (getFPPmode() & PLAYER_MODE)
		{
			if ((FPPstatus == FPP_STATUS_PLAYLIST_PLAYING) ||
				(FPPstatus == FPP_STATUS_STOPPING_GRACEFULLY))
			{
				if (prevFPPstatus == FPP_STATUS_IDLE)
				{
					playlist->PlayListPlayingInit();
					sleepms = 10000;
				}

				// Check again here in case PlayListPlayingInit
				// didn't find anything and put us back to IDLE
				if ((FPPstatus == FPP_STATUS_PLAYLIST_PLAYING) ||
					(FPPstatus == FPP_STATUS_STOPPING_GRACEFULLY))
				{
					playlist->PlayListPlayingProcess();
				}
			}

			int reactivated = 0;
			if (FPPstatus == FPP_STATUS_IDLE)
			{
				if ((prevFPPstatus == FPP_STATUS_PLAYLIST_PLAYING) ||
					(prevFPPstatus == FPP_STATUS_STOPPING_GRACEFULLY))
				{
					playlist->PlayListPlayingCleanup();

					if (FPPstatus != FPP_STATUS_IDLE)
						reactivated = 1;
					else
						sleepms = 50000;
				}
			}

			if (reactivated)
				prevFPPstatus = FPP_STATUS_IDLE;
			else
				prevFPPstatus = FPPstatus;

			scheduler->ScheduleProc();
		}
		else if (getFPPmode() == REMOTE_MODE)
		{
			if(mediaOutputStatus.status == MEDIAOUTPUTSTATUS_PLAYING)
			{
				playlist->PlaylistProcessMediaData();
			}
		}

		CheckGPIOInputs();
	}

	StopChannelOutputThread();
	ShutdownControlSocket();

	if (getFPPmode() == BRIDGE_MODE)
		Bridge_Shutdown();

	LogInfo(VB_GENERAL, "Main Loop complete, shutting down.\n");
}
Ejemplo n.º 6
0
void Renderer::initOpenGL() {
	//TODO: minden opengl setup cucc ide
	initVSync(getSettingInt(rData->settingsXml, "vsync"));
}
Ejemplo n.º 7
0
Archivo: Player.cpp Proyecto: dkulp/fpp
/*
 * Kick off the channel output thread
 */
int Player::StartChannelOutputThread(void)
{
	LogDebug(VB_PLAYER | VB_CHANNELOUT, "StartChannelOutputThread()\n");
	if (!ChannelOutputThreadIsRunning())
	{
		// Give a little time in case we were shutting down
		usleep(200000);
		if (ChannelOutputThreadIsRunning())
		{
			LogDebug(VB_PLAYER | VB_CHANNELOUT, "Channel Output thread is already running\n");
			return 1;
		}
	}

	int mediaOffsetInt = getSettingInt("mediaOffset");
	if (mediaOffsetInt)
		m_mediaOffset = (float)mediaOffsetInt * 0.001;
	else
		m_mediaOffset = 0.0;

	LogDebug(VB_PLAYER | VB_MEDIAOUT, "Using mediaOffset of %.3f\n", m_mediaOffset);

	int E131BridgingInterval = getSettingInt("E131BridgingInterval");

	if ((getFPPmode() == BRIDGE_MODE) && (E131BridgingInterval))
		m_defaultLightDelay = E131BridgingInterval * 1000;
	else
		m_defaultLightDelay = 1000000 / m_refreshRate;

	m_lightDelay = m_defaultLightDelay;

	m_runOutputThread = 1;
	int result = pthread_create(&m_outputThreadID, NULL, &ChannelOutputThread, this);

	if (result)
	{
		char msg[256];

		m_runOutputThread = 0;

		switch (result)
		{
			case EAGAIN: strcpy(msg, "Insufficient Resources");
				break;
			case EINVAL: strcpy(msg, "Invalid settings");
				break;
			case EPERM : strcpy(msg, "Invalid Permissions");
				break;
		}

		LogErr(VB_PLAYER | VB_CHANNELOUT, "ERROR creating channel output thread: %s\n", msg );
		return 0;
	}
	else
	{
		pthread_detach(m_outputThreadID);
	}

	// Wait for thread to start
	while (!ChannelOutputThreadIsRunning())
		usleep(10000);

	return 1;
}
Ejemplo n.º 8
0
int InitializeChannelOutputs(void) {
	Json::Value root;
	Json::Reader reader;
	int i = 0;

	channelOutputFrame = 0;

	for (i = 0; i < FPPD_MAX_CHANNEL_OUTPUTS; i++) {
		bzero(&channelOutputs[i], sizeof(channelOutputs[i]));
	}

	// Reset index so we can start populating the outputs array
	i = 0;

	if (FPDOutput.isConfigured())
	{
		channelOutputs[i].startChannel = getSettingInt("FPDStartChannelOffset");
		channelOutputs[i].outputOld = &FPDOutput;

		if (FPDOutput.open("", &channelOutputs[i].privData)) {
			channelOutputs[i].channelCount = channelOutputs[i].outputOld->maxChannels(channelOutputs[i].privData);

			i++;
		} else {
			LogErr(VB_CHANNELOUT, "ERROR Opening FPD Channel Output\n");
		}
	}

	if (((getFPPmode() != BRIDGE_MODE) ||
		 (getSettingInt("E131Bridging"))) &&
		(E131Output.isConfigured()))
	{
		channelOutputs[i].startChannel = 0;
		channelOutputs[i].outputOld  = &E131Output;

		if (E131Output.open("", &channelOutputs[i].privData)) {
			channelOutputs[i].channelCount = channelOutputs[i].outputOld->maxChannels(channelOutputs[i].privData);

			i++;
		} else {
			LogErr(VB_CHANNELOUT, "ERROR Opening E1.31 Channel Output\n");
		}
	}

	FILE *fp;
	char filename[1024];
	char buf[2048];

	// Parse the channeloutputs.json config file
	strcpy(filename, getMediaDirectory());
	strcat(filename, "/config/channeloutputs.json");

	LogDebug(VB_CHANNELOUT, "Loading %s\n", filename);

	if (FileExists(filename))
	{
		std::ifstream t(filename);
		std::stringstream buffer;

		buffer << t.rdbuf();

		std::string config = buffer.str();

		bool success = reader.parse(buffer.str(), root);
		if (!success)
		{
			LogErr(VB_CHANNELOUT, "Error parsing %s\n", filename);
			return 0;
		}

		const Json::Value outputs = root["channelOutputs"];
		std::string type;
		int start = 0;
		int count = 0;

		for (int c = 0; c < outputs.size(); c++)
		{
			type = outputs[c]["type"].asString();

			if (!outputs[c]["enabled"].asInt())
			{
				LogDebug(VB_CHANNELOUT, "Skipping Disabled Channel Output: %s\n", type.c_str());
				continue;
			}

			start = outputs[c]["startChannel"].asInt();
			count = outputs[c]["channelCount"].asInt();

			// internally we start channel counts at zero
			start -= 1;

			channelOutputs[i].startChannel = start;
			channelOutputs[i].channelCount = count;

			if (type == "LEDPanelMatrix") {
#if defined(PLATFORM_PI) || defined(PLATFORM_ODROID)
				if (outputs[c]["subType"] == "RGBMatrix")
					channelOutputs[i].output = new RGBMatrixOutput(start, count);
				else
				{
					LogErr(VB_CHANNELOUT, "%s subType not valid on Pi\n", outputs[c]["subType"].asString().c_str());
					continue;
				}
#endif
#ifdef PLATFORM_BBB
				if (outputs[c]["subType"] == "LEDscapeMatrix")
					channelOutputs[i].output = new LEDscapeMatrixOutput(start, count);
				else
				{
					LogErr(VB_CHANNELOUT, "%s subType not valid on BBB\n", outputs[c]["subType"].asString().c_str());
					continue;
				}
			} else if (type == "BBB48String") {
				channelOutputs[i].output = new BBB48StringOutput(start, count);
			} else if (type == "BBBSerial") {
				channelOutputs[i].output = new BBBSerialOutput(start, count);
#endif
#ifdef USEOLA
			} else if (type == "OLA") {
				channelOutputs[i].output = new OLAOutput(start, count);
#endif
			} else if (type == "USBRelay") {
				channelOutputs[i].output = new USBRelayOutput(start, count);
#if defined(PLATFORM_PI)
			} else if (type == "Hill320") {
				channelOutputs[i].output = new Hill320Output(start, count);
#endif
#ifdef USE_X11Matrix
			} else if (type == "X11Matrix") {
				channelOutputs[i].output = new X11MatrixOutput(start, count);
#endif
			} else {
				LogErr(VB_CHANNELOUT, "Unknown Channel Output type: %s\n", type.c_str());
				continue;
			}

			if (channelOutputs[i].output->Init(outputs[c])) {
				i++;
			} else {
				LogErr(VB_CHANNELOUT, "ERROR Opening %s Channel Output\n", type.c_str());
			}
		}
	}

	// Parse the channeloutputs config file
	strcpy(filename, getMediaDirectory());
	strcat(filename, "/channeloutputs");

	if (FileExists(filename))
	{
		LogDebug(VB_CHANNELOUT, "Loading %s\n", filename);

		fp = fopen(filename, "r");

		if (fp == NULL)
		{
			LogErr(VB_CHANNELOUT,
				"Could not open Channel Outputs config file %s: %s\n",
				filename, strerror(errno));
			channelOutputCount = 0;

			return 0;
		}

		while(fgets(buf, 2048, fp) != NULL)
		{
			int  enabled = 0;
			char type[32];
			int  start = 0;
			int  count = 0;
			char deviceConfig[160];

			if (buf[0] == '#') // Allow # comments for testing
				continue;

			int fields = sscanf(buf, "%d,%[^,],%d,%d,%s",
				&enabled, type, &start, &count, deviceConfig);

			if (fields != 5) {
				LogErr(VB_CHANNELOUT,
					"Invalid line in channeloutputs config file: %s\n", buf);
				continue;
			}

			if (!enabled) {
				LogDebug(VB_CHANNELOUT, "Skipping disabled channel output: %s", buf);
				continue;
			}

			if (count > (FPPD_MAX_CHANNELS - start)) {
				LogWarn(VB_CHANNELOUT,
					"Channel Output config, start (%d) + count (%d) exceeds max (%d) channel\n",
					start, count, FPPD_MAX_CHANNELS);

				count = FPPD_MAX_CHANNELS - start;

				LogWarn(VB_CHANNELOUT,
					"Count suppressed to %d for config line: %s\n", count, buf);
			}

			if (strlen(deviceConfig))
				strcat(deviceConfig, ";");

			strcat(deviceConfig, "type=");
			strcat(deviceConfig, type);

			LogDebug(VB_CHANNELOUT, "ChannelOutput: %d %s %d %d %s\n", enabled, type, start, count, deviceConfig);

			// internally we start channel counts at zero
			start -= 1;

			channelOutputs[i].startChannel = start;
			channelOutputs[i].channelCount = count;


			if ((!strcmp(type, "Pixelnet-Lynx")) ||
				(!strcmp(type, "Pixelnet-Open")))
			{
				channelOutputs[i].output = new USBPixelnetOutput(start, count);
			} else if ((!strcmp(type, "DMX-Pro")) ||
					   (!strcmp(type, "DMX-Open"))) {
				channelOutputs[i].output = new USBDMXOutput(start, count);
			} else if ((!strcmp(type, "VirtualMatrix")) ||
						(!strcmp(type, "FBMatrix"))) {
				channelOutputs[i].output = new FBMatrixOutput(start, count);
			} else if (!strcmp(type, "GPIO")) {
				channelOutputs[i].output = new GPIOOutput(start, count);
			} else if (!strcmp(type, "GenericSerial")) {
				channelOutputs[i].output = new GenericSerialOutput(start, count);
			} else if (!strcmp(type, "LOR")) {
				channelOutputs[i].outputOld = &LOROutput;
			} else if (!strcmp(type, "Renard")) {
				channelOutputs[i].outputOld = &USBRenardOutput;
#ifdef PLATFORM_PI
			} else if (!strcmp(type, "RPIWS281X")) {
				channelOutputs[i].output = new RPIWS281xOutput(start, count);
#endif
			} else if (!strcmp(type, "SPI-WS2801")) {
				channelOutputs[i].output = new SPIws2801Output(start, count);
			} else if (!strcmp(type, "SPI-nRF24L01")) {
				channelOutputs[i].outputOld = &SPInRF24L01Output;
			} else if (!strcmp(type, "Triks-C")) {
				channelOutputs[i].outputOld = &TriksCOutput;
			} else if (!strcmp(type, "GPIO-595")) {
				channelOutputs[i].output = new GPIO595Output(start, count);
			} else if (!strcmp(type, "Debug")) {
				channelOutputs[i].output = new DebugOutput(start, count);
			} else {
				LogErr(VB_CHANNELOUT, "Unknown Channel Output type: %s\n", type);
				continue;
			}

			if ((channelOutputs[i].outputOld) &&
				(channelOutputs[i].outputOld->open(deviceConfig, &channelOutputs[i].privData)))
			{
				if (channelOutputs[i].channelCount > channelOutputs[i].outputOld->maxChannels(channelOutputs[i].privData)) {
					LogWarn(VB_CHANNELOUT,
						"Channel Output config, count (%d) exceeds max (%d) channel for configured output\n",
						channelOutputs[i].channelCount, channelOutputs[i].outputOld->maxChannels(channelOutputs[i].privData));

					channelOutputs[i].channelCount = channelOutputs[i].outputOld->maxChannels(channelOutputs[i].privData);

					LogWarn(VB_CHANNELOUT,
						"Count suppressed to %d for config: %s\n", channelOutputs[i].channelCount, buf);
				}
				i++;
			} else if ((channelOutputs[i].output) &&
					   (channelOutputs[i].output->Init(deviceConfig))) {
				i++;
			} else {
				LogErr(VB_CHANNELOUT, "ERROR Opening %s Channel Output\n", type);
			}
		}
	}

	channelOutputCount = i;

	LogDebug(VB_CHANNELOUT, "%d Channel Outputs configured\n", channelOutputCount);

	LoadChannelRemapData();

	return 1;
}
Ejemplo n.º 9
0
int FalconPassThroughData(int offset, unsigned char *inBuf, int size)
{
	LogDebug(VB_SETTING, "FalconPassThroughData(%p)\n", inBuf);

	if ((logLevel & LOG_DEBUG) && (logMask & VB_SETTING))
		HexDump("Falcon Pass-through data", inBuf, size);

	// Disable channel outputs and let them quiesce before sending config info
 	DisableChannelOutput();
	usleep(100000);

	if (getSettingInt("FPDEnabled"))
	{
		unsigned char *buf = (unsigned char *)malloc(FALCON_CFG_BUF_SIZE);
		if (!buf)
		{
			LogErr(VB_SETTING,
				"Unable to allocate %d byte buffer for passing through Falcon data: %s\n",
				FALCON_CFG_BUF_SIZE, strerror(errno));
			return -1;
		}

		bzero(buf, FALCON_CFG_BUF_SIZE);

		if(offset < (FALCON_CFG_BUF_SIZE - size))
		{
			LogDebug(VB_SETTING, "Offset = %d\n", offset);
		}
		else
		{
			LogErr(VB_SETTING,"Offset %d is invalid: %s\n",offset, strerror(errno));
		}

		buf[0] = 0xCC;
		buf[1] = 0xCC;
		buf[2] = 0xCC;
		buf[3] = 0xCC;
		buf[4] = 0xCC;
		buf[5] = 0x55;

		memcpy(buf+FALCON_CFG_HEADER_SIZE+offset, inBuf, size);

		int bytesWritten;

		bytesWritten = wiringPiSPIDataRW (0, (unsigned char *)buf, FALCON_CFG_BUF_SIZE);
		if (bytesWritten != FALCON_CFG_BUF_SIZE)
		{
			LogErr(VB_SETTING,
				"Error: wiringPiSPIDataRW returned %d, expecting %d\n",
				bytesWritten, FALCON_CFG_BUF_SIZE);
		}
		free(buf);

		usleep(100000);
	}

	// Pass data on to our regular channel outputs followed by blanking data
	bzero(sequence->m_seqData + offset, 4096);
	memcpy(sequence->m_seqData + offset, inBuf, FALCON_PASSTHROUGH_DATA_SIZE);
	sequence->SendSequenceData();
	sequence->SendBlankingData(); // reset data so we don't keep reprogramming

	// Give changes time to take effect then turn back on channel outputs
	usleep(100000);
	EnableChannelOutput();
}