mirror of
https://github.com/hyperion-project/hyperion.ng.git
synced 2025-03-01 10:33:28 +00:00
Feature/CEC detection (#877)
* Add CEC functionality * Initial commit * removed libCEC from the system skip list Co-authored-by: Paulchen Panther <16664240+Paulchen-Panther@users.noreply.github.com>
This commit is contained in:
@@ -406,4 +406,4 @@ private:
|
||||
|
||||
// current instance index
|
||||
quint8 _currInstanceIndex;
|
||||
};
|
||||
};
|
||||
|
8
include/cec/CECEvent.h
Normal file
8
include/cec/CECEvent.h
Normal file
@@ -0,0 +1,8 @@
|
||||
#pragma once
|
||||
|
||||
enum class CECEvent
|
||||
{
|
||||
On,
|
||||
Off
|
||||
};
|
||||
|
69
include/cec/CECHandler.h
Normal file
69
include/cec/CECHandler.h
Normal file
@@ -0,0 +1,69 @@
|
||||
#pragma once
|
||||
|
||||
#include <QObject>
|
||||
#include <QVector>
|
||||
|
||||
#include <iostream>
|
||||
|
||||
#include <libcec/cec.h>
|
||||
|
||||
#include <cec/CECEvent.h>
|
||||
|
||||
using CECCallbacks = CEC::ICECCallbacks;
|
||||
using CECAdapter = CEC::ICECAdapter;
|
||||
using CECAdapterDescriptor = CEC::cec_adapter_descriptor;
|
||||
using CECLogMessage = CEC::cec_log_message;
|
||||
using CECKeyPress = CEC::cec_keypress;
|
||||
using CECCommand = CEC::cec_command;
|
||||
using CECLogicalAddress = CEC::cec_logical_address;
|
||||
using CECLogicalAddresses = CEC::cec_logical_addresses;
|
||||
using CECMenuState = CEC::cec_menu_state;
|
||||
using CECPowerStatus = CEC::cec_power_status;
|
||||
using CECVendorId = CEC::cec_vendor_id;
|
||||
using CECParameter = CEC::libcec_parameter;
|
||||
using CECConfig = CEC::libcec_configuration;
|
||||
using CECAlert = CEC::libcec_alert;
|
||||
|
||||
class Logger;
|
||||
|
||||
class CECHandler : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
CECHandler();
|
||||
~CECHandler() override;
|
||||
|
||||
QString scan() const;
|
||||
|
||||
public slots:
|
||||
bool start();
|
||||
void stop();
|
||||
|
||||
signals:
|
||||
void cecEvent(CECEvent event);
|
||||
|
||||
private:
|
||||
/* CEC Callbacks */
|
||||
static void onCecLogMessage (void * context, const CECLogMessage * message);
|
||||
static void onCecKeyPress (void * context, const CECKeyPress * key);
|
||||
static void onCecAlert (void * context, const CECAlert alert, const CECParameter data);
|
||||
static void onCecConfigurationChanged (void * context, const CECConfig * configuration);
|
||||
static void onCecCommandReceived (void * context, const CECCommand * command);
|
||||
static void onCecSourceActivated (void * context, const CECLogicalAddress address, const uint8_t activated);
|
||||
static int onCecMenuStateChanged (void * context, const CECMenuState state);
|
||||
|
||||
/* CEC Adapter helpers */
|
||||
QVector<CECAdapterDescriptor> getAdapters() const;
|
||||
bool openAdapter(const CECAdapterDescriptor & descriptor);
|
||||
void printAdapter(const CECAdapterDescriptor & descriptor) const;
|
||||
|
||||
/* CEC Helpers */
|
||||
CECCallbacks getCallbacks() const;
|
||||
CECConfig getConfig() const;
|
||||
|
||||
CECAdapter * _cecAdapter {};
|
||||
CECCallbacks _cecCallbacks {};
|
||||
CECConfig _cecConfig {};
|
||||
|
||||
Logger * _logger {};
|
||||
};
|
@@ -16,6 +16,7 @@
|
||||
#include <hyperion/Grabber.h>
|
||||
#include <grabber/VideoStandard.h>
|
||||
#include <utils/Components.h>
|
||||
#include <cec/CECEvent.h>
|
||||
|
||||
// general JPEG decoder includes
|
||||
#ifdef HAVE_JPEG_DECODER
|
||||
@@ -67,6 +68,7 @@ public:
|
||||
}
|
||||
|
||||
bool getSignalDetectionEnabled() { return _signalDetectionEnabled; }
|
||||
bool getCecDetectionEnabled() { return _cecDetectionEnabled; }
|
||||
|
||||
int grabFrame(Image<ColorRgb> &);
|
||||
|
||||
@@ -98,6 +100,11 @@ public:
|
||||
///
|
||||
void setSignalDetectionEnable(bool enable) override;
|
||||
|
||||
///
|
||||
/// @brief overwrite Grabber.h implementation
|
||||
///
|
||||
void setCecDetectionEnable(bool enable) override;
|
||||
|
||||
///
|
||||
/// @brief overwrite Grabber.h implementation
|
||||
///
|
||||
@@ -149,6 +156,8 @@ public slots:
|
||||
|
||||
void stop();
|
||||
|
||||
void handleCecEvent(CECEvent event);
|
||||
|
||||
signals:
|
||||
void newFrame(const Image<ColorRgb> & image);
|
||||
void readError(const char* err);
|
||||
@@ -257,6 +266,8 @@ private:
|
||||
int _noSignalCounterThreshold;
|
||||
ColorRgb _noSignalThresholdColor;
|
||||
bool _signalDetectionEnabled;
|
||||
bool _cecDetectionEnabled;
|
||||
bool _cecStandbyActivated;
|
||||
bool _noSignalDetected;
|
||||
int _noSignalCounter;
|
||||
double _x_frac_min;
|
||||
|
@@ -19,6 +19,7 @@ public:
|
||||
~V4L2Wrapper() override;
|
||||
|
||||
bool getSignalDetectionEnable();
|
||||
bool getCecDetectionEnable();
|
||||
|
||||
public slots:
|
||||
bool start();
|
||||
@@ -28,9 +29,9 @@ public slots:
|
||||
void setCropping(unsigned cropLeft, unsigned cropRight, unsigned cropTop, unsigned cropBottom);
|
||||
void setSignalDetectionOffset(double verticalMin, double horizontalMin, double verticalMax, double horizontalMax);
|
||||
void setSignalDetectionEnable(bool enable);
|
||||
void setCecDetectionEnable(bool enable);
|
||||
void setDeviceVideoStandard(QString device, VideoStandard videoStandard);
|
||||
|
||||
signals:
|
||||
void handleCecEvent(CECEvent event);
|
||||
|
||||
private slots:
|
||||
void newFrame(const Image<ColorRgb> & image);
|
||||
|
@@ -80,6 +80,11 @@ public:
|
||||
///
|
||||
virtual void setSignalDetectionEnable(bool enable) {}
|
||||
|
||||
///
|
||||
/// @brief Apply CecDetectionEnable (used from v4l)
|
||||
///
|
||||
virtual void setCecDetectionEnable(bool enable) {}
|
||||
|
||||
///
|
||||
/// @brief Apply device and videoStanded (used from v4l)
|
||||
///
|
||||
|
@@ -550,6 +550,5 @@ private:
|
||||
/// Boblight instance
|
||||
BoblightServer* _boblightServer;
|
||||
|
||||
/// mutex
|
||||
QMutex _changes;
|
||||
};
|
||||
|
Reference in New Issue
Block a user