mirror of
				https://github.com/hyperion-project/hyperion.ng.git
				synced 2025-03-01 10:33:28 +00:00 
			
		
		
		
	Logging migration continues ... (#97)
* migrate logging for blackborder and bonjour. fix logging bug in hyperion * fix kodichecker when kodi is not there
This commit is contained in:
		| @@ -3,6 +3,7 @@ | ||||
|  | ||||
| // Jsoncpp includes | ||||
| #include <json/json.h> | ||||
|  | ||||
| // Local Hyperion includes | ||||
| #include "BlackBorderDetector.h" | ||||
|  | ||||
| @@ -107,6 +108,5 @@ namespace hyperion | ||||
| 		unsigned _consistentCnt; | ||||
| 		/// The number of frame the previous detected border NOT matched the incomming border | ||||
| 		unsigned _inconsistentCnt; | ||||
|  | ||||
| 	}; | ||||
| } // end namespace hyperion | ||||
|   | ||||
| @@ -1,12 +1,14 @@ | ||||
| #include <iostream> | ||||
| #include <utils/Logger.h> | ||||
|  | ||||
| // BlackBorders includes | ||||
| #include <blackborder/BlackBorderDetector.h> | ||||
| #include <cmath> | ||||
|  | ||||
| using namespace hyperion; | ||||
|  | ||||
| BlackBorderDetector::BlackBorderDetector(double threshold) : | ||||
| 	_blackborderThreshold(calculateThreshold(threshold)) | ||||
| BlackBorderDetector::BlackBorderDetector(double threshold) | ||||
| 	: _blackborderThreshold(calculateThreshold(threshold)) | ||||
| { | ||||
| 	// empty | ||||
| } | ||||
| @@ -21,7 +23,7 @@ uint8_t BlackBorderDetector::calculateThreshold(double threshold) | ||||
|  | ||||
| 	uint8_t blackborderThreshold = uint8_t(rgbThreshold); | ||||
|  | ||||
| 	std::cout << "BLACKBORDER INFO: threshold set to " << threshold << " (" << int(blackborderThreshold) << ")" << std::endl; | ||||
| 	Info(Logger::getInstance("BLACKBORDER"), "threshold set to %f (%d)", threshold , int(blackborderThreshold)); | ||||
|  | ||||
| 	return blackborderThreshold; | ||||
| } | ||||
|   | ||||
| @@ -1,8 +1,6 @@ | ||||
| #include <iostream> | ||||
| /* | ||||
| #include <iomanip> | ||||
| using std::setw; | ||||
| //*/ | ||||
|  | ||||
| #include <utils/Logger.h> | ||||
|  | ||||
| // Blackborder includes | ||||
| #include <blackborder/BlackBorderProcessor.h> | ||||
| @@ -10,20 +8,19 @@ using std::setw; | ||||
|  | ||||
| using namespace hyperion; | ||||
|  | ||||
| BlackBorderProcessor::BlackBorderProcessor(const Json::Value &blackborderConfig) : | ||||
| 	_unknownSwitchCnt(blackborderConfig.get("unknownFrameCnt", 600).asUInt()), | ||||
| 	_borderSwitchCnt(blackborderConfig.get("borderFrameCnt", 50).asUInt()), | ||||
| 	_maxInconsistentCnt(blackborderConfig.get("maxInconsistentCnt", 10).asUInt()), | ||||
| 	_blurRemoveCnt(blackborderConfig.get("blurRemoveCnt", 1).asUInt()), | ||||
| 	_detectionMode(blackborderConfig.get("mode", "default").asString()), | ||||
| 	_detector(blackborderConfig.get("threshold", 0.01).asDouble()), | ||||
| 	_currentBorder({true, -1, -1}), | ||||
| 	_previousDetectedBorder({true, -1, -1}), | ||||
| 	_consistentCnt(0), | ||||
| 	_inconsistentCnt(10) | ||||
| BlackBorderProcessor::BlackBorderProcessor(const Json::Value &blackborderConfig) | ||||
| 	: _unknownSwitchCnt(blackborderConfig.get("unknownFrameCnt", 600).asUInt()) | ||||
| 	, _borderSwitchCnt(blackborderConfig.get("borderFrameCnt", 50).asUInt()) | ||||
| 	, _maxInconsistentCnt(blackborderConfig.get("maxInconsistentCnt", 10).asUInt()) | ||||
| 	, _blurRemoveCnt(blackborderConfig.get("blurRemoveCnt", 1).asUInt()) | ||||
| 	, _detectionMode(blackborderConfig.get("mode", "default").asString()) | ||||
| 	, _detector(blackborderConfig.get("threshold", 0.01).asDouble()) | ||||
| 	, _currentBorder({true, -1, -1}) | ||||
| 	, _previousDetectedBorder({true, -1, -1}) | ||||
| 	, _consistentCnt(0) | ||||
| 	, _inconsistentCnt(10) | ||||
| { | ||||
| 	std::cout << "BLACKBORDER INFO: mode:" << _detectionMode << std::endl; | ||||
| 	// empty | ||||
| 	Info(Logger::getInstance("BLACKBORDER"), "mode: %s", _detectionMode.c_str()); | ||||
| } | ||||
|  | ||||
| BlackBorder BlackBorderProcessor::getCurrentBorder() const | ||||
|   | ||||
| @@ -31,6 +31,8 @@ ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | ||||
|  | ||||
| #include <QtCore/QSocketNotifier> | ||||
|  | ||||
| #include <utils/Logger.h> | ||||
|  | ||||
| BonjourServiceRegister::BonjourServiceRegister(QObject *parent) | ||||
|     : QObject(parent), dnssref(0), bonjourSocket(0) | ||||
| { | ||||
| @@ -39,49 +41,56 @@ BonjourServiceRegister::BonjourServiceRegister(QObject *parent) | ||||
|  | ||||
| BonjourServiceRegister::~BonjourServiceRegister() | ||||
| { | ||||
|     if (dnssref) { | ||||
|         DNSServiceRefDeallocate(dnssref); | ||||
|         dnssref = 0; | ||||
|     } | ||||
| 	if (dnssref) | ||||
| 	{ | ||||
| 		DNSServiceRefDeallocate(dnssref); | ||||
| 		dnssref = 0; | ||||
| 	} | ||||
| } | ||||
|  | ||||
| void BonjourServiceRegister::registerService(const BonjourRecord &record, quint16 servicePort) | ||||
| { | ||||
|     if (dnssref) { | ||||
|         qWarning("Warning: Already registered a service for this object, aborting new register"); | ||||
|         return; | ||||
|     } | ||||
|     quint16 bigEndianPort = servicePort; | ||||
| 	if (dnssref) | ||||
| 	{ | ||||
| 		Warning(Logger::getInstance("BonJour"), "Already registered a service for this object, aborting new register"); | ||||
| 		return; | ||||
| 	} | ||||
| 	quint16 bigEndianPort = servicePort; | ||||
| #if Q_BYTE_ORDER == Q_LITTLE_ENDIAN | ||||
|     { | ||||
|         bigEndianPort =  0 | ((servicePort & 0x00ff) << 8) | ((servicePort & 0xff00) >> 8); | ||||
|     } | ||||
| 	{ | ||||
| 		bigEndianPort =  0 | ((servicePort & 0x00ff) << 8) | ((servicePort & 0xff00) >> 8); | ||||
| 	} | ||||
| #endif | ||||
|  | ||||
|     DNSServiceErrorType err = DNSServiceRegister(&dnssref, 0, 0, record.serviceName.toUtf8().constData(), | ||||
|                                                  record.registeredType.toUtf8().constData(), | ||||
|                                                  record.replyDomain.isEmpty() ? 0 | ||||
|                                                           : record.replyDomain.toUtf8().constData(), 0, | ||||
|                                                  bigEndianPort, 0, 0, bonjourRegisterService, this); | ||||
|     if (err != kDNSServiceErr_NoError) { | ||||
|         emit error(err); | ||||
|     } else { | ||||
|         int sockfd = DNSServiceRefSockFD(dnssref); | ||||
|         if (sockfd == -1) { | ||||
|             emit error(kDNSServiceErr_Invalid); | ||||
|         } else { | ||||
|             bonjourSocket = new QSocketNotifier(sockfd, QSocketNotifier::Read, this); | ||||
|             connect(bonjourSocket, SIGNAL(activated(int)), this, SLOT(bonjourSocketReadyRead())); | ||||
|         } | ||||
|     } | ||||
| 	DNSServiceErrorType err = DNSServiceRegister(&dnssref, 0, 0, record.serviceName.toUtf8().constData(), | ||||
| 	                                            record.registeredType.toUtf8().constData(), | ||||
| 	                                            (record.replyDomain.isEmpty() ? 0 : record.replyDomain.toUtf8().constData()), | ||||
| 	                                            0, bigEndianPort, 0, 0, bonjourRegisterService, this); | ||||
| 	if (err != kDNSServiceErr_NoError) | ||||
| 	{ | ||||
| 		emit error(err); | ||||
| 	} | ||||
| 	else | ||||
| 	{ | ||||
| 		int sockfd = DNSServiceRefSockFD(dnssref); | ||||
| 		if (sockfd == -1) | ||||
| 		{ | ||||
| 			emit error(kDNSServiceErr_Invalid); | ||||
| 		} | ||||
| 		else | ||||
| 		{ | ||||
| 			bonjourSocket = new QSocketNotifier(sockfd, QSocketNotifier::Read, this); | ||||
| 			connect(bonjourSocket, SIGNAL(activated(int)), this, SLOT(bonjourSocketReadyRead())); | ||||
| 		} | ||||
| 	} | ||||
| } | ||||
|  | ||||
|  | ||||
| void BonjourServiceRegister::bonjourSocketReadyRead() | ||||
| { | ||||
|     DNSServiceErrorType err = DNSServiceProcessResult(dnssref); | ||||
|     if (err != kDNSServiceErr_NoError) | ||||
|         emit error(err); | ||||
| 	DNSServiceErrorType err = DNSServiceProcessResult(dnssref); | ||||
| 	if (err != kDNSServiceErr_NoError) | ||||
| 		emit error(err); | ||||
| } | ||||
|  | ||||
|  | ||||
| @@ -90,13 +99,16 @@ void BonjourServiceRegister::bonjourRegisterService(DNSServiceRef, DNSServiceFla | ||||
|                                                    const char *regtype, const char *domain, | ||||
|                                                    void *data) | ||||
| { | ||||
|     BonjourServiceRegister *serviceRegister = static_cast<BonjourServiceRegister *>(data); | ||||
|     if (errorCode != kDNSServiceErr_NoError) { | ||||
|         emit serviceRegister->error(errorCode); | ||||
|     } else { | ||||
|         serviceRegister->finalRecord = BonjourRecord(QString::fromUtf8(name), | ||||
|                                                 QString::fromUtf8(regtype), | ||||
|                                                 QString::fromUtf8(domain)); | ||||
|         emit serviceRegister->serviceRegistered(serviceRegister->finalRecord); | ||||
|     } | ||||
| 	BonjourServiceRegister *serviceRegister = static_cast<BonjourServiceRegister *>(data); | ||||
| 	if (errorCode != kDNSServiceErr_NoError) | ||||
| 	{ | ||||
| 		emit serviceRegister->error(errorCode); | ||||
| 	} | ||||
| 	else | ||||
| 	{ | ||||
| 		serviceRegister->finalRecord = BonjourRecord(QString::fromUtf8(name), | ||||
| 		                                        QString::fromUtf8(regtype), | ||||
| 		                                        QString::fromUtf8(domain)); | ||||
| 		emit serviceRegister->serviceRegistered(serviceRegister->finalRecord); | ||||
| 	} | ||||
| } | ||||
|   | ||||
| @@ -138,8 +138,6 @@ bool EffectEngine::loadEffectDefinition(const std::string &path, const std::stri | ||||
| 	effectDefinition.script = path + QDir::separator().toLatin1() + config["script"].asString(); | ||||
| 	effectDefinition.args = config["args"]; | ||||
|  | ||||
| 	// return succes //BLACKLIST OUTPUT TO LOG (Spam). This is more a effect development thing and the list gets longer and longer | ||||
| //	std::cout << "EFFECTENGINE INFO: Effect loaded: " + effectDefinition.name << std::endl; | ||||
| 	return true; | ||||
| } | ||||
|  | ||||
|   | ||||
| @@ -202,7 +202,7 @@ MultiColorTransform * Hyperion::createLedColorsTransform(const unsigned ledCnt, | ||||
| 			for (int i=0; i<ledIndexList.size(); ++i) { | ||||
| 				if (i > 0) | ||||
| 				{ | ||||
| 					std::cout << ", "; | ||||
| 					ss << ", "; | ||||
| 				} | ||||
| 				if (ledIndexList[i].contains("-")) | ||||
| 				{ | ||||
| @@ -211,13 +211,13 @@ MultiColorTransform * Hyperion::createLedColorsTransform(const unsigned ledCnt, | ||||
| 					int endInd   = ledIndices[1].toInt(); | ||||
|  | ||||
| 					transform->setTransformForLed(colorTransform->_id, startInd, endInd); | ||||
| 					std::cout << startInd << "-" << endInd; | ||||
| 					ss << startInd << "-" << endInd; | ||||
| 				} | ||||
| 				else | ||||
| 				{ | ||||
| 					int index = ledIndexList[i].toInt(); | ||||
| 					transform->setTransformForLed(colorTransform->_id, index, index); | ||||
| 					std::cout << index; | ||||
| 					ss << index; | ||||
| 				} | ||||
| 			} | ||||
| 			Info(log, "ColorTransform '%s' => [%s]", colorTransform->_id.c_str(), ss.str().c_str());  | ||||
|   | ||||
| @@ -310,7 +310,7 @@ void KODIVideoChecker::reconnect() | ||||
|  | ||||
| void KODIVideoChecker::connectionError(QAbstractSocket::SocketError error) | ||||
| { | ||||
| 	Error(_log,"Connection error (%s)", error); | ||||
| 	Error(_log,"Connection error (%s)", _socket.errorString().toStdString().c_str()); | ||||
|  | ||||
| 	// close the socket | ||||
| 	_socket.close(); | ||||
|   | ||||
		Reference in New Issue
	
	Block a user