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

Commit 26acf7d

Browse files
committed
Cleanup of XBMC 3D checker code
1 parent b83c685 commit 26acf7d

File tree

2 files changed

+17
-15
lines changed

2 files changed

+17
-15
lines changed

include/xbmcvideochecker/XBMCVideoChecker.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -131,4 +131,7 @@ private slots:
131131

132132
/// Previous emitted video mode
133133
VideoMode _previousVideoMode;
134+
135+
/// XBMC version number
136+
int _xbmcVersion;
134137
};

libsrc/xbmcvideochecker/XBMCVideoChecker.cpp

Lines changed: 14 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -18,10 +18,8 @@
1818
// {"id":668,"jsonrpc":"2.0","result":{"System.ScreenSaverActive":false}}
1919

2020
// 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;
21+
// {"jsonrpc":"2.0","method":"GUI.GetProperties","params":{"properties":["stereoscopicmode"]},"id":669}
22+
// {"id":669,"jsonrpc":"2.0","result":{"stereoscopicmode":{"label":"Nebeneinander","mode":"split_vertical"}}}
2523

2624
XBMCVideoChecker::XBMCVideoChecker(const std::string & address, uint16_t port, bool grabVideo, bool grabPhoto, bool grabAudio, bool grabMenu, bool grabScreensaver, bool enable3DDetection) :
2725
QObject(),
@@ -30,8 +28,8 @@ XBMCVideoChecker::XBMCVideoChecker(const std::string & address, uint16_t port, b
3028
_activePlayerRequest(R"({"id":666,"jsonrpc":"2.0","method":"Player.GetActivePlayers"})"),
3129
_currentPlayingItemRequest(R"({"id":667,"jsonrpc":"2.0","method":"Player.GetItem","params":{"playerid":%1,"properties":["file"]}})"),
3230
_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})"),
31+
_getStereoscopicMode(R"({"jsonrpc":"2.0","method":"GUI.GetProperties","params":{"properties":["stereoscopicmode"]},"id":669})"),
32+
_getXbmcVersion(R"({"jsonrpc":"2.0","method":"Application.GetProperties","params":{"properties":["version"]},"id":670})"),
3533
_socket(),
3634
_grabVideo(grabVideo),
3735
_grabPhoto(grabPhoto),
@@ -41,7 +39,8 @@ XBMCVideoChecker::XBMCVideoChecker(const std::string & address, uint16_t port, b
4139
_enable3DDetection(enable3DDetection),
4240
_previousScreensaverMode(false),
4341
_previousGrabbingMode(GRABBINGMODE_INVALID),
44-
_previousVideoMode(VIDEO_2D)
42+
_previousVideoMode(VIDEO_2D),
43+
_xbmcVersion(0)
4544
{
4645
// setup socket
4746
connect(&_socket, SIGNAL(readyRead()), this, SLOT(receiveReply()));
@@ -124,10 +123,10 @@ void XBMCVideoChecker::receiveReply()
124123
}
125124
else if (reply.contains("\"id\":667"))
126125
{
127-
if (xbmcVersion >= 13)
126+
if (_xbmcVersion >= 13)
128127
{
129-
// check of active stereoscopicmode
130-
_socket.write(_getStereoscopicMode.toUtf8());
128+
// check of active stereoscopicmode
129+
_socket.write(_getStereoscopicMode.toUtf8());
131130
}
132131
else
133132
{
@@ -162,13 +161,13 @@ void XBMCVideoChecker::receiveReply()
162161
// check here xbmc version
163162
if (_socket.state() == QTcpSocket::ConnectedState)
164163
{
165-
if (xbmcVersion == 0)
166-
{
164+
if (_xbmcVersion == 0)
165+
{
167166
_socket.write(_getXbmcVersion.toUtf8());
168167
}
169168
}
170169
}
171-
else if (reply.contains("\"stereoscopicmode\""))
170+
else if (reply.contains("\"id\":669"))
172171
{
173172
QRegExp regex("\"mode\":\"(split_vertical|split_horizontal)\"");
174173
int pos = regex.indexIn(reply);
@@ -185,13 +184,13 @@ void XBMCVideoChecker::receiveReply()
185184
}
186185
}
187186
}
188-
else if (reply.contains("\"version\":"))
187+
else if (reply.contains("\"id\":670"))
189188
{
190189
QRegExp regex("\"major\":(\\d+)");
191190
int pos = regex.indexIn(reply);
192191
if (pos > 0)
193192
{
194-
xbmcVersion = regex.cap(1).toInt();
193+
_xbmcVersion = regex.cap(1).toInt();
195194
}
196195
}
197196
}

0 commit comments

Comments
 (0)