mirror of
https://github.com/HifiExperiments/overte.git
synced 2025-08-09 22:51:28 +02:00
Move the local web entity logic to c++ - might not be working
This commit is contained in:
parent
40814f9086
commit
a41ae3daa9
2 changed files with 66 additions and 4 deletions
|
@ -11,11 +11,13 @@
|
||||||
|
|
||||||
#include <QCoreApplication>
|
#include <QCoreApplication>
|
||||||
#include <QDesktopServices>
|
#include <QDesktopServices>
|
||||||
|
#include <QJsonDocument>
|
||||||
#include <QThread>
|
#include <QThread>
|
||||||
#include <QUrl>
|
#include <QUrl>
|
||||||
|
|
||||||
#include <AddressManager.h>
|
#include <AddressManager.h>
|
||||||
|
|
||||||
|
#include "EntityScriptingInterface.h"
|
||||||
#include "ScreenshareScriptingInterface.h"
|
#include "ScreenshareScriptingInterface.h"
|
||||||
|
|
||||||
ScreenshareScriptingInterface::ScreenshareScriptingInterface() {
|
ScreenshareScriptingInterface::ScreenshareScriptingInterface() {
|
||||||
|
@ -25,7 +27,11 @@ ScreenshareScriptingInterface::~ScreenshareScriptingInterface() {
|
||||||
stopScreenshare();
|
stopScreenshare();
|
||||||
}
|
}
|
||||||
|
|
||||||
void ScreenshareScriptingInterface::startScreenshare(const bool& isPresenter) {
|
static const EntityTypes::EntityType LOCAL_SCREENSHARE_WEB_ENTITY_TYPE = EntityTypes::Web;
|
||||||
|
static const uint8_t LOCAL_SCREENSHARE_WEB_ENTITY_FPS = 30;
|
||||||
|
static const glm::vec3 LOCAL_SCREENSHARE_WEB_ENTITY_LOCAL_POSITION(0.0f, 0.0f, 0.1f);
|
||||||
|
static const QString LOCAL_SCREENSHARE_WEB_ENTITY_URL = "https://s3.amazonaws.com/hifi-content/Experiences/Releases/usefulUtilities/smartBoard/screenshareViewer/screenshareClient.html";
|
||||||
|
void ScreenshareScriptingInterface::startScreenshare(const QUuid& screenshareZoneID, const QUuid& smartboardEntityID, const bool& isPresenter) {
|
||||||
if (QThread::currentThread() != thread()) {
|
if (QThread::currentThread() != thread()) {
|
||||||
// We must start a new QProcess from the main thread.
|
// We must start a new QProcess from the main thread.
|
||||||
QMetaObject::invokeMethod(
|
QMetaObject::invokeMethod(
|
||||||
|
@ -79,9 +85,57 @@ void ScreenshareScriptingInterface::startScreenshare(const bool& isPresenter) {
|
||||||
});
|
});
|
||||||
|
|
||||||
_screenshareProcess->start(SCREENSHARE_EXE_PATH, arguments);
|
_screenshareProcess->start(SCREENSHARE_EXE_PATH, arguments);
|
||||||
} else {
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!_screenshareViewerLocalWebEntityUUID.isNull()) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
auto esi = DependencyManager::get<EntityScriptingInterface>();
|
||||||
|
if (!esi) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
EntityItemProperties localScreenshareWebEntityProps;
|
||||||
|
localScreenshareWebEntityProps.setType(LOCAL_SCREENSHARE_WEB_ENTITY_TYPE);
|
||||||
|
localScreenshareWebEntityProps.setMaxFPS(LOCAL_SCREENSHARE_WEB_ENTITY_FPS);
|
||||||
|
localScreenshareWebEntityProps.setLocalPosition(LOCAL_SCREENSHARE_WEB_ENTITY_LOCAL_POSITION);
|
||||||
|
localScreenshareWebEntityProps.setSourceUrl(LOCAL_SCREENSHARE_WEB_ENTITY_URL);
|
||||||
|
localScreenshareWebEntityProps.setParentID(smartboardEntityID);
|
||||||
|
|
||||||
|
EntityPropertyFlags desiredSmartboardProperties;
|
||||||
|
desiredSmartboardProperties += PROP_POSITION;
|
||||||
|
desiredSmartboardProperties += PROP_DIMENSIONS;
|
||||||
|
EntityItemProperties smartboardProps = esi->getEntityProperties(smartboardEntityID, desiredSmartboardProperties);
|
||||||
|
|
||||||
|
localScreenshareWebEntityProps.setPosition(smartboardProps.getPosition());
|
||||||
|
localScreenshareWebEntityProps.setDimensions(smartboardProps.getDimensions());
|
||||||
|
|
||||||
|
_screenshareViewerLocalWebEntityUUID = esi->addEntity(localScreenshareWebEntityProps, "local");
|
||||||
|
|
||||||
|
QObject::connect(esi.data(), &EntityScriptingInterface::webEventReceived, this, [&](const QUuid& entityID, const QVariant& message) {
|
||||||
|
if (entityID == _screenshareViewerLocalWebEntityUUID) {
|
||||||
|
auto esi = DependencyManager::get<EntityScriptingInterface>();
|
||||||
|
if (!esi) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
QJsonDocument jsonMessage = QJsonDocument::fromVariant(message);
|
||||||
|
QJsonObject jsonObject = jsonMessage.object();
|
||||||
|
|
||||||
|
if (jsonObject["type"] == "eventbridge_ready") {
|
||||||
|
QJsonObject responseObject;
|
||||||
|
responseObject.insert("type", "receiveConnectionInfo");
|
||||||
|
QJsonObject responseObjectData;
|
||||||
|
responseObjectData.insert("token", token);
|
||||||
|
responseObjectData.insert("projectAPIKey", apiKey);
|
||||||
|
responseObjectData.insert("sessionID", sessionID);
|
||||||
|
responseObject.insert("data", responseObjectData);
|
||||||
|
|
||||||
|
esi->emitScriptEvent(_screenshareViewerLocalWebEntityUUID, responseObject.toVariantMap());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
void ScreenshareScriptingInterface::stopScreenshare() {
|
void ScreenshareScriptingInterface::stopScreenshare() {
|
||||||
|
@ -93,4 +147,11 @@ void ScreenshareScriptingInterface::stopScreenshare() {
|
||||||
if (_screenshareProcess && _screenshareProcess->state() != QProcess::NotRunning) {
|
if (_screenshareProcess && _screenshareProcess->state() != QProcess::NotRunning) {
|
||||||
_screenshareProcess->terminate();
|
_screenshareProcess->terminate();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!_screenshareViewerLocalWebEntityUUID.isNull()) {
|
||||||
|
auto esi = DependencyManager::get<EntityScriptingInterface>();
|
||||||
|
if (esi) {
|
||||||
|
esi->deleteEntity(_screenshareViewerLocalWebEntityUUID);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -14,7 +14,7 @@ public:
|
||||||
ScreenshareScriptingInterface();
|
ScreenshareScriptingInterface();
|
||||||
~ScreenshareScriptingInterface();
|
~ScreenshareScriptingInterface();
|
||||||
|
|
||||||
Q_INVOKABLE void startScreenshare(const bool& isPresenter);
|
Q_INVOKABLE void startScreenshare(const QUuid& screenshareZoneID, const QUuid& smartboardEntityID, const bool& isPresenter = false);
|
||||||
Q_INVOKABLE void stopScreenshare();
|
Q_INVOKABLE void stopScreenshare();
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
|
@ -43,6 +43,7 @@ private:
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
std::unique_ptr<QProcess> _screenshareProcess{ nullptr };
|
std::unique_ptr<QProcess> _screenshareProcess{ nullptr };
|
||||||
|
QUuid _screenshareViewerLocalWebEntityUUID;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // hifi_ScreenshareScriptingInterface_h
|
#endif // hifi_ScreenshareScriptingInterface_h
|
Loading…
Reference in a new issue