Merge pull request #94 from bimsarck/master

add 3D autodetection for xbmc with versions check

Former-commit-id: 683e152b5d419442a094cb2eee51b341e08b8f2d
This commit is contained in:
poljvd 2014-04-30 22:39:40 +02:00
commit 019374f57d
2 changed files with 75 additions and 18 deletions

View File

@ -96,6 +96,12 @@ private:
/// The JSON-RPC message to check the screensaver /// The JSON-RPC message to check the screensaver
const QString _checkScreensaverRequest; const QString _checkScreensaverRequest;
/// The JSON-RPC message to check the active stereoscopicmode
const QString _getStereoscopicMode;
/// The JSON-RPC message to check the xbmc version
const QString _getXbmcVersion;
/// The QT TCP Socket with connection to XBMC /// The QT TCP Socket with connection to XBMC
QTcpSocket _socket; QTcpSocket _socket;
@ -111,7 +117,7 @@ private:
/// Flag indicating whether or not to grab when XBMC is playing nothing (in menu) /// Flag indicating whether or not to grab when XBMC is playing nothing (in menu)
const bool _grabMenu; const bool _grabMenu;
/// Flag inidcating whether or not to grab when the XBMC screensaver is activated /// Flag indicating whether or not to grab when the XBMC screensaver is activated
const bool _grabScreensaver; const bool _grabScreensaver;
/// 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

View File

@ -17,6 +17,12 @@
// {"id":668,"jsonrpc":"2.0","method":"XBMC.GetInfoBooleans","params":{"booleans":["System.ScreenSaverActive"]}} // {"id":668,"jsonrpc":"2.0","method":"XBMC.GetInfoBooleans","params":{"booleans":["System.ScreenSaverActive"]}}
// {"id":668,"jsonrpc":"2.0","result":{"System.ScreenSaverActive":false}} // {"id":668,"jsonrpc":"2.0","result":{"System.ScreenSaverActive":false}}
// Request stereoscopicmode example:
// {"jsonrpc":"2.0","method":"GUI.GetProperties","params":{"properties":["stereoscopicmode"]},"id":1}
// {"id":1,"jsonrpc":"2.0","result":{"stereoscopicmode":{"label":"Nebeneinander","mode":"split_vertical"}}}
int xbmcVersion = 0;
XBMCVideoChecker::XBMCVideoChecker(const std::string & address, uint16_t port, bool grabVideo, bool grabPhoto, bool grabAudio, bool grabMenu, bool grabScreensaver, bool enable3DDetection) : XBMCVideoChecker::XBMCVideoChecker(const std::string & address, uint16_t port, bool grabVideo, bool grabPhoto, bool grabAudio, bool grabMenu, bool grabScreensaver, bool enable3DDetection) :
QObject(), QObject(),
_address(QString::fromStdString(address)), _address(QString::fromStdString(address)),
@ -24,6 +30,8 @@ XBMCVideoChecker::XBMCVideoChecker(const std::string & address, uint16_t port, b
_activePlayerRequest(R"({"id":666,"jsonrpc":"2.0","method":"Player.GetActivePlayers"})"), _activePlayerRequest(R"({"id":666,"jsonrpc":"2.0","method":"Player.GetActivePlayers"})"),
_currentPlayingItemRequest(R"({"id":667,"jsonrpc":"2.0","method":"Player.GetItem","params":{"playerid":%1,"properties":["file"]}})"), _currentPlayingItemRequest(R"({"id":667,"jsonrpc":"2.0","method":"Player.GetItem","params":{"playerid":%1,"properties":["file"]}})"),
_checkScreensaverRequest(R"({"id":668,"jsonrpc":"2.0","method":"XBMC.GetInfoBooleans","params":{"booleans":["System.ScreenSaverActive"]}})"), _checkScreensaverRequest(R"({"id":668,"jsonrpc":"2.0","method":"XBMC.GetInfoBooleans","params":{"booleans":["System.ScreenSaverActive"]}})"),
_getStereoscopicMode(R"({"jsonrpc":"2.0","method":"GUI.GetProperties","params":{"properties":["stereoscopicmode"]},"id":1})"),
_getXbmcVersion(R"({"jsonrpc":"2.0","method":"Application.GetProperties","params":{"properties":["version"]},"id":1})"),
_socket(), _socket(),
_grabVideo(grabVideo), _grabVideo(grabVideo),
_grabPhoto(grabPhoto), _grabPhoto(grabPhoto),
@ -115,6 +123,13 @@ void XBMCVideoChecker::receiveReply()
} }
} }
else if (reply.contains("\"id\":667")) else if (reply.contains("\"id\":667"))
{
if (xbmcVersion >= 13)
{
// check of active stereoscopicmode
_socket.write(_getStereoscopicMode.toUtf8());
}
else
{ {
// result of Player.GetItem // result of Player.GetItem
// TODO: what if the filename contains a '"'. In Json this should have been escaped // TODO: what if the filename contains a '"'. In Json this should have been escaped
@ -137,11 +152,47 @@ void XBMCVideoChecker::receiveReply()
} }
} }
} }
}
else if (reply.contains("\"id\":668")) else if (reply.contains("\"id\":668"))
{ {
// result of System.ScreenSaverActive // result of System.ScreenSaverActive
bool active = reply.contains("\"System.ScreenSaverActive\":true"); bool active = reply.contains("\"System.ScreenSaverActive\":true");
setScreensaverMode(!_grabScreensaver && active); setScreensaverMode(!_grabScreensaver && active);
// check here xbmc version
if (_socket.state() == QTcpSocket::ConnectedState)
{
if (xbmcVersion == 0)
{
_socket.write(_getXbmcVersion.toUtf8());
}
}
}
else if (reply.contains("\"stereoscopicmode\""))
{
QRegExp regex("\"mode\":\"(split_vertical|split_horizontal)\"");
int pos = regex.indexIn(reply);
if (pos > 0)
{
QString sMode = regex.cap(1);
if (sMode == "split_vertical")
{
setVideoMode(VIDEO_3DSBS);
}
else if (sMode == "split_horizontal")
{
setVideoMode(VIDEO_3DTAB);
}
}
}
else if (reply.contains("\"version\":"))
{
QRegExp regex("\"major\":(\\d+)");
int pos = regex.indexIn(reply);
if (pos > 0)
{
xbmcVersion = regex.cap(1).toInt();
}
} }
} }