hyperion.ng/include/xbmcvideochecker/XBMCVideoChecker.h

60 lines
1.3 KiB
C
Raw Normal View History

2013-08-23 20:44:53 +02:00
#pragma once
// system includes
#include <cstdint>
#include <string>
// QT includes
#include <QTimer>
#include <QString>
#include <QTcpSocket>
#include <QByteArray>
2013-08-23 20:44:53 +02:00
// Hyperion includes
#include <hyperion/Hyperion.h>
2013-08-31 14:36:54 +02:00
/// This class will check if XBMC 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 XBMC menus.
///
/// Note: The json TCP server needs to be enabled manually in XBMC in System/Settings/Network/Services
2013-08-23 20:44:53 +02:00
class XBMCVideoChecker : public QObject
{
Q_OBJECT
public:
2013-08-31 14:36:54 +02:00
/// @Constructor
/// @param address Netwrok address of the XBMC instance
/// @param port Port number to use (XBMC default = 9090)
/// @param interval The interval at which XBMC is polled
/// @param hyperion The Hyperion instance
/// @param priority The priority at which to send the all black data
XBMCVideoChecker(const std::string & address, uint16_t port, uint64_t interval, Hyperion * hyperion, int priority);
2013-08-23 20:44:53 +02:00
2013-08-31 14:36:54 +02:00
/// \brief Start polling XBMC
2013-08-23 20:44:53 +02:00
void start();
private slots:
2013-08-31 14:36:54 +02:00
/// \brief Send a request to XBMC
2013-08-23 20:44:53 +02:00
void sendRequest();
2013-08-31 14:36:54 +02:00
/// @brief receive a reply from XBMC
void receiveReply();
2013-08-23 20:44:53 +02:00
private:
const QString _address;
const uint16_t _port;
2013-08-23 20:44:53 +02:00
const QByteArray _request;
QTimer _timer;
2013-08-23 20:44:53 +02:00
QTcpSocket _socket;
2013-08-23 20:44:53 +02:00
Hyperion * _hyperion;
const int _priority;
2013-08-23 20:44:53 +02:00
};