mirror of
				https://github.com/hyperion-project/hyperion.ng.git
				synced 2025-03-01 10:33:28 +00:00 
			
		
		
		
	Improvements
This commit is contained in:
		
							
								
								
									
										3
									
								
								.gitignore
									
									
									
									
										vendored
									
									
								
							
							
						
						
									
										3
									
								
								.gitignore
									
									
									
									
										vendored
									
									
								
							| @@ -29,3 +29,6 @@ libsrc/flatbufserver/hyperion_request_generated.h | |||||||
| # Visual Studio 2015/2017/2019 cache/options directory | # Visual Studio 2015/2017/2019 cache/options directory | ||||||
| .vs/ | .vs/ | ||||||
| CMakeSettings.json | CMakeSettings.json | ||||||
|  |  | ||||||
|  | # LedDevice 'File' output | ||||||
|  | NULL | ||||||
|   | |||||||
| @@ -102,7 +102,7 @@ private: | |||||||
| 	void process_image(const void *frameImageBuffer, int size); | 	void process_image(const void *frameImageBuffer, int size); | ||||||
| 	void checkSignalDetectionEnabled(Image<ColorRgb> image); | 	void checkSignalDetectionEnabled(Image<ColorRgb> image); | ||||||
|  |  | ||||||
| 	QString										_deviceName; | 	QString										_currentDeviceName, _newDeviceName; | ||||||
| 	QMap<QString, MFGrabber::DeviceProperties>	_deviceProperties; | 	QMap<QString, MFGrabber::DeviceProperties>	_deviceProperties; | ||||||
| 	HRESULT										_hr; | 	HRESULT										_hr; | ||||||
| 	SourceReaderCB*								_sourceReaderCB; | 	SourceReaderCB*								_sourceReaderCB; | ||||||
|   | |||||||
| @@ -6,7 +6,8 @@ namespace { const bool verbose = false; } | |||||||
|  |  | ||||||
| MFGrabber::MFGrabber(const QString & device, unsigned width, unsigned height, unsigned fps, int pixelDecimation, QString flipMode) | MFGrabber::MFGrabber(const QString & device, unsigned width, unsigned height, unsigned fps, int pixelDecimation, QString flipMode) | ||||||
| 	: Grabber("V4L2:"+device) | 	: Grabber("V4L2:"+device) | ||||||
| 	, _deviceName(device) | 	, _currentDeviceName(device) | ||||||
|  | 	, _newDeviceName(device) | ||||||
| 	, _hr(S_FALSE) | 	, _hr(S_FALSE) | ||||||
| 	, _sourceReader(nullptr) | 	, _sourceReader(nullptr) | ||||||
| 	, _pixelDecimation(pixelDecimation) | 	, _pixelDecimation(pixelDecimation) | ||||||
| @@ -59,14 +60,14 @@ bool MFGrabber::init() | |||||||
| 	{ | 	{ | ||||||
| 		QString foundDevice = ""; | 		QString foundDevice = ""; | ||||||
| 		int     foundIndex = -1, bestGuess = -1, bestGuessMinX = INT_MAX, bestGuessMinFPS = INT_MAX; | 		int     foundIndex = -1, bestGuess = -1, bestGuessMinX = INT_MAX, bestGuessMinFPS = INT_MAX; | ||||||
| 		bool    autoDiscovery = (QString::compare(_deviceName, "auto", Qt::CaseInsensitive) == 0 ); | 		bool    autoDiscovery = (QString::compare(_currentDeviceName, "auto", Qt::CaseInsensitive) == 0 ); | ||||||
|  |  | ||||||
| 		// enumerate the video capture devices on the user's system | 		// enumerate the video capture devices on the user's system | ||||||
| 		enumVideoCaptureDevices(); | 		enumVideoCaptureDevices(); | ||||||
|  |  | ||||||
| 		if(!autoDiscovery && !_deviceProperties.contains(_deviceName)) | 		if(!autoDiscovery && !_deviceProperties.contains(_currentDeviceName)) | ||||||
| 		{ | 		{ | ||||||
| 			Debug(_log, "Device '%s' is not available. Changing to auto.", QSTRING_CSTR(_deviceName)); | 			Debug(_log, "Device '%s' is not available. Changing to auto.", QSTRING_CSTR(_currentDeviceName)); | ||||||
| 			autoDiscovery = true; | 			autoDiscovery = true; | ||||||
| 		} | 		} | ||||||
|  |  | ||||||
| @@ -76,12 +77,12 @@ bool MFGrabber::init() | |||||||
| 			if(_deviceProperties.count()>0) | 			if(_deviceProperties.count()>0) | ||||||
| 			{ | 			{ | ||||||
| 				foundDevice = _deviceProperties.firstKey(); | 				foundDevice = _deviceProperties.firstKey(); | ||||||
| 				_deviceName = foundDevice; | 				_currentDeviceName = foundDevice; | ||||||
| 				Debug(_log, "Auto discovery set to %s", QSTRING_CSTR(_deviceName)); | 				Debug(_log, "Auto discovery set to %s", QSTRING_CSTR(_currentDeviceName)); | ||||||
| 			} | 			} | ||||||
| 		} | 		} | ||||||
| 		else | 		else | ||||||
| 			foundDevice = _deviceName; | 			foundDevice = _currentDeviceName; | ||||||
|  |  | ||||||
| 		if(foundDevice.isNull() || foundDevice.isEmpty() || !_deviceProperties.contains(foundDevice)) | 		if(foundDevice.isNull() || foundDevice.isEmpty() || !_deviceProperties.contains(foundDevice)) | ||||||
| 		{ | 		{ | ||||||
| @@ -132,7 +133,7 @@ bool MFGrabber::init() | |||||||
|  |  | ||||||
| 		if(foundIndex < 0 && bestGuess >= 0) | 		if(foundIndex < 0 && bestGuess >= 0) | ||||||
| 		{ | 		{ | ||||||
| 			if(!autoDiscovery) | 			if(!autoDiscovery && _width != 0 && _height != 0) | ||||||
| 				Warning(_log, "Selected resolution not found in supported modes. Forcing best resolution"); | 				Warning(_log, "Selected resolution not found in supported modes. Forcing best resolution"); | ||||||
| 			else | 			else | ||||||
| 				Debug(_log, "Forcing best resolution"); | 				Debug(_log, "Forcing best resolution"); | ||||||
| @@ -157,7 +158,7 @@ void MFGrabber::uninit() | |||||||
| 	// stop if the grabber was not stopped | 	// stop if the grabber was not stopped | ||||||
| 	if(_initialized) | 	if(_initialized) | ||||||
| 	{ | 	{ | ||||||
| 		Debug(_log,"uninit grabber: %s", QSTRING_CSTR(_deviceName)); | 		Debug(_log,"uninit grabber: %s", QSTRING_CSTR(_newDeviceName)); | ||||||
| 		stop(); | 		stop(); | ||||||
| 	} | 	} | ||||||
| } | } | ||||||
| @@ -607,6 +608,8 @@ void MFGrabber::setSignalDetectionOffset(double horizontalMin, double verticalMi | |||||||
| bool MFGrabber::start() | bool MFGrabber::start() | ||||||
| { | { | ||||||
| 	try | 	try | ||||||
|  | 	{ | ||||||
|  | 		if(!_initialized) | ||||||
| 		{ | 		{ | ||||||
| 			_threadManager.start(); | 			_threadManager.start(); | ||||||
| 			DebugIf(verbose, _log, "Decoding threads: %d",_threadManager._maxThreads); | 			DebugIf(verbose, _log, "Decoding threads: %d",_threadManager._maxThreads); | ||||||
| @@ -618,6 +621,7 @@ bool MFGrabber::start() | |||||||
| 				return true; | 				return true; | ||||||
| 			} | 			} | ||||||
| 		} | 		} | ||||||
|  | 	} | ||||||
| 	catch(std::exception& e) | 	catch(std::exception& e) | ||||||
| 	{ | 	{ | ||||||
| 		Error(_log, "Start failed (%s)", e.what()); | 		Error(_log, "Start failed (%s)", e.what()); | ||||||
| @@ -743,9 +747,9 @@ void MFGrabber::setCecDetectionEnable(bool enable) | |||||||
|  |  | ||||||
| bool MFGrabber::setDevice(QString device) | bool MFGrabber::setDevice(QString device) | ||||||
| { | { | ||||||
| 	if(_deviceName != device) | 	if(_currentDeviceName != device) | ||||||
| 	{ | 	{ | ||||||
| 		_deviceName = device; | 		_currentDeviceName = device; | ||||||
| 		return true; | 		return true; | ||||||
| 	} | 	} | ||||||
| 	return false; | 	return false; | ||||||
| @@ -767,9 +771,16 @@ bool MFGrabber::setWidthHeight(int width, int height) | |||||||
| { | { | ||||||
| 	if(Grabber::setWidthHeight(width, height)) | 	if(Grabber::setWidthHeight(width, height)) | ||||||
| 	{ | 	{ | ||||||
| 		Debug(_log,"Set width:height to: %i:%i", width, height); | 		Debug(_log,"Set device resolution to width: %i, height: %i", width, height); | ||||||
| 		return true; | 		return true; | ||||||
| 	} | 	} | ||||||
|  | 	else if(width == 0 && height == 0) | ||||||
|  | 	{ | ||||||
|  | 		_width = _height = 0; | ||||||
|  | 		Debug(_log,"Set device resolution to 'Automatic'"); | ||||||
|  | 		return true; | ||||||
|  | 	} | ||||||
|  |  | ||||||
| 	return false; | 	return false; | ||||||
| } | } | ||||||
|  |  | ||||||
| @@ -827,6 +838,8 @@ void MFGrabber::reloadGrabber() | |||||||
| 		uninit(); | 		uninit(); | ||||||
| 		// restore pixelformat to configs value | 		// restore pixelformat to configs value | ||||||
| 		_pixelFormat = _pixelFormatConfig; | 		_pixelFormat = _pixelFormatConfig; | ||||||
|  | 		// set _newDeviceName | ||||||
|  | 		_newDeviceName = _currentDeviceName; | ||||||
| 		// start grabber | 		// start grabber | ||||||
| 		start(); | 		start(); | ||||||
| 	} | 	} | ||||||
|   | |||||||
| @@ -43,6 +43,8 @@ public: | |||||||
| 		, _grabber(grabber) | 		, _grabber(grabber) | ||||||
| 		, _bEOS(FALSE) | 		, _bEOS(FALSE) | ||||||
| 		, _hrStatus(S_OK) | 		, _hrStatus(S_OK) | ||||||
|  | 		, _transform(nullptr) | ||||||
|  | 		, _pixelformat(PixelFormat::NO_CHANGE) | ||||||
| 	{ | 	{ | ||||||
| 		InitializeCriticalSection(&_critsec); | 		InitializeCriticalSection(&_critsec); | ||||||
| 	} | 	} | ||||||
| @@ -332,9 +334,13 @@ public: | |||||||
|  |  | ||||||
| private: | private: | ||||||
| 	virtual ~SourceReaderCB() | 	virtual ~SourceReaderCB() | ||||||
|  | 	{ | ||||||
|  | 		if (_transform) | ||||||
| 		{ | 		{ | ||||||
| 			_transform->ProcessMessage(MFT_MESSAGE_NOTIFY_END_OF_STREAM, 0); | 			_transform->ProcessMessage(MFT_MESSAGE_NOTIFY_END_OF_STREAM, 0); | ||||||
| 			_transform->ProcessMessage(MFT_MESSAGE_NOTIFY_END_STREAMING, 0); | 			_transform->ProcessMessage(MFT_MESSAGE_NOTIFY_END_STREAMING, 0); | ||||||
|  | 		} | ||||||
|  |  | ||||||
| 		SAFE_RELEASE(_transform); | 		SAFE_RELEASE(_transform); | ||||||
| 	} | 	} | ||||||
|  |  | ||||||
|   | |||||||
| @@ -24,10 +24,7 @@ MFThread::~MFThread() | |||||||
| 		tjDestroy(_decompress); | 		tjDestroy(_decompress); | ||||||
|  |  | ||||||
| 	if (_localData) | 	if (_localData) | ||||||
| 	{ | 		tjFree(_localData); | ||||||
| 		free(_localData); |  | ||||||
| 		_localData = nullptr; |  | ||||||
| 	} |  | ||||||
| } | } | ||||||
|  |  | ||||||
| void MFThread::setup( | void MFThread::setup( | ||||||
|   | |||||||
| @@ -28,7 +28,7 @@ void Grabber::setEnabled(bool enable) | |||||||
|  |  | ||||||
| void Grabber::setVideoMode(VideoMode mode) | void Grabber::setVideoMode(VideoMode mode) | ||||||
| { | { | ||||||
| 	Debug(_log,"Set videomode to %d", mode); | 	Debug(_log,"Set videomode to %s", QSTRING_CSTR(videoMode2String(mode))); | ||||||
| 	_videoMode = mode; | 	_videoMode = mode; | ||||||
| 	if ( _useImageResampler ) | 	if ( _useImageResampler ) | ||||||
| 	{ | 	{ | ||||||
| @@ -98,6 +98,7 @@ bool Grabber::setWidthHeight(int width, int height) | |||||||
| 			Error(_log, "Rejecting invalid width/height values as it collides with image cropping: width: %d, height: %d", width, height); | 			Error(_log, "Rejecting invalid width/height values as it collides with image cropping: width: %d, height: %d", width, height); | ||||||
| 			return false; | 			return false; | ||||||
| 		} | 		} | ||||||
|  |  | ||||||
| 		Debug(_log, "Set new width: %d, height: %d for capture", width, height); | 		Debug(_log, "Set new width: %d, height: %d for capture", width, height); | ||||||
| 		_width = width; | 		_width = width; | ||||||
| 		_height = height; | 		_height = height; | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user