SDRdaemon: added channel sink

This commit is contained in:
f4exb 2018-08-19 23:36:30 +02:00
parent ef3bc466d6
commit dfb619cd98
5 changed files with 161 additions and 0 deletions

View File

@ -5,6 +5,7 @@ set(sdrdaemon_SOURCES
sdrdaemonpreferences.cpp
sdrdaemonsettings.cpp
sdrdaemonparser.cpp
channel/sdrdaemonchannelsink.cpp
webapi/webapiadapterdaemon.cpp
webapi/webapirequestmapper.cpp
webapi/webapiserver.cpp
@ -15,6 +16,7 @@ set(sdrdaemon_HEADERS
sdrdaemonpreferences.h
sdrdaemonsettings.h
sdrdaemonparser.h
channel/sdrdaemonchannelsink.h
webapi/webapiadapterdaemon.h
webapi/webapirequestmapper.h
webapi/webapiserver.h

View File

@ -0,0 +1,84 @@
///////////////////////////////////////////////////////////////////////////////////
// Copyright (C) 2018 Edouard Griffiths, F4EXB. //
// //
// SDRdaemon sink channel (Rx) //
// //
// SDRdaemon is a detached SDR front end that handles the interface with a //
// physical device and sends or receives the I/Q samples stream to or from a //
// SDRangel instance via UDP. It is controlled via a Web REST API. //
// //
// 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/>. //
///////////////////////////////////////////////////////////////////////////////////
#include "util/simpleserializer.h"
#include "dsp/threadedbasebandsamplesink.h"
#include "dsp/downchannelizer.h"
#include "device/devicesourceapi.h"
#include "sdrdaemonchannelsink.h"
const QString SDRDaemonChannelSink::m_channelIdURI = "sdrangel.channel.sdrdaemonsink";
const QString SDRDaemonChannelSink::m_channelId = "SDRDaemonChannelSink";
SDRDaemonChannelSink::SDRDaemonChannelSink(DeviceSourceAPI *deviceAPI) :
ChannelSinkAPI(m_channelIdURI),
m_deviceAPI(deviceAPI),
m_running(false)
{
setObjectName(m_channelId);
m_channelizer = new DownChannelizer(this);
m_threadedChannelizer = new ThreadedBasebandSampleSink(m_channelizer, this);
m_deviceAPI->addThreadedSink(m_threadedChannelizer);
m_deviceAPI->addChannelAPI(this);
}
SDRDaemonChannelSink::~SDRDaemonChannelSink()
{
m_deviceAPI->removeChannelAPI(this);
m_deviceAPI->removeThreadedSink(m_threadedChannelizer);
delete m_threadedChannelizer;
delete m_channelizer;
}
void SDRDaemonChannelSink::feed(const SampleVector::const_iterator& begin, const SampleVector::const_iterator& end, bool firstOfBurst __attribute__((unused)))
{
qDebug("SDRDaemonChannelSink::feed: received %d samples", (int) (end - begin));
}
void SDRDaemonChannelSink::start()
{
qDebug("SDRDaemonChannelSink::start");
m_running = true;
}
void SDRDaemonChannelSink::stop()
{
qDebug("SDRDaemonChannelSink::stop");
m_running = false;
}
bool SDRDaemonChannelSink::handleMessage(const Message& cmd __attribute__((unused)))
{
return false;
}
QByteArray SDRDaemonChannelSink::serialize() const
{
SimpleSerializer s(1);
return s.final();
}
bool SDRDaemonChannelSink::deserialize(const QByteArray& data __attribute__((unused)))
{
return false;
}

View File

@ -0,0 +1,64 @@
///////////////////////////////////////////////////////////////////////////////////
// Copyright (C) 2018 Edouard Griffiths, F4EXB. //
// //
// SDRdaemon sink channel (Rx) //
// //
// SDRdaemon is a detached SDR front end that handles the interface with a //
// physical device and sends or receives the I/Q samples stream to or from a //
// SDRangel instance via UDP. It is controlled via a Web REST API. //
// //
// 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 SDRDAEMON_CHANNEL_SDRDAEMONCHANNELSINK_H_
#define SDRDAEMON_CHANNEL_SDRDAEMONCHANNELSINK_H_
#include "dsp/basebandsamplesink.h"
#include "channel/channelsinkapi.h"
class DeviceSourceAPI;
class ThreadedBasebandSampleSink;
class DownChannelizer;
class SDRDaemonChannelSink : public BasebandSampleSink, public ChannelSinkAPI {
Q_OBJECT
public:
SDRDaemonChannelSink(DeviceSourceAPI *deviceAPI);
virtual ~SDRDaemonChannelSink();
virtual void destroy() { delete this; }
virtual void feed(const SampleVector::const_iterator& begin, const SampleVector::const_iterator& end, bool po);
virtual void start();
virtual void stop();
virtual bool handleMessage(const Message& cmd);
virtual void getIdentifier(QString& id) { id = objectName(); }
virtual void getTitle(QString& title) { title = "SDRDaemon Sink"; }
virtual qint64 getCenterFrequency() const { return 0; }
virtual QByteArray serialize() const;
virtual bool deserialize(const QByteArray& data);
static const QString m_channelIdURI;
static const QString m_channelId;
private:
DeviceSourceAPI *m_deviceAPI;
ThreadedBasebandSampleSink* m_threadedChannelizer;
DownChannelizer* m_channelizer;
bool m_running;
};
#endif /* SDRDAEMON_CHANNEL_SDRDAEMONCHANNELSINK_H_ */

View File

@ -37,6 +37,7 @@
#include "webapi/webapiadapterdaemon.h"
#include "webapi/webapirequestmapper.h"
#include "webapi/webapiserver.h"
#include "channel/sdrdaemonchannelsink.h"
#include "sdrdaemonparser.h"
#include "sdrdaemonmain.h"
@ -85,6 +86,7 @@ SDRDaemonMain::SDRDaemonMain(qtwebapp::LoggerWithFile *logger, const SDRDaemonPa
m_deviceSinkEngine = 0;
m_deviceSourceAPI = 0;
m_deviceSinkAPI = 0;
m_channelSink = 0;
if (m_tx)
{
@ -123,6 +125,7 @@ SDRDaemonMain::SDRDaemonMain(qtwebapp::LoggerWithFile *logger, const SDRDaemonPa
QDebug info = qInfo();
info.noquote();
info << msg;
m_channelSink = new SDRDaemonChannelSink(m_deviceSourceAPI);
}
else
{
@ -283,6 +286,11 @@ void SDRDaemonMain::removeDevice()
m_deviceSourceEngine->stopAcquistion();
// deletes old UI and input object
if (m_channelSink) {
m_channelSink->destroy();
}
m_deviceSourceAPI->resetSampleSourceId();
m_deviceSourceAPI->getPluginInterface()->deleteSampleSourcePluginInstanceInput(
m_deviceSourceAPI->getSampleSource());

View File

@ -47,6 +47,7 @@ class DSPDeviceSourceEngine;
class DeviceSourceAPI;
class DSPDeviceSinkEngine;
class DeviceSinkAPI;
class SDRDaemonChannelSink;
class SDRDaemonMain : public QObject {
Q_OBJECT
@ -92,11 +93,13 @@ private:
DeviceSourceAPI *m_deviceSourceAPI;
DSPDeviceSinkEngine *m_deviceSinkEngine;
DeviceSinkAPI *m_deviceSinkAPI;
SDRDaemonChannelSink *m_channelSink;
void loadSettings();
void setLoggingOptions();
int getDeviceIndex();
bool handleMessage(const Message& cmd);
void addChannelSink();
private slots:
void handleMessages();