SDRAngel  4.11.5
Developer docs for <a href="https://github.com/f4exb/sdrangel">SDRangel<\a>, an Open Source Qt5 / OpenGL 3.0+ SDR and signal analyzer frontend to various hardware.
soapysdroutputplugin.cpp
Go to the documentation of this file.
1 // Copyright (C) 2018 Edouard Griffiths, F4EXB //
3 // //
4 // This program is free software; you can redistribute it and/or modify //
5 // it under the terms of the GNU General Public License as published by //
6 // the Free Software Foundation as version 3 of the License, or //
7 // (at your option) any later version. //
8 // //
9 // This program is distributed in the hope that it will be useful, //
10 // but WITHOUT ANY WARRANTY; without even the implied warranty of //
11 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the //
12 // GNU General Public License V3 for more details. //
13 // //
14 // You should have received a copy of the GNU General Public License //
15 // along with this program. If not, see <http://www.gnu.org/licenses/>. //
17 
18 #include <QtPlugin>
19 
20 #include "plugin/pluginapi.h"
21 #include "util/simpleserializer.h"
23 
24 #include "soapysdroutputplugin.h"
25 
26 #ifdef SERVER_MODE
27 #include "soapysdroutput.h"
28 #else
29 #include "soapysdroutputgui.h"
30 #endif
31 
33  QString("SoapySDR Output"),
34  QString("4.5.2"),
35  QString("(c) Edouard Griffiths, F4EXB"),
36  QString("https://github.com/f4exb/sdrangel"),
37  true,
38  QString("https://github.com/f4exb/sdrangel")
39 };
40 
41 const QString SoapySDROutputPlugin::m_hardwareID = "SoapySDR";
43 
45  QObject(parent)
46 {
47 }
48 
50 {
51  return m_pluginDescriptor;
52 }
53 
55 {
56  pluginAPI->registerSampleSink(m_deviceTypeID, this);
57 }
58 
60 {
61  SamplingDevices result;
62  DeviceSoapySDR& deviceSoapySDR = DeviceSoapySDR::instance();
63  const std::vector<DeviceSoapySDRScan::SoapySDRDeviceEnum>& devicesEnumeration = deviceSoapySDR.getDevicesEnumeration();
64  qDebug("SoapySDROutputPlugin::enumSampleSinks: %lu SoapySDR devices. Enumerate these with Tx channel(s):", devicesEnumeration.size());
65  std::vector<DeviceSoapySDRScan::SoapySDRDeviceEnum>::const_iterator it = devicesEnumeration.begin();
66 
67  for (int idev = 0; it != devicesEnumeration.end(); ++it, idev++)
68  {
69  unsigned int nbTxChannels = it->m_nbTx;
70 
71  for (unsigned int ichan = 0; ichan < nbTxChannels; ichan++)
72  {
73  QString displayedName(QString("SoapySDR[%1:%2] %3").arg(idev).arg(ichan).arg(it->m_label));
74  QString serial(QString("%1-%2").arg(it->m_driverName).arg(it->m_sequence));
75  qDebug("SoapySDROutputPlugin::enumSampleSinks: device #%d (%s) serial %s channel %u",
76  idev, it->m_label.toStdString().c_str(), serial.toStdString().c_str(), ichan);
77  result.append(SamplingDevice(displayedName,
80  serial,
81  idev,
84  nbTxChannels,
85  ichan));
86  }
87  }
88 
89  return result;
90 }
91 
92 #ifdef SERVER_MODE
94  const QString& sinkId,
95  QWidget **widget,
96  DeviceUISet *deviceUISet)
97 {
98  (void) sinkId;
99  (void) widget;
100  (void) deviceUISet;
101  return 0;
102 }
103 #else
105  const QString& sinkId,
106  QWidget **widget,
107  DeviceUISet *deviceUISet)
108 {
109  if(sinkId == m_deviceTypeID)
110  {
111  SoapySDROutputGui* gui = new SoapySDROutputGui(deviceUISet);
112  *widget = gui;
113  return gui;
114  }
115  else
116  {
117  return 0;
118  }
119 }
120 #endif
121 
123 {
124  if(sinkId == m_deviceTypeID)
125  {
126  SoapySDROutput* output = new SoapySDROutput(deviceAPI);
127  return output;
128  }
129  else
130  {
131  return 0;
132  }
133 }
134 
135 
136 
137 
138 
virtual PluginInstanceGUI * createSampleSinkPluginInstanceGUI(const QString &sinkId, QWidget **widget, DeviceUISet *deviceUISet)
static const QString m_deviceTypeID
static const PluginDescriptor m_pluginDescriptor
#define SOAPYSDROUTPUT_DEVICE_TYPE_ID
void registerSampleSink(const QString &sinkName, PluginInterface *plugin)
Definition: pluginapi.cpp:24
virtual DeviceSampleSink * createSampleSinkPluginInstance(const QString &sinkId, DeviceAPI *deviceAPI)
static DeviceSoapySDR & instance()
const std::vector< DeviceSoapySDRScan::SoapySDRDeviceEnum > & getDevicesEnumeration() const
Fixed< IntType, IntBits > arg(const std::complex< Fixed< IntType, IntBits > > &val)
Definition: fixed.h:2401
SoapySDROutputPlugin(QObject *parent=0)
Exposes a single output stream that can be one of the streams of a physical device.
void initPlugin(PluginAPI *pluginAPI)
static const QString m_hardwareID
const PluginDescriptor & getPluginDescriptor() const
virtual SamplingDevices enumSampleSinks()
QList< SamplingDevice > SamplingDevices