mirror of
https://github.com/hyperion-project/hyperion.ng.git
synced 2023-10-10 13:36:59 +02:00
Merge remote-tracking branch 'remotes/origin/master'
Former-commit-id: 074fda5f355536bb2782119850117a403404677c
This commit is contained in:
commit
f37af20fd6
@ -1,24 +1,27 @@
|
||||
#!/bin/sh
|
||||
|
||||
# Script for removing the existing boblight library and replacing it with Hyperion
|
||||
# Script for downloading and installing the latest Hyperion release
|
||||
|
||||
# First stop the current BobLight demon and XBMC
|
||||
initctl stop xbmc
|
||||
initctl stop boblight
|
||||
# Make sure that the boblight daemon is no longer running
|
||||
BOBLIGHT_PROCNR=$(ps -e | grep "boblight" | wc -l)
|
||||
if [ $BOBLIGHT_PROCNR -eq 1 ];
|
||||
then
|
||||
echo 'Found running instance of boblight. Please stop boblight via XBMC menu before installing hyperion'
|
||||
exit
|
||||
fi
|
||||
|
||||
# Install the RapsiLight library
|
||||
cp libbob2hyperion.so /usr/lib/libbob2hyperion.so
|
||||
chmod 755 /usr/lib/libbob2hyperion.so
|
||||
cp hyperion.config.json /etc/
|
||||
cp hyperion.schema.json /etc/
|
||||
# Stop hyperion daemon if it is running
|
||||
initctl stop hyperion
|
||||
|
||||
# Remove the existing boblight client library (make backup)
|
||||
cp /usr/lib/libboblight.so.0.0.0 /usr/lib/libboblight.old
|
||||
# Rename the settings file to ensure that the boblight-deamon does not start
|
||||
mv /etc/bobconfig.txt /etc/bobconfig.txt.old
|
||||
# Copy the hyperion-binaries to the /usr/bin
|
||||
wget github.com/tvdzwan/hyperion/tree/master/deploy/hyperiond -P /usr/bin/
|
||||
wget github.com/tvdzwan/hyperion/tree/master/deploy/hyperion-remote -P /usr/bin/
|
||||
|
||||
# Link libboblight to the new installed library
|
||||
ln -s /usr/lib/libbob2hyperion.so /usr/lib/libboblight.so.0.0.0
|
||||
# Copy the hyperion configuration file to /etc
|
||||
wget github.com/tvdzwan/hyperion/tree/master/config/hyperion.config.json -P /etc/
|
||||
|
||||
# Restart only XBMC
|
||||
initctl start xbmc
|
||||
# Copy the service control configuration to /etc/int
|
||||
wget github.com/tvdzwan/hyperion/tree/master/bin/hyperion.conf -P /etc/init/
|
||||
|
||||
# Start the hyperion daemon
|
||||
initctl start hyperion
|
||||
|
BIN
deploy/hyperion-remote
Executable file
BIN
deploy/hyperion-remote
Executable file
Binary file not shown.
BIN
deploy/hyperiond
Executable file
BIN
deploy/hyperiond
Executable file
Binary file not shown.
@ -55,10 +55,10 @@ public slots:
|
||||
void stop();
|
||||
|
||||
///
|
||||
/// \brief Set the grabbing mode
|
||||
/// \param mode The new grabbing mode
|
||||
/// Set the grabbing mode
|
||||
/// @param[in] mode The new grabbing mode
|
||||
///
|
||||
void setGrabbingMode(GrabbingMode mode);
|
||||
void setGrabbingMode(const GrabbingMode mode);
|
||||
|
||||
private:
|
||||
/// The update rate [Hz]
|
||||
|
@ -1,8 +1,13 @@
|
||||
#pragma once
|
||||
|
||||
/**
|
||||
* Enumeration of the possible modes in which frame-grabbing is performed.
|
||||
*/
|
||||
enum GrabbingMode
|
||||
{
|
||||
/** Frame grabbing is switched off */
|
||||
GRABBINGMODE_OFF,
|
||||
/** Frame grabbing during video */
|
||||
GRABBINGMODE_VIDEO,
|
||||
GRABBINGMODE_PHOTO,
|
||||
GRABBINGMODE_AUDIO,
|
||||
|
@ -1,9 +1,22 @@
|
||||
|
||||
#include "DispmanxFrameGrabber.h"
|
||||
|
||||
// Because the shapshot function is incompatible between versions (use of different enum as
|
||||
// third argument) and no proper version number is available as preprocessor define we cast the
|
||||
// function to the same function with the third argument as 'int'.
|
||||
// This way we can call the function in both versions of the VideoCore library without
|
||||
// switching.
|
||||
static int my_vc_dispmanx_snapshot(DISPMANX_DISPLAY_HANDLE_T display, DISPMANX_RESOURCE_HANDLE_T snapshot_resource, int transform)
|
||||
{
|
||||
typedef int (*SnapshotFunctionPtr)(DISPMANX_DISPLAY_HANDLE_T, DISPMANX_RESOURCE_HANDLE_T, int);
|
||||
SnapshotFunctionPtr snapshot = (SnapshotFunctionPtr) &vc_dispmanx_snapshot;
|
||||
return (*snapshot)(display, snapshot_resource, transform);
|
||||
}
|
||||
|
||||
DispmanxFrameGrabber::DispmanxFrameGrabber(const unsigned width, const unsigned height) :
|
||||
_vc_display(0),
|
||||
_vc_resource(0),
|
||||
_vc_flags(0),
|
||||
_width(width),
|
||||
_height(height)
|
||||
{
|
||||
@ -50,6 +63,11 @@ DispmanxFrameGrabber::~DispmanxFrameGrabber()
|
||||
bcm_host_deinit();
|
||||
}
|
||||
|
||||
void DispmanxFrameGrabber::setFlags(const int vc_flags)
|
||||
{
|
||||
_vc_flags = vc_flags;
|
||||
}
|
||||
|
||||
void DispmanxFrameGrabber::grabFrame(RgbImage& image)
|
||||
{
|
||||
// Sanity check of the given image size
|
||||
@ -59,7 +77,7 @@ void DispmanxFrameGrabber::grabFrame(RgbImage& image)
|
||||
_vc_display = vc_dispmanx_display_open(0);
|
||||
|
||||
// Create the snapshot (incl down-scaling)
|
||||
vc_dispmanx_snapshot(_vc_display, _vc_resource, VC_IMAGE_ROT0);
|
||||
my_vc_dispmanx_snapshot(_vc_display, _vc_resource, _vc_flags);
|
||||
|
||||
// Read the snapshot into the memory
|
||||
void* image_ptr = image.memptr();
|
||||
|
@ -26,6 +26,13 @@ public:
|
||||
DispmanxFrameGrabber(const unsigned width, const unsigned height);
|
||||
~DispmanxFrameGrabber();
|
||||
|
||||
///
|
||||
/// Updates the frame-grab flags as used by the VC library for frame grabbing
|
||||
///
|
||||
/// @param vc_flags The snapshot grabbing mask
|
||||
///
|
||||
void setFlags(const int vc_flags);
|
||||
|
||||
///
|
||||
/// Captures a single snapshot of the display and writes the data to the given image. The
|
||||
/// provided image should have the same dimensions as the configured values (_width and
|
||||
@ -46,8 +53,12 @@ private:
|
||||
/// Rectangle of the captured resource that is transfered to user space
|
||||
VC_RECT_T _rectangle;
|
||||
|
||||
/// Flags (transforms) for creating snapshots
|
||||
int _vc_flags;
|
||||
|
||||
/// With of the captured snapshot [pixels]
|
||||
unsigned _width;
|
||||
/// Height of the captured snapshot [pixels]
|
||||
unsigned _height;
|
||||
|
||||
};
|
||||
|
@ -61,10 +61,23 @@ void DispmanxWrapper::stop()
|
||||
_timer.stop();
|
||||
}
|
||||
|
||||
void DispmanxWrapper::setGrabbingMode(GrabbingMode mode)
|
||||
void DispmanxWrapper::setGrabbingMode(const GrabbingMode mode)
|
||||
{
|
||||
if (mode == GRABBINGMODE_VIDEO)
|
||||
switch (mode)
|
||||
{
|
||||
case GRABBINGMODE_VIDEO:
|
||||
_frameGrabber->setFlags(DISPMANX_SNAPSHOT_NO_RGB|DISPMANX_SNAPSHOT_FILL);
|
||||
start();
|
||||
else
|
||||
case GRABBINGMODE_AUDIO:
|
||||
case GRABBINGMODE_PHOTO:
|
||||
case GRABBINGMODE_MENU:
|
||||
_frameGrabber->setFlags(0);
|
||||
start();
|
||||
break;
|
||||
case GRABBINGMODE_OFF:
|
||||
stop();
|
||||
break;
|
||||
case GRABBINGMODE_INVALID:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
@ -200,6 +200,42 @@
|
||||
}
|
||||
},
|
||||
"additionalProperties" : false
|
||||
},
|
||||
"bootsequence" :
|
||||
{
|
||||
"type" : "object",
|
||||
"required" : true,
|
||||
"properties" : {
|
||||
"type" : {
|
||||
"type" : "string",
|
||||
"required" : true
|
||||
},
|
||||
"duration_ms" : {
|
||||
"type" : "integer",
|
||||
"required" : true
|
||||
}
|
||||
},
|
||||
"additionalProperties" : false
|
||||
},
|
||||
"framegrabber" :
|
||||
{
|
||||
"type" : "object",
|
||||
"required" : true,
|
||||
"properties" : {
|
||||
"width" : {
|
||||
"type" : "integer",
|
||||
"required" : true
|
||||
},
|
||||
"height" : {
|
||||
"type" : "integer",
|
||||
"required" : true
|
||||
},
|
||||
"frequency_Hz" : {
|
||||
"type" : "integer",
|
||||
"required" : true
|
||||
}
|
||||
},
|
||||
"additionalProperties" : false
|
||||
}
|
||||
},
|
||||
"additionalProperties" : false
|
||||
|
@ -2,50 +2,64 @@
|
||||
// STL includes
|
||||
#include <cstdlib>
|
||||
|
||||
// QT includes
|
||||
#include <QResource>
|
||||
|
||||
// JsonSchema includes
|
||||
#include <utils/jsonschema/JsonFactory.h>
|
||||
|
||||
// hyperion includes
|
||||
#include <hyperion/LedString.h>
|
||||
|
||||
int main()
|
||||
Json::Value loadConfig(const std::string & configFile)
|
||||
{
|
||||
std::string homeDir = getenv("RASPILIGHT_HOME");
|
||||
// make sure the resources are loaded (they may be left out after static linking)
|
||||
Q_INIT_RESOURCE(resource);
|
||||
|
||||
const std::string schemaFile = homeDir + "/hyperion.schema.json";
|
||||
const std::string configFile = homeDir + "/hyperion.config.json";
|
||||
|
||||
Json::Value config;
|
||||
if (JsonFactory::load(schemaFile, configFile, config) < 0)
|
||||
// read the json schema from the resource
|
||||
QResource schemaData(":/hyperion-schema");
|
||||
if (!schemaData.isValid()) \
|
||||
{
|
||||
std::cerr << "UNABLE TO LOAD CONFIGURATION" << std::endl;
|
||||
return -1;
|
||||
throw std::runtime_error("Schema not found");
|
||||
}
|
||||
|
||||
const Json::Value& deviceConfig = config["device"];
|
||||
if (deviceConfig.empty())
|
||||
Json::Reader jsonReader;
|
||||
Json::Value schemaJson;
|
||||
if (!jsonReader.parse(reinterpret_cast<const char *>(schemaData.data()), reinterpret_cast<const char *>(schemaData.data()) + schemaData.size(), schemaJson, false))
|
||||
{
|
||||
std::cout << "Missing DEVICE configuration 'device'" << std::endl;
|
||||
throw std::runtime_error("Schema error: " + jsonReader.getFormattedErrorMessages()) ;
|
||||
}
|
||||
const Json::Value& ledConfig = config["leds"];
|
||||
if (ledConfig.empty())
|
||||
{
|
||||
std::cout << "Missing LEDS configuration 'leds'" << std::endl;
|
||||
JsonSchemaChecker schemaChecker;
|
||||
schemaChecker.setSchema(schemaJson);
|
||||
|
||||
const Json::Value jsonConfig = JsonFactory::readJson(configFile);
|
||||
schemaChecker.validate(jsonConfig);
|
||||
|
||||
return jsonConfig;
|
||||
}
|
||||
|
||||
const Json::Value& colorConfig = config["color"];
|
||||
if (colorConfig.empty())
|
||||
int main(int argc, char** argv)
|
||||
{
|
||||
std::cout << "Missing COLORS configuration 'colors'" << std::endl;
|
||||
if (argc != 2)
|
||||
{
|
||||
std::cerr << "Missing required configuration file to test" << std::endl;
|
||||
std::cerr << "Usage: test_configfile [configfile]" << std::endl;
|
||||
return 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
std::cout << "COLOR CONFIGURATION: " << colorConfig.toStyledString() << std::endl;
|
||||
|
||||
const Json::Value& redConfig = colorConfig["red"];
|
||||
double redGamma = redConfig["gamma"].asDouble();
|
||||
std::cout << "RED GAMMA = " << redGamma << std::endl;
|
||||
std::cout << "RED GAMMA = " << colorConfig["red.gamma"].asDouble() << std::endl;
|
||||
const std::string configFile(argv[1]);
|
||||
std::cout << "Configuration file selected: " << configFile.c_str() << std::endl;
|
||||
std::cout << "Attemp to load...\t";
|
||||
try
|
||||
{
|
||||
Json::Value value = loadConfig(configFile);
|
||||
(void)value;
|
||||
std::cout << "PASSED" << std::endl;
|
||||
}
|
||||
catch (std::runtime_error exception)
|
||||
{
|
||||
std::cout << "FAILED" << std::endl;
|
||||
std::cout << exception.what() << std::endl;
|
||||
}
|
||||
|
||||
return 0;
|
||||
|
Loading…
Reference in New Issue
Block a user