2016-11-13 01:59:31 +00: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 //
|
|
|
|
// //
|
|
|
|
// 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 <QAction>
|
2016-11-15 14:57:13 +00:00
|
|
|
#include <mirisdr.h>
|
2016-11-13 01:59:31 +00:00
|
|
|
#include "plugin/pluginapi.h"
|
|
|
|
#include "util/simpleserializer.h"
|
|
|
|
#include "sdrplaygui.h"
|
|
|
|
#include "sdrplayplugin.h"
|
|
|
|
#include <device/devicesourceapi.h>
|
|
|
|
|
|
|
|
const PluginDescriptor SDRPlayPlugin::m_pluginDescriptor = {
|
2016-12-29 11:41:10 +00:00
|
|
|
QString("SDRPlay RSP1 Input"),
|
2017-12-26 01:19:03 +00:00
|
|
|
QString("3.9.0"),
|
2016-11-13 01:59:31 +00:00
|
|
|
QString("(c) Edouard Griffiths, F4EXB"),
|
|
|
|
QString("https://github.com/f4exb/sdrangel"),
|
|
|
|
true,
|
|
|
|
QString("https://github.com/f4exb/sdrangel")
|
|
|
|
};
|
|
|
|
|
2016-12-29 11:41:10 +00:00
|
|
|
const QString SDRPlayPlugin::m_hardwareID = "SDRplay1";
|
2016-11-13 01:59:31 +00: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 14:57:13 +00: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 11:41:10 +00:00
|
|
|
m_hardwareID,
|
2016-11-15 14:57:13 +00:00
|
|
|
m_deviceTypeID,
|
|
|
|
QString(serial),
|
2017-11-01 09:37:00 +00:00
|
|
|
i,
|
2017-11-01 19:06:33 +00:00
|
|
|
PluginInterface::SamplingDevice::PhysicalDevice,
|
2017-11-01 09:37:00 +00:00
|
|
|
true,
|
2017-11-19 00:05:16 +00:00
|
|
|
1,
|
2017-11-01 09:37:00 +00:00
|
|
|
0));
|
2016-11-15 14:57:13 +00:00
|
|
|
}
|
2016-11-14 17:06:20 +00:00
|
|
|
|
2016-11-13 01:59:31 +00:00
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
2017-10-29 23:02:28 +00:00
|
|
|
PluginInstanceGUI* SDRPlayPlugin::createSampleSourcePluginInstanceGUI(
|
|
|
|
const QString& sourceId,
|
|
|
|
QWidget **widget,
|
|
|
|
DeviceUISet *deviceUISet)
|
2016-11-13 01:59:31 +00:00
|
|
|
{
|
|
|
|
if(sourceId == m_deviceTypeID)
|
|
|
|
{
|
2017-10-29 23:45:23 +00:00
|
|
|
SDRPlayGui* gui = new SDRPlayGui(deviceUISet);
|
2016-11-13 01:59:31 +00:00
|
|
|
*widget = gui;
|
|
|
|
return gui;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
}
|
2017-09-14 11:34:32 +00:00
|
|
|
|
|
|
|
DeviceSampleSource *SDRPlayPlugin::createSampleSourcePluginInstanceInput(const QString& sourceId, DeviceSourceAPI *deviceAPI)
|
|
|
|
{
|
|
|
|
if (sourceId == m_deviceTypeID)
|
|
|
|
{
|
|
|
|
SDRPlayInput* input = new SDRPlayInput(deviceAPI);
|
|
|
|
return input;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|