mirror of
https://github.com/hyperion-project/hyperion.ng.git
synced 2023-10-10 13:36:59 +02:00
Merge pull request #94 from bimsarck/master
add 3D autodetection for xbmc with versions check Former-commit-id: 683e152b5d419442a094cb2eee51b341e08b8f2d
This commit is contained in:
commit
019374f57d
@ -38,7 +38,7 @@ public:
|
||||
/// @param grabPhoto Whether or not to grab when the XBMC photo player is playing
|
||||
/// @param grabAudio Whether or not to grab when the XBMC audio player is playing
|
||||
/// @param grabMenu Whether or not to grab when nothing is playing (in XBMC menu)
|
||||
/// @param grabScreensaver Whether or not to grab when the XBMC screensaver is activated
|
||||
/// @param grabScreensaver Whether or not to grab when the XBMC screensaver is activated
|
||||
/// @param enable3DDetection Wheter or not to enable the detection of 3D movies playing
|
||||
///
|
||||
XBMCVideoChecker(const std::string & address, uint16_t port, bool grabVideo, bool grabPhoto, bool grabAudio, bool grabMenu, bool grabScreensaver, bool enable3DDetection);
|
||||
@ -96,6 +96,12 @@ private:
|
||||
/// The JSON-RPC message to check the screensaver
|
||||
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
|
||||
QTcpSocket _socket;
|
||||
|
||||
@ -111,7 +117,7 @@ private:
|
||||
/// Flag indicating whether or not to grab when XBMC is playing nothing (in menu)
|
||||
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;
|
||||
|
||||
/// Flag indicating wheter or not to enable the detection of 3D movies playing
|
||||
|
@ -17,6 +17,12 @@
|
||||
// {"id":668,"jsonrpc":"2.0","method":"XBMC.GetInfoBooleans","params":{"booleans":["System.ScreenSaverActive"]}}
|
||||
// {"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) :
|
||||
QObject(),
|
||||
_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"})"),
|
||||
_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"]}})"),
|
||||
_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(),
|
||||
_grabVideo(grabVideo),
|
||||
_grabPhoto(grabPhoto),
|
||||
@ -116,24 +124,32 @@ void XBMCVideoChecker::receiveReply()
|
||||
}
|
||||
else if (reply.contains("\"id\":667"))
|
||||
{
|
||||
// result of Player.GetItem
|
||||
// TODO: what if the filename contains a '"'. In Json this should have been escaped
|
||||
QRegExp regex("\"file\":\"((?!\").)*\"");
|
||||
int pos = regex.indexIn(reply);
|
||||
if (pos > 0)
|
||||
if (xbmcVersion >= 13)
|
||||
{
|
||||
QStringRef filename = QStringRef(&reply, pos+8, regex.matchedLength()-9);
|
||||
if (filename.contains("3DSBS", Qt::CaseInsensitive) || filename.contains("HSBS", Qt::CaseInsensitive))
|
||||
// check of active stereoscopicmode
|
||||
_socket.write(_getStereoscopicMode.toUtf8());
|
||||
}
|
||||
else
|
||||
{
|
||||
// result of Player.GetItem
|
||||
// TODO: what if the filename contains a '"'. In Json this should have been escaped
|
||||
QRegExp regex("\"file\":\"((?!\").)*\"");
|
||||
int pos = regex.indexIn(reply);
|
||||
if (pos > 0)
|
||||
{
|
||||
setVideoMode(VIDEO_3DSBS);
|
||||
}
|
||||
else if (filename.contains("3DTAB", Qt::CaseInsensitive) || filename.contains("HTAB", Qt::CaseInsensitive))
|
||||
{
|
||||
setVideoMode(VIDEO_3DTAB);
|
||||
}
|
||||
else
|
||||
{
|
||||
setVideoMode(VIDEO_2D);
|
||||
QStringRef filename = QStringRef(&reply, pos+8, regex.matchedLength()-9);
|
||||
if (filename.contains("3DSBS", Qt::CaseInsensitive) || filename.contains("HSBS", Qt::CaseInsensitive))
|
||||
{
|
||||
setVideoMode(VIDEO_3DSBS);
|
||||
}
|
||||
else if (filename.contains("3DTAB", Qt::CaseInsensitive) || filename.contains("HTAB", Qt::CaseInsensitive))
|
||||
{
|
||||
setVideoMode(VIDEO_3DTAB);
|
||||
}
|
||||
else
|
||||
{
|
||||
setVideoMode(VIDEO_2D);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -142,6 +158,41 @@ void XBMCVideoChecker::receiveReply()
|
||||
// result of System.ScreenSaverActive
|
||||
bool active = reply.contains("\"System.ScreenSaverActive\":true");
|
||||
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();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user