Merge remote-tracking branch 'remotes/origin/master'

Former-commit-id: 074fda5f355536bb2782119850117a403404677c
This commit is contained in:
T. van der Zwan 2013-10-05 18:46:19 +02:00
commit f37af20fd6
10 changed files with 149 additions and 49 deletions

View File

@ -1,24 +1,27 @@
#!/bin/sh #!/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 # Make sure that the boblight daemon is no longer running
initctl stop xbmc BOBLIGHT_PROCNR=$(ps -e | grep "boblight" | wc -l)
initctl stop boblight 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 # Stop hyperion daemon if it is running
cp libbob2hyperion.so /usr/lib/libbob2hyperion.so initctl stop hyperion
chmod 755 /usr/lib/libbob2hyperion.so
cp hyperion.config.json /etc/
cp hyperion.schema.json /etc/
# Remove the existing boblight client library (make backup) # Copy the hyperion-binaries to the /usr/bin
cp /usr/lib/libboblight.so.0.0.0 /usr/lib/libboblight.old wget github.com/tvdzwan/hyperion/tree/master/deploy/hyperiond -P /usr/bin/
# Rename the settings file to ensure that the boblight-deamon does not start wget github.com/tvdzwan/hyperion/tree/master/deploy/hyperion-remote -P /usr/bin/
mv /etc/bobconfig.txt /etc/bobconfig.txt.old
# Link libboblight to the new installed library # Copy the hyperion configuration file to /etc
ln -s /usr/lib/libbob2hyperion.so /usr/lib/libboblight.so.0.0.0 wget github.com/tvdzwan/hyperion/tree/master/config/hyperion.config.json -P /etc/
# Restart only XBMC # Copy the service control configuration to /etc/int
initctl start xbmc 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

Binary file not shown.

BIN
deploy/hyperiond Executable file

Binary file not shown.

View File

@ -55,10 +55,10 @@ public slots:
void stop(); void stop();
/// ///
/// \brief Set the grabbing mode /// Set the grabbing mode
/// \param mode The new grabbing mode /// @param[in] mode The new grabbing mode
/// ///
void setGrabbingMode(GrabbingMode mode); void setGrabbingMode(const GrabbingMode mode);
private: private:
/// The update rate [Hz] /// The update rate [Hz]

View File

@ -1,8 +1,13 @@
#pragma once #pragma once
/**
* Enumeration of the possible modes in which frame-grabbing is performed.
*/
enum GrabbingMode enum GrabbingMode
{ {
/** Frame grabbing is switched off */
GRABBINGMODE_OFF, GRABBINGMODE_OFF,
/** Frame grabbing during video */
GRABBINGMODE_VIDEO, GRABBINGMODE_VIDEO,
GRABBINGMODE_PHOTO, GRABBINGMODE_PHOTO,
GRABBINGMODE_AUDIO, GRABBINGMODE_AUDIO,

View File

@ -1,9 +1,22 @@
#include "DispmanxFrameGrabber.h" #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) : DispmanxFrameGrabber::DispmanxFrameGrabber(const unsigned width, const unsigned height) :
_vc_display(0), _vc_display(0),
_vc_resource(0), _vc_resource(0),
_vc_flags(0),
_width(width), _width(width),
_height(height) _height(height)
{ {
@ -50,6 +63,11 @@ DispmanxFrameGrabber::~DispmanxFrameGrabber()
bcm_host_deinit(); bcm_host_deinit();
} }
void DispmanxFrameGrabber::setFlags(const int vc_flags)
{
_vc_flags = vc_flags;
}
void DispmanxFrameGrabber::grabFrame(RgbImage& image) void DispmanxFrameGrabber::grabFrame(RgbImage& image)
{ {
// Sanity check of the given image size // Sanity check of the given image size
@ -59,7 +77,7 @@ void DispmanxFrameGrabber::grabFrame(RgbImage& image)
_vc_display = vc_dispmanx_display_open(0); _vc_display = vc_dispmanx_display_open(0);
// Create the snapshot (incl down-scaling) // 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 // Read the snapshot into the memory
void* image_ptr = image.memptr(); void* image_ptr = image.memptr();

View File

@ -26,6 +26,13 @@ public:
DispmanxFrameGrabber(const unsigned width, const unsigned height); DispmanxFrameGrabber(const unsigned width, const unsigned height);
~DispmanxFrameGrabber(); ~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 /// 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 /// 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 /// Rectangle of the captured resource that is transfered to user space
VC_RECT_T _rectangle; VC_RECT_T _rectangle;
/// Flags (transforms) for creating snapshots
int _vc_flags;
/// With of the captured snapshot [pixels] /// With of the captured snapshot [pixels]
unsigned _width; unsigned _width;
/// Height of the captured snapshot [pixels] /// Height of the captured snapshot [pixels]
unsigned _height; unsigned _height;
}; };

View File

@ -61,10 +61,23 @@ void DispmanxWrapper::stop()
_timer.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(); start();
else case GRABBINGMODE_AUDIO:
case GRABBINGMODE_PHOTO:
case GRABBINGMODE_MENU:
_frameGrabber->setFlags(0);
start();
break;
case GRABBINGMODE_OFF:
stop(); stop();
break;
case GRABBINGMODE_INVALID:
break;
}
} }

View File

@ -200,6 +200,42 @@
} }
}, },
"additionalProperties" : false "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 "additionalProperties" : false

View File

@ -2,50 +2,64 @@
// STL includes // STL includes
#include <cstdlib> #include <cstdlib>
// QT includes
#include <QResource>
// JsonSchema includes // JsonSchema includes
#include <utils/jsonschema/JsonFactory.h> #include <utils/jsonschema/JsonFactory.h>
// hyperion includes // hyperion includes
#include <hyperion/LedString.h> #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"; // read the json schema from the resource
const std::string configFile = homeDir + "/hyperion.config.json"; QResource schemaData(":/hyperion-schema");
if (!schemaData.isValid()) \
Json::Value config;
if (JsonFactory::load(schemaFile, configFile, config) < 0)
{ {
std::cerr << "UNABLE TO LOAD CONFIGURATION" << std::endl; throw std::runtime_error("Schema not found");
return -1;
} }
const Json::Value& deviceConfig = config["device"]; Json::Reader jsonReader;
if (deviceConfig.empty()) 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"]; JsonSchemaChecker schemaChecker;
if (ledConfig.empty()) schemaChecker.setSchema(schemaJson);
const Json::Value jsonConfig = JsonFactory::readJson(configFile);
schemaChecker.validate(jsonConfig);
return jsonConfig;
}
int main(int argc, char** argv)
{
if (argc != 2)
{ {
std::cout << "Missing LEDS configuration 'leds'" << std::endl; std::cerr << "Missing required configuration file to test" << std::endl;
std::cerr << "Usage: test_configfile [configfile]" << std::endl;
return 0;
} }
const Json::Value& colorConfig = config["color"]; const std::string configFile(argv[1]);
if (colorConfig.empty()) std::cout << "Configuration file selected: " << configFile.c_str() << std::endl;
std::cout << "Attemp to load...\t";
try
{ {
std::cout << "Missing COLORS configuration 'colors'" << std::endl; Json::Value value = loadConfig(configFile);
(void)value;
std::cout << "PASSED" << std::endl;
} }
else catch (std::runtime_error exception)
{ {
std::cout << "COLOR CONFIGURATION: " << colorConfig.toStyledString() << std::endl; std::cout << "FAILED" << std::endl;
std::cout << exception.what() << 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;
} }
return 0; return 0;