2016-11-13 01:59:31 +00: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 PLUGINS_SAMPLESOURCE_SDRPLAY_SDRPLAYINPUT_H_
|
|
|
|
#define PLUGINS_SAMPLESOURCE_SDRPLAY_SDRPLAYINPUT_H_
|
|
|
|
|
|
|
|
#include <dsp/devicesamplesource.h>
|
|
|
|
|
|
|
|
#include "sdrplaysettings.h"
|
2016-11-15 17:58:17 +00:00
|
|
|
#include <mirisdr.h>
|
2016-11-13 01:59:31 +00:00
|
|
|
#include <QString>
|
2016-11-15 17:58:17 +00:00
|
|
|
#include <stdint.h>
|
2016-11-13 01:59:31 +00:00
|
|
|
|
|
|
|
class DeviceSourceAPI;
|
|
|
|
class SDRPlayThread;
|
2017-09-04 22:40:42 +00:00
|
|
|
class FileRecord;
|
2016-11-13 01:59:31 +00:00
|
|
|
|
|
|
|
class SDRPlayInput : public DeviceSampleSource {
|
|
|
|
public:
|
|
|
|
class MsgConfigureSDRPlay : public Message {
|
|
|
|
MESSAGE_CLASS_DECLARATION
|
|
|
|
|
|
|
|
public:
|
|
|
|
const SDRPlaySettings& getSettings() const { return m_settings; }
|
|
|
|
|
|
|
|
static MsgConfigureSDRPlay* create(const SDRPlaySettings& settings)
|
|
|
|
{
|
|
|
|
return new MsgConfigureSDRPlay(settings);
|
|
|
|
}
|
|
|
|
|
|
|
|
private:
|
|
|
|
SDRPlaySettings m_settings;
|
|
|
|
|
|
|
|
MsgConfigureSDRPlay(const SDRPlaySettings& settings) :
|
|
|
|
Message(),
|
|
|
|
m_settings(settings)
|
|
|
|
{ }
|
|
|
|
};
|
|
|
|
|
2016-11-18 01:46:35 +00:00
|
|
|
class MsgReportSDRPlayGains : public Message {
|
2016-11-13 01:59:31 +00:00
|
|
|
MESSAGE_CLASS_DECLARATION
|
|
|
|
|
|
|
|
public:
|
2016-11-18 01:46:35 +00:00
|
|
|
static MsgReportSDRPlayGains* create(int lnaGain, int mixerGain, int basebandGain, int tunerGain)
|
2016-11-13 01:59:31 +00:00
|
|
|
{
|
2016-11-18 01:46:35 +00:00
|
|
|
return new MsgReportSDRPlayGains(lnaGain, mixerGain, basebandGain, tunerGain);
|
2016-11-13 01:59:31 +00:00
|
|
|
}
|
|
|
|
|
2016-11-18 01:46:35 +00:00
|
|
|
int getLNAGain() const { return m_lnaGain; }
|
|
|
|
int getMixerGain() const { return m_mixerGain; }
|
|
|
|
int getBasebandGain() const { return m_basebandGain; }
|
|
|
|
int getTunerGain() const { return m_tunerGain; }
|
|
|
|
|
2016-11-13 01:59:31 +00:00
|
|
|
protected:
|
2016-11-18 01:46:35 +00:00
|
|
|
int m_lnaGain;
|
|
|
|
int m_mixerGain;
|
|
|
|
int m_basebandGain;
|
|
|
|
int m_tunerGain;
|
2016-11-15 17:58:17 +00:00
|
|
|
|
2016-11-18 01:46:35 +00:00
|
|
|
MsgReportSDRPlayGains(int lnaGain, int mixerGain, int basebandGain, int tunerGain) :
|
2016-11-15 17:58:17 +00:00
|
|
|
Message(),
|
2016-11-18 01:46:35 +00:00
|
|
|
m_lnaGain(lnaGain),
|
|
|
|
m_mixerGain(mixerGain),
|
|
|
|
m_basebandGain(basebandGain),
|
|
|
|
m_tunerGain(tunerGain)
|
2016-11-13 01:59:31 +00:00
|
|
|
{ }
|
|
|
|
};
|
|
|
|
|
2017-09-04 22:40:42 +00:00
|
|
|
class MsgFileRecord : public Message {
|
|
|
|
MESSAGE_CLASS_DECLARATION
|
|
|
|
|
|
|
|
public:
|
|
|
|
bool getStartStop() const { return m_startStop; }
|
|
|
|
|
|
|
|
static MsgFileRecord* create(bool startStop) {
|
|
|
|
return new MsgFileRecord(startStop);
|
|
|
|
}
|
|
|
|
|
|
|
|
protected:
|
|
|
|
bool m_startStop;
|
|
|
|
|
|
|
|
MsgFileRecord(bool startStop) :
|
|
|
|
Message(),
|
|
|
|
m_startStop(startStop)
|
|
|
|
{ }
|
|
|
|
};
|
|
|
|
|
2016-11-13 01:59:31 +00:00
|
|
|
SDRPlayInput(DeviceSourceAPI *deviceAPI);
|
|
|
|
virtual ~SDRPlayInput();
|
|
|
|
|
2017-04-14 01:40:45 +00:00
|
|
|
virtual bool start();
|
2016-11-13 01:59:31 +00:00
|
|
|
virtual void stop();
|
|
|
|
|
|
|
|
virtual const QString& getDeviceDescription() const;
|
|
|
|
virtual int getSampleRate() const;
|
|
|
|
virtual quint64 getCenterFrequency() const;
|
|
|
|
|
|
|
|
virtual bool handleMessage(const Message& message);
|
|
|
|
|
|
|
|
private:
|
2017-04-14 00:49:41 +00:00
|
|
|
bool openDevice();
|
|
|
|
void closeDevice();
|
2016-11-19 03:11:19 +00:00
|
|
|
bool applySettings(const SDRPlaySettings& settings, bool forwardChange, bool force);
|
2016-11-16 01:38:21 +00:00
|
|
|
bool setCenterFrequency(quint64 freq);
|
2016-11-13 01:59:31 +00:00
|
|
|
|
|
|
|
DeviceSourceAPI *m_deviceAPI;
|
|
|
|
QMutex m_mutex;
|
|
|
|
SDRPlaySettings m_settings;
|
2016-11-15 17:58:17 +00:00
|
|
|
mirisdr_dev_t* m_dev;
|
2016-11-13 01:59:31 +00:00
|
|
|
SDRPlayThread* m_sdrPlayThread;
|
|
|
|
QString m_deviceDescription;
|
2016-11-19 03:11:19 +00:00
|
|
|
int m_devNumber;
|
2017-04-14 00:49:41 +00:00
|
|
|
bool m_running;
|
2017-09-04 22:40:42 +00:00
|
|
|
FileRecord *m_fileSink; //!< File sink to record device I/Q output
|
2016-11-13 01:59:31 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif /* PLUGINS_SAMPLESOURCE_SDRPLAY_SDRPLAYINPUT_H_ */
|