Merge remote-tracking branch 'remotes/origin/master'

Former-commit-id: 0f424826def93b35209c055244003dc21d07e9b7
This commit is contained in:
T. van der Zwan 2013-09-25 09:25:14 +02:00
commit 6792321192
4 changed files with 363 additions and 318 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

@ -7,7 +7,7 @@ XBMCVideoChecker::XBMCVideoChecker(const std::string & address, uint16_t port, u
QObject(), QObject(),
_address(QString::fromStdString(address)), _address(QString::fromStdString(address)),
_port(port), _port(port),
_request("{\"jsonrpc\":\"2.0\",\"method\":\"Player.GetActivePlayers\",\"id\":1}"), _request("{\"jsonrpc\":\"2.0\",\"method\":\"Player.GetActivePlayers\",\"id\":666}"),
_timer(), _timer(),
_socket(), _socket(),
_grabVideo(grabVideo), _grabVideo(grabVideo),
@ -54,6 +54,13 @@ 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());
// check if the resply is a reply to one of my requests
if (!reply.contains("\"id\":666"))
{
// probably not. Leave this mreply as is and don't act on it
return;
}
GrabbingMode newMode = GRABBINGMODE_INVALID; GrabbingMode newMode = GRABBINGMODE_INVALID;
if (reply.contains("video")) if (reply.contains("video"))
{ {
@ -62,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();