2014-05-18 11:52:39 -04:00
|
|
|
#ifndef INCLUDE_PLUGINMANAGER_H
|
|
|
|
#define INCLUDE_PLUGINMANAGER_H
|
|
|
|
|
2017-05-26 04:35:29 -04:00
|
|
|
#include <stdint.h>
|
2014-05-18 11:52:39 -04:00
|
|
|
#include <QObject>
|
|
|
|
#include <QDir>
|
|
|
|
#include "plugin/plugininterface.h"
|
|
|
|
#include "plugin/pluginapi.h"
|
|
|
|
#include "util/export.h"
|
|
|
|
|
|
|
|
class QComboBox;
|
|
|
|
class QPluginLoader;
|
|
|
|
class Preset;
|
|
|
|
class MainWindow;
|
|
|
|
class Message;
|
2016-05-12 04:31:57 -04:00
|
|
|
class MessageQueue;
|
2016-10-10 19:17:55 -04:00
|
|
|
class DeviceSourceAPI;
|
2016-10-19 12:07:27 -04:00
|
|
|
class DeviceSinkAPI;
|
2014-05-18 11:52:39 -04:00
|
|
|
|
2015-08-29 19:26:51 -04:00
|
|
|
class SDRANGEL_API PluginManager : public QObject {
|
2014-05-18 11:52:39 -04:00
|
|
|
Q_OBJECT
|
|
|
|
|
|
|
|
public:
|
2015-08-08 22:09:05 -04:00
|
|
|
struct Plugin
|
|
|
|
{
|
2014-05-18 11:52:39 -04:00
|
|
|
QString filename;
|
|
|
|
QPluginLoader* loader;
|
2015-09-30 02:55:58 -04:00
|
|
|
PluginInterface* pluginInterface;
|
2015-08-08 22:09:05 -04:00
|
|
|
|
2014-05-18 11:52:39 -04:00
|
|
|
Plugin(const QString& _filename, QPluginLoader* pluginLoader, PluginInterface* _plugin) :
|
|
|
|
filename(_filename),
|
|
|
|
loader(pluginLoader),
|
2015-09-30 02:55:58 -04:00
|
|
|
pluginInterface(_plugin)
|
2014-05-18 11:52:39 -04:00
|
|
|
{ }
|
|
|
|
};
|
2015-08-08 22:09:05 -04:00
|
|
|
|
2014-05-18 11:52:39 -04:00
|
|
|
typedef QList<Plugin> Plugins;
|
|
|
|
|
2016-05-16 18:04:27 -04:00
|
|
|
explicit PluginManager(MainWindow* mainWindow, QObject* parent = NULL);
|
2014-05-18 11:52:39 -04:00
|
|
|
~PluginManager();
|
|
|
|
|
2016-05-14 04:38:29 -04:00
|
|
|
void loadPlugins();
|
2014-05-18 11:52:39 -04:00
|
|
|
const Plugins& getPlugins() const { return m_plugins; }
|
|
|
|
|
2016-05-14 12:12:39 -04:00
|
|
|
// Callbacks from the plugins
|
2016-10-13 16:23:43 -04:00
|
|
|
void registerRxChannel(const QString& channelName, PluginInterface* plugin);
|
2014-05-18 11:52:39 -04:00
|
|
|
void registerSampleSource(const QString& sourceName, PluginInterface* plugin);
|
2016-10-19 12:07:27 -04:00
|
|
|
void registerTxChannel(const QString& channelName, PluginInterface* plugin);
|
|
|
|
void registerSampleSink(const QString& sourceName, PluginInterface* plugin);
|
2016-05-14 12:12:39 -04:00
|
|
|
|
2016-10-13 16:23:43 -04:00
|
|
|
PluginAPI::ChannelRegistrations *getRxChannelRegistrations() { return &m_rxChannelRegistrations; }
|
2016-10-19 12:07:27 -04:00
|
|
|
PluginAPI::ChannelRegistrations *getTxChannelRegistrations() { return &m_txChannelRegistrations; }
|
2016-05-16 12:53:01 -04:00
|
|
|
|
2014-05-18 11:52:39 -04:00
|
|
|
void updateSampleSourceDevices();
|
2016-05-22 18:21:13 -04:00
|
|
|
void duplicateLocalSampleSourceDevices(uint deviceUID);
|
2016-05-22 15:56:07 -04:00
|
|
|
void fillSampleSourceSelector(QComboBox* comboBox, uint deviceUID);
|
2017-01-11 19:24:08 -05:00
|
|
|
int getSampleSourceSelectorIndex(QComboBox* comboBox, DeviceSourceAPI *deviceSourceAPI);
|
2016-05-15 21:21:21 -04:00
|
|
|
|
2016-10-19 12:07:27 -04:00
|
|
|
void updateSampleSinkDevices();
|
|
|
|
void duplicateLocalSampleSinkDevices(uint deviceUID);
|
|
|
|
void fillSampleSinkSelector(QComboBox* comboBox, uint deviceUID);
|
2017-01-11 19:24:08 -05:00
|
|
|
int getSampleSinkSelectorIndex(QComboBox* comboBox, DeviceSinkAPI *deviceSinkAPI);
|
2016-10-19 12:07:27 -04:00
|
|
|
|
2016-10-10 19:17:55 -04:00
|
|
|
int selectSampleSourceByIndex(int index, DeviceSourceAPI *deviceAPI);
|
2017-05-25 14:13:34 -04:00
|
|
|
int selectSampleSourceBySerialOrSequence(const QString& sourceId, const QString& sourceSerial, uint32_t sourceSequence, DeviceSourceAPI *deviceAPI);
|
2016-10-10 19:17:55 -04:00
|
|
|
void selectSampleSourceByDevice(void *devicePtr, DeviceSourceAPI *deviceAPI);
|
2014-05-18 11:52:39 -04:00
|
|
|
|
2016-10-19 12:07:27 -04:00
|
|
|
int selectSampleSinkByIndex(int index, DeviceSinkAPI *deviceAPI);
|
2017-05-25 14:13:34 -04:00
|
|
|
int selectSampleSinkBySerialOrSequence(const QString& sinkId, const QString& sinkSerial, uint32_t sinkSequence, DeviceSinkAPI *deviceAPI);
|
2016-10-19 12:07:27 -04:00
|
|
|
void selectSampleSinkByDevice(void *devicePtr, DeviceSinkAPI *deviceAPI);
|
|
|
|
|
2016-10-13 17:42:08 -04:00
|
|
|
void populateRxChannelComboBox(QComboBox *channels);
|
|
|
|
void createRxChannelInstance(int channelPluginIndex, DeviceSourceAPI *deviceAPI);
|
2016-05-14 12:12:39 -04:00
|
|
|
|
2016-10-19 12:07:27 -04:00
|
|
|
void populateTxChannelComboBox(QComboBox *channels);
|
|
|
|
void createTxChannelInstance(int channelPluginIndex, DeviceSinkAPI *deviceAPI);
|
|
|
|
|
2014-05-18 11:52:39 -04:00
|
|
|
private:
|
2016-10-13 16:23:43 -04:00
|
|
|
struct SamplingDeviceRegistration {
|
|
|
|
QString m_deviceId;
|
2014-05-18 11:52:39 -04:00
|
|
|
PluginInterface* m_plugin;
|
2016-10-13 16:23:43 -04:00
|
|
|
SamplingDeviceRegistration(const QString& deviceId, PluginInterface* plugin) :
|
|
|
|
m_deviceId(deviceId),
|
2014-05-18 11:52:39 -04:00
|
|
|
m_plugin(plugin)
|
|
|
|
{ }
|
|
|
|
};
|
2016-05-16 18:04:27 -04:00
|
|
|
|
2016-10-13 16:23:43 -04:00
|
|
|
typedef QList<SamplingDeviceRegistration> SamplingDeviceRegistrations;
|
2014-05-18 11:52:39 -04:00
|
|
|
|
2016-10-13 16:23:43 -04:00
|
|
|
struct SamplingDevice {
|
2014-05-18 11:52:39 -04:00
|
|
|
PluginInterface* m_plugin;
|
|
|
|
QString m_displayName;
|
2016-12-29 06:41:10 -05:00
|
|
|
QString m_hadrwareId;
|
2016-10-13 16:23:43 -04:00
|
|
|
QString m_deviceId;
|
|
|
|
QString m_deviceSerial;
|
2017-05-25 14:13:34 -04:00
|
|
|
uint32_t m_deviceSequence;
|
2015-09-30 00:57:40 -04:00
|
|
|
|
2016-10-13 16:23:43 -04:00
|
|
|
SamplingDevice(PluginInterface* plugin,
|
2015-09-30 00:57:40 -04:00
|
|
|
const QString& displayName,
|
2016-12-29 06:41:10 -05:00
|
|
|
const QString& hadrwareId,
|
2016-10-13 16:23:43 -04:00
|
|
|
const QString& deviceId,
|
|
|
|
const QString& deviceSerial,
|
|
|
|
int deviceSequence) :
|
2014-05-18 11:52:39 -04:00
|
|
|
m_plugin(plugin),
|
|
|
|
m_displayName(displayName),
|
2016-12-29 06:41:10 -05:00
|
|
|
m_hadrwareId(hadrwareId),
|
2016-10-13 16:23:43 -04:00
|
|
|
m_deviceId(deviceId),
|
|
|
|
m_deviceSerial(deviceSerial),
|
|
|
|
m_deviceSequence(deviceSequence)
|
2014-05-18 11:52:39 -04:00
|
|
|
{ }
|
|
|
|
};
|
2016-05-16 18:04:27 -04:00
|
|
|
|
2016-10-13 16:23:43 -04:00
|
|
|
typedef QList<SamplingDevice> SamplingDevices;
|
2014-05-18 11:52:39 -04:00
|
|
|
|
|
|
|
PluginAPI m_pluginAPI;
|
|
|
|
Plugins m_plugins;
|
|
|
|
|
2016-10-13 16:23:43 -04:00
|
|
|
PluginAPI::ChannelRegistrations m_rxChannelRegistrations; //!< Channel plugins register here
|
|
|
|
SamplingDeviceRegistrations m_sampleSourceRegistrations; //!< Input source plugins (one per device kind) register here
|
|
|
|
SamplingDevices m_sampleSourceDevices; //!< Instances of input sources present in the system
|
2014-05-18 11:52:39 -04:00
|
|
|
|
2016-10-19 12:07:27 -04:00
|
|
|
PluginAPI::ChannelRegistrations m_txChannelRegistrations; //!< Channel plugins register here
|
|
|
|
SamplingDeviceRegistrations m_sampleSinkRegistrations; //!< Output sink plugins (one per device kind) register here
|
|
|
|
SamplingDevices m_sampleSinkDevices; //!< Instances of output sinks present in the system
|
|
|
|
|
2016-05-22 18:21:13 -04:00
|
|
|
// "Local" sample source device IDs
|
2016-12-29 06:41:10 -05:00
|
|
|
static const QString m_sdrDaemonHardwareID; //!< SDRdaemon hardware ID
|
2016-10-19 12:07:27 -04:00
|
|
|
static const QString m_sdrDaemonDeviceTypeID; //!< SDRdaemon source plugin ID
|
2016-12-29 06:41:10 -05:00
|
|
|
static const QString m_sdrDaemonFECHardwareID; //!< SDRdaemon with FEC hardware ID
|
2016-10-19 12:07:27 -04:00
|
|
|
static const QString m_sdrDaemonFECDeviceTypeID; //!< SDRdaemon with FEC source plugin ID
|
2016-12-29 06:41:10 -05:00
|
|
|
static const QString m_fileSourceHardwareID; //!< FileSource source hardware ID
|
2016-10-19 12:07:27 -04:00
|
|
|
static const QString m_fileSourceDeviceTypeID; //!< FileSource source plugin ID
|
|
|
|
|
|
|
|
// "Local" sample sink device IDs
|
|
|
|
static const QString m_fileSinkDeviceTypeID; //!< FileSink sink plugin ID
|
2016-05-22 15:56:07 -04:00
|
|
|
|
2014-05-18 11:52:39 -04:00
|
|
|
void loadPlugins(const QDir& dir);
|
2016-05-16 18:04:27 -04:00
|
|
|
|
|
|
|
friend class MainWindow;
|
2014-05-18 11:52:39 -04:00
|
|
|
};
|
|
|
|
|
|
|
|
static inline bool operator<(const PluginManager::Plugin& a, const PluginManager::Plugin& b)
|
|
|
|
{
|
2015-09-30 02:55:58 -04:00
|
|
|
return a.pluginInterface->getPluginDescriptor().displayedName < b.pluginInterface->getPluginDescriptor().displayedName;
|
2014-05-18 11:52:39 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
#endif // INCLUDE_PLUGINMANAGER_H
|