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:
Paulchen-Panther 2016-07-21 20:15:54 +02:00 committed by redPanther
parent a930d4e403
commit 5bd8c33529
9 changed files with 22 additions and 30 deletions

View File

@ -87,8 +87,6 @@ private:
/// Set the grabbing mode
void setGrabbingMode(GrabbingMode grabbingMode);
void setScreensaverMode(bool isOnScreensaver);
/// Set the video mode
void setVideoMode(VideoMode videoMode);
@ -138,9 +136,6 @@ private:
/// Flag indicating wheter or not to enable the detection of 3D movies playing
bool _enable3DDetection;
/// Flag indicating if KODI is on screensaver
bool _previousScreensaverMode;
/// Previous emitted grab mode
GrabbingMode _previousGrabbingMode;

View File

@ -13,5 +13,6 @@ enum GrabbingMode
GRABBINGMODE_PHOTO,
GRABBINGMODE_AUDIO,
GRABBINGMODE_MENU,
GRABBINGMODE_SCREENSAVER,
GRABBINGMODE_INVALID
};

View File

@ -87,6 +87,7 @@ void AmlogicWrapper::setGrabbingMode(const GrabbingMode mode)
case GRABBINGMODE_AUDIO:
case GRABBINGMODE_PHOTO:
case GRABBINGMODE_MENU:
case GRABBINGMODE_SCREENSAVER:
case GRABBINGMODE_INVALID:
// _frameGrabber->setFlags(0);
start();

View File

@ -82,6 +82,7 @@ void DispmanxWrapper::setGrabbingMode(const GrabbingMode mode)
case GRABBINGMODE_AUDIO:
case GRABBINGMODE_PHOTO:
case GRABBINGMODE_MENU:
case GRABBINGMODE_SCREENSAVER:
case GRABBINGMODE_INVALID:
_frameGrabber->setFlags(0);
start();

View File

@ -68,6 +68,7 @@ void FramebufferWrapper::setGrabbingMode(const GrabbingMode mode)
case GRABBINGMODE_AUDIO:
case GRABBINGMODE_PHOTO:
case GRABBINGMODE_MENU:
case GRABBINGMODE_SCREENSAVER:
case GRABBINGMODE_INVALID:
start();
break;

View File

@ -68,6 +68,7 @@ void OsxWrapper::setGrabbingMode(const GrabbingMode mode)
case GRABBINGMODE_AUDIO:
case GRABBINGMODE_PHOTO:
case GRABBINGMODE_MENU:
case GRABBINGMODE_SCREENSAVER:
case GRABBINGMODE_INVALID:
start();
break;

View File

@ -56,7 +56,6 @@ KODIVideoChecker::KODIVideoChecker(const std::string & address, uint16_t port, b
, _grabPause(grabPause)
, _grabScreensaver(grabScreensaver)
, _enable3DDetection(enable3DDetection)
, _previousScreensaverMode(false)
, _previousGrabbingMode(GRABBINGMODE_INVALID)
, _previousVideoMode(VIDEO_2D)
, _kodiVersion(0)
@ -87,7 +86,6 @@ void KODIVideoChecker::setConfig(const std::string & address, uint16_t port, boo
_grabPause = grabPause;
_grabScreensaver = grabScreensaver;
_enable3DDetection = enable3DDetection;
_previousScreensaverMode = false;
_previousGrabbingMode = GRABBINGMODE_INVALID;
_previousVideoMode = VIDEO_2D;
_kodiVersion = 0;
@ -126,7 +124,7 @@ void KODIVideoChecker::receiveReply()
if (doc.isObject())
{
Debug(_log, "message: %s", doc.toJson(QJsonDocument::Compact).constData());
// Reply
if (doc.object().contains("id"))
{
@ -145,7 +143,7 @@ void KODIVideoChecker::receiveReply()
emit videoMode(VIDEO_2D);
QString type = resultArray[0].toObject()["type"].toString();
int playerid = resultArray[0].toObject()["playerid"].toInt();
int playerid = resultArray[0].toObject()["playerid"].toInt();
if (type == "video")
{
@ -200,7 +198,10 @@ void KODIVideoChecker::receiveReply()
if (doc.object()["result"].toObject().contains("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
if (_socket.state() == QTcpSocket::ConnectedState)
@ -258,9 +259,9 @@ void KODIVideoChecker::receiveReply()
// player at pause
setGrabbingMode(_grabPause ? GRABBINGMODE_PAUSE : GRABBINGMODE_OFF);
else if (method == "GUI.OnScreensaverActivated")
setScreensaverMode(!_grabScreensaver);
setGrabbingMode(_grabScreensaver ? GRABBINGMODE_SCREENSAVER : GRABBINGMODE_OFF);
else if (method == "GUI.OnScreensaverDeactivated")
setScreensaverMode(false);
_socket.write(_activePlayerRequest.toUtf8());
else if (method == "Playlist.OnAdd" &&
(doc.object()["params"]
.toObject()["data"]
@ -290,6 +291,9 @@ void KODIVideoChecker::connected()
void KODIVideoChecker::disconnected()
{
Info(_log, "Disconnected");
_previousGrabbingMode = GRABBINGMODE_INVALID;
_previousVideoMode = VIDEO_2D;
_kodiVersion = 0;
reconnect();
}
@ -357,31 +361,18 @@ void KODIVideoChecker::setGrabbingMode(GrabbingMode newGrabbingMode)
case GRABBINGMODE_OFF:
Info(_log, "switching to OFF mode");
break;
case GRABBINGMODE_SCREENSAVER:
Info(_log, "switching to SCREENSAVER mode");
break;
default:
Warning(_log, "switching to INVALID mode");
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;
}
void KODIVideoChecker::setScreensaverMode(bool isOnScreensaver)
{
if (isOnScreensaver == _previousScreensaverMode)
{
// no change
return;
}
emit grabbingMode(isOnScreensaver ? GRABBINGMODE_OFF : _previousGrabbingMode);
_previousScreensaverMode = isOnScreensaver;
}
void KODIVideoChecker::setVideoMode(VideoMode newVideoMode)
{
if (newVideoMode == _previousVideoMode)

View File

@ -229,7 +229,7 @@ bool ProtoConnection::parseReply(const proto::HyperionReply &reply)
}
case proto::HyperionReply::GRABBING:
{
int grabbing = reply.has_grabbing() ? reply.grabbing() : 6;
int grabbing = reply.has_grabbing() ? reply.grabbing() : 7;
GrabbingMode gMode = (GrabbingMode)grabbing;
emit setGrabbingMode(gMode);
break;

View File

@ -49,6 +49,7 @@ void X11Wrapper::setGrabbingMode(const GrabbingMode mode)
case GRABBINGMODE_AUDIO:
case GRABBINGMODE_PHOTO:
case GRABBINGMODE_MENU:
case GRABBINGMODE_SCREENSAVER:
case GRABBINGMODE_INVALID:
start();
break;