Beispiel #1
0
void NetworkManager::handleReq(QHttpRequest *req, QHttpResponse *resp)
{
    QObject::connect(resp, &QHttpResponse::destroyed, req, &QHttpRequest::deleteLater);

    if(req->url().path().startsWith("/preview"))
    {
        QSharedPointer<MediaFile> mediaEntry = parseMedia(req->url().path(), resp);
        if(mediaEntry != nullptr)
        {
            handlePreview(mediaEntry, req, resp);
        }
    }
    else if(req->url().path().startsWith("/video"))
    {
        QSharedPointer<MediaFile> mediaEntry = parseMedia(req->url().path(), resp);
        if(mediaEntry != nullptr)
        {
            handleVideo(mediaEntry, req, resp);
        }
    }
    else if(req->url().path().startsWith("/cmd"))
    {
        Command::run(req, resp);
    }
    else
    {
        resp->writeHead(QHttpResponse::STATUS_NOT_FOUND);
        resp->end();
    }
}
Beispiel #2
0
int Simulator::handleAll()
{
	if (handleConfiguration())
		return -1;
	if (handleScore())
		return -1;
	if (handleAlgorithms())
		return -1;
	if (handleHouses())
		return -1;
	handleThreads();
	if (handleVideo())
		return -1;
	return 0;
}
Beispiel #3
0
void PacketHandler::receive(const uint8* data, int length)
{
	// not even a header & length
	if (length<4)
	{
		_nfpvrInterface.notify(INfpvrInterface::NotifyWarning, "Received packet with length<4");
		return;
	}
	
	uint16 header     = Bitfield::decode<uint16>(data+0);
	uint16 dataLength = Bitfield::decode<uint16>(data+2);

	bool streaming = (_state != StateStarted) && (_state != StateStopped);
		
	if (header == 0x3810)
	{
		handleFilename(data+4, dataLength);	
	}
	else if (header == 0x381A)
	{
		if (streaming)
			handleStop();
	}
	else if (header == 0x3800)
	{
		if (_nfpvrInterface.getOptions()._writeMpeg && streaming)
			handleVideo(data+4, dataLength);
	}
	else if (header == 0x3801)
	{
		if (_nfpvrInterface.getOptions()._writeMpeg && streaming)
			handleAudio(data+4, dataLength);
	}
	else if (header == 0x3880)
	{
		// ignore, reply from PC to NF
	}
	else
	{
		_nfpvrInterface.notify(INfpvrInterface::NotifyWarning, "Received packet with unknown header 0x%04x", header);
	}
}