Skip to content

Commit f1cc82b

Browse files
authored
enable components at runtime + grabber refactoring (hyperion-project#160)
* implement enable/disable on runtime for: - smoothing - kodi - udplistener - boblight * implement enable/disable for forwarder refactor component * - implement grabber enable/disable at runtime - big grabber refactoring. now with common base class for all grabbers * implement enable/disable at runtime for bb detector * osx fix * try to fix cutted travis output for osx build
1 parent 0d3f6c7 commit f1cc82b

36 files changed

+471
-495
lines changed

.travis/travis_build.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,8 @@
1010
# compile hyperion on osx
1111
if [[ $TRAVIS_OS_NAME == 'osx' ]]
1212
then
13-
procs=$(sysctl -n hw.ncpu | xargs)
14-
echo "Processes: $procs"
13+
procs=$(sysctl -n hw.ncpu | xargs)
14+
echo "Processes: $procs"
1515

1616
mkdir build || exit 1
1717
cd build

PULL_REQUEST_TEMPLATE

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33

44
**2.** If this changes affect the .conf file. Please provide the changed section
55

6-
**3.** Reference a issue (optional)
6+
**3.** Reference an issue (optional)
77

88
Note: For further discussions use our forum: forum.hyperion-project.org
99

include/boblightserver/BoblightServer.h

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
// Hyperion includes
1111
#include <hyperion/Hyperion.h>
1212
#include <utils/Logger.h>
13+
#include <utils/Components.h>
1314

1415
class BoblightClientConnection;
1516

@@ -37,7 +38,8 @@ class BoblightServer : public QObject
3738
/// @return true if server is active (bind to a port)
3839
///
3940
bool active() { return _isActive; };
40-
41+
bool componentState() { return active(); };
42+
4143
public slots:
4244
///
4345
/// bind server to network
@@ -49,6 +51,8 @@ public slots:
4951
///
5052
void stop();
5153

54+
void componentStateChanged(const hyperion::Components component, bool enable);
55+
5256
signals:
5357
void statusChanged(bool isActive);
5458

include/grabber/AmlogicWrapper.h

Lines changed: 4 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,12 @@
11
#pragma once
22

3-
// QT includes
4-
#include <QObject>
5-
#include <QTimer>
6-
73
// Utils includes
84
#include <utils/Image.h>
95
#include <utils/ColorBgr.h>
106
#include <utils/ColorRgb.h>
117
#include <utils/GrabbingMode.h>
128
#include <utils/VideoMode.h>
9+
#include <hyperion/GrabberWrapper.h>
1310

1411
// Forward class declaration
1512
class AmlogicGrabber;
@@ -21,7 +18,7 @@ class ImageProcessor;
2118
/// displayed content. This ImageRgb is processed to a ColorRgb for each led and commmited to the
2219
/// attached Hyperion.
2320
///
24-
class AmlogicWrapper : public QObject
21+
class AmlogicWrapper : public GrabberWrapper
2522
{
2623
Q_OBJECT
2724
public:
@@ -41,20 +38,10 @@ class AmlogicWrapper : public QObject
4138
virtual ~AmlogicWrapper();
4239

4340
public slots:
44-
///
45-
/// Starts the grabber wich produces led values with the specified update rate
46-
///
47-
void start();
48-
4941
///
5042
/// Performs a single frame grab and computes the led-colors
5143
///
52-
void action();
53-
54-
///
55-
/// Stops the grabber
56-
///
57-
void stop();
44+
virtual void action();
5845

5946
///
6047
/// Set the grabbing mode
@@ -68,33 +55,17 @@ public slots:
6855
///
6956
void setVideoMode(const VideoMode videoMode);
7057

71-
signals:
72-
void emitImage(int priority, const Image<ColorRgb> & image, const int timeout_ms);
73-
7458
private:
7559
/// The update rate [Hz]
7660
const int _updateInterval_ms;
7761
/// The timeout of the led colors [ms]
7862
const int _timeout_ms;
79-
/// The priority of the led colors
80-
const int _priority;
81-
82-
/// The timer for generating events with the specified update rate
83-
QTimer _timer;
8463

8564
/// The image used for grabbing frames
8665
Image<ColorBgr> _image;
8766
/// The actual grabber
88-
AmlogicGrabber * _frameGrabber;
89-
/// The processor for transforming images to led colors
90-
ImageProcessor * _processor;
67+
AmlogicGrabber * _grabber;
9168

9269
/// The list with computed led colors
9370
std::vector<ColorRgb> _ledColors;
94-
95-
/// Pointer to Hyperion for writing led values
96-
Hyperion * _hyperion;
97-
98-
// forwarding enabled
99-
bool _forward;
10071
};

include/grabber/DispmanxWrapper.h

Lines changed: 4 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,23 @@
11
#pragma once
22

3-
// QT includes
4-
#include <QObject>
5-
#include <QTimer>
6-
73
// Utils includes
84
#include <utils/Image.h>
95
#include <utils/ColorRgb.h>
106
#include <utils/ColorRgba.h>
117
#include <utils/GrabbingMode.h>
128
#include <utils/VideoMode.h>
9+
#include <hyperion/GrabberWrapper.h>
1310

1411
// Forward class declaration
1512
class DispmanxFrameGrabber;
16-
class Hyperion;
1713
class ImageProcessor;
1814

1915
///
2016
/// The DispmanxWrapper uses an instance of the DispmanxFrameGrabber to obtain ImageRgb's from the
2117
/// displayed content. This ImageRgb is processed to a ColorRgb for each led and commmited to the
2218
/// attached Hyperion.
2319
///
24-
class DispmanxWrapper: public QObject
20+
class DispmanxWrapper: public GrabberWrapper
2521
{
2622
Q_OBJECT
2723
public:
@@ -41,20 +37,10 @@ class DispmanxWrapper: public QObject
4137
virtual ~DispmanxWrapper();
4238

4339
public slots:
44-
///
45-
/// Starts the grabber wich produces led values with the specified update rate
46-
///
47-
void start();
48-
4940
///
5041
/// Performs a single frame grab and computes the led-colors
5142
///
52-
void action();
53-
54-
///
55-
/// Stops the grabber
56-
///
57-
void stop();
43+
virtual void action();
5844

5945
void setCropping(const unsigned cropLeft, const unsigned cropRight,
6046
const unsigned cropTop, const unsigned cropBottom);
@@ -71,9 +57,6 @@ public slots:
7157
///
7258
void setVideoMode(const VideoMode videoMode);
7359

74-
signals:
75-
void emitImage(int priority, const Image<ColorRgb> & image, const int timeout_ms);
76-
7760
private:
7861
/// The update rate [Hz]
7962
const int _updateInterval_ms;
@@ -82,22 +65,11 @@ public slots:
8265
/// The priority of the led colors
8366
const int _priority;
8467

85-
/// The timer for generating events with the specified update rate
86-
QTimer _timer;
87-
8868
/// The image used for grabbing frames
8969
Image<ColorRgba> _image;
9070
/// The actual grabber
91-
DispmanxFrameGrabber * _frameGrabber;
92-
/// The processor for transforming images to led colors
93-
ImageProcessor * _processor;
71+
DispmanxFrameGrabber * _grabber;
9472

9573
/// The list with computed led colors
9674
std::vector<ColorRgb> _ledColors;
97-
98-
/// Pointer to Hyperion for writing led values
99-
Hyperion * _hyperion;
100-
101-
// forwarding enabled
102-
bool _forward;
10375
};

include/grabber/FramebufferWrapper.h

Lines changed: 4 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,22 @@
11
#pragma once
22

3-
// QT includes
4-
#include <QObject>
5-
#include <QTimer>
6-
73
// Utils includes
84
#include <utils/Image.h>
95
#include <utils/ColorRgb.h>
106
#include <utils/GrabbingMode.h>
117
#include <utils/VideoMode.h>
8+
#include <hyperion/GrabberWrapper.h>
129

1310
// Forward class declaration
1411
class FramebufferFrameGrabber;
15-
class Hyperion;
1612
class ImageProcessor;
1713

1814
///
1915
/// The FramebufferWrapper uses an instance of the FramebufferFrameGrabber to obtain ImageRgb's from the
2016
/// displayed content. This ImageRgb is processed to a ColorRgb for each led and commmited to the
2117
/// attached Hyperion.
2218
///
23-
class FramebufferWrapper: public QObject
19+
class FramebufferWrapper: public GrabberWrapper
2420
{
2521
Q_OBJECT
2622
public:
@@ -40,20 +36,10 @@ class FramebufferWrapper: public QObject
4036
virtual ~FramebufferWrapper();
4137

4238
public slots:
43-
///
44-
/// Starts the grabber wich produces led values with the specified update rate
45-
///
46-
void start();
47-
4839
///
4940
/// Performs a single frame grab and computes the led-colors
5041
///
51-
void action();
52-
53-
///
54-
/// Stops the grabber
55-
///
56-
void stop();
42+
virtual void action();
5743

5844
///
5945
/// Set the grabbing mode
@@ -67,30 +53,17 @@ public slots:
6753
///
6854
void setVideoMode(const VideoMode videoMode);
6955

70-
signals:
71-
void emitImage(int priority, const Image<ColorRgb> & image, const int timeout_ms);
72-
7356
private:
7457
/// The update rate [Hz]
7558
const int _updateInterval_ms;
7659
/// The timeout of the led colors [ms]
7760
const int _timeout_ms;
78-
/// The priority of the led colors
79-
const int _priority;
80-
81-
/// The timer for generating events with the specified update rate
82-
QTimer _timer;
8361

8462
/// The image used for grabbing frames
8563
Image<ColorRgb> _image;
8664
/// The actual grabber
87-
FramebufferFrameGrabber * _frameGrabber;
88-
/// The processor for transforming images to led colors
89-
ImageProcessor * _processor;
65+
FramebufferFrameGrabber * _grabber;
9066

9167
/// The list with computed led colors
9268
std::vector<ColorRgb> _ledColors;
93-
94-
/// Pointer to Hyperion for writing led values
95-
Hyperion * _hyperion;
9669
};

include/grabber/OsxWrapper.h

Lines changed: 4 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,23 @@
11
#pragma once
22

3-
// QT includes
4-
#include <QObject>
5-
#include <QTimer>
6-
73
// Utils includes
84
#include <utils/Image.h>
95
#include <utils/ColorRgb.h>
106
#include <utils/ColorRgba.h>
117
#include <utils/GrabbingMode.h>
128
#include <utils/VideoMode.h>
9+
#include <hyperion/GrabberWrapper.h>
1310

1411
// Forward class declaration
1512
class OsxFrameGrabber;
16-
class Hyperion;
1713
class ImageProcessor;
1814

1915
///
2016
/// The OsxWrapper uses an instance of the OsxFrameGrabber to obtain ImageRgb's from the
2117
/// displayed content. This ImageRgb is processed to a ColorRgb for each led and commmited to the
2218
/// attached Hyperion.
2319
///
24-
class OsxWrapper: public QObject
20+
class OsxWrapper: public GrabberWrapper
2521
{
2622
Q_OBJECT
2723
public:
@@ -42,20 +38,10 @@ class OsxWrapper: public QObject
4238
virtual ~OsxWrapper();
4339

4440
public slots:
45-
///
46-
/// Starts the grabber wich produces led values with the specified update rate
47-
///
48-
void start();
49-
5041
///
5142
/// Performs a single frame grab and computes the led-colors
5243
///
53-
void action();
54-
55-
///
56-
/// Stops the grabber
57-
///
58-
void stop();
44+
virtual void action();
5945

6046
///
6147
/// Set the grabbing mode
@@ -69,30 +55,17 @@ public slots:
6955
///
7056
void setVideoMode(const VideoMode videoMode);
7157

72-
signals:
73-
void emitImage(int priority, const Image<ColorRgb> & image, const int timeout_ms);
74-
7558
private:
7659
/// The update rate [Hz]
7760
const int _updateInterval_ms;
7861
/// The timeout of the led colors [ms]
7962
const int _timeout_ms;
80-
/// The priority of the led colors
81-
const int _priority;
82-
83-
/// The timer for generating events with the specified update rate
84-
QTimer _timer;
8563

8664
/// The image used for grabbing frames
8765
Image<ColorRgb> _image;
8866
/// The actual grabber
89-
OsxFrameGrabber * _frameGrabber;
90-
/// The processor for transforming images to led colors
91-
ImageProcessor * _processor;
67+
OsxFrameGrabber * _grabber;
9268

9369
/// The list with computed led colors
9470
std::vector<ColorRgb> _ledColors;
95-
96-
/// Pointer to Hyperion for writing led values
97-
Hyperion * _hyperion;
9871
};

0 commit comments

Comments
 (0)