2019-05-01 22:02:40 -04:00
|
|
|
///////////////////////////////////////////////////////////////////////////////////
|
|
|
|
// Copyright (C) 2019 Edouard Griffiths, F4EXB //
|
|
|
|
// //
|
|
|
|
// This program is free software; you can redistribute it and/or modify //
|
|
|
|
// it under the terms of the GNU General Public License as published by //
|
|
|
|
// the Free Software Foundation as version 3 of the License, or //
|
|
|
|
// (at your option) any later version. //
|
|
|
|
// //
|
|
|
|
// This program is distributed in the hope that it will be useful, //
|
|
|
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of //
|
|
|
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the //
|
|
|
|
// GNU General Public License V3 for more details. //
|
|
|
|
// //
|
|
|
|
// You should have received a copy of the GNU General Public License //
|
|
|
|
// along with this program. If not, see <http://www.gnu.org/licenses/>. //
|
|
|
|
///////////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
|
|
|
#include <QtPlugin>
|
|
|
|
|
|
|
|
#include "plugin/pluginapi.h"
|
|
|
|
#include "util/simpleserializer.h"
|
|
|
|
|
|
|
|
#ifdef SERVER_MODE
|
|
|
|
#include "localinput.h"
|
|
|
|
#else
|
|
|
|
#include "localinputgui.h"
|
|
|
|
#endif
|
|
|
|
#include "localinputplugin.h"
|
2019-08-04 14:24:44 -04:00
|
|
|
#include "localinputwebapiadapter.h"
|
2019-05-01 22:02:40 -04:00
|
|
|
|
|
|
|
const PluginDescriptor LocalInputPlugin::m_pluginDescriptor = {
|
2020-11-21 09:38:04 -05:00
|
|
|
QStringLiteral("LocalInput"),
|
|
|
|
QStringLiteral("Local device input"),
|
2022-05-14 07:16:33 -04:00
|
|
|
QStringLiteral("7.0.0"),
|
2020-11-21 09:38:04 -05:00
|
|
|
QStringLiteral("(c) Edouard Griffiths, F4EXB"),
|
|
|
|
QStringLiteral("https://github.com/f4exb/sdrangel"),
|
2019-05-01 22:02:40 -04:00
|
|
|
true,
|
2020-11-21 09:38:04 -05:00
|
|
|
QStringLiteral("https://github.com/f4exb/sdrangel")
|
2019-05-01 22:02:40 -04:00
|
|
|
};
|
|
|
|
|
2020-11-21 14:24:18 -05:00
|
|
|
static constexpr const char* const m_hardwareID = "LocalInput";
|
|
|
|
static constexpr const char* const m_deviceTypeID = LOCALINPUT_DEVICE_TYPE_ID;
|
2019-05-01 22:02:40 -04:00
|
|
|
|
|
|
|
LocalInputPlugin::LocalInputPlugin(QObject* parent) :
|
|
|
|
QObject(parent)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
const PluginDescriptor& LocalInputPlugin::getPluginDescriptor() const
|
|
|
|
{
|
|
|
|
return m_pluginDescriptor;
|
|
|
|
}
|
|
|
|
|
|
|
|
void LocalInputPlugin::initPlugin(PluginAPI* pluginAPI)
|
|
|
|
{
|
|
|
|
pluginAPI->registerSampleSource(m_deviceTypeID, this);
|
|
|
|
}
|
|
|
|
|
2019-09-16 18:34:11 -04:00
|
|
|
void LocalInputPlugin::enumOriginDevices(QStringList& listedHwIds, OriginDevices& originDevices)
|
|
|
|
{
|
|
|
|
if (listedHwIds.contains(m_hardwareID)) { // check if it was done
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
originDevices.append(OriginDevice(
|
|
|
|
"LocalInput",
|
|
|
|
m_hardwareID,
|
2019-10-24 16:18:36 -04:00
|
|
|
QString(),
|
2019-09-16 18:34:11 -04:00
|
|
|
0,
|
|
|
|
1, // nb Rx
|
|
|
|
0 // nb Tx
|
|
|
|
));
|
|
|
|
|
|
|
|
listedHwIds.append(m_hardwareID);
|
|
|
|
}
|
|
|
|
|
|
|
|
PluginInterface::SamplingDevices LocalInputPlugin::enumSampleSources(const OriginDevices& originDevices)
|
2019-05-01 22:02:40 -04:00
|
|
|
{
|
|
|
|
SamplingDevices result;
|
|
|
|
|
2019-09-16 18:34:11 -04:00
|
|
|
for (OriginDevices::const_iterator it = originDevices.begin(); it != originDevices.end(); ++it)
|
|
|
|
{
|
|
|
|
if (it->hardwareId == m_hardwareID)
|
|
|
|
{
|
|
|
|
result.append(SamplingDevice(
|
|
|
|
it->displayableName,
|
|
|
|
m_hardwareID,
|
|
|
|
m_deviceTypeID,
|
|
|
|
it->serial,
|
|
|
|
it->sequence,
|
|
|
|
PluginInterface::SamplingDevice::BuiltInDevice,
|
|
|
|
PluginInterface::SamplingDevice::StreamSingleRx,
|
|
|
|
1,
|
|
|
|
0
|
|
|
|
));
|
|
|
|
}
|
|
|
|
}
|
2019-05-01 22:02:40 -04:00
|
|
|
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
|
|
|
#ifdef SERVER_MODE
|
2020-10-05 13:23:13 -04:00
|
|
|
DeviceGUI* LocalInputPlugin::createSampleSourcePluginInstanceGUI(
|
2019-05-24 03:37:13 -04:00
|
|
|
const QString& sourceId,
|
|
|
|
QWidget **widget,
|
|
|
|
DeviceUISet *deviceUISet)
|
2019-05-01 22:02:40 -04:00
|
|
|
{
|
2019-06-19 12:50:55 -04:00
|
|
|
(void) sourceId;
|
|
|
|
(void) widget;
|
|
|
|
(void) deviceUISet;
|
2019-05-01 22:02:40 -04:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
#else
|
2020-10-05 13:23:13 -04:00
|
|
|
DeviceGUI* LocalInputPlugin::createSampleSourcePluginInstanceGUI(
|
2019-05-01 22:02:40 -04:00
|
|
|
const QString& sourceId,
|
|
|
|
QWidget **widget,
|
|
|
|
DeviceUISet *deviceUISet)
|
|
|
|
{
|
|
|
|
if(sourceId == m_deviceTypeID)
|
|
|
|
{
|
|
|
|
LocalInputGui* gui = new LocalInputGui(deviceUISet);
|
|
|
|
*widget = gui;
|
|
|
|
return gui;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2019-05-19 04:28:50 -04:00
|
|
|
DeviceSampleSource *LocalInputPlugin::createSampleSourcePluginInstance(const QString& sourceId, DeviceAPI *deviceAPI)
|
2019-05-01 22:02:40 -04:00
|
|
|
{
|
|
|
|
if (sourceId == m_deviceTypeID)
|
|
|
|
{
|
|
|
|
LocalInput* input = new LocalInput(deviceAPI);
|
|
|
|
return input;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
}
|
2019-08-04 14:24:44 -04:00
|
|
|
|
|
|
|
DeviceWebAPIAdapter *LocalInputPlugin::createDeviceWebAPIAdapter() const
|
|
|
|
{
|
|
|
|
return new LocalInputWebAPIAdapter();
|
|
|
|
}
|