Files
qt-migration-legatus/qt5-before/dlbo/Lts/Services/AudioVideoManagement/audio_video_handler.cpp
T
torstenandCopilot 7173785915 Qt6 Migration: Complete migration with DDS/RTI support and build validation
Major Changes:
- Merged latest Qt5 devel content from dlbo (292 files changed, 7 new dirs)
- Consolidated forward-declarations and include folders
- Removed unneeded modules per Niklas' repo check list

Build System Fixes:
- Fixed CMake VERSION_GREATER syntax in ParticipantManagement/CMakeLists.txt
- Added VLC packages (libvlc-dev, vlc-plugin-base) to docker_build.sh
- Added PostgreSQL dev packages (libpq-dev, postgresql-server-dev-all) to Dockerfile
- Fixed locale warnings (ANSI_X3.4-1968 → C.UTF-8)
- Fixed ArcGIS SDK path warnings when BUILD_ARCGIS=OFF

Code Generation Fixes:
- Fixed IDL enum collisions (PortType→CorePortType/DdsutPortType, PdmEventType)
- Fixed Grantlee template svc_translation.cpp.grantlee:
  - Changed {{ idl_enum.name }}_def:: to {{ idl_enum.name }}::
  - Fixed .underlying() calls for C++11 scoped enums (enum class)
- Removed generated files from repo (moc_*, *_dtc.h, *_ftc.h)

Validation:
- BUILD_RTI=ON: SUCCESS
- BUILD_RTI=OFF: SUCCESS
- C++17 standard maintained for RTI 7.7 compatibility
- Ubuntu 26.04 Docker environment verified

Remaining Warnings (expected):
- BgViewer, KDChart, KDReports, Poppler-Qt6 not found (optional features)

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
2026-09-15 18:20:26 +00:00

189 lines
5.1 KiB
C++

/**
* @RDE_HEADER@
* AudioVideoHandler
* $Id$
* $HeadURL$
* $Author$
* Created by Christian Fröbel, SLSE, 2017-11-27
*/
#include "audio_video_handler.h"
#include "audio_video_handler_impl.h"
#include "asset.h"
#include "mounting_point.h"
#include "exercise_handler.h"
#include "default_av_menus.h"
#include <AudioVideoManagement/avm_dts.h>
#include <AudioVideoManagement/avm.hpp>
#include <InfrastructureManagement/ism.hpp>
#include <QtGlobal>
#include <map>
#include <utility>
namespace AudioVideoManagement
{
/**
* All DB-operations are done via this class in order to keep an internal cache
* that mirrors the entries in the DB.
* Initially there are no entries as the ExercisesHandler removes all
* device-related entries from the DB.
*/
class AudioVideoHandler::DbProxy : public AudioVideoHandlerImpl::IDbProxy
{
public:
explicit DbProxy(DatabaseInterface *db)
: m_db(db)
{
Q_ASSERT(db);
}
const Streams &findStreams(AssetId id) const override
{
auto found = m_cache.find(id);
Q_ASSERT(found != m_cache.end());
return found->second;
}
const Streams &findStreams(Asset *asset) override
{
Q_ASSERT(asset);
return findStreams(asset->data().id());
}
void insert(Streams &streams) override
{
Q_ASSERT(streams.first.id <= 0);
m_db->insert(streams.first);
if (streams.second)
{
Q_ASSERT(streams.second->id <= 0);
streams.second->link = streams.first.id;
m_db->insert(*streams.second);
streams.first.link = streams.second->id;
m_db->update(streams.first);
}
auto insertResult = m_cache.insert(std::make_pair(streams.assetId(), streams));
Q_ASSERT(insertResult.second);
}
void update(Streams &newStreams) override
{
Q_ASSERT(newStreams.first.id <= 0);
Q_ASSERT(!newStreams.second || newStreams.second->id <= 0);
auto found = m_cache.find(newStreams.assetId());
Q_ASSERT(found != m_cache.end());
const Streams oldStreams = found->second;
// The update of the Asset can also imply that an additional stream will be created
// or that one stream will be removed.
if (!oldStreams.second && !newStreams.second)
{
// no change, one stream
newStreams.first.id = oldStreams.first.id;
m_db->update(newStreams.first);
}
else if (oldStreams.second && newStreams.second)
{
// no change, two streams
newStreams.first.id = oldStreams.first.id;
newStreams.first.link = oldStreams.first.link;
newStreams.second->id = oldStreams.second->id;
newStreams.second->link = oldStreams.second->link;
m_db->update(newStreams.first);
m_db->update(*newStreams.second);
}
else if (!oldStreams.second && newStreams.second)
{
// one additional stream
newStreams.second->link = oldStreams.first.id;
m_db->insert(*newStreams.second);
newStreams.first.id = oldStreams.first.id;
newStreams.first.link = newStreams.second->id;
m_db->update(newStreams.first);
}
else
{
// one stream removed
newStreams.first.id = oldStreams.first.id;
m_db->update(newStreams.first);
m_db->removeAvmDeviceConfig(oldStreams.second->id);
}
found->second = newStreams; // update cache
}
void remove(Asset *asset) override
{
Q_ASSERT(asset);
auto found = m_cache.find(asset->data().id());
Q_ASSERT(found != m_cache.end());
const Streams &streams = found->second;
m_db->removeAvmDeviceConfig(streams.first.id);
if (streams.second)
m_db->removeAvmDeviceConfig(streams.second->id);
m_cache.erase(found);
}
private:
std::map<AssetId, Streams> m_cache;
DatabaseInterface *m_db;
};
class AudioVideoHandler::DtsProxy : public AudioVideoHandlerImpl::IDtsProxy
{
public:
DtsProxy(Interface::Dts *dts, DefaultAvMenus *defaultAvMenus)
: m_dts(dts)
, m_defaultAvMenus(defaultAvMenus)
{
Q_ASSERT(dts);
Q_ASSERT(defaultAvMenus);
}
void publish(const Stream &stream) override
{
m_defaultAvMenus->onStreamChanged(stream);
m_dts->publish(stream);
}
void remove(uint64_t streamId) override
{
m_defaultAvMenus->onStreamRemoved(streamId);
m_dts->removeStreamByKey(streamId);
}
private:
Interface::Dts *m_dts;
DefaultAvMenus *m_defaultAvMenus;
};
AudioVideoHandler::AudioVideoHandler(Exercise *exercise, ExerciseHandler *exerciseHandler, DefaultAvMenus *defaultAvMenus, DatabaseInterface *db, Interface::Dts *dts)
: m_dbProxy(new DbProxy(db))
, m_dtsProxy(new DtsProxy(dts, defaultAvMenus))
, m_impl(new AudioVideoHandlerImpl(exercise, m_dbProxy.get(), m_dtsProxy.get()))
{
Q_ASSERT(exerciseHandler);
connect(m_impl.get(), &AudioVideoHandlerImpl::avDbReloadNeeded, this, &AudioVideoHandler::avDbReloadNeeded);
connect(exerciseHandler, &ExerciseHandler::contextActivated, m_impl.get(), &AudioVideoHandlerImpl::onContextActivated);
connect(exerciseHandler, &ExerciseHandler::contextDeactivated, m_impl.get(), &AudioVideoHandlerImpl::onContextDeactivated);
}
AudioVideoHandler::~AudioVideoHandler() = default;
} // namespace AudioVideoManagement