|
17 | 17 | // {"id":668,"jsonrpc":"2.0","method":"XBMC.GetInfoBooleans","params":{"booleans":["System.ScreenSaverActive"]}}
|
18 | 18 | // {"id":668,"jsonrpc":"2.0","result":{"System.ScreenSaverActive":false}}
|
19 | 19 |
|
| 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 | + |
20 | 26 | XBMCVideoChecker::XBMCVideoChecker(const std::string & address, uint16_t port, bool grabVideo, bool grabPhoto, bool grabAudio, bool grabMenu, bool grabScreensaver, bool enable3DDetection) :
|
21 | 27 | QObject(),
|
22 | 28 | _address(QString::fromStdString(address)),
|
23 | 29 | _port(port),
|
24 | 30 | _activePlayerRequest(R"({"id":666,"jsonrpc":"2.0","method":"Player.GetActivePlayers"})"),
|
25 | 31 | _currentPlayingItemRequest(R"({"id":667,"jsonrpc":"2.0","method":"Player.GetItem","params":{"playerid":%1,"properties":["file"]}})"),
|
26 | 32 | _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})"), |
27 | 35 | _socket(),
|
28 | 36 | _grabVideo(grabVideo),
|
29 | 37 | _grabPhoto(grabPhoto),
|
@@ -116,32 +124,75 @@ void XBMCVideoChecker::receiveReply()
|
116 | 124 | }
|
117 | 125 | else if (reply.contains("\"id\":667"))
|
118 | 126 | {
|
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)\""); |
122 | 174 | int pos = regex.indexIn(reply);
|
123 | 175 | if (pos > 0)
|
124 | 176 | {
|
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") |
127 | 179 | {
|
128 | 180 | setVideoMode(VIDEO_3DSBS);
|
129 | 181 | }
|
130 |
| - else if (filename.contains("3DTAB", Qt::CaseInsensitive) || filename.contains("HTAB", Qt::CaseInsensitive)) |
| 182 | + else if (sMode == "split_horizontal") |
131 | 183 | {
|
132 | 184 | setVideoMode(VIDEO_3DTAB);
|
133 | 185 | }
|
134 |
| - else |
135 |
| - { |
136 |
| - setVideoMode(VIDEO_2D); |
137 |
| - } |
138 | 186 | }
|
139 | 187 | }
|
140 |
| - else if (reply.contains("\"id\":668")) |
| 188 | + else if (reply.contains("\"version\":")) |
141 | 189 | {
|
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 | + } |
145 | 196 | }
|
146 | 197 | }
|
147 | 198 |
|
|
0 commit comments