2013-08-23 20:44:53 +02:00
|
|
|
|
|
|
|
#pragma once
|
|
|
|
|
|
|
|
// system includes
|
|
|
|
#include <cstdint>
|
|
|
|
#include <string>
|
|
|
|
|
|
|
|
// QT includes
|
|
|
|
#include <QTimer>
|
|
|
|
#include <QString>
|
2013-08-23 21:40:42 +02:00
|
|
|
#include <QTcpSocket>
|
|
|
|
#include <QByteArray>
|
2013-08-23 20:44:53 +02:00
|
|
|
|
|
|
|
// Hyperion includes
|
|
|
|
#include <hyperion/Hyperion.h>
|
|
|
|
|
2013-09-23 22:33:38 +02:00
|
|
|
// Utils includes
|
|
|
|
#include <utils/GrabbingMode.h>
|
2013-12-21 14:32:30 +01:00
|
|
|
#include <utils/VideoMode.h>
|
2016-07-10 22:04:31 +02:00
|
|
|
#include <utils/Logger.h>
|
2013-09-23 22:33:38 +02:00
|
|
|
|
2013-09-09 04:54:13 +02:00
|
|
|
///
|
2016-07-10 22:04:31 +02:00
|
|
|
/// This class will check if KODI is playing something. When it does not, this class will send all black data to Hyperion.
|
|
|
|
/// This allows grabbed screen data to be overriden while in the KODI menus.
|
2013-08-23 21:40:42 +02:00
|
|
|
///
|
2016-07-10 22:04:31 +02:00
|
|
|
/// Note: The json TCP server needs to be enabled manually in KODI in System/Settings/Network/Services
|
2013-09-09 04:54:13 +02:00
|
|
|
///
|
2016-07-10 22:04:31 +02:00
|
|
|
class KODIVideoChecker : public QObject
|
2013-08-23 20:44:53 +02:00
|
|
|
{
|
|
|
|
Q_OBJECT
|
|
|
|
|
|
|
|
public:
|
2016-07-10 22:04:31 +02:00
|
|
|
static KODIVideoChecker* initInstance(const std::string & address, uint16_t port, bool grabVideo, bool grabPhoto, bool grabAudio, bool grabMenu, bool grabPause, bool grabScreensaver, bool enable3DDetection);
|
|
|
|
static KODIVideoChecker* getInstance();
|
2013-08-23 20:44:53 +02:00
|
|
|
|
2016-07-10 22:04:31 +02:00
|
|
|
~KODIVideoChecker();
|
|
|
|
void setConfig(const std::string & address, uint16_t port, bool grabVideo, bool grabPhoto, bool grabAudio, bool grabMenu, bool grabPause, bool grabScreensaver, bool enable3DDetection);
|
|
|
|
|
|
|
|
public slots:
|
2013-09-09 04:54:13 +02:00
|
|
|
///
|
2016-07-10 22:04:31 +02:00
|
|
|
/// Start polling KODI
|
2013-09-09 04:54:13 +02:00
|
|
|
///
|
2013-08-23 20:44:53 +02:00
|
|
|
void start();
|
|
|
|
|
2016-07-10 22:04:31 +02:00
|
|
|
///
|
|
|
|
/// Stop polling KODI
|
|
|
|
///
|
|
|
|
void stop();
|
|
|
|
|
2013-09-23 22:33:38 +02:00
|
|
|
signals:
|
2013-12-21 14:32:30 +01:00
|
|
|
/// Signal emitted when the grabbing mode changes
|
2013-09-23 22:33:38 +02:00
|
|
|
void grabbingMode(GrabbingMode grabbingMode);
|
|
|
|
|
2013-12-21 14:32:30 +01:00
|
|
|
/// Signal emitted when a 3D movie is detected
|
|
|
|
void videoMode(VideoMode videoMode);
|
2013-08-23 20:44:53 +02:00
|
|
|
|
2013-12-21 14:32:30 +01:00
|
|
|
private slots:
|
2016-07-10 22:04:31 +02:00
|
|
|
/// Receive a reply from KODI
|
2013-08-23 21:40:42 +02:00
|
|
|
void receiveReply();
|
2013-08-23 20:44:53 +02:00
|
|
|
|
2016-07-10 22:04:31 +02:00
|
|
|
/// Called when connected to KODI
|
2013-12-21 14:32:30 +01:00
|
|
|
void connected();
|
|
|
|
|
2016-07-10 22:04:31 +02:00
|
|
|
/// Called when disconnected from KODI
|
2013-12-21 14:32:30 +01:00
|
|
|
void disconnected();
|
|
|
|
|
2016-07-10 22:04:31 +02:00
|
|
|
/// reconnect to KODI
|
2013-12-21 17:20:02 +01:00
|
|
|
void reconnect();
|
|
|
|
|
2013-12-21 14:32:30 +01:00
|
|
|
/// Called when a connection error was encountered
|
|
|
|
void connectionError(QAbstractSocket::SocketError error);
|
|
|
|
|
|
|
|
private:
|
2016-06-17 01:25:40 +02:00
|
|
|
///
|
|
|
|
/// Constructor
|
|
|
|
///
|
2016-07-10 22:04:31 +02:00
|
|
|
/// @param address Network address of the KODI instance
|
|
|
|
/// @param port Port number to use (KODI default = 9090)
|
|
|
|
/// @param grabVideo Whether or not to grab when the KODI video player is playing
|
|
|
|
/// @param grabPhoto Whether or not to grab when the KODI photo player is playing
|
|
|
|
/// @param grabAudio Whether or not to grab when the KODI audio player is playing
|
|
|
|
/// @param grabMenu Whether or not to grab when nothing is playing (in KODI menu)
|
|
|
|
/// @param grabScreensaver Whether or not to grab when the KODI screensaver is activated
|
2016-06-17 01:25:40 +02:00
|
|
|
/// @param enable3DDetection Wheter or not to enable the detection of 3D movies playing
|
|
|
|
///
|
2016-07-10 22:04:31 +02:00
|
|
|
KODIVideoChecker(const std::string & address, uint16_t port, bool grabVideo, bool grabPhoto, bool grabAudio, bool grabMenu, bool grabPause, bool grabScreensaver, bool enable3DDetection);
|
2016-06-17 01:25:40 +02:00
|
|
|
|
2013-12-21 14:32:30 +01:00
|
|
|
/// Set the grabbing mode
|
|
|
|
void setGrabbingMode(GrabbingMode grabbingMode);
|
|
|
|
|
|
|
|
void setScreensaverMode(bool isOnScreensaver);
|
2016-06-07 12:34:50 +02:00
|
|
|
|
2013-12-21 14:32:30 +01:00
|
|
|
/// Set the video mode
|
|
|
|
void setVideoMode(VideoMode videoMode);
|
|
|
|
|
2013-08-23 20:44:53 +02:00
|
|
|
private:
|
2016-07-10 22:04:31 +02:00
|
|
|
/// The network address of the KODI instance
|
|
|
|
QString _address;
|
2013-08-23 21:40:42 +02:00
|
|
|
|
2016-07-10 22:04:31 +02:00
|
|
|
/// The port number of KODI
|
|
|
|
uint16_t _port;
|
2013-08-23 20:44:53 +02:00
|
|
|
|
2013-12-21 14:32:30 +01:00
|
|
|
/// The JSON-RPC message to check the active player
|
|
|
|
const QString _activePlayerRequest;
|
|
|
|
|
|
|
|
/// The JSON-RPC message to check the currently playing file
|
|
|
|
const QString _currentPlayingItemRequest;
|
2013-08-23 21:40:42 +02:00
|
|
|
|
2013-12-21 14:32:30 +01:00
|
|
|
/// The JSON-RPC message to check the screensaver
|
|
|
|
const QString _checkScreensaverRequest;
|
2013-08-23 20:44:53 +02:00
|
|
|
|
2014-04-26 00:58:47 +02:00
|
|
|
/// The JSON-RPC message to check the active stereoscopicmode
|
|
|
|
const QString _getStereoscopicMode;
|
|
|
|
|
2016-07-10 22:04:31 +02:00
|
|
|
/// The JSON-RPC message to check the kodi version
|
|
|
|
QString _getKodiVersion;
|
2014-04-26 00:58:47 +02:00
|
|
|
|
2016-07-10 22:04:31 +02:00
|
|
|
/// The QT TCP Socket with connection to KODI
|
2013-08-23 21:40:42 +02:00
|
|
|
QTcpSocket _socket;
|
2013-08-23 20:44:53 +02:00
|
|
|
|
2016-07-10 22:04:31 +02:00
|
|
|
/// Flag indicating whether or not to grab when the KODI video player is playing
|
|
|
|
bool _grabVideo;
|
2013-09-23 22:33:38 +02:00
|
|
|
|
2016-07-10 22:04:31 +02:00
|
|
|
/// Flag indicating whether or not to grab when the KODI photo player is playing
|
|
|
|
bool _grabPhoto;
|
2013-09-23 22:33:38 +02:00
|
|
|
|
2016-07-10 22:04:31 +02:00
|
|
|
/// Flag indicating whether or not to grab when the KODI audio player is playing
|
|
|
|
bool _grabAudio;
|
2013-09-23 22:33:38 +02:00
|
|
|
|
2016-07-10 22:04:31 +02:00
|
|
|
/// Flag indicating whether or not to grab when KODI is playing nothing (in menu)
|
|
|
|
bool _grabMenu;
|
2013-12-21 14:32:30 +01:00
|
|
|
|
2016-07-10 22:04:31 +02:00
|
|
|
/// Flag indicating whether or not to grab when the KODI videoplayer is at pause state
|
|
|
|
bool _grabPause;
|
2016-06-07 12:34:50 +02:00
|
|
|
|
2016-07-10 22:04:31 +02:00
|
|
|
/// Flag indicating whether or not to grab when the KODI screensaver is activated
|
|
|
|
bool _grabScreensaver;
|
2013-12-21 14:32:30 +01:00
|
|
|
|
|
|
|
/// Flag indicating wheter or not to enable the detection of 3D movies playing
|
2016-07-10 22:04:31 +02:00
|
|
|
bool _enable3DDetection;
|
2013-12-21 14:32:30 +01:00
|
|
|
|
2016-07-10 22:04:31 +02:00
|
|
|
/// Flag indicating if KODI is on screensaver
|
2013-12-21 14:32:30 +01:00
|
|
|
bool _previousScreensaverMode;
|
2016-06-07 12:34:50 +02:00
|
|
|
|
2013-12-21 14:32:30 +01:00
|
|
|
/// Previous emitted grab mode
|
|
|
|
GrabbingMode _previousGrabbingMode;
|
2013-08-23 20:44:53 +02:00
|
|
|
|
2013-12-21 14:32:30 +01:00
|
|
|
/// Previous emitted video mode
|
|
|
|
VideoMode _previousVideoMode;
|
2014-04-30 22:46:26 +02:00
|
|
|
|
2016-07-10 22:04:31 +02:00
|
|
|
/// KODI version number
|
|
|
|
int _kodiVersion;
|
|
|
|
|
|
|
|
/// Logger Instance
|
|
|
|
Logger * _log;
|
2016-06-17 01:25:40 +02:00
|
|
|
|
2016-07-10 22:04:31 +02:00
|
|
|
/// flag indicating state
|
|
|
|
bool _active;
|
|
|
|
|
|
|
|
static KODIVideoChecker* _kodichecker;
|
2013-08-23 20:44:53 +02:00
|
|
|
};
|