/////////////////////////////////////////////////////////////////////////////////// // 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 . // /////////////////////////////////////////////////////////////////////////////////// #include #include #include #include "xtrx_api.h" #include "plugin/pluginapi.h" #include "util/simpleserializer.h" #include "xtrx/devicextrxparam.h" #ifdef SERVER_MODE #include "xtrxoutput.h" #else #include "xtrxoutputgui.h" #endif #include "xtrxoutputplugin.h" #include "xtrxoutputwebapiadapter.h" const PluginDescriptor XTRXOutputPlugin::m_pluginDescriptor = { QString("XTRX Output"), QString("4.11.6"), QString("(c) Edouard Griffiths, F4EXB"), QString("https://github.com/f4exb/sdrangel"), true, QString("https://github.com/f4exb/sdrangel") }; const QString XTRXOutputPlugin::m_hardwareID = "XTRX"; const QString XTRXOutputPlugin::m_deviceTypeID = XTRXOUTPUT_DEVICE_TYPE_ID; XTRXOutputPlugin::XTRXOutputPlugin(QObject* parent) : QObject(parent) { } const PluginDescriptor& XTRXOutputPlugin::getPluginDescriptor() const { return m_pluginDescriptor; } void XTRXOutputPlugin::initPlugin(PluginAPI* pluginAPI) { pluginAPI->registerSampleSink(m_deviceTypeID, this); } PluginInterface::SamplingDevices XTRXOutputPlugin::enumSampleSinks() { SamplingDevices result; xtrx_device_info_t devs[32]; int res = xtrx_discovery(devs, 32); int i; for (i = 0; i < res; i++) { DeviceXTRXParams XTRXParams; for (unsigned int j = 0; j < XTRXParams.m_nbTxChannels; j++) { qDebug("XTRXInputPlugin::enumSampleSinks: device #%d channel %u: %s", i, j, devs[i].uniqname); QString displayedName(QString("XTRX[%1:%2] %3").arg(i).arg(j).arg(devs[i].uniqname)); result.append(SamplingDevice(displayedName, m_hardwareID, m_deviceTypeID, QString(devs[i].uniqname), i, PluginInterface::SamplingDevice::PhysicalDevice, PluginInterface::SamplingDevice::StreamSingleTx, XTRXParams.m_nbTxChannels, j)); } } return result; } #ifdef SERVER_MODE PluginInstanceGUI* XTRXOutputPlugin::createSampleSinkPluginInstanceGUI( const QString& sinkId, QWidget **widget, DeviceUISet *deviceUISet) { (void) sinkId; (void) widget; (void) deviceUISet; return 0; } #else PluginInstanceGUI* XTRXOutputPlugin::createSampleSinkPluginInstanceGUI( const QString& sinkId, QWidget **widget, DeviceUISet *deviceUISet) { if(sinkId == m_deviceTypeID) { XTRXOutputGUI* gui = new XTRXOutputGUI(deviceUISet); *widget = gui; return gui; } else { return 0; } } #endif DeviceSampleSink* XTRXOutputPlugin::createSampleSinkPluginInstance(const QString& sinkId, DeviceAPI *deviceAPI) { if(sinkId == m_deviceTypeID) { XTRXOutput* output = new XTRXOutput(deviceAPI); return output; } else { return 0; } } DeviceWebAPIAdapter *XTRXOutputPlugin::createDeviceWebAPIAdapter() const { return new XTRXOutputWebAPIAdapter(); }