| 
									
										
										
										
											2016-10-17 18:15:08 +02: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-18 00:03:51 +02:00
										 |  |  | #include "dsp/dspdevicesinkengine.h"
 | 
					
						
							| 
									
										
										
										
											2018-03-20 13:49:21 +01:00
										 |  |  | #include "export.h"
 | 
					
						
							| 
									
										
										
										
											2016-10-17 18:15:08 +02:00
										 |  |  | 
 | 
					
						
							|  |  |  | class BasebandSampleSource; | 
					
						
							|  |  |  | class ThreadedBasebandSampleSource; | 
					
						
							|  |  |  | class DeviceSampleSink; | 
					
						
							|  |  |  | class MessageQueue; | 
					
						
							| 
									
										
										
										
											2017-09-26 00:22:08 +02:00
										 |  |  | class PluginInstanceGUI; | 
					
						
							| 
									
										
										
										
											2017-09-15 01:49:18 +02:00
										 |  |  | class PluginInterface; | 
					
						
							| 
									
										
										
										
											2016-10-17 18:15:08 +02:00
										 |  |  | class Preset; | 
					
						
							| 
									
										
										
										
											2016-12-29 12:41:10 +01:00
										 |  |  | class DeviceSourceAPI; | 
					
						
							| 
									
										
										
										
											2017-11-19 03:38:07 +01:00
										 |  |  | class ChannelSourceAPI; | 
					
						
							| 
									
										
										
										
											2016-10-17 18:15:08 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-03-03 20:23:38 +01:00
										 |  |  | class SDRBASE_API DeviceSinkAPI : public QObject { | 
					
						
							| 
									
										
										
										
											2016-10-17 18:15:08 +02:00
										 |  |  |     Q_OBJECT | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | public: | 
					
						
							| 
									
										
										
										
											2017-10-24 17:07:11 +02:00
										 |  |  |     DeviceSinkAPI(int deviceTabIndex, | 
					
						
							| 
									
										
										
										
											2017-11-01 00:18:10 +01:00
										 |  |  |             DSPDeviceSinkEngine *deviceEngine); | 
					
						
							| 
									
										
										
										
											2017-10-24 17:07:11 +02:00
										 |  |  |     ~DeviceSinkAPI(); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-10-17 18:15:08 +02:00
										 |  |  |     // Device engine stuff
 | 
					
						
							| 
									
										
										
										
											2016-10-24 18:06:44 +02: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 18:15:08 +02: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
 | 
					
						
							| 
									
										
										
										
											2017-11-19 03:38:07 +01:00
										 |  |  |     void addChannelAPI(ChannelSourceAPI* channelAPI); | 
					
						
							|  |  |  |     void removeChannelAPI(ChannelSourceAPI* channelAPI); | 
					
						
							| 
									
										
										
										
											2016-12-26 15:26:25 +01:00
										 |  |  |     uint32_t getNumberOfSources(); | 
					
						
							| 
									
										
										
										
											2017-09-16 11:34:25 +02:00
										 |  |  |     void setSampleSink(DeviceSampleSink* sink);                    //!< Set device engine sample sink type
 | 
					
						
							|  |  |  |     DeviceSampleSink *getSampleSink();                             //!< Return pointer to the device sample sink
 | 
					
						
							| 
									
										
										
										
											2016-10-17 18:15:08 +02:00
										 |  |  |     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
 | 
					
						
							| 
									
										
										
										
											2017-09-13 23:42:28 +02:00
										 |  |  |     MessageQueue *getDeviceEngineInputMessageQueue(); | 
					
						
							| 
									
										
										
										
											2017-09-17 17:35:03 +02:00
										 |  |  |     MessageQueue *getSampleSinkInputMessageQueue(); | 
					
						
							|  |  |  |     MessageQueue *getSampleSinkGUIMessageQueue(); | 
					
						
							| 
									
										
										
										
											2017-10-30 01:11:35 +01:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-12-29 12:41:10 +01:00
										 |  |  |     void setHardwareId(const QString& id); | 
					
						
							| 
									
										
										
										
											2016-10-17 18:15:08 +02:00
										 |  |  |     void setSampleSinkId(const QString& id); | 
					
						
							| 
									
										
										
										
											2017-09-16 11:34:25 +02:00
										 |  |  |     void resetSampleSinkId(); | 
					
						
							| 
									
										
										
										
											2016-10-17 18:15:08 +02:00
										 |  |  |     void setSampleSinkSerial(const QString& serial); | 
					
						
							| 
									
										
										
										
											2017-09-15 01:49:18 +02:00
										 |  |  |     void setSampleSinkDisplayName(const QString& serial); | 
					
						
							| 
									
										
										
										
											2016-10-17 18:15:08 +02:00
										 |  |  |     void setSampleSinkSequence(int sequence); | 
					
						
							| 
									
										
										
										
											2017-11-19 01:05:16 +01:00
										 |  |  |     void setNbItems(uint32_t nbItems); | 
					
						
							| 
									
										
										
										
											2017-11-02 09:17:38 +01:00
										 |  |  |     void setItemIndex(uint32_t index); | 
					
						
							| 
									
										
										
										
											2017-09-15 18:48:30 +02:00
										 |  |  |     void setSampleSinkPluginInterface(PluginInterface *iface); | 
					
						
							| 
									
										
										
										
											2017-09-26 00:22:08 +02:00
										 |  |  |     void setSampleSinkPluginInstanceUI(PluginInstanceGUI *gui); | 
					
						
							| 
									
										
										
										
											2016-10-17 18:15:08 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-12-29 12:41:10 +01:00
										 |  |  |     const QString& getHardwareId() const { return m_hardwareId; } | 
					
						
							|  |  |  |     const QString& getSampleSinkId() const { return m_sampleSinkId; } | 
					
						
							|  |  |  |     const QString& getSampleSinkSerial() const { return m_sampleSinkSerial; } | 
					
						
							| 
									
										
										
										
											2017-09-15 01:49:18 +02:00
										 |  |  |     const QString& getSampleSinkDisplayName() const { return m_sampleSinkDisplayName; } | 
					
						
							| 
									
										
										
										
											2017-05-25 20:13:34 +02:00
										 |  |  |     uint32_t getSampleSinkSequence() const { return m_sampleSinkSequence; } | 
					
						
							| 
									
										
										
										
											2017-11-19 01:05:16 +01:00
										 |  |  |     uint32_t getNbItems() const { return m_nbItems; } | 
					
						
							| 
									
										
										
										
											2017-11-02 09:17:38 +01:00
										 |  |  |     uint32_t getItemIndex() const { return m_itemIndex; } | 
					
						
							|  |  |  |     PluginInterface *getPluginInterface() { return m_pluginInterface; } | 
					
						
							| 
									
										
										
										
											2017-09-26 00:22:08 +02:00
										 |  |  |     PluginInstanceGUI *getSampleSinkPluginInstanceGUI() { return m_sampleSinkPluginInstanceUI; } | 
					
						
							| 
									
										
										
										
											2017-11-19 01:05:16 +01:00
										 |  |  |     void getDeviceEngineStateStr(QString& state); | 
					
						
							| 
									
										
										
										
											2017-11-19 03:38:07 +01:00
										 |  |  |     ChannelSourceAPI *getChanelAPIAt(int index); | 
					
						
							|  |  |  |     int getNbChannels() const { return m_channelAPIs.size(); } | 
					
						
							| 
									
										
										
										
											2016-12-29 12:41:10 +01:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-09-26 00:22:08 +02:00
										 |  |  |     void registerChannelInstance(const QString& channelName, PluginInstanceGUI* pluginGUI); | 
					
						
							|  |  |  |     void removeChannelInstance(PluginInstanceGUI* pluginGUI); | 
					
						
							| 
									
										
										
										
											2016-10-17 18:15:08 +02:00
										 |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     void loadSinkSettings(const Preset* preset); | 
					
						
							|  |  |  |     void saveSinkSettings(Preset* preset); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-12-29 12:41:10 +01: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 19:26:45 +01:00
										 |  |  |     void clearBuddiesLists(); | 
					
						
							| 
									
										
										
										
											2016-12-30 16:13:28 +01:00
										 |  |  |     void *getBuddySharedPtr() const { return m_buddySharedPtr; } | 
					
						
							|  |  |  |     void setBuddySharedPtr(void *ptr) { m_buddySharedPtr = ptr; } | 
					
						
							| 
									
										
										
										
											2017-07-03 08:59:48 +02:00
										 |  |  |     bool isBuddyLeader() const { return m_isBuddyLeader; } | 
					
						
							|  |  |  |     void setBuddyLeader(bool isBuddyLeader) { m_isBuddyLeader = isBuddyLeader; } | 
					
						
							| 
									
										
										
										
											2016-10-17 18:15:08 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-10-30 00:02:28 +01:00
										 |  |  |     const QTimer& getMasterTimer() const { return m_masterTimer; } //!< This is the DSPEngine master timer
 | 
					
						
							| 
									
										
										
										
											2017-09-14 13:55:57 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-10-17 18:15:08 +02:00
										 |  |  | protected: | 
					
						
							|  |  |  |     int m_deviceTabIndex; | 
					
						
							| 
									
										
										
										
											2016-10-18 00:03:51 +02:00
										 |  |  |     DSPDeviceSinkEngine *m_deviceSinkEngine; | 
					
						
							| 
									
										
										
										
											2016-10-17 18:15:08 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-11-02 09:17:38 +01:00
										 |  |  |     QString m_hardwareId;            //!< The internal id that identifies the type of hardware (i.e. HackRF, BladeRF, ...)
 | 
					
						
							|  |  |  |     QString m_sampleSinkId;          //!< The internal plugin ID corresponding to the device (i.e. for HackRF input, for HackRF output ...)
 | 
					
						
							|  |  |  |     QString m_sampleSinkSerial;      //!< The device serial number defined by the vendor
 | 
					
						
							|  |  |  |     QString m_sampleSinkDisplayName; //!< The human readable name identifying this instance
 | 
					
						
							|  |  |  |     uint32_t m_sampleSinkSequence;   //!< The device sequence. >0 when more than one device of the same type is connected
 | 
					
						
							| 
									
										
										
										
											2017-11-19 01:05:16 +01:00
										 |  |  |     uint32_t m_nbItems;              //!< Number of items or streams in the device. Can be >1 for NxM devices (i.e. 2 for LimeSDR)
 | 
					
						
							|  |  |  |     uint32_t m_itemIndex;            //!< The Tx stream index. Can be >0 for NxM devices (i.e. 0 or 1 for LimeSDR)
 | 
					
						
							| 
									
										
										
										
											2017-09-15 01:49:18 +02:00
										 |  |  |     PluginInterface* m_pluginInterface; | 
					
						
							| 
									
										
										
										
											2017-09-26 00:22:08 +02:00
										 |  |  |     PluginInstanceGUI* m_sampleSinkPluginInstanceUI; | 
					
						
							| 
									
										
										
										
											2016-10-17 18:15:08 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-12-29 12:41:10 +01: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 16:13:28 +01:00
										 |  |  |     void *m_buddySharedPtr; | 
					
						
							| 
									
										
										
										
											2017-07-03 08:59:48 +02:00
										 |  |  |     bool m_isBuddyLeader; | 
					
						
							| 
									
										
										
										
											2017-10-30 00:02:28 +01:00
										 |  |  |     const QTimer& m_masterTimer; //!< This is the DSPEngine master timer
 | 
					
						
							| 
									
										
										
										
											2016-12-29 12:41:10 +01:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-11-19 03:38:07 +01:00
										 |  |  |     QList<ChannelSourceAPI*> m_channelAPIs; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-01-02 23:30:50 +01:00
										 |  |  |     friend class DeviceSourceAPI; | 
					
						
							| 
									
										
										
										
											2017-11-19 03:38:07 +01:00
										 |  |  | 
 | 
					
						
							|  |  |  | private: | 
					
						
							|  |  |  |     void renumerateChannels(); | 
					
						
							| 
									
										
										
										
											2016-10-17 18:15:08 +02:00
										 |  |  | }; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | #endif /* SDRBASE_DEVICE_DEVICESINKAPI_H_ */
 |