mirror of
https://github.com/hyperion-project/hyperion.ng.git
synced 2025-03-01 10:33:28 +00:00
remove kodiVideoChecker (#475)
This commit is contained in:
@@ -13,7 +13,6 @@ add_subdirectory(boblightserver)
|
||||
add_subdirectory(udplistener)
|
||||
add_subdirectory(leddevice)
|
||||
add_subdirectory(utils)
|
||||
add_subdirectory(kodivideochecker)
|
||||
add_subdirectory(effectengine)
|
||||
add_subdirectory(grabber)
|
||||
add_subdirectory(webconfig)
|
||||
|
@@ -15,8 +15,7 @@ V4L2Wrapper::V4L2Wrapper(const QString &device,
|
||||
double redSignalThreshold,
|
||||
double greenSignalThreshold,
|
||||
double blueSignalThreshold,
|
||||
const int priority,
|
||||
bool useGrabbingMode)
|
||||
const int priority)
|
||||
: GrabberWrapper("V4L2:"+device, &_grabber, width, height, 8, priority, hyperion::COMP_V4L)
|
||||
, _grabber(device,
|
||||
input,
|
||||
@@ -41,10 +40,6 @@ V4L2Wrapper::V4L2Wrapper(const QString &device,
|
||||
QObject::connect(&_grabber, SIGNAL(newFrame(Image<ColorRgb>)), this, SLOT(newFrame(Image<ColorRgb>)), Qt::DirectConnection);
|
||||
QObject::connect(&_grabber, SIGNAL(readError(const char*)), this, SLOT(readError(const char*)), Qt::DirectConnection);
|
||||
|
||||
if (!useGrabbingMode)
|
||||
{
|
||||
disconnect(_hyperion, SIGNAL(grabbingMode(GrabbingMode)), this, 0);
|
||||
}
|
||||
_timer.setInterval(500);
|
||||
}
|
||||
|
||||
@@ -83,7 +78,7 @@ void V4L2Wrapper::readError(const char* err)
|
||||
Error(_log, "stop grabber, because reading device failed. (%s)", err);
|
||||
stop();
|
||||
}
|
||||
|
||||
|
||||
void V4L2Wrapper::checkSources()
|
||||
{
|
||||
if ( _hyperion->isCurrentPriority(_priority))
|
||||
|
@@ -27,14 +27,13 @@ GrabberWrapper::GrabberWrapper(QString grabberName, Grabber * ggrabber, unsigned
|
||||
|
||||
_image.resize(width, height);
|
||||
_processor->setSize(width, height);
|
||||
|
||||
|
||||
_forward = _hyperion->getForwarder()->protoForwardingEnabled();
|
||||
_hyperion->getComponentRegister().componentStateChanged(hyperion::COMP_BLACKBORDER, _processor->blackBorderDetectorEnabled());
|
||||
qRegisterMetaType<hyperion::Components>("hyperion::Components");
|
||||
|
||||
connect(_hyperion, SIGNAL(imageToLedsMappingChanged(int)), _processor, SLOT(setLedMappingType(int)));
|
||||
connect(_hyperion, SIGNAL(imageToLedsMappingChanged(int)), _processor, SLOT(setLedMappingType(int)));
|
||||
connect(_hyperion, SIGNAL(componentStateChanged(hyperion::Components,bool)), this, SLOT(componentStateChanged(hyperion::Components,bool)));
|
||||
connect(_hyperion, SIGNAL(grabbingMode(GrabbingMode)), this, SLOT(setGrabbingMode(GrabbingMode)));
|
||||
connect(_hyperion, SIGNAL(videoMode(VideoMode)), this, SLOT(setVideoMode(VideoMode)));
|
||||
connect(this, SIGNAL(emitImage(int, const Image<ColorRgb>&, const int)), _hyperion, SLOT(setImage(int, const Image<ColorRgb>&, const int)) );
|
||||
connect(&_timer, SIGNAL(timeout()), this, SLOT(actionWrapper()));
|
||||
@@ -104,18 +103,6 @@ void GrabberWrapper::componentStateChanged(const hyperion::Components component,
|
||||
}
|
||||
}
|
||||
|
||||
void GrabberWrapper::setGrabbingMode(const GrabbingMode mode)
|
||||
{
|
||||
if (mode == GRABBINGMODE_OFF)
|
||||
{
|
||||
stop();
|
||||
}
|
||||
else
|
||||
{
|
||||
start();
|
||||
}
|
||||
}
|
||||
|
||||
void GrabberWrapper::setColors(const std::vector<ColorRgb> &ledColors, const int timeout_ms)
|
||||
{
|
||||
_hyperion->setColors(_priority, ledColors, timeout_ms, true, _grabberComponentId);
|
||||
@@ -171,4 +158,3 @@ void GrabberWrapper::setImageProcessorEnabled(bool enable)
|
||||
{
|
||||
_imageProcessorEnabled = enable;
|
||||
}
|
||||
|
||||
|
@@ -402,7 +402,6 @@ Hyperion::Hyperion(const QJsonObject &qjsonConfig, const QString configFile, con
|
||||
, _bonjourBrowser(this)
|
||||
, _bonjourResolver(this)
|
||||
, _videoMode(VIDEO_2D)
|
||||
, _grabbingMode(GRABBINGMODE_INVALID)
|
||||
{
|
||||
|
||||
if (!_raw2ledAdjustment->verifyAdjustments())
|
||||
@@ -814,12 +813,6 @@ void Hyperion::setVideoMode(VideoMode mode)
|
||||
emit videoMode(mode);
|
||||
}
|
||||
|
||||
void Hyperion::setGrabbingMode(GrabbingMode mode)
|
||||
{
|
||||
_grabbingMode = mode;
|
||||
emit grabbingMode(mode);
|
||||
}
|
||||
|
||||
|
||||
void Hyperion::hyperionStateChanged()
|
||||
{
|
||||
|
@@ -35,10 +35,6 @@
|
||||
{
|
||||
"$ref": "schema-blackborderdetector.json"
|
||||
},
|
||||
"kodiVideoChecker" :
|
||||
{
|
||||
"$ref": "schema-kodiVideoChecker.json"
|
||||
},
|
||||
"foregroundEffect" :
|
||||
{
|
||||
"$ref": "schema-foregroundEffect.json"
|
||||
|
@@ -11,7 +11,6 @@
|
||||
<file alias="schema-grabberV4L2.json">schema/schema-grabberV4L2.json</file>
|
||||
<file alias="schema-framegrabber.json">schema/schema-framegrabber.json</file>
|
||||
<file alias="schema-blackborderdetector.json">schema/schema-blackborderdetector.json</file>
|
||||
<file alias="schema-kodiVideoChecker.json">schema/schema-kodiVideoChecker.json</file>
|
||||
<file alias="schema-foregroundEffect.json">schema/schema-foregroundEffect.json</file>
|
||||
<file alias="schema-backgroundEffect.json">schema/schema-backgroundEffect.json</file>
|
||||
<file alias="schema-forwarder.json">schema/schema-forwarder.json</file>
|
||||
|
@@ -96,14 +96,6 @@
|
||||
"required" : true,
|
||||
"propertyOrder" : 9
|
||||
},
|
||||
"useKodiChecker" :
|
||||
{
|
||||
"type" : "boolean",
|
||||
"title" : "edt_conf_v4l2_useKodiChecker_title",
|
||||
"default" : false,
|
||||
"required" : true,
|
||||
"propertyOrder" : 10
|
||||
},
|
||||
"cropLeft" :
|
||||
{
|
||||
"type" : "integer",
|
||||
|
@@ -1,80 +0,0 @@
|
||||
{
|
||||
"type" : "object",
|
||||
"title" : "edt_conf_kodic_heading_title",
|
||||
"properties" :
|
||||
{
|
||||
"enable" :
|
||||
{
|
||||
"type" : "boolean",
|
||||
"title" : "edt_conf_general_enable_title",
|
||||
"default" : false,
|
||||
"propertyOrder" : 1
|
||||
},
|
||||
"kodiAddress" :
|
||||
{
|
||||
"type" : "string",
|
||||
"title" : "edt_conf_kodic_kodiAddress_title",
|
||||
"default" : "127.0.0.1",
|
||||
"propertyOrder" : 2
|
||||
},
|
||||
"kodiTcpPort" :
|
||||
{
|
||||
"type" : "integer",
|
||||
"title" : "edt_conf_kodic_kodiTcpPort_title",
|
||||
"minimum" : 0,
|
||||
"maximum" : 65535,
|
||||
"default" : 9090,
|
||||
"propertyOrder" : 3
|
||||
},
|
||||
"grabVideo" :
|
||||
{
|
||||
"type" : "boolean",
|
||||
"title" : "edt_conf_kodic_grabVideo_title",
|
||||
"default" : true,
|
||||
"propertyOrder" : 4
|
||||
},
|
||||
"grabPictures" :
|
||||
{
|
||||
"type" : "boolean",
|
||||
"title" : "edt_conf_kodic_grabPictures_title",
|
||||
"default" : true,
|
||||
"propertyOrder" : 5
|
||||
},
|
||||
"grabAudio" :
|
||||
{
|
||||
"type" : "boolean",
|
||||
"title" : "edt_conf_kodic_grabAudio_title",
|
||||
"default" : true,
|
||||
"propertyOrder" : 6
|
||||
},
|
||||
"grabMenu" :
|
||||
{
|
||||
"type" : "boolean",
|
||||
"title" : "edt_conf_kodic_grabMenu_title",
|
||||
"default" : false,
|
||||
"propertyOrder" : 7
|
||||
},
|
||||
"grabPause" :
|
||||
{
|
||||
"type" : "boolean",
|
||||
"title" : "edt_conf_kodic_grabPause_title",
|
||||
"default" : false,
|
||||
"propertyOrder" : 8
|
||||
},
|
||||
"grabScreensaver" :
|
||||
{
|
||||
"type" : "boolean",
|
||||
"title" : "edt_conf_kodic_grabScreensaver_title",
|
||||
"default" : false,
|
||||
"propertyOrder" : 9
|
||||
},
|
||||
"enable3DDetection" :
|
||||
{
|
||||
"type" : "boolean",
|
||||
"title" : "edt_conf_kodic_enable3DDetection_title",
|
||||
"default" : false,
|
||||
"propertyOrder" : 10
|
||||
}
|
||||
},
|
||||
"additionalProperties" : false
|
||||
}
|
@@ -1,12 +0,0 @@
|
||||
|
||||
# Define the current source locations
|
||||
SET(CURRENT_HEADER_DIR ${CMAKE_SOURCE_DIR}/include/kodivideochecker)
|
||||
SET(CURRENT_SOURCE_DIR ${CMAKE_SOURCE_DIR}/libsrc/kodivideochecker)
|
||||
|
||||
FILE ( GLOB KODIVideoChecker_SOURCES "${CURRENT_HEADER_DIR}/*.h" "${CURRENT_SOURCE_DIR}/*.h" "${CURRENT_SOURCE_DIR}/*.cpp" )
|
||||
|
||||
add_library(kodivideochecker ${KODIVideoChecker_SOURCES} )
|
||||
|
||||
target_link_libraries(kodivideochecker
|
||||
hyperion
|
||||
${QT_LIBRARIES})
|
@@ -1,507 +0,0 @@
|
||||
// Qt includes
|
||||
#include <QJsonDocument>
|
||||
#include <QJsonObject>
|
||||
#include <QJsonArray>
|
||||
|
||||
#include <kodivideochecker/KODIVideoChecker.h>
|
||||
#include <hyperion/Hyperion.h>
|
||||
|
||||
using namespace hyperion;
|
||||
|
||||
KODIVideoChecker* KODIVideoChecker::_kodichecker = nullptr;
|
||||
|
||||
KODIVideoChecker* KODIVideoChecker::initInstance(const QString & address, uint16_t port, bool grabVideo, bool grabPhoto, bool grabAudio, bool grabMenu, bool grabPause, bool grabScreensaver, bool enable3DDetection)
|
||||
{
|
||||
if ( KODIVideoChecker::_kodichecker != nullptr )
|
||||
throw std::runtime_error("KODIVideoChecker::initInstance can be called only one time");
|
||||
KODIVideoChecker::_kodichecker = new KODIVideoChecker(address, port, grabVideo, grabPhoto, grabAudio, grabMenu, grabPause, grabScreensaver, enable3DDetection);
|
||||
|
||||
return KODIVideoChecker::_kodichecker;
|
||||
}
|
||||
|
||||
KODIVideoChecker* KODIVideoChecker::getInstance()
|
||||
{
|
||||
return KODIVideoChecker::_kodichecker;
|
||||
}
|
||||
|
||||
|
||||
// Request player example:
|
||||
// {"jsonrpc":"2.0","method":"Player.GetActivePlayers", "id":666}
|
||||
// {"id":666,"jsonrpc":"2.0","result":[{"playerid":1,"type":"video"}]}
|
||||
|
||||
// Request playing item example:
|
||||
// {"id":667,"jsonrpc":"2.0","method":"Player.GetItem","params":{"playerid":1,"properties":["file"]}}
|
||||
// {"id":667,"jsonrpc":"2.0","result":{"item":{"file":"smb://xbmc:xbmc@192.168.53.12/video/Movies/Avatar (2009)/Avatar.mkv","label":"Avatar","type":"unknown"}}}
|
||||
|
||||
// Request if screensaver is on
|
||||
// {"id":668,"jsonrpc":"2.0","method":"XBMC.GetInfoBooleans","params":{"booleans":["System.ScreenSaverActive"]}}
|
||||
// {"id":668,"jsonrpc":"2.0","result":{"System.ScreenSaverActive":false}}
|
||||
|
||||
// Request stereoscopicmode example:
|
||||
// {"jsonrpc":"2.0","method":"GUI.GetProperties","params":{"properties":["stereoscopicmode"]},"id":669}
|
||||
// {"id":669,"jsonrpc":"2.0","result":{"stereoscopicmode":{"label":"Nebeneinander","mode":"split_vertical"}}}
|
||||
|
||||
KODIVideoChecker::KODIVideoChecker(const QString & address, uint16_t port, bool grabVideo, bool grabPhoto, bool grabAudio, bool grabMenu, bool grabPause, bool grabScreensaver, bool enable3DDetection)
|
||||
: QObject()
|
||||
, _address(address)
|
||||
, _port(port)
|
||||
, _activePlayerRequest(R"({"jsonrpc":"2.0","method":"Player.GetActivePlayers", "id":666})")
|
||||
, _currentPlayingItemRequest(R"({"id":667,"jsonrpc":"2.0","method":"Player.GetItem","params":{"playerid":%1,"properties":["file"]}})")
|
||||
, _checkScreensaverRequest(R"({"id":668,"jsonrpc":"2.0","method":"XBMC.GetInfoBooleans","params":{"booleans":["System.ScreenSaverActive"]}})")
|
||||
, _getStereoscopicMode(R"({"jsonrpc":"2.0","method":"GUI.GetProperties","params":{"properties":["stereoscopicmode"]},"id":669})")
|
||||
, _getKodiVersion(R"({"jsonrpc":"2.0","method":"Application.GetProperties","params":{"properties":["version"]},"id":670})")
|
||||
, _getCurrentPlaybackState(R"({"id":671,"jsonrpc":"2.0","method":"Player.GetProperties","params":{"playerid":%1,"properties":["speed"]}})")
|
||||
, _socket()
|
||||
, _grabVideo(grabVideo)
|
||||
, _grabPhoto(grabPhoto)
|
||||
, _grabAudio(grabAudio)
|
||||
, _grabMenu(grabMenu)
|
||||
, _grabPause(grabPause)
|
||||
, _grabScreensaver(grabScreensaver)
|
||||
, _enable3DDetection(enable3DDetection)
|
||||
, _previousGrabbingMode(GRABBINGMODE_INVALID)
|
||||
, _previousVideoMode(VIDEO_2D)
|
||||
, _currentPlaybackState(false)
|
||||
, _currentPlayerID(0)
|
||||
, _kodiVersion(0)
|
||||
, _log(Logger::getInstance("KODI"))
|
||||
, _active(false)
|
||||
, _getCurrentPlaybackStateInitialized(false)
|
||||
{
|
||||
// setup socket
|
||||
connect(&_socket, SIGNAL(readyRead()), this, SLOT(receiveReply()));
|
||||
connect(&_socket, SIGNAL(disconnected()), this, SLOT(disconnected()));
|
||||
connect(&_socket, SIGNAL(connected()), this, SLOT(connected()));
|
||||
connect(&_socket, SIGNAL(error(QAbstractSocket::SocketError)), this, SLOT(connectionError(QAbstractSocket::SocketError)));
|
||||
}
|
||||
|
||||
KODIVideoChecker::~KODIVideoChecker()
|
||||
{
|
||||
stop();
|
||||
}
|
||||
|
||||
|
||||
void KODIVideoChecker::setConfig(const QString & address, uint16_t port, bool grabVideo, bool grabPhoto, bool grabAudio, bool grabMenu, bool grabPause, bool grabScreensaver, bool enable3DDetection)
|
||||
{
|
||||
_address = address;
|
||||
_port = port;
|
||||
_grabVideo = grabVideo;
|
||||
_grabPhoto = grabPhoto;
|
||||
_grabAudio = grabAudio;
|
||||
_grabMenu = grabMenu;
|
||||
_grabPause = grabPause;
|
||||
_grabScreensaver = grabScreensaver;
|
||||
_enable3DDetection = enable3DDetection;
|
||||
_previousGrabbingMode = GRABBINGMODE_INVALID;
|
||||
_previousVideoMode = VIDEO_2D;
|
||||
_kodiVersion = 0;
|
||||
|
||||
// restart if active
|
||||
if (_active)
|
||||
{
|
||||
stop();
|
||||
QTimer::singleShot(2000, this, SLOT(()));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void KODIVideoChecker::start()
|
||||
{
|
||||
Info(_log, "started");
|
||||
_active = true;
|
||||
reconnect();
|
||||
}
|
||||
|
||||
void KODIVideoChecker::stop()
|
||||
{
|
||||
Info(_log, "stopped");
|
||||
_active = false;
|
||||
_socket.close();
|
||||
}
|
||||
|
||||
void KODIVideoChecker::componentStateChanged(const hyperion::Components component, bool enable)
|
||||
{
|
||||
if (component == COMP_KODICHECKER)
|
||||
{
|
||||
if (_active != enable)
|
||||
{
|
||||
if (enable) start();
|
||||
else stop();
|
||||
Info(_log, "change state to %s", (_active ? "enabled" : "disabled") );
|
||||
}
|
||||
Hyperion::getInstance()->getComponentRegister().componentStateChanged(component, _active);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void KODIVideoChecker::receiveReply()
|
||||
{
|
||||
QJsonParseError error;
|
||||
QByteArray qtreply = _socket.readAll();
|
||||
QJsonDocument doc = QJsonDocument::fromJson(qtreply, &error);
|
||||
|
||||
if (error.error == QJsonParseError::NoError)
|
||||
{
|
||||
if (doc.isObject())
|
||||
{
|
||||
Debug(_log, "message: %s", doc.toJson(QJsonDocument::Compact).constData());
|
||||
|
||||
// Reply
|
||||
if (doc.object().contains("id"))
|
||||
{
|
||||
|
||||
int id = doc.object()["id"].toInt();
|
||||
switch (id)
|
||||
{
|
||||
case 666:
|
||||
{
|
||||
if (doc.object()["result"].isArray())
|
||||
{
|
||||
QJsonArray resultArray = doc.object()["result"].toArray();
|
||||
|
||||
if (!resultArray.isEmpty())
|
||||
{
|
||||
// always start a new video in 2D mode
|
||||
emit videoMode(VIDEO_2D);
|
||||
|
||||
QString type = resultArray[0].toObject()["type"].toString();
|
||||
|
||||
int prevCurrentPlayerID = _currentPlayerID;
|
||||
_currentPlayerID = resultArray[0].toObject()["playerid"].toInt();
|
||||
|
||||
// set initial player state
|
||||
if (! _getCurrentPlaybackStateInitialized && prevCurrentPlayerID == 0 && _currentPlayerID != 0)
|
||||
{
|
||||
_socket.write(_getCurrentPlaybackState.arg(_currentPlayerID).toUtf8());
|
||||
_getCurrentPlaybackStateInitialized = true;
|
||||
return;
|
||||
}
|
||||
|
||||
if (type == "video")
|
||||
{
|
||||
if (_currentPlaybackState)
|
||||
{
|
||||
// video is playing
|
||||
setGrabbingMode(_grabVideo ? GRABBINGMODE_VIDEO : GRABBINGMODE_OFF);
|
||||
}
|
||||
else
|
||||
{
|
||||
setGrabbingMode(_grabPause ? GRABBINGMODE_PAUSE : GRABBINGMODE_OFF);
|
||||
}
|
||||
|
||||
// request info of the playing item
|
||||
_socket.write(_currentPlayingItemRequest.arg(_currentPlayerID).toUtf8());
|
||||
}
|
||||
else if (type == "picture")
|
||||
{
|
||||
if (_currentPlaybackState)
|
||||
{
|
||||
// picture is playing
|
||||
setGrabbingMode(_grabPhoto ? GRABBINGMODE_PHOTO : GRABBINGMODE_OFF);
|
||||
}
|
||||
else
|
||||
{
|
||||
setGrabbingMode(_grabPause ? GRABBINGMODE_PAUSE : GRABBINGMODE_OFF);
|
||||
}
|
||||
}
|
||||
else if (type == "audio")
|
||||
{
|
||||
// audio is playing
|
||||
if (_currentPlaybackState)
|
||||
{
|
||||
// audio is playing
|
||||
setGrabbingMode(_grabAudio ? GRABBINGMODE_AUDIO : GRABBINGMODE_OFF);
|
||||
}
|
||||
else
|
||||
{
|
||||
setGrabbingMode(_grabPause ? GRABBINGMODE_PAUSE : GRABBINGMODE_OFF);
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// Nothing is playing.
|
||||
setGrabbingMode(_grabMenu ? GRABBINGMODE_MENU : GRABBINGMODE_OFF);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
setGrabbingMode(_grabMenu ? GRABBINGMODE_MENU : GRABBINGMODE_OFF);
|
||||
}
|
||||
break;
|
||||
}
|
||||
case 667:
|
||||
{
|
||||
if (_kodiVersion >= 13)
|
||||
{
|
||||
// check of active stereoscopicmode
|
||||
_socket.write(_getStereoscopicMode.toUtf8());
|
||||
}
|
||||
else
|
||||
{
|
||||
if (doc.object()["result"].toObject()["item"].toObject().contains("file"))
|
||||
{
|
||||
QString filename = doc.object()["result"].toObject()["item"].toObject()["file"].toString();
|
||||
if (filename.contains("3DSBS", Qt::CaseInsensitive) || filename.contains("HSBS", Qt::CaseInsensitive))
|
||||
setVideoMode(VIDEO_3DSBS);
|
||||
else if (filename.contains("3DTAB", Qt::CaseInsensitive) || filename.contains("HTAB", Qt::CaseInsensitive))
|
||||
setVideoMode(VIDEO_3DTAB);
|
||||
else
|
||||
setVideoMode(VIDEO_2D);
|
||||
}
|
||||
else
|
||||
{
|
||||
setGrabbingMode(_grabMenu ? GRABBINGMODE_MENU : GRABBINGMODE_OFF);
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
case 668:
|
||||
{
|
||||
if (doc.object()["result"].toObject().contains("System.ScreenSaverActive"))
|
||||
{
|
||||
// result of System.ScreenSaverActive
|
||||
if (doc.object()["result"].toObject()["System.ScreenSaverActive"].toBool())
|
||||
setGrabbingMode(_grabScreensaver ? GRABBINGMODE_SCREENSAVER : GRABBINGMODE_OFF);
|
||||
else
|
||||
_socket.write(_activePlayerRequest.toUtf8());
|
||||
|
||||
// check here kodi version
|
||||
if (_socket.state() == QTcpSocket::ConnectedState)
|
||||
{
|
||||
if (_kodiVersion == 0)
|
||||
{
|
||||
_socket.write(_getKodiVersion.toUtf8());
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
setGrabbingMode(_grabMenu ? GRABBINGMODE_MENU : GRABBINGMODE_OFF);
|
||||
}
|
||||
break;
|
||||
}
|
||||
case 669:
|
||||
{
|
||||
if (doc.object()["result"].toObject()["stereoscopicmode"].toObject().contains("mode"))
|
||||
{
|
||||
// result of stereoscopicmode
|
||||
QString mode = doc.object()["result"].toObject()["stereoscopicmode"].toObject()["mode"].toString();
|
||||
if (mode == "split_vertical")
|
||||
setVideoMode(VIDEO_3DSBS);
|
||||
else if (mode == "split_horizontal")
|
||||
setVideoMode(VIDEO_3DTAB);
|
||||
}
|
||||
else
|
||||
{
|
||||
setGrabbingMode(_grabMenu ? GRABBINGMODE_MENU : GRABBINGMODE_OFF);
|
||||
}
|
||||
break;
|
||||
}
|
||||
case 670:
|
||||
{
|
||||
if (doc.object()["result"].toObject()["version"].toObject().contains("major"))
|
||||
{
|
||||
// kodi major version
|
||||
_kodiVersion = doc.object()["result"].toObject()["version"].toObject()["major"].toInt();
|
||||
}
|
||||
else
|
||||
{
|
||||
setGrabbingMode(_grabMenu ? GRABBINGMODE_MENU : GRABBINGMODE_OFF);
|
||||
}
|
||||
break;
|
||||
}
|
||||
case 671:
|
||||
{
|
||||
if (doc.object()["result"].toObject().contains("speed"))
|
||||
{
|
||||
// result of Player.PlayPause
|
||||
_currentPlaybackState = static_cast<bool>(doc.object()["result"].toObject()["speed"].toInt());
|
||||
}
|
||||
else
|
||||
{
|
||||
setGrabbingMode(_grabMenu ? GRABBINGMODE_MENU : GRABBINGMODE_OFF);
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
// Notification
|
||||
else if (doc.object().contains("method"))
|
||||
{
|
||||
QString method = doc.object()["method"].toString();
|
||||
if (method == "Player.OnPlay")
|
||||
{
|
||||
if (doc.object()["params"].toObject()["data"].toObject()["player"].toObject().contains("speed"))
|
||||
{
|
||||
_getCurrentPlaybackStateInitialized = true;
|
||||
_currentPlaybackState = static_cast<bool>(doc.object()["params"].toObject()["data"].toObject()["player"].toObject()["speed"].toInt());
|
||||
}
|
||||
// send a request for the current player state
|
||||
_socket.write(_activePlayerRequest.toUtf8());
|
||||
return;
|
||||
}
|
||||
else if (method == "Player.OnStop")
|
||||
{
|
||||
// the player has stopped
|
||||
setGrabbingMode(_grabMenu ? GRABBINGMODE_MENU : GRABBINGMODE_OFF);
|
||||
setVideoMode(VIDEO_2D);
|
||||
}
|
||||
else if (method == "Player.OnPause")
|
||||
{
|
||||
if (doc.object()["params"].toObject()["data"].toObject()["player"].toObject().contains("speed"))
|
||||
{
|
||||
_getCurrentPlaybackStateInitialized = true;
|
||||
_currentPlaybackState = static_cast<bool>(doc.object()["params"].toObject()["data"].toObject()["player"].toObject()["speed"].toInt());
|
||||
}
|
||||
// player at pause
|
||||
setGrabbingMode(_grabPause ? GRABBINGMODE_PAUSE : GRABBINGMODE_OFF);
|
||||
}
|
||||
else if (method == "GUI.OnScreensaverActivated")
|
||||
setGrabbingMode(_grabScreensaver ? GRABBINGMODE_SCREENSAVER : GRABBINGMODE_OFF);
|
||||
else if (method == "GUI.OnScreensaverDeactivated")
|
||||
_socket.write(_activePlayerRequest.toUtf8());
|
||||
else if (method == "Playlist.OnAdd" &&
|
||||
(doc.object()["params"]
|
||||
.toObject()["data"]
|
||||
.toObject()["item"]
|
||||
.toObject()["type"]) == QString("picture"))
|
||||
{
|
||||
// picture viewer is playing
|
||||
setGrabbingMode(_grabPhoto ? GRABBINGMODE_PHOTO : GRABBINGMODE_OFF);
|
||||
}
|
||||
else if (method == "Input.OnInputFinished")
|
||||
{
|
||||
// This Event is fired when Kodi Login
|
||||
_socket.write(_activePlayerRequest.toUtf8());
|
||||
_socket.write(_checkScreensaverRequest.toUtf8());
|
||||
if (_currentPlayerID != 0)
|
||||
_socket.write(_getCurrentPlaybackState.arg(_currentPlayerID).toUtf8());
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
Debug(_log, "Incomplete data");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void KODIVideoChecker::connected()
|
||||
{
|
||||
Info(_log, "Connected");
|
||||
_getCurrentPlaybackStateInitialized = false;
|
||||
// send a request for the current player state
|
||||
_socket.write(_activePlayerRequest.toUtf8());
|
||||
_socket.write(_checkScreensaverRequest.toUtf8());
|
||||
}
|
||||
|
||||
void KODIVideoChecker::disconnected()
|
||||
{
|
||||
Info(_log, "Disconnected");
|
||||
_previousGrabbingMode = GRABBINGMODE_INVALID;
|
||||
_previousVideoMode = VIDEO_2D;
|
||||
_kodiVersion = 0;
|
||||
reconnect();
|
||||
}
|
||||
|
||||
void KODIVideoChecker::reconnect()
|
||||
{
|
||||
if (_socket.state() == QTcpSocket::ConnectedState || ! _active )
|
||||
{
|
||||
return;
|
||||
}
|
||||
Debug(_log, "try reconnect");
|
||||
|
||||
// try to connect
|
||||
switch (_socket.state())
|
||||
{
|
||||
case QTcpSocket::ConnectingState:
|
||||
// Somehow when KODI restarts we get stuck in connecting state
|
||||
// If we get here we tried to connect already for 5 seconds. abort and try again in 1 second.
|
||||
_socket.reset();
|
||||
_socket.waitForDisconnected(50);
|
||||
QTimer::singleShot(1000, this, SLOT(reconnect()));
|
||||
break;
|
||||
case QTcpSocket::UnconnectedState:
|
||||
_socket.connectToHost(_address, _port);
|
||||
QTimer::singleShot(10000, this, SLOT(reconnect()));
|
||||
break;
|
||||
default:
|
||||
QTimer::singleShot(10000, this, SLOT(reconnect()));
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
void KODIVideoChecker::connectionError(QAbstractSocket::SocketError error)
|
||||
{
|
||||
Error(_log,"Connection error (%s)", _socket.errorString().toStdString().c_str());
|
||||
|
||||
// close the socket
|
||||
_socket.close();
|
||||
}
|
||||
|
||||
void KODIVideoChecker::setGrabbingMode(GrabbingMode newGrabbingMode)
|
||||
{
|
||||
if (newGrabbingMode == _previousGrabbingMode)
|
||||
{
|
||||
// no change
|
||||
return;
|
||||
}
|
||||
|
||||
switch (newGrabbingMode)
|
||||
{
|
||||
case GRABBINGMODE_VIDEO:
|
||||
Info(_log, "switching to VIDEO mode");
|
||||
break;
|
||||
case GRABBINGMODE_PHOTO:
|
||||
Info(_log, "switching to PHOTO mode");
|
||||
break;
|
||||
case GRABBINGMODE_AUDIO:
|
||||
Info(_log, "switching to AUDIO mode");
|
||||
break;
|
||||
case GRABBINGMODE_MENU:
|
||||
Info(_log, "switching to MENU mode");
|
||||
break;
|
||||
case GRABBINGMODE_PAUSE:
|
||||
Info(_log, "switching to PAUSE mode");
|
||||
break;
|
||||
case GRABBINGMODE_OFF:
|
||||
Info(_log, "switching to OFF mode");
|
||||
break;
|
||||
case GRABBINGMODE_SCREENSAVER:
|
||||
Info(_log, "switching to SCREENSAVER mode");
|
||||
break;
|
||||
default:
|
||||
Warning(_log, "switching to INVALID mode");
|
||||
break;
|
||||
}
|
||||
|
||||
emit grabbingMode(newGrabbingMode);
|
||||
_previousGrabbingMode = newGrabbingMode;
|
||||
}
|
||||
|
||||
void KODIVideoChecker::setVideoMode(VideoMode newVideoMode)
|
||||
{
|
||||
if (newVideoMode == _previousVideoMode)
|
||||
{
|
||||
// no change
|
||||
return;
|
||||
}
|
||||
|
||||
switch (newVideoMode)
|
||||
{
|
||||
case VIDEO_2D:
|
||||
Info(_log, "switching to 2D mode");
|
||||
break;
|
||||
case VIDEO_3DSBS:
|
||||
Info(_log, "switching to 3D SBS mode");
|
||||
break;
|
||||
case VIDEO_3DTAB:
|
||||
Info(_log, "switching to 3D TAB mode");
|
||||
break;
|
||||
}
|
||||
|
||||
emit videoMode(newVideoMode);
|
||||
_previousVideoMode = newVideoMode;
|
||||
}
|
@@ -34,7 +34,7 @@ ProtoClientConnection::ProtoClientConnection(QTcpSocket *socket)
|
||||
// connect internal signals and slots
|
||||
connect(_socket, SIGNAL(disconnected()), this, SLOT(socketClosed()));
|
||||
connect(_socket, SIGNAL(readyRead()), this, SLOT(readData()));
|
||||
connect(_hyperion, SIGNAL(imageToLedsMappingChanged(int)), _imageProcessor, SLOT(setLedMappingType(int)));
|
||||
connect(_hyperion, SIGNAL(imageToLedsMappingChanged(int)), _imageProcessor, SLOT(setLedMappingType(int)));
|
||||
}
|
||||
|
||||
ProtoClientConnection::~ProtoClientConnection()
|
||||
@@ -85,27 +85,14 @@ void ProtoClientConnection::socketClosed()
|
||||
emit connectionClosed(this);
|
||||
}
|
||||
|
||||
void ProtoClientConnection::setGrabbingMode(const GrabbingMode mode)
|
||||
{
|
||||
int grabbing_mode = (int)mode;
|
||||
proto::HyperionReply gMode;
|
||||
|
||||
// create proto message
|
||||
gMode.set_type(proto::HyperionReply::GRABBING);
|
||||
gMode.set_grabbing(grabbing_mode);
|
||||
|
||||
// send message
|
||||
sendMessage(gMode);
|
||||
}
|
||||
|
||||
void ProtoClientConnection::setVideoMode(const VideoMode videoMode)
|
||||
{
|
||||
int video_Mode = (int)videoMode;
|
||||
proto::HyperionReply vMode;
|
||||
|
||||
|
||||
// create proto message
|
||||
vMode.set_type(proto::HyperionReply::VIDEO);
|
||||
vMode.set_grabbing(video_Mode);
|
||||
vMode.set_video(video_Mode);
|
||||
|
||||
// send message
|
||||
sendMessage(vMode);
|
||||
@@ -149,7 +136,7 @@ void ProtoClientConnection::handleMessage(const proto::HyperionRequest & message
|
||||
default:
|
||||
handleNotImplemented();
|
||||
}
|
||||
|
||||
|
||||
if (prevPriority != _priority)
|
||||
{
|
||||
_hyperion->registerPriority(_priorityChannelName, _priority);
|
||||
|
@@ -13,7 +13,6 @@
|
||||
#include <hyperion/Hyperion.h>
|
||||
|
||||
//Utils includes
|
||||
#include <utils/GrabbingMode.h>
|
||||
#include <utils/VideoMode.h>
|
||||
|
||||
// proto includes
|
||||
@@ -41,12 +40,11 @@ public:
|
||||
/// Destructor
|
||||
///
|
||||
~ProtoClientConnection();
|
||||
|
||||
|
||||
public slots:
|
||||
///
|
||||
/// Send KODI Video Checker message to connected client
|
||||
/// Send video mode message to connected client
|
||||
///
|
||||
void setGrabbingMode(const GrabbingMode mode);
|
||||
void setVideoMode(const VideoMode videoMode);
|
||||
|
||||
signals:
|
||||
@@ -138,9 +136,9 @@ private:
|
||||
|
||||
/// The buffer used for reading data from the socket
|
||||
QByteArray _receiveBuffer;
|
||||
|
||||
|
||||
int _priority;
|
||||
|
||||
|
||||
QString _priorityChannelName;
|
||||
|
||||
/// address of client
|
||||
|
@@ -47,7 +47,7 @@ ProtoConnection::~ProtoConnection()
|
||||
}
|
||||
|
||||
void ProtoConnection::readData()
|
||||
{
|
||||
{
|
||||
_receiveBuffer += _socket.readAll();
|
||||
|
||||
// check if we can read a message size
|
||||
@@ -68,18 +68,18 @@ void ProtoConnection::readData()
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
// read a message
|
||||
proto::HyperionReply reply;
|
||||
|
||||
|
||||
if (!reply.ParseFromArray(_receiveBuffer.data() + 4, messageSize))
|
||||
{
|
||||
Error(_log, "Unable to parse message");
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
parseReply(reply);
|
||||
|
||||
|
||||
// remove message data from buffer
|
||||
_receiveBuffer = _receiveBuffer.mid(messageSize + 4);
|
||||
}
|
||||
@@ -139,7 +139,7 @@ void ProtoConnection::clearAll()
|
||||
|
||||
void ProtoConnection::connectToHost()
|
||||
{
|
||||
// try connection only when
|
||||
// try connection only when
|
||||
if (_socket.state() == QAbstractSocket::UnconnectedState)
|
||||
{
|
||||
_socket.connectToHost(_host, _port);
|
||||
@@ -201,7 +201,7 @@ void ProtoConnection::sendMessage(const proto::HyperionRequest &message)
|
||||
bool ProtoConnection::parseReply(const proto::HyperionReply &reply)
|
||||
{
|
||||
bool success = false;
|
||||
|
||||
|
||||
switch (reply.type())
|
||||
{
|
||||
case proto::HyperionReply::REPLY:
|
||||
@@ -226,13 +226,6 @@ bool ProtoConnection::parseReply(const proto::HyperionReply &reply)
|
||||
}
|
||||
break;
|
||||
}
|
||||
case proto::HyperionReply::GRABBING:
|
||||
{
|
||||
int grabbing = reply.has_grabbing() ? reply.grabbing() : 7;
|
||||
GrabbingMode gMode = (GrabbingMode)grabbing;
|
||||
emit setGrabbingMode(gMode);
|
||||
break;
|
||||
}
|
||||
case proto::HyperionReply::VIDEO:
|
||||
{
|
||||
int video = reply.has_video() ? reply.video() : 0;
|
||||
@@ -241,6 +234,6 @@ bool ProtoConnection::parseReply(const proto::HyperionReply &reply)
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
return success;
|
||||
}
|
||||
|
@@ -10,7 +10,6 @@ ProtoConnectionWrapper::ProtoConnectionWrapper(const QString &address,
|
||||
, _connection(address)
|
||||
{
|
||||
_connection.setSkipReply(skipProtoReply);
|
||||
connect(&_connection, SIGNAL(setGrabbingMode(GrabbingMode)), this, SIGNAL(setGrabbingMode(GrabbingMode)));
|
||||
connect(&_connection, SIGNAL(setVideoMode(VideoMode)), this, SIGNAL(setVideoMode(VideoMode)));
|
||||
}
|
||||
|
||||
|
@@ -45,7 +45,7 @@ ProtoServer::~ProtoServer()
|
||||
foreach (ProtoClientConnection * connection, _openConnections) {
|
||||
delete connection;
|
||||
}
|
||||
|
||||
|
||||
while (!_proxy_connections.isEmpty())
|
||||
delete _proxy_connections.takeFirst();
|
||||
}
|
||||
@@ -68,11 +68,9 @@ void ProtoServer::newConnection()
|
||||
// register slot for cleaning up after the connection closed
|
||||
connect(connection, SIGNAL(connectionClosed(ProtoClientConnection*)), this, SLOT(closedConnection(ProtoClientConnection*)));
|
||||
connect(connection, SIGNAL(newMessage(const proto::HyperionRequest*)), this, SLOT(newMessage(const proto::HyperionRequest*)));
|
||||
|
||||
// register forward signal for kodi checker
|
||||
connect(this, SIGNAL(grabbingMode(GrabbingMode)), connection, SLOT(setGrabbingMode(GrabbingMode)));
|
||||
connect(this, SIGNAL(videoMode(VideoMode)), connection, SLOT(setVideoMode(VideoMode)));
|
||||
|
||||
// register forward signal for video mode
|
||||
connect(this, SIGNAL(videoMode(VideoMode)), connection, SLOT(setVideoMode(VideoMode)));
|
||||
}
|
||||
}
|
||||
|
||||
|
@@ -63,22 +63,18 @@ message ClearRequest {
|
||||
message HyperionReply {
|
||||
enum Type {
|
||||
REPLY = 1;
|
||||
GRABBING = 2;
|
||||
VIDEO = 3;
|
||||
VIDEO = 2;
|
||||
}
|
||||
|
||||
|
||||
// Identifies which field is filled in.
|
||||
required Type type = 1;
|
||||
|
||||
|
||||
// flag indication success or failure
|
||||
optional bool success = 2;
|
||||
|
||||
// string indicating the reason for failure (if applicable)
|
||||
optional string error = 3;
|
||||
|
||||
// KODI Video Checker Proto Messages for Grabbing mode
|
||||
optional int32 grabbing = 4;
|
||||
|
||||
// KODI Video Checker Proto Messages for Video mode
|
||||
optional int32 video = 5;
|
||||
// Proto Messages for video mode
|
||||
optional int32 video = 4;
|
||||
}
|
||||
|
@@ -21,7 +21,7 @@
|
||||
"component":
|
||||
{
|
||||
"type" : "string",
|
||||
"enum" : ["ALL", "SMOOTHING", "BLACKBORDER", "KODICHECKER", "FORWARDER", "UDPLISTENER", "BOBLIGHTSERVER", "GRABBER", "V4L", "LEDDEVICE"],
|
||||
"enum" : ["ALL", "SMOOTHING", "BLACKBORDER", "FORWARDER", "UDPLISTENER", "BOBLIGHTSERVER", "GRABBER", "V4L", "LEDDEVICE"],
|
||||
"required": true
|
||||
},
|
||||
"state":
|
||||
|
Reference in New Issue
Block a user