sdrangel/plugins/samplesink/sdrdaemonsink/sdrdaemonsinkoutput.h

162 lines
4.6 KiB
C
Raw Normal View History

2017-05-14 18:58:56 -04:00
///////////////////////////////////////////////////////////////////////////////////
2017-05-20 22:19:12 -04:00
// Copyright (C) 2017 Edouard Griffiths, F4EXB //
2017-05-14 18:58:56 -04:00
// //
// 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/>. //
///////////////////////////////////////////////////////////////////////////////////
2017-05-20 22:19:12 -04:00
#ifndef INCLUDE_SDRDAEMONSINKOUTPUT_H
#define INCLUDE_SDRDAEMONSINKOUTPUT_H
2017-05-14 18:58:56 -04:00
#include <QString>
#include <QTimer>
#include <ctime>
#include <iostream>
#include <fstream>
#include "dsp/devicesamplesink.h"
#include "sdrdaemonsinksettings.h"
2017-05-20 22:19:12 -04:00
class SDRdaemonSinkThread;
2017-05-14 18:58:56 -04:00
class DeviceSinkAPI;
2017-05-20 22:19:12 -04:00
class SDRdaemonSinkOutput : public DeviceSampleSink {
2017-05-14 18:58:56 -04:00
public:
2017-05-20 22:19:12 -04:00
class MsgConfigureSDRdaemonSink : public Message {
2017-05-14 18:58:56 -04:00
MESSAGE_CLASS_DECLARATION
public:
2017-05-20 22:19:12 -04:00
const SDRdaemonSinkSettings& getSettings() const { return m_settings; }
2017-05-22 19:41:30 -04:00
bool getForce() const { return m_force; }
2017-05-14 18:58:56 -04:00
2017-05-22 19:41:30 -04:00
static MsgConfigureSDRdaemonSink* create(const SDRdaemonSinkSettings& settings, bool force = false)
2017-05-14 18:58:56 -04:00
{
2017-05-22 19:41:30 -04:00
return new MsgConfigureSDRdaemonSink(settings, force);
2017-05-14 18:58:56 -04:00
}
private:
2017-05-20 22:19:12 -04:00
SDRdaemonSinkSettings m_settings;
2017-05-22 19:41:30 -04:00
bool m_force;
2017-05-14 18:58:56 -04:00
2017-05-22 19:41:30 -04:00
MsgConfigureSDRdaemonSink(const SDRdaemonSinkSettings& settings, bool force) :
2017-05-14 18:58:56 -04:00
Message(),
2017-05-22 19:41:30 -04:00
m_settings(settings),
m_force(force)
2017-05-14 18:58:56 -04:00
{ }
};
2017-05-20 22:19:12 -04:00
class MsgConfigureSDRdaemonSinkWork : public Message {
2017-05-14 18:58:56 -04:00
MESSAGE_CLASS_DECLARATION
public:
bool isWorking() const { return m_working; }
2017-05-20 22:19:12 -04:00
static MsgConfigureSDRdaemonSinkWork* create(bool working)
2017-05-14 18:58:56 -04:00
{
2017-05-20 22:19:12 -04:00
return new MsgConfigureSDRdaemonSinkWork(working);
2017-05-14 18:58:56 -04:00
}
private:
bool m_working;
2017-05-20 22:19:12 -04:00
MsgConfigureSDRdaemonSinkWork(bool working) :
2017-05-14 18:58:56 -04:00
Message(),
m_working(working)
{ }
};
class MsgConfigureSDRdaemonSinkChunkCorrection : public Message {
MESSAGE_CLASS_DECLARATION
public:
int getChunkCorrection() const { return m_chunkCorrection; }
static MsgConfigureSDRdaemonSinkChunkCorrection* create(int chunkCorrection)
{
return new MsgConfigureSDRdaemonSinkChunkCorrection(chunkCorrection);
}
private:
int m_chunkCorrection;
MsgConfigureSDRdaemonSinkChunkCorrection(int chunkCorrection) :
Message(),
m_chunkCorrection(chunkCorrection)
{ }
};
2017-05-20 22:19:12 -04:00
class MsgConfigureSDRdaemonSinkStreamTiming : public Message {
2017-05-14 18:58:56 -04:00
MESSAGE_CLASS_DECLARATION
public:
2017-05-20 22:19:12 -04:00
static MsgConfigureSDRdaemonSinkStreamTiming* create()
2017-05-14 18:58:56 -04:00
{
2017-05-20 22:19:12 -04:00
return new MsgConfigureSDRdaemonSinkStreamTiming();
2017-05-14 18:58:56 -04:00
}
private:
2017-05-20 22:19:12 -04:00
MsgConfigureSDRdaemonSinkStreamTiming() :
2017-05-14 18:58:56 -04:00
Message()
{ }
};
2017-05-20 22:19:12 -04:00
class MsgReportSDRdaemonSinkStreamTiming : public Message {
2017-05-14 18:58:56 -04:00
MESSAGE_CLASS_DECLARATION
public:
std::size_t getSamplesCount() const { return m_samplesCount; }
2017-05-20 22:19:12 -04:00
static MsgReportSDRdaemonSinkStreamTiming* create(std::size_t samplesCount)
2017-05-14 18:58:56 -04:00
{
2017-05-20 22:19:12 -04:00
return new MsgReportSDRdaemonSinkStreamTiming(samplesCount);
2017-05-14 18:58:56 -04:00
}
protected:
std::size_t m_samplesCount;
2017-05-20 22:19:12 -04:00
MsgReportSDRdaemonSinkStreamTiming(std::size_t samplesCount) :
2017-05-14 18:58:56 -04:00
Message(),
m_samplesCount(samplesCount)
{ }
};
SDRdaemonSinkOutput(DeviceSinkAPI *deviceAPI);
2017-05-20 22:19:12 -04:00
virtual ~SDRdaemonSinkOutput();
virtual void destroy();
2017-05-14 18:58:56 -04:00
virtual bool start();
virtual void stop();
virtual const QString& getDeviceDescription() const;
virtual int getSampleRate() const;
virtual quint64 getCenterFrequency() const;
std::time_t getStartingTimeStamp() const;
virtual bool handleMessage(const Message& message);
private:
DeviceSinkAPI *m_deviceAPI;
QMutex m_mutex;
2017-05-20 22:19:12 -04:00
SDRdaemonSinkSettings m_settings;
SDRdaemonSinkThread* m_sdrDaemonSinkThread;
2017-05-14 18:58:56 -04:00
QString m_deviceDescription;
std::time_t m_startingTimeStamp;
const QTimer& m_masterTimer;
2017-05-20 22:19:12 -04:00
void applySettings(const SDRdaemonSinkSettings& settings, bool force = false);
2017-05-14 18:58:56 -04:00
};
2017-05-20 22:19:12 -04:00
#endif // INCLUDE_SDRDAEMONSINKOUTPUT_H