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/>. //
|
|
|
|
///////////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
|
|
|
#include <QDebug>
|
|
|
|
|
2019-05-08 16:11:53 -04:00
|
|
|
#include "device/deviceapi.h"
|
2018-02-22 16:52:49 -05:00
|
|
|
|
2019-12-03 18:08:05 -05:00
|
|
|
#include "datvdemod.h"
|
|
|
|
|
2020-11-21 14:24:18 -05:00
|
|
|
const char* const DATVDemod::m_channelIdURI = "sdrangel.channel.demoddatv";
|
|
|
|
const char* const DATVDemod::m_channelId = "DATVDemod";
|
2018-02-22 16:52:49 -05:00
|
|
|
|
|
|
|
MESSAGE_CLASS_DEFINITION(DATVDemod::MsgConfigureDATVDemod, Message)
|
|
|
|
|
2019-05-08 16:11:53 -04:00
|
|
|
DATVDemod::DATVDemod(DeviceAPI *deviceAPI) :
|
2019-05-09 11:27:12 -04:00
|
|
|
ChannelAPI(m_channelIdURI, ChannelAPI::StreamSingleSink),
|
2018-02-25 19:04:45 -05:00
|
|
|
m_deviceAPI(deviceAPI),
|
2019-12-03 18:08:05 -05:00
|
|
|
m_basebandSampleRate(0)
|
2018-02-22 16:52:49 -05:00
|
|
|
{
|
2019-12-03 18:08:05 -05:00
|
|
|
qDebug("DATVDemod::DATVDemod");
|
2018-02-22 16:52:49 -05:00
|
|
|
setObjectName("DATVDemod");
|
2019-12-03 18:08:05 -05:00
|
|
|
m_basebandSink = new DATVDemodBaseband();
|
2021-03-23 03:35:30 -04:00
|
|
|
m_basebandSink->moveToThread(&m_thread);
|
2018-02-22 16:52:49 -05:00
|
|
|
|
2019-12-03 18:08:05 -05:00
|
|
|
applySettings(m_settings, true);
|
2018-02-22 16:52:49 -05:00
|
|
|
|
2019-12-03 18:08:05 -05:00
|
|
|
m_deviceAPI->addChannelSink(this);
|
2019-05-08 16:11:53 -04:00
|
|
|
m_deviceAPI->addChannelSinkAPI(this);
|
2019-12-03 18:08:05 -05:00
|
|
|
|
2018-02-22 16:52:49 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
DATVDemod::~DATVDemod()
|
|
|
|
{
|
2019-12-03 18:08:05 -05:00
|
|
|
qDebug("DATVDemod::~DATVDemod");
|
2019-05-08 16:11:53 -04:00
|
|
|
m_deviceAPI->removeChannelSinkAPI(this);
|
2019-12-03 18:08:05 -05:00
|
|
|
m_deviceAPI->removeChannelSink(this);
|
2021-03-23 03:35:30 -04:00
|
|
|
|
|
|
|
if (m_basebandSink->isRunning()) {
|
|
|
|
stop();
|
|
|
|
}
|
|
|
|
|
|
|
|
m_basebandSink->deleteLater();
|
2018-02-22 16:52:49 -05:00
|
|
|
}
|
|
|
|
|
2018-11-12 18:45:03 -05:00
|
|
|
void DATVDemod::feed(const SampleVector::const_iterator& begin, const SampleVector::const_iterator& end, bool firstOfBurst)
|
2018-02-22 16:52:49 -05:00
|
|
|
{
|
2018-11-12 18:45:03 -05:00
|
|
|
(void) firstOfBurst;
|
2019-12-03 18:08:05 -05:00
|
|
|
m_basebandSink->feed(begin, end);
|
2018-02-22 16:52:49 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
void DATVDemod::start()
|
|
|
|
{
|
2019-12-03 18:08:05 -05:00
|
|
|
qDebug("DATVDemod::start");
|
|
|
|
|
|
|
|
if (m_basebandSampleRate != 0) {
|
|
|
|
m_basebandSink->setBasebandSampleRate(m_basebandSampleRate);
|
|
|
|
}
|
|
|
|
|
|
|
|
m_basebandSink->reset();
|
2021-03-23 03:35:30 -04:00
|
|
|
m_basebandSink->startWork();
|
|
|
|
m_thread.start();
|
|
|
|
|
|
|
|
DATVDemodBaseband::MsgConfigureDATVDemodBaseband *msg = DATVDemodBaseband::MsgConfigureDATVDemodBaseband::create(m_settings, true);
|
|
|
|
m_basebandSink->getInputMessageQueue()->push(msg);
|
2018-02-22 16:52:49 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
void DATVDemod::stop()
|
|
|
|
{
|
2019-12-03 18:08:05 -05:00
|
|
|
qDebug("DATVDemod::stop");
|
2021-03-23 03:35:30 -04:00
|
|
|
m_basebandSink->stopWork();
|
|
|
|
m_thread.quit();
|
|
|
|
m_thread.wait();
|
2018-02-22 16:52:49 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
bool DATVDemod::handleMessage(const Message& cmd)
|
|
|
|
{
|
2019-12-03 18:08:05 -05:00
|
|
|
if (MsgConfigureDATVDemod::match(cmd))
|
2018-02-25 19:04:45 -05:00
|
|
|
{
|
2018-02-24 21:22:30 -05:00
|
|
|
MsgConfigureDATVDemod& objCfg = (MsgConfigureDATVDemod&) cmd;
|
2019-03-17 21:26:03 -04:00
|
|
|
qDebug() << "DATVDemod::handleMessage: MsgConfigureDATVDemod";
|
|
|
|
applySettings(objCfg.getSettings(), objCfg.getForce());
|
2018-02-25 19:04:45 -05:00
|
|
|
|
2019-03-16 20:36:44 -04:00
|
|
|
return true;
|
2018-02-25 19:04:45 -05:00
|
|
|
}
|
2019-07-14 09:35:45 -04:00
|
|
|
else if(DSPSignalNotification::match(cmd))
|
|
|
|
{
|
2019-12-03 18:08:05 -05:00
|
|
|
DSPSignalNotification& notif = (DSPSignalNotification&) cmd;
|
|
|
|
m_basebandSampleRate = notif.getSampleRate(); // store for init at start
|
|
|
|
qDebug() << "DATVDemod::handleMessage: DSPSignalNotification" << m_basebandSampleRate;
|
|
|
|
|
|
|
|
// Forward to the sink
|
|
|
|
DSPSignalNotification* notifToSink = new DSPSignalNotification(notif); // make a copy
|
|
|
|
m_basebandSink->getInputMessageQueue()->push(notifToSink);
|
2019-07-14 09:35:45 -04:00
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
2018-02-25 19:04:45 -05:00
|
|
|
else
|
|
|
|
{
|
|
|
|
return false;
|
|
|
|
}
|
2018-02-22 16:52:49 -05:00
|
|
|
}
|
|
|
|
|
2019-03-17 21:26:03 -04:00
|
|
|
void DATVDemod::applySettings(const DATVDemodSettings& settings, bool force)
|
2018-02-22 16:52:49 -05:00
|
|
|
{
|
2019-12-03 18:08:05 -05:00
|
|
|
QString debugMsg = tr("DATVDemod::applySettings: force: %1").arg(force);
|
|
|
|
settings.debug(debugMsg);
|
2019-03-23 01:06:42 -04:00
|
|
|
|
2019-12-03 18:08:05 -05:00
|
|
|
DATVDemodBaseband::MsgConfigureDATVDemodBaseband *msg = DATVDemodBaseband::MsgConfigureDATVDemodBaseband::create(settings, force);
|
|
|
|
m_basebandSink->getInputMessageQueue()->push(msg);
|
2019-03-17 21:26:03 -04:00
|
|
|
|
|
|
|
m_settings = settings;
|
2018-02-22 16:52:49 -05:00
|
|
|
}
|
2020-09-21 14:10:17 -04:00
|
|
|
|
|
|
|
uint32_t DATVDemod::getNumberOfDeviceStreams() const
|
|
|
|
{
|
|
|
|
return m_deviceAPI->getNbSourceStreams();
|
|
|
|
}
|