2016-11-12 20:59:31 -05:00
|
|
|
///////////////////////////////////////////////////////////////////////////////////
|
|
|
|
// Copyright (C) 2016 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 //
|
2019-04-11 00:57:41 -04:00
|
|
|
// (at your option) any later version. //
|
2016-11-12 20:59:31 -05:00
|
|
|
// //
|
|
|
|
// 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>
|
2016-11-15 09:57:13 -05:00
|
|
|
#include <mirisdr.h>
|
2016-11-12 20:59:31 -05:00
|
|
|
#include "plugin/pluginapi.h"
|
|
|
|
#include "util/simpleserializer.h"
|
2019-05-09 06:10:27 -04:00
|
|
|
|
2018-05-29 14:52:44 -04:00
|
|
|
#ifdef SERVER_MODE
|
|
|
|
#include "sdrplayinput.h"
|
|
|
|
#else
|
2016-11-12 20:59:31 -05:00
|
|
|
#include "sdrplaygui.h"
|
2018-05-29 14:52:44 -04:00
|
|
|
#endif
|
2016-11-12 20:59:31 -05:00
|
|
|
#include "sdrplayplugin.h"
|
|
|
|
|
|
|
|
const PluginDescriptor SDRPlayPlugin::m_pluginDescriptor = {
|
2016-12-29 06:41:10 -05:00
|
|
|
QString("SDRPlay RSP1 Input"),
|
2019-03-25 08:41:38 -04:00
|
|
|
QString("4.5.2"),
|
2016-11-12 20:59:31 -05:00
|
|
|
QString("(c) Edouard Griffiths, F4EXB"),
|
|
|
|
QString("https://github.com/f4exb/sdrangel"),
|
|
|
|
true,
|
|
|
|
QString("https://github.com/f4exb/sdrangel")
|
|
|
|
};
|
|
|
|
|
2016-12-29 06:41:10 -05:00
|
|
|
const QString SDRPlayPlugin::m_hardwareID = "SDRplay1";
|
2016-11-12 20:59:31 -05:00
|
|
|
const QString SDRPlayPlugin::m_deviceTypeID = SDRPLAY_DEVICE_TYPE_ID;
|
|
|
|
|
|
|
|
SDRPlayPlugin::SDRPlayPlugin(QObject* parent) :
|
|
|
|
QObject(parent)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
const PluginDescriptor& SDRPlayPlugin::getPluginDescriptor() const
|
|
|
|
{
|
|
|
|
return m_pluginDescriptor;
|
|
|
|
}
|
|
|
|
|
|
|
|
void SDRPlayPlugin::initPlugin(PluginAPI* pluginAPI)
|
|
|
|
{
|
|
|
|
pluginAPI->registerSampleSource(m_deviceTypeID, this);
|
|
|
|
}
|
|
|
|
|
|
|
|
PluginInterface::SamplingDevices SDRPlayPlugin::enumSampleSources()
|
|
|
|
{
|
2016-11-15 09:57:13 -05:00
|
|
|
SamplingDevices result;
|
|
|
|
int count = mirisdr_get_device_count();
|
|
|
|
|
|
|
|
char vendor[256];
|
|
|
|
char product[256];
|
|
|
|
char serial[256];
|
|
|
|
|
|
|
|
for(int i = 0; i < count; i++)
|
|
|
|
{
|
|
|
|
vendor[0] = '\0';
|
|
|
|
product[0] = '\0';
|
|
|
|
serial[0] = '\0';
|
|
|
|
|
|
|
|
if (mirisdr_get_device_usb_strings((uint32_t)i, vendor, product, serial) != 0)
|
|
|
|
{
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
|
|
|
qDebug("SDRPlayPlugin::enumSampleSources: found %s:%s (%s)", vendor, product, serial);
|
|
|
|
QString displayedName(QString("SDRPlay[%1] %2").arg(i).arg(serial));
|
|
|
|
|
|
|
|
result.append(SamplingDevice(displayedName,
|
2016-12-29 06:41:10 -05:00
|
|
|
m_hardwareID,
|
2016-11-15 09:57:13 -05:00
|
|
|
m_deviceTypeID,
|
|
|
|
QString(serial),
|
2017-11-01 05:37:00 -04:00
|
|
|
i,
|
2017-11-01 15:06:33 -04:00
|
|
|
PluginInterface::SamplingDevice::PhysicalDevice,
|
2019-05-07 12:58:20 -04:00
|
|
|
PluginInterface::SamplingDevice::StreamSingleRx,
|
2017-11-18 19:05:16 -05:00
|
|
|
1,
|
2017-11-01 05:37:00 -04:00
|
|
|
0));
|
2016-11-15 09:57:13 -05:00
|
|
|
}
|
2016-11-14 12:06:20 -05:00
|
|
|
|
2016-11-12 20:59:31 -05:00
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
2018-05-29 14:52:44 -04:00
|
|
|
#ifdef SERVER_MODE
|
|
|
|
PluginInstanceGUI* SDRPlayPlugin::createSampleSourcePluginInstanceGUI(
|
|
|
|
const QString& sourceId __attribute((unused)),
|
|
|
|
QWidget **widget __attribute((unused)),
|
|
|
|
DeviceUISet *deviceUISet __attribute((unused)))
|
|
|
|
{
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
#else
|
2017-10-29 19:02:28 -04:00
|
|
|
PluginInstanceGUI* SDRPlayPlugin::createSampleSourcePluginInstanceGUI(
|
|
|
|
const QString& sourceId,
|
|
|
|
QWidget **widget,
|
|
|
|
DeviceUISet *deviceUISet)
|
2016-11-12 20:59:31 -05:00
|
|
|
{
|
|
|
|
if(sourceId == m_deviceTypeID)
|
|
|
|
{
|
2017-10-29 19:45:23 -04:00
|
|
|
SDRPlayGui* gui = new SDRPlayGui(deviceUISet);
|
2016-11-12 20:59:31 -05:00
|
|
|
*widget = gui;
|
|
|
|
return gui;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
}
|
2018-05-29 14:52:44 -04:00
|
|
|
#endif
|
2017-09-14 07:34:32 -04:00
|
|
|
|
2019-05-19 04:28:50 -04:00
|
|
|
DeviceSampleSource *SDRPlayPlugin::createSampleSourcePluginInstance(const QString& sourceId, DeviceAPI *deviceAPI)
|
2017-09-14 07:34:32 -04:00
|
|
|
{
|
|
|
|
if (sourceId == m_deviceTypeID)
|
|
|
|
{
|
|
|
|
SDRPlayInput* input = new SDRPlayInput(deviceAPI);
|
|
|
|
return input;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|