New XBMC checker functionality: 3D video detection (filename based) and screensaver detection

Former-commit-id: ea95e4ecde3ab9378bdf9c4c60950713947bd0ac
This commit is contained in:
johan
2013-12-21 14:32:30 +01:00
parent e1a60e6944
commit 78795b9fa8
12 changed files with 347 additions and 110 deletions

View File

@@ -9,6 +9,7 @@
#include <utils/ColorRgb.h>
#include <utils/ColorRgba.h>
#include <utils/GrabbingMode.h>
#include <utils/VideoMode.h>
// Forward class declaration
class DispmanxFrameGrabber;
@@ -61,6 +62,12 @@ public slots:
///
void setGrabbingMode(const GrabbingMode mode);
///
/// Set the video mode (2D/3D)
/// @param[in] mode The new video mode
///
void setVideoMode(const VideoMode videoMode);
private:
/// The update rate [Hz]
const int _updateInterval_ms;

View File

@@ -118,6 +118,22 @@ public:
return _pixels[toIndex(x,y)];
}
/// Resize the image
/// @param width The width of the image
/// @param height The height of the image
void resize(const unsigned width, const unsigned height)
{
if ((width*height) > (_endOfPixels-_pixels))
{
delete[] _pixels;
_pixels = new Pixel_T[width*height + 1];
_endOfPixels = _pixels + width*height;
}
_width = width;
_height = height;
}
///
/// Copies another image into this image. The images should have exactly the same size.
///
@@ -165,9 +181,9 @@ private:
private:
/// The width of the image
const unsigned _width;
unsigned _width;
/// The height of the image
const unsigned _height;
unsigned _height;
/// The pixels of the image
Pixel_T* _pixels;

11
include/utils/VideoMode.h Normal file
View File

@@ -0,0 +1,11 @@
#pragma once
/**
* Enumeration of the possible modes in which video can be playing (2D, 3D)
*/
enum VideoMode
{
VIDEO_2D,
VIDEO_3DSBS,
VIDEO_3DTAB
};

View File

@@ -16,6 +16,7 @@
// Utils includes
#include <utils/GrabbingMode.h>
#include <utils/VideoMode.h>
///
/// This class will check if XBMC is playing something. When it does not, this class will send all black data to Hyperion.
@@ -33,13 +34,14 @@ public:
///
/// @param address Network address of the XBMC instance
/// @param port Port number to use (XBMC default = 9090)
/// @param interval The interval at which XBMC is polled
/// @param grabVideo Whether or not to grab when the XBMC video player is playing
/// @param grabPhoto Whether or not to grab when the XBMC photo player is playing
/// @param grabAudio Whether or not to grab when the XBMC audio player is playing
/// @param grabMenu Whether or not to grab when nothing is playing (in XBMC menu)
/// @param grabScreensaver Whether or not to grab when the XBMC screensaver is activated
/// @param enable3DDetection Wheter or not to enable the detection of 3D movies playing
///
XBMCVideoChecker(const std::string & address, uint16_t port, uint64_t interval, bool grabVideo, bool grabPhoto, bool grabAudio, bool grabMenu);
XBMCVideoChecker(const std::string & address, uint16_t port, bool grabVideo, bool grabPhoto, bool grabAudio, bool grabMenu, bool grabScreensaver, bool enable3DDetection);
///
/// Start polling XBMC
@@ -47,19 +49,34 @@ public:
void start();
signals:
/// Signal emitted when the grabbing mode changes
void grabbingMode(GrabbingMode grabbingMode);
private slots:
///
/// Send a request to XBMC
///
void sendRequest();
/// Signal emitted when a 3D movie is detected
void videoMode(VideoMode videoMode);
///
private slots:
/// Receive a reply from XBMC
///
void receiveReply();
/// Called when connected to XBMC
void connected();
/// Called when disconnected from XBMC
void disconnected();
/// Called when a connection error was encountered
void connectionError(QAbstractSocket::SocketError error);
private:
/// Set the grabbing mode
void setGrabbingMode(GrabbingMode grabbingMode);
void setScreensaverMode(bool isOnScreensaver);
/// Set the video mode
void setVideoMode(VideoMode videoMode);
private:
/// The network address of the XBMC instance
const QString _address;
@@ -67,27 +84,42 @@ private:
/// The port number of XBMC
const uint16_t _port;
/// The JSON-RPC request message
const QByteArray _request;
/// The JSON-RPC message to check the active player
const QString _activePlayerRequest;
/// The timer that schedules XBMC queries
QTimer _timer;
/// The JSON-RPC message to check the currently playing file
const QString _currentPlayingItemRequest;
/// The JSON-RPC message to check the screensaver
const QString _checkScreensaverRequest;
/// The QT TCP Socket with connection to XBMC
QTcpSocket _socket;
/// Flag indicating whether or not to grab when the XBMC video player is playing
bool _grabVideo;
const bool _grabVideo;
/// Flag indicating whether or not to grab when the XBMC photo player is playing
bool _grabPhoto;
const bool _grabPhoto;
/// Flag indicating whether or not to grab when the XBMC audio player is playing
bool _grabAudio;
const bool _grabAudio;
/// Flag indicating whether or not to grab when XBMC is playing nothing (in menu)
bool _grabMenu;
const bool _grabMenu;
/// Previous emitted grab state
GrabbingMode _previousMode;
/// Flag inidcating whether or not to grab when the XBMC screensaver is activated
const bool _grabScreensaver;
/// Flag indicating wheter or not to enable the detection of 3D movies playing
const bool _enable3DDetection;
/// Flag indicating if XBMC is on screensaver
bool _previousScreensaverMode;
/// Previous emitted grab mode
GrabbingMode _previousGrabbingMode;
/// Previous emitted video mode
VideoMode _previousVideoMode;
};