mirror of
https://github.com/hyperion-project/hyperion.ng.git
synced 2023-10-10 13:36:59 +02:00
Add Screensaver mode to Kodi video checker (#132)
* Update KODIVideoChecker.h * Update GrabbingMode.h * Update AmlogicWrapper.cpp * Update DispmanxWrapper.cpp * Update FramebufferWrapper.cpp * Update OsxWrapper.cpp * Update KODIVideoChecker.cpp * Update ProtoConnection.cpp * Update X11Wrapper.cpp
This commit is contained in:
parent
a930d4e403
commit
5bd8c33529
@ -88,8 +88,6 @@ private:
|
|||||||
/// Set the grabbing mode
|
/// Set the grabbing mode
|
||||||
void setGrabbingMode(GrabbingMode grabbingMode);
|
void setGrabbingMode(GrabbingMode grabbingMode);
|
||||||
|
|
||||||
void setScreensaverMode(bool isOnScreensaver);
|
|
||||||
|
|
||||||
/// Set the video mode
|
/// Set the video mode
|
||||||
void setVideoMode(VideoMode videoMode);
|
void setVideoMode(VideoMode videoMode);
|
||||||
|
|
||||||
@ -139,9 +137,6 @@ private:
|
|||||||
/// Flag indicating wheter or not to enable the detection of 3D movies playing
|
/// Flag indicating wheter or not to enable the detection of 3D movies playing
|
||||||
bool _enable3DDetection;
|
bool _enable3DDetection;
|
||||||
|
|
||||||
/// Flag indicating if KODI is on screensaver
|
|
||||||
bool _previousScreensaverMode;
|
|
||||||
|
|
||||||
/// Previous emitted grab mode
|
/// Previous emitted grab mode
|
||||||
GrabbingMode _previousGrabbingMode;
|
GrabbingMode _previousGrabbingMode;
|
||||||
|
|
||||||
|
@ -13,5 +13,6 @@ enum GrabbingMode
|
|||||||
GRABBINGMODE_PHOTO,
|
GRABBINGMODE_PHOTO,
|
||||||
GRABBINGMODE_AUDIO,
|
GRABBINGMODE_AUDIO,
|
||||||
GRABBINGMODE_MENU,
|
GRABBINGMODE_MENU,
|
||||||
|
GRABBINGMODE_SCREENSAVER,
|
||||||
GRABBINGMODE_INVALID
|
GRABBINGMODE_INVALID
|
||||||
};
|
};
|
||||||
|
@ -87,6 +87,7 @@ void AmlogicWrapper::setGrabbingMode(const GrabbingMode mode)
|
|||||||
case GRABBINGMODE_AUDIO:
|
case GRABBINGMODE_AUDIO:
|
||||||
case GRABBINGMODE_PHOTO:
|
case GRABBINGMODE_PHOTO:
|
||||||
case GRABBINGMODE_MENU:
|
case GRABBINGMODE_MENU:
|
||||||
|
case GRABBINGMODE_SCREENSAVER:
|
||||||
case GRABBINGMODE_INVALID:
|
case GRABBINGMODE_INVALID:
|
||||||
// _frameGrabber->setFlags(0);
|
// _frameGrabber->setFlags(0);
|
||||||
start();
|
start();
|
||||||
|
@ -82,6 +82,7 @@ void DispmanxWrapper::setGrabbingMode(const GrabbingMode mode)
|
|||||||
case GRABBINGMODE_AUDIO:
|
case GRABBINGMODE_AUDIO:
|
||||||
case GRABBINGMODE_PHOTO:
|
case GRABBINGMODE_PHOTO:
|
||||||
case GRABBINGMODE_MENU:
|
case GRABBINGMODE_MENU:
|
||||||
|
case GRABBINGMODE_SCREENSAVER:
|
||||||
case GRABBINGMODE_INVALID:
|
case GRABBINGMODE_INVALID:
|
||||||
_frameGrabber->setFlags(0);
|
_frameGrabber->setFlags(0);
|
||||||
start();
|
start();
|
||||||
|
@ -68,6 +68,7 @@ void FramebufferWrapper::setGrabbingMode(const GrabbingMode mode)
|
|||||||
case GRABBINGMODE_AUDIO:
|
case GRABBINGMODE_AUDIO:
|
||||||
case GRABBINGMODE_PHOTO:
|
case GRABBINGMODE_PHOTO:
|
||||||
case GRABBINGMODE_MENU:
|
case GRABBINGMODE_MENU:
|
||||||
|
case GRABBINGMODE_SCREENSAVER:
|
||||||
case GRABBINGMODE_INVALID:
|
case GRABBINGMODE_INVALID:
|
||||||
start();
|
start();
|
||||||
break;
|
break;
|
||||||
|
@ -68,6 +68,7 @@ void OsxWrapper::setGrabbingMode(const GrabbingMode mode)
|
|||||||
case GRABBINGMODE_AUDIO:
|
case GRABBINGMODE_AUDIO:
|
||||||
case GRABBINGMODE_PHOTO:
|
case GRABBINGMODE_PHOTO:
|
||||||
case GRABBINGMODE_MENU:
|
case GRABBINGMODE_MENU:
|
||||||
|
case GRABBINGMODE_SCREENSAVER:
|
||||||
case GRABBINGMODE_INVALID:
|
case GRABBINGMODE_INVALID:
|
||||||
start();
|
start();
|
||||||
break;
|
break;
|
||||||
|
@ -56,7 +56,6 @@ KODIVideoChecker::KODIVideoChecker(const std::string & address, uint16_t port, b
|
|||||||
, _grabPause(grabPause)
|
, _grabPause(grabPause)
|
||||||
, _grabScreensaver(grabScreensaver)
|
, _grabScreensaver(grabScreensaver)
|
||||||
, _enable3DDetection(enable3DDetection)
|
, _enable3DDetection(enable3DDetection)
|
||||||
, _previousScreensaverMode(false)
|
|
||||||
, _previousGrabbingMode(GRABBINGMODE_INVALID)
|
, _previousGrabbingMode(GRABBINGMODE_INVALID)
|
||||||
, _previousVideoMode(VIDEO_2D)
|
, _previousVideoMode(VIDEO_2D)
|
||||||
, _kodiVersion(0)
|
, _kodiVersion(0)
|
||||||
@ -87,7 +86,6 @@ void KODIVideoChecker::setConfig(const std::string & address, uint16_t port, boo
|
|||||||
_grabPause = grabPause;
|
_grabPause = grabPause;
|
||||||
_grabScreensaver = grabScreensaver;
|
_grabScreensaver = grabScreensaver;
|
||||||
_enable3DDetection = enable3DDetection;
|
_enable3DDetection = enable3DDetection;
|
||||||
_previousScreensaverMode = false;
|
|
||||||
_previousGrabbingMode = GRABBINGMODE_INVALID;
|
_previousGrabbingMode = GRABBINGMODE_INVALID;
|
||||||
_previousVideoMode = VIDEO_2D;
|
_previousVideoMode = VIDEO_2D;
|
||||||
_kodiVersion = 0;
|
_kodiVersion = 0;
|
||||||
@ -200,7 +198,10 @@ void KODIVideoChecker::receiveReply()
|
|||||||
if (doc.object()["result"].toObject().contains("System.ScreenSaverActive"))
|
if (doc.object()["result"].toObject().contains("System.ScreenSaverActive"))
|
||||||
{
|
{
|
||||||
// result of System.ScreenSaverActive
|
// result of System.ScreenSaverActive
|
||||||
setScreensaverMode(!_grabScreensaver && doc.object()["result"].toObject()["System.ScreenSaverActive"].toBool());
|
if (doc.object()["result"].toObject()["System.ScreenSaverActive"].toBool())
|
||||||
|
setGrabbingMode(_grabScreensaver ? GRABBINGMODE_SCREENSAVER : GRABBINGMODE_OFF);
|
||||||
|
else
|
||||||
|
_socket.write(_activePlayerRequest.toUtf8());
|
||||||
|
|
||||||
// check here kodi version
|
// check here kodi version
|
||||||
if (_socket.state() == QTcpSocket::ConnectedState)
|
if (_socket.state() == QTcpSocket::ConnectedState)
|
||||||
@ -258,9 +259,9 @@ void KODIVideoChecker::receiveReply()
|
|||||||
// player at pause
|
// player at pause
|
||||||
setGrabbingMode(_grabPause ? GRABBINGMODE_PAUSE : GRABBINGMODE_OFF);
|
setGrabbingMode(_grabPause ? GRABBINGMODE_PAUSE : GRABBINGMODE_OFF);
|
||||||
else if (method == "GUI.OnScreensaverActivated")
|
else if (method == "GUI.OnScreensaverActivated")
|
||||||
setScreensaverMode(!_grabScreensaver);
|
setGrabbingMode(_grabScreensaver ? GRABBINGMODE_SCREENSAVER : GRABBINGMODE_OFF);
|
||||||
else if (method == "GUI.OnScreensaverDeactivated")
|
else if (method == "GUI.OnScreensaverDeactivated")
|
||||||
setScreensaverMode(false);
|
_socket.write(_activePlayerRequest.toUtf8());
|
||||||
else if (method == "Playlist.OnAdd" &&
|
else if (method == "Playlist.OnAdd" &&
|
||||||
(doc.object()["params"]
|
(doc.object()["params"]
|
||||||
.toObject()["data"]
|
.toObject()["data"]
|
||||||
@ -290,6 +291,9 @@ void KODIVideoChecker::connected()
|
|||||||
void KODIVideoChecker::disconnected()
|
void KODIVideoChecker::disconnected()
|
||||||
{
|
{
|
||||||
Info(_log, "Disconnected");
|
Info(_log, "Disconnected");
|
||||||
|
_previousGrabbingMode = GRABBINGMODE_INVALID;
|
||||||
|
_previousVideoMode = VIDEO_2D;
|
||||||
|
_kodiVersion = 0;
|
||||||
reconnect();
|
reconnect();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -357,31 +361,18 @@ void KODIVideoChecker::setGrabbingMode(GrabbingMode newGrabbingMode)
|
|||||||
case GRABBINGMODE_OFF:
|
case GRABBINGMODE_OFF:
|
||||||
Info(_log, "switching to OFF mode");
|
Info(_log, "switching to OFF mode");
|
||||||
break;
|
break;
|
||||||
|
case GRABBINGMODE_SCREENSAVER:
|
||||||
|
Info(_log, "switching to SCREENSAVER mode");
|
||||||
|
break;
|
||||||
default:
|
default:
|
||||||
Warning(_log, "switching to INVALID mode");
|
Warning(_log, "switching to INVALID mode");
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
// only emit the new state when we want to grab in screensaver mode or when the screensaver is deactivated
|
|
||||||
if (!_previousScreensaverMode)
|
|
||||||
{
|
|
||||||
emit grabbingMode(newGrabbingMode);
|
emit grabbingMode(newGrabbingMode);
|
||||||
}
|
|
||||||
_previousGrabbingMode = newGrabbingMode;
|
_previousGrabbingMode = newGrabbingMode;
|
||||||
}
|
}
|
||||||
|
|
||||||
void KODIVideoChecker::setScreensaverMode(bool isOnScreensaver)
|
|
||||||
{
|
|
||||||
if (isOnScreensaver == _previousScreensaverMode)
|
|
||||||
{
|
|
||||||
// no change
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
emit grabbingMode(isOnScreensaver ? GRABBINGMODE_OFF : _previousGrabbingMode);
|
|
||||||
_previousScreensaverMode = isOnScreensaver;
|
|
||||||
}
|
|
||||||
|
|
||||||
void KODIVideoChecker::setVideoMode(VideoMode newVideoMode)
|
void KODIVideoChecker::setVideoMode(VideoMode newVideoMode)
|
||||||
{
|
{
|
||||||
if (newVideoMode == _previousVideoMode)
|
if (newVideoMode == _previousVideoMode)
|
||||||
|
@ -229,7 +229,7 @@ bool ProtoConnection::parseReply(const proto::HyperionReply &reply)
|
|||||||
}
|
}
|
||||||
case proto::HyperionReply::GRABBING:
|
case proto::HyperionReply::GRABBING:
|
||||||
{
|
{
|
||||||
int grabbing = reply.has_grabbing() ? reply.grabbing() : 6;
|
int grabbing = reply.has_grabbing() ? reply.grabbing() : 7;
|
||||||
GrabbingMode gMode = (GrabbingMode)grabbing;
|
GrabbingMode gMode = (GrabbingMode)grabbing;
|
||||||
emit setGrabbingMode(gMode);
|
emit setGrabbingMode(gMode);
|
||||||
break;
|
break;
|
||||||
|
@ -49,6 +49,7 @@ void X11Wrapper::setGrabbingMode(const GrabbingMode mode)
|
|||||||
case GRABBINGMODE_AUDIO:
|
case GRABBINGMODE_AUDIO:
|
||||||
case GRABBINGMODE_PHOTO:
|
case GRABBINGMODE_PHOTO:
|
||||||
case GRABBINGMODE_MENU:
|
case GRABBINGMODE_MENU:
|
||||||
|
case GRABBINGMODE_SCREENSAVER:
|
||||||
case GRABBINGMODE_INVALID:
|
case GRABBINGMODE_INVALID:
|
||||||
start();
|
start();
|
||||||
break;
|
break;
|
||||||
|
Loading…
Reference in New Issue
Block a user