Skip to content
This repository was archived by the owner on May 6, 2021. It is now read-only.

Commit b83c685

Browse files
committed
Merge branch 'master' of https://github.com/tvdzwan/hyperion
2 parents 6fc5dc0 + 683e152 commit b83c685

File tree

2 files changed

+73
-16
lines changed

2 files changed

+73
-16
lines changed

include/xbmcvideochecker/XBMCVideoChecker.h

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ Q_OBJECT
3838
/// @param grabPhoto Whether or not to grab when the XBMC photo player is playing
3939
/// @param grabAudio Whether or not to grab when the XBMC audio player is playing
4040
/// @param grabMenu Whether or not to grab when nothing is playing (in XBMC menu)
41-
/// @param grabScreensaver Whether or not to grab when the XBMC screensaver is activated
41+
/// @param grabScreensaver Whether or not to grab when the XBMC screensaver is activated
4242
/// @param enable3DDetection Wheter or not to enable the detection of 3D movies playing
4343
///
4444
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 slots:
9696
/// The JSON-RPC message to check the screensaver
9797
const QString _checkScreensaverRequest;
9898

99+
/// The JSON-RPC message to check the active stereoscopicmode
100+
const QString _getStereoscopicMode;
101+
102+
/// The JSON-RPC message to check the xbmc version
103+
const QString _getXbmcVersion;
104+
99105
/// The QT TCP Socket with connection to XBMC
100106
QTcpSocket _socket;
101107

@@ -111,7 +117,7 @@ private slots:
111117
/// Flag indicating whether or not to grab when XBMC is playing nothing (in menu)
112118
const bool _grabMenu;
113119

114-
/// Flag inidcating whether or not to grab when the XBMC screensaver is activated
120+
/// Flag indicating whether or not to grab when the XBMC screensaver is activated
115121
const bool _grabScreensaver;
116122

117123
/// Flag indicating wheter or not to enable the detection of 3D movies playing

libsrc/xbmcvideochecker/XBMCVideoChecker.cpp

Lines changed: 65 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -17,13 +17,21 @@
1717
// {"id":668,"jsonrpc":"2.0","method":"XBMC.GetInfoBooleans","params":{"booleans":["System.ScreenSaverActive"]}}
1818
// {"id":668,"jsonrpc":"2.0","result":{"System.ScreenSaverActive":false}}
1919

20+
// Request stereoscopicmode example:
21+
// {"jsonrpc":"2.0","method":"GUI.GetProperties","params":{"properties":["stereoscopicmode"]},"id":1}
22+
// {"id":1,"jsonrpc":"2.0","result":{"stereoscopicmode":{"label":"Nebeneinander","mode":"split_vertical"}}}
23+
24+
int xbmcVersion = 0;
25+
2026
XBMCVideoChecker::XBMCVideoChecker(const std::string & address, uint16_t port, bool grabVideo, bool grabPhoto, bool grabAudio, bool grabMenu, bool grabScreensaver, bool enable3DDetection) :
2127
QObject(),
2228
_address(QString::fromStdString(address)),
2329
_port(port),
2430
_activePlayerRequest(R"({"id":666,"jsonrpc":"2.0","method":"Player.GetActivePlayers"})"),
2531
_currentPlayingItemRequest(R"({"id":667,"jsonrpc":"2.0","method":"Player.GetItem","params":{"playerid":%1,"properties":["file"]}})"),
2632
_checkScreensaverRequest(R"({"id":668,"jsonrpc":"2.0","method":"XBMC.GetInfoBooleans","params":{"booleans":["System.ScreenSaverActive"]}})"),
33+
_getStereoscopicMode(R"({"jsonrpc":"2.0","method":"GUI.GetProperties","params":{"properties":["stereoscopicmode"]},"id":1})"),
34+
_getXbmcVersion(R"({"jsonrpc":"2.0","method":"Application.GetProperties","params":{"properties":["version"]},"id":1})"),
2735
_socket(),
2836
_grabVideo(grabVideo),
2937
_grabPhoto(grabPhoto),
@@ -116,32 +124,75 @@ void XBMCVideoChecker::receiveReply()
116124
}
117125
else if (reply.contains("\"id\":667"))
118126
{
119-
// result of Player.GetItem
120-
// TODO: what if the filename contains a '"'. In Json this should have been escaped
121-
QRegExp regex("\"file\":\"((?!\").)*\"");
127+
if (xbmcVersion >= 13)
128+
{
129+
// check of active stereoscopicmode
130+
_socket.write(_getStereoscopicMode.toUtf8());
131+
}
132+
else
133+
{
134+
// result of Player.GetItem
135+
// TODO: what if the filename contains a '"'. In Json this should have been escaped
136+
QRegExp regex("\"file\":\"((?!\").)*\"");
137+
int pos = regex.indexIn(reply);
138+
if (pos > 0)
139+
{
140+
QStringRef filename = QStringRef(&reply, pos+8, regex.matchedLength()-9);
141+
if (filename.contains("3DSBS", Qt::CaseInsensitive) || filename.contains("HSBS", Qt::CaseInsensitive))
142+
{
143+
setVideoMode(VIDEO_3DSBS);
144+
}
145+
else if (filename.contains("3DTAB", Qt::CaseInsensitive) || filename.contains("HTAB", Qt::CaseInsensitive))
146+
{
147+
setVideoMode(VIDEO_3DTAB);
148+
}
149+
else
150+
{
151+
setVideoMode(VIDEO_2D);
152+
}
153+
}
154+
}
155+
}
156+
else if (reply.contains("\"id\":668"))
157+
{
158+
// result of System.ScreenSaverActive
159+
bool active = reply.contains("\"System.ScreenSaverActive\":true");
160+
setScreensaverMode(!_grabScreensaver && active);
161+
162+
// check here xbmc version
163+
if (_socket.state() == QTcpSocket::ConnectedState)
164+
{
165+
if (xbmcVersion == 0)
166+
{
167+
_socket.write(_getXbmcVersion.toUtf8());
168+
}
169+
}
170+
}
171+
else if (reply.contains("\"stereoscopicmode\""))
172+
{
173+
QRegExp regex("\"mode\":\"(split_vertical|split_horizontal)\"");
122174
int pos = regex.indexIn(reply);
123175
if (pos > 0)
124176
{
125-
QStringRef filename = QStringRef(&reply, pos+8, regex.matchedLength()-9);
126-
if (filename.contains("3DSBS", Qt::CaseInsensitive) || filename.contains("HSBS", Qt::CaseInsensitive))
177+
QString sMode = regex.cap(1);
178+
if (sMode == "split_vertical")
127179
{
128180
setVideoMode(VIDEO_3DSBS);
129181
}
130-
else if (filename.contains("3DTAB", Qt::CaseInsensitive) || filename.contains("HTAB", Qt::CaseInsensitive))
182+
else if (sMode == "split_horizontal")
131183
{
132184
setVideoMode(VIDEO_3DTAB);
133185
}
134-
else
135-
{
136-
setVideoMode(VIDEO_2D);
137-
}
138186
}
139187
}
140-
else if (reply.contains("\"id\":668"))
188+
else if (reply.contains("\"version\":"))
141189
{
142-
// result of System.ScreenSaverActive
143-
bool active = reply.contains("\"System.ScreenSaverActive\":true");
144-
setScreensaverMode(!_grabScreensaver && active);
190+
QRegExp regex("\"major\":(\\d+)");
191+
int pos = regex.indexIn(reply);
192+
if (pos > 0)
193+
{
194+
xbmcVersion = regex.cap(1).toInt();
195+
}
145196
}
146197
}
147198

0 commit comments

Comments
 (0)