1
0
mirror of https://github.com/f4exb/sdrangel.git synced 2024-11-26 17:58:43 -05:00
sdrangel/plugins/channelrx/demoddatv/datvdemod.h

194 lines
7.9 KiB
C
Raw Normal View History

2018-02-22 16:52:49 -05:00
///////////////////////////////////////////////////////////////////////////////////
// Copyright (C) 2018 F4HKW //
// for F4EXB / SDRAngel //
// using LeanSDR Framework (C) 2016 F4DAV //
// //
// 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 //
2019-04-11 00:39:30 -04:00
// (at your option) any later version. //
2018-02-22 16:52:49 -05:00
// //
// 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 INCLUDE_DATVDEMOD_H
#define INCLUDE_DATVDEMOD_H
2019-05-08 16:11:53 -04:00
class DeviceAPI;
2018-02-22 16:52:49 -05:00
#include <QNetworkRequest>
#include <QThread>
2019-05-09 11:27:12 -04:00
#include "channel/channelapi.h"
2018-03-10 19:00:27 -05:00
#include "dsp/basebandsamplesink.h"
#include "dsp/devicesamplesource.h"
#include "dsp/dspcommands.h"
2018-02-22 16:52:49 -05:00
#include "util/message.h"
2018-03-10 19:00:27 -05:00
2019-12-03 12:49:52 -05:00
#include "datvdemodbaseband.h"
class QNetworkAccessManager;
class QNetworkReply;
class ObjectPipe;
2019-05-09 11:27:12 -04:00
class DATVDemod : public BasebandSampleSink, public ChannelAPI
2018-02-22 16:52:49 -05:00
{
public:
2019-05-08 16:11:53 -04:00
DATVDemod(DeviceAPI *);
virtual ~DATVDemod();
2018-02-25 19:04:45 -05:00
virtual void destroy() { delete this; }
virtual void setDeviceAPI(DeviceAPI *deviceAPI);
virtual DeviceAPI *getDeviceAPI() { return m_deviceAPI; }
virtual void getIdentifier(QString& id) { id = objectName(); }
virtual QString getIdentifier() const { return objectName(); }
2018-02-25 19:04:45 -05:00
virtual void getTitle(QString& title) { title = objectName(); }
virtual qint64 getCenterFrequency() const { return m_settings.m_centerFrequency; }
virtual void setCenterFrequency(qint64 frequency);
2018-02-22 16:52:49 -05:00
2018-02-25 19:04:45 -05:00
virtual QByteArray serialize() const { return QByteArray(); }
virtual bool deserialize(const QByteArray& data) { (void) data; return false; }
2018-02-22 16:52:49 -05:00
using BasebandSampleSink::feed;
virtual void feed(const SampleVector::const_iterator& begin, const SampleVector::const_iterator& end, bool po);
2018-02-25 19:04:45 -05:00
virtual void start();
virtual void stop();
virtual void pushMessage(Message *msg) { m_inputMessageQueue.push(msg); }
virtual QString getSinkName() { return objectName(); }
2018-02-22 16:52:49 -05:00
2019-05-09 11:27:12 -04:00
virtual int getNbSinkStreams() const { return 1; }
virtual int getNbSourceStreams() const { return 0; }
uint32_t getNumberOfDeviceStreams() const;
2019-05-09 11:27:12 -04:00
virtual qint64 getStreamCenterFrequency(int streamIndex, bool sinkElseSource) const
{
(void) streamIndex;
(void) sinkElseSource;
return m_settings.m_centerFrequency;
}
virtual int webapiSettingsGet(
SWGSDRangel::SWGChannelSettings& response,
QString& errorMessage);
virtual int webapiWorkspaceGet(
SWGSDRangel::SWGWorkspaceInfo& response,
QString& errorMessage);
virtual int webapiSettingsPutPatch(
bool force,
const QStringList& channelSettingsKeys,
SWGSDRangel::SWGChannelSettings& response,
QString& errorMessage);
virtual int webapiReportGet(
SWGSDRangel::SWGChannelReport& response,
QString& errorMessage);
static void webapiFormatChannelSettings(
SWGSDRangel::SWGChannelSettings& response,
const DATVDemodSettings& settings);
static void webapiUpdateChannelSettings(
DATVDemodSettings& settings,
const QStringList& channelSettingsKeys,
SWGSDRangel::SWGChannelSettings& response);
2021-03-28 12:40:43 -04:00
void setMessageQueueToGUI(MessageQueue* queue) override
{
2021-03-08 02:35:30 -05:00
ChannelAPI::setMessageQueueToGUI(queue);
m_basebandSink->setMessageQueueToGUI(queue);
}
2021-03-28 12:40:43 -04:00
void SetTVScreen(TVScreen *tvScreen) { m_basebandSink->setTVScreen(tvScreen); }
void SetVideoRender(DATVideoRender *objScreen) { m_basebandSink->SetVideoRender(objScreen); }
DATVideostream *getVideoStream() { return m_basebandSink->getVideoStream(); }
DATVUDPStream *getUDPStream() { return m_basebandSink->getUDPStream(); }
2019-12-03 12:49:52 -05:00
bool audioActive() { return m_basebandSink->audioActive(); }
bool audioDecodeOK() { return m_basebandSink->audioDecodeOK(); }
bool videoActive() { return m_basebandSink->videoActive(); }
bool videoDecodeOK() { return m_basebandSink->videoDecodeOK(); }
bool udpRunning() { return m_basebandSink->udpRunning(); }
2018-02-22 16:52:49 -05:00
bool playVideo() { return m_basebandSink->playVideo(); }
2018-02-25 19:04:45 -05:00
2019-12-03 12:49:52 -05:00
double getMagSq() const { return m_basebandSink->getMagSq(); } //!< Beware this is scaled to 2^30
int getModcodModulation() const { return m_basebandSink->getModcodModulation(); }
int getModcodCodeRate() const { return m_basebandSink->getModcodCodeRate(); }
bool isCstlnSetByModcod() const { return m_basebandSink->isCstlnSetByModcod(); }
2018-02-22 16:52:49 -05:00
float getMERAvg() const { return m_basebandSink->getMERAvg(); }
float getMERRMS() const { return m_basebandSink->getMERRMS(); }
float getMERPeak() const { return m_basebandSink->getMERPeak(); }
int getMERNbAvg() const { return m_basebandSink->getMERNbAvg(); }
float getCNRAvg() const { return m_basebandSink->getCNRAvg(); }
float getCNRRMS() const { return m_basebandSink->getCNRRMS(); }
float getCNRPeak() const { return m_basebandSink->getCNRPeak(); }
int getCNRNbAvg() const { return m_basebandSink->getCNRNbAvg(); }
static const char* const m_channelIdURI;
static const char* const m_channelId;
2018-02-22 16:52:49 -05:00
class MsgConfigureDATVDemod : public Message {
2018-02-25 19:04:45 -05:00
MESSAGE_CLASS_DECLARATION
2018-02-24 18:07:08 -05:00
public:
const DATVDemodSettings& getSettings() const { return m_settings; }
bool getForce() const { return m_force; }
2018-02-25 19:04:45 -05:00
static MsgConfigureDATVDemod* create(const DATVDemodSettings& settings, bool force)
{
return new MsgConfigureDATVDemod(settings, force);
}
2018-02-25 19:04:45 -05:00
private:
DATVDemodSettings m_settings;
bool m_force;
MsgConfigureDATVDemod(const DATVDemodSettings& settings, bool force) :
Message(),
m_settings(settings),
m_force(force)
{ }
2018-02-22 16:52:49 -05:00
};
private:
2019-05-08 16:11:53 -04:00
DeviceAPI* m_deviceAPI;
QThread m_thread;
2019-12-03 12:49:52 -05:00
DATVDemodBaseband* m_basebandSink;
DATVDemodSettings m_settings;
2019-12-03 12:49:52 -05:00
int m_basebandSampleRate; //!< stored from device message used when starting baseband sink
2021-11-03 19:13:08 -04:00
QNetworkAccessManager *m_networkManager;
QNetworkRequest m_networkRequest;
2018-02-22 16:52:49 -05:00
virtual bool handleMessage(const Message& cmd);
void applySettings(const DATVDemodSettings& settings, bool force = false);
void webapiFormatChannelReport(SWGSDRangel::SWGChannelReport& response);
void webapiReverseSendSettings(QList<QString>& channelSettingsKeys, const DATVDemodSettings& settings, bool force);
void sendChannelSettings(
const QList<ObjectPipe*>& pipes,
QList<QString>& channelSettingsKeys,
const DATVDemodSettings& settings,
bool force
);
void webapiFormatChannelSettings(
QList<QString>& channelSettingsKeys,
SWGSDRangel::SWGChannelSettings *swgChannelSettings,
const DATVDemodSettings& settings,
bool force
);
private slots:
void networkManagerFinished(QNetworkReply *reply);
void handleIndexInDeviceSetChanged(int index);
2018-02-22 16:52:49 -05:00
};
#endif // INCLUDE_DATVDEMOD_H