Added configuration to XBMC video checker

Former-commit-id: 82a73ca5a31c7152572f06bff50befd26053d8df
This commit is contained in:
johan 2013-09-24 21:45:27 +02:00
parent f31ed069ef
commit 876100249e
4 changed files with 355 additions and 319 deletions

View File

@ -1,6 +1,4 @@
// Automatically generated configuration file for 'Hyperion' // Hyperion configuration
// Generation script: ./WriteConfig
{ {
"device" : "device" :
{ {
@ -296,10 +294,28 @@
} }
], ],
// The XBMC video checker will connect to XBMC to check its player state and adjust the grabbing on it
"xbmcVideoChecker" : { "xbmcVideoChecker" : {
// Enable the use of the XBMC checker
"enable" : true, "enable" : true,
// Address of the hoxt running XBMC
"xbmcAddress" : "127.0.0.1", "xbmcAddress" : "127.0.0.1",
"xbmcTcpPort" : 9090
// Port used by XBMC for the TCP json service (Default disabled by XBMC for non-local clients)
"xbmcTcpPort" : 9090,
// Grab screen when XBMC is playing video
"grabVideo" : true,
// Grab screen when XBMC is playing pictures
"grabPictures" : true,
// Grab screen when XBMC is playing audio
"grabAudio" : true,
// Grab screen when XBMC is not playing anything (in menu)
"grabMenu" : true
}, },
"bootsequence" : "bootsequence" :
@ -314,5 +330,4 @@
"height" : 64, "height" : 64,
"frequency_Hz" : 10 "frequency_Hz" : 10
} }
} }

View File

@ -181,6 +181,22 @@
"xbmcTcpPort" : { "xbmcTcpPort" : {
"type" : "integer", "type" : "integer",
"required" : true "required" : true
},
"grabVideo" : {
"type" : "boolean",
"required" : true
},
"grabPictures" : {
"type" : "boolean",
"required" : true
},
"grabAudio" : {
"type" : "boolean",
"required" : true
},
"grabMenu" : {
"type" : "boolean",
"required" : true
} }
}, },
"additionalProperties" : false "additionalProperties" : false

View File

@ -54,8 +54,6 @@ void XBMCVideoChecker::receiveReply()
// expect that the reply is received as a single message. Probably oke considering the size of the expected reply // expect that the reply is received as a single message. Probably oke considering the size of the expected reply
QString reply(_socket.readAll()); QString reply(_socket.readAll());
std::cout << reply.toStdString() << std::endl;
// check if the resply is a reply to one of my requests // check if the resply is a reply to one of my requests
if (!reply.contains("\"id\":666")) if (!reply.contains("\"id\":666"))
{ {
@ -71,13 +69,13 @@ void XBMCVideoChecker::receiveReply()
} }
else if (reply.contains("picture")) else if (reply.contains("picture"))
{ {
// photo viewer is playing // picture viewer is playing
newMode = _grabVideo ? GRABBINGMODE_PHOTO : GRABBINGMODE_OFF; newMode = _grabPhoto ? GRABBINGMODE_PHOTO : GRABBINGMODE_OFF;
} }
else if (reply.contains("audio")) else if (reply.contains("audio"))
{ {
// photo viewer is playing // audio is playing
newMode = _grabVideo ? GRABBINGMODE_AUDIO : GRABBINGMODE_OFF; newMode = _grabAudio ? GRABBINGMODE_AUDIO : GRABBINGMODE_OFF;
} }
else else
{ {

View File

@ -83,7 +83,14 @@ int main(int argc, char** argv)
} }
const Json::Value & videoCheckerConfig = config["xbmcVideoChecker"]; const Json::Value & videoCheckerConfig = config["xbmcVideoChecker"];
XBMCVideoChecker xbmcVideoChecker(videoCheckerConfig["xbmcAddress"].asString(), videoCheckerConfig["xbmcTcpPort"].asUInt(), 1000, true, true, true, true); XBMCVideoChecker xbmcVideoChecker(
videoCheckerConfig["xbmcAddress"].asString(),
videoCheckerConfig["xbmcTcpPort"].asUInt(),
1000,
videoCheckerConfig["grabVideo"].asBool(),
videoCheckerConfig["grabPictures"].asBool(),
videoCheckerConfig["grabAudio"].asBool(),
videoCheckerConfig["grabMenu"].asBool());
if (videoCheckerConfig["enable"].asBool()) if (videoCheckerConfig["enable"].asBool())
{ {
xbmcVideoChecker.start(); xbmcVideoChecker.start();