1
0
mirror of https://github.com/f4exb/sdrangel.git synced 2024-12-25 20:22:10 -05:00
sdrangel/plugins/samplesource/rtlsdr/rtlsdrplugin.cpp

109 lines
2.4 KiB
C++
Raw Normal View History

#include <QtPlugin>
#include <rtl-sdr.h>
2017-12-28 18:33:37 -05:00
#include "plugin/pluginapi.h"
#include "util/simpleserializer.h"
#include <device/devicesourceapi.h>
2017-12-28 18:33:37 -05:00
#ifdef SERVER_MODE
#include "rtlsdrinput.h"
#else
#include "rtlsdrgui.h"
2017-12-28 18:33:37 -05:00
#endif
#include "rtlsdrplugin.h"
const PluginDescriptor RTLSDRPlugin::m_pluginDescriptor = {
QString("RTL-SDR Input"),
QString("4.5.4"),
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 RTLSDRPlugin::m_hardwareID = "RTLSDR";
const QString RTLSDRPlugin::m_deviceTypeID = RTLSDR_DEVICE_TYPE_ID;
RTLSDRPlugin::RTLSDRPlugin(QObject* parent) :
QObject(parent)
{
}
const PluginDescriptor& RTLSDRPlugin::getPluginDescriptor() const
{
return m_pluginDescriptor;
}
void RTLSDRPlugin::initPlugin(PluginAPI* pluginAPI)
{
pluginAPI->registerSampleSource(m_deviceTypeID, this);
}
2016-10-13 16:23:43 -04:00
PluginInterface::SamplingDevices RTLSDRPlugin::enumSampleSources()
{
2016-10-13 16:23:43 -04:00
SamplingDevices result;
int count = rtlsdr_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';
2014-11-03 12:11:08 -05:00
if(rtlsdr_get_device_usb_strings((uint32_t)i, vendor, product, serial) != 0)
continue;
2015-09-30 23:44:33 -04:00
QString displayedName(QString("RTL-SDR[%1] %2").arg(i).arg(serial));
2016-10-13 16:23:43 -04:00
result.append(SamplingDevice(displayedName,
2016-12-29 06:41:10 -05:00
m_hardwareID,
m_deviceTypeID,
QString(serial),
i,
PluginInterface::SamplingDevice::PhysicalDevice,
true,
1,
0));
}
return result;
}
#ifdef SERVER_MODE
PluginInstanceGUI* RTLSDRPlugin::createSampleSourcePluginInstanceGUI(
const QString& sourceId __attribute((unused)),
QWidget **widget __attribute((unused)),
DeviceUISet *deviceUISet __attribute((unused)))
{
return 0;
}
#else
PluginInstanceGUI* RTLSDRPlugin::createSampleSourcePluginInstanceGUI(
const QString& sourceId,
QWidget **widget,
DeviceUISet *deviceUISet)
{
if(sourceId == m_deviceTypeID) {
RTLSDRGui* gui = new RTLSDRGui(deviceUISet);
*widget = gui;
return gui;
} else {
return 0;
}
}
#endif
DeviceSampleSource *RTLSDRPlugin::createSampleSourcePluginInstanceInput(const QString& sourceId, DeviceSourceAPI *deviceAPI)
{
if (sourceId == m_deviceTypeID)
{
RTLSDRInput* input = new RTLSDRInput(deviceAPI);
return input;
}
else
{
return 0;
}
}