2016-10-17 12:15:08 -04: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/>. //
|
|
|
|
///////////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
|
|
|
#ifndef SDRBASE_DEVICE_DEVICESINKAPI_H_
|
|
|
|
#define SDRBASE_DEVICE_DEVICESINKAPI_H_
|
|
|
|
|
|
|
|
#include <QObject>
|
|
|
|
#include <QString>
|
|
|
|
|
2016-10-17 18:03:51 -04:00
|
|
|
#include "dsp/dspdevicesinkengine.h"
|
2016-10-17 12:15:08 -04:00
|
|
|
#include "util/export.h"
|
|
|
|
|
|
|
|
class MainWindow;
|
|
|
|
class GLSpectrum;
|
|
|
|
class ChannelWindow;
|
|
|
|
class BasebandSampleSource;
|
|
|
|
class ThreadedBasebandSampleSource;
|
|
|
|
class DeviceSampleSink;
|
|
|
|
class MessageQueue;
|
|
|
|
class ChannelMarker;
|
|
|
|
class QWidget;
|
2017-09-03 13:55:00 -04:00
|
|
|
class PluginInstanceUI;
|
2016-10-17 12:15:08 -04:00
|
|
|
class PluginAPI;
|
|
|
|
class Preset;
|
2016-12-29 06:41:10 -05:00
|
|
|
class DeviceSourceAPI;
|
2016-10-17 12:15:08 -04:00
|
|
|
|
|
|
|
class SDRANGEL_API DeviceSinkAPI : public QObject {
|
|
|
|
Q_OBJECT
|
|
|
|
|
|
|
|
public:
|
|
|
|
// Device engine stuff
|
2016-10-24 12:06:44 -04:00
|
|
|
void addSpectrumSink(BasebandSampleSink* sink); //!< Add the spectrum sample sink to device engine (spectrum vis)
|
|
|
|
void removeSpectrumSink(BasebandSampleSink* sink); //!< Remove the spectrum sample sink from device engine (spectrum vis)
|
2016-10-17 12:15:08 -04:00
|
|
|
void addSource(BasebandSampleSource* source); //!< Add a baseband sample source to device engine
|
|
|
|
void removeSource(BasebandSampleSource* sink); //!< Remove a baseband sample source from device engine
|
|
|
|
void addThreadedSource(ThreadedBasebandSampleSource* sink); //!< Add a baseband sample source that will run on its own thread to device engine
|
|
|
|
void removeThreadedSource(ThreadedBasebandSampleSource* sink); //!< Remove a baseband sample source that runs on its own thread from device engine
|
2016-12-26 09:26:25 -05:00
|
|
|
uint32_t getNumberOfSources();
|
2016-10-17 12:15:08 -04:00
|
|
|
void setSink(DeviceSampleSink* sink); //!< Set device engine sample sink type
|
|
|
|
bool initGeneration(); //!< Initialize device engine generation sequence
|
|
|
|
bool startGeneration(); //!< Start device engine generation sequence
|
|
|
|
void stopGeneration(); //!< Stop device engine generation sequence
|
|
|
|
DSPDeviceSinkEngine::State state() const; //!< device engine state
|
|
|
|
QString errorMessage(); //!< Return the current device engine error message
|
|
|
|
uint getDeviceUID() const; //!< Return the current device engine unique ID
|
|
|
|
MessageQueue *getDeviceInputMessageQueue();
|
|
|
|
MessageQueue *getDeviceOutputMessageQueue();
|
|
|
|
// device related stuff
|
|
|
|
GLSpectrum *getSpectrum(); //!< Direct spectrum getter
|
|
|
|
void addChannelMarker(ChannelMarker* channelMarker); //!< Add channel marker to spectrum
|
|
|
|
ChannelWindow *getChannelWindow(); //!< Direct channel window getter
|
|
|
|
void addRollupWidget(QWidget *widget); //!< Add rollup widget to channel window
|
|
|
|
void setOutputGUI(QWidget* outputGUI, const QString& sinkDisplayName);
|
|
|
|
|
2016-12-29 06:41:10 -05:00
|
|
|
void setHardwareId(const QString& id);
|
2016-10-17 12:15:08 -04:00
|
|
|
void setSampleSinkId(const QString& id);
|
|
|
|
void setSampleSinkSerial(const QString& serial);
|
|
|
|
void setSampleSinkSequence(int sequence);
|
2017-09-03 14:24:17 -04:00
|
|
|
void setSampleSinkPluginInstanceUI(PluginInstanceUI *gui);
|
2016-10-17 12:15:08 -04:00
|
|
|
|
2016-12-29 06:41:10 -05:00
|
|
|
const QString& getHardwareId() const { return m_hardwareId; }
|
|
|
|
const QString& getSampleSinkId() const { return m_sampleSinkId; }
|
|
|
|
const QString& getSampleSinkSerial() const { return m_sampleSinkSerial; }
|
2017-05-25 14:13:34 -04:00
|
|
|
uint32_t getSampleSinkSequence() const { return m_sampleSinkSequence; }
|
2016-12-29 06:41:10 -05:00
|
|
|
|
2017-09-03 13:55:00 -04:00
|
|
|
void registerChannelInstance(const QString& channelName, PluginInstanceUI* pluginGUI);
|
|
|
|
void removeChannelInstance(PluginInstanceUI* pluginGUI);
|
2016-10-17 12:15:08 -04:00
|
|
|
|
|
|
|
void freeAll();
|
|
|
|
|
|
|
|
void loadSinkSettings(const Preset* preset);
|
|
|
|
void saveSinkSettings(Preset* preset);
|
|
|
|
void loadChannelSettings(const Preset* preset, PluginAPI *pluginAPI);
|
|
|
|
void saveChannelSettings(Preset* preset);
|
|
|
|
|
|
|
|
MainWindow *getMainWindow() { return m_mainWindow; }
|
2016-12-29 06:41:10 -05:00
|
|
|
DSPDeviceSinkEngine *getDeviceSinkEngine() { return m_deviceSinkEngine; }
|
|
|
|
|
|
|
|
const std::vector<DeviceSourceAPI*>& getSourceBuddies() const { return m_sourceBuddies; }
|
|
|
|
const std::vector<DeviceSinkAPI*>& getSinkBuddies() const { return m_sinkBuddies; }
|
|
|
|
void addSourceBuddy(DeviceSourceAPI* buddy);
|
|
|
|
void addSinkBuddy(DeviceSinkAPI* buddy);
|
|
|
|
void removeSourceBuddy(DeviceSourceAPI* buddy);
|
|
|
|
void removeSinkBuddy(DeviceSinkAPI* buddy);
|
2016-12-29 13:26:45 -05:00
|
|
|
void clearBuddiesLists();
|
2016-12-30 10:13:28 -05:00
|
|
|
void *getBuddySharedPtr() const { return m_buddySharedPtr; }
|
|
|
|
void setBuddySharedPtr(void *ptr) { m_buddySharedPtr = ptr; }
|
2017-07-03 02:59:48 -04:00
|
|
|
bool isBuddyLeader() const { return m_isBuddyLeader; }
|
|
|
|
void setBuddyLeader(bool isBuddyLeader) { m_isBuddyLeader = isBuddyLeader; }
|
2016-10-17 12:15:08 -04:00
|
|
|
|
|
|
|
protected:
|
|
|
|
struct ChannelInstanceRegistration
|
|
|
|
{
|
|
|
|
QString m_channelName;
|
2017-09-03 13:55:00 -04:00
|
|
|
PluginInstanceUI* m_gui;
|
2016-10-17 12:15:08 -04:00
|
|
|
|
|
|
|
ChannelInstanceRegistration() :
|
|
|
|
m_channelName(),
|
|
|
|
m_gui(0)
|
|
|
|
{ }
|
|
|
|
|
2017-09-03 13:55:00 -04:00
|
|
|
ChannelInstanceRegistration(const QString& channelName, PluginInstanceUI* pluginGUI) :
|
2016-10-17 12:15:08 -04:00
|
|
|
m_channelName(channelName),
|
|
|
|
m_gui(pluginGUI)
|
|
|
|
{ }
|
|
|
|
|
|
|
|
bool operator<(const ChannelInstanceRegistration& other) const;
|
|
|
|
};
|
|
|
|
|
|
|
|
typedef QList<ChannelInstanceRegistration> ChannelInstanceRegistrations;
|
|
|
|
|
|
|
|
DeviceSinkAPI(MainWindow *mainWindow,
|
|
|
|
int deviceTabIndex,
|
2016-10-17 18:03:51 -04:00
|
|
|
DSPDeviceSinkEngine *deviceEngine,
|
2016-10-17 12:15:08 -04:00
|
|
|
GLSpectrum *glSpectrum,
|
|
|
|
ChannelWindow *channelWindow);
|
|
|
|
~DeviceSinkAPI();
|
|
|
|
|
|
|
|
void renameChannelInstances();
|
|
|
|
|
|
|
|
MainWindow *m_mainWindow;
|
|
|
|
int m_deviceTabIndex;
|
2016-10-17 18:03:51 -04:00
|
|
|
DSPDeviceSinkEngine *m_deviceSinkEngine;
|
2016-10-17 12:15:08 -04:00
|
|
|
GLSpectrum *m_spectrum;
|
|
|
|
ChannelWindow *m_channelWindow;
|
|
|
|
|
2016-12-29 06:41:10 -05:00
|
|
|
QString m_hardwareId;
|
2016-10-17 12:15:08 -04:00
|
|
|
QString m_sampleSinkId;
|
|
|
|
QString m_sampleSinkSerial;
|
2017-05-25 14:13:34 -04:00
|
|
|
uint32_t m_sampleSinkSequence;
|
2017-09-03 14:24:17 -04:00
|
|
|
PluginInstanceUI* m_sampleSinkPluginInstanceUI;
|
2016-10-17 12:15:08 -04:00
|
|
|
|
|
|
|
ChannelInstanceRegistrations m_channelInstanceRegistrations;
|
|
|
|
|
2016-12-29 06:41:10 -05:00
|
|
|
std::vector<DeviceSourceAPI*> m_sourceBuddies; //!< Device source APIs referencing the same physical device
|
|
|
|
std::vector<DeviceSinkAPI*> m_sinkBuddies; //!< Device sink APIs referencing the same physical device
|
2016-12-30 10:13:28 -05:00
|
|
|
void *m_buddySharedPtr;
|
2017-07-03 02:59:48 -04:00
|
|
|
bool m_isBuddyLeader;
|
2016-12-29 06:41:10 -05:00
|
|
|
|
2016-10-17 12:15:08 -04:00
|
|
|
friend class MainWindow;
|
2017-01-02 17:30:50 -05:00
|
|
|
friend class DeviceSourceAPI;
|
2016-10-17 12:15:08 -04:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#endif /* SDRBASE_DEVICE_DEVICESINKAPI_H_ */
|