mirror of
https://github.com/f4exb/sdrangel.git
synced 2026-06-05 23:45:00 -04:00
Full renaming of FileSource device to FileInput
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
project(samplesource)
|
||||
|
||||
add_subdirectory(filesource)
|
||||
add_subdirectory(fileinput)
|
||||
add_subdirectory(testsource)
|
||||
add_subdirectory(localinput)
|
||||
|
||||
|
||||
@@ -0,0 +1,54 @@
|
||||
project(fileinput)
|
||||
|
||||
set(fileinput_SOURCES
|
||||
fileinput.cpp
|
||||
fileinputplugin.cpp
|
||||
fileinputthread.cpp
|
||||
fileinputsettings.cpp
|
||||
)
|
||||
|
||||
set(fileinput_HEADERS
|
||||
fileinput.h
|
||||
fileinputplugin.h
|
||||
fileinputthread.h
|
||||
fileinputsettings.h
|
||||
)
|
||||
|
||||
include_directories(
|
||||
${CMAKE_SOURCE_DIR}/swagger/sdrangel/code/qt5/client
|
||||
)
|
||||
|
||||
if(NOT SERVER_MODE)
|
||||
set(fileinput_SOURCES
|
||||
${fileinput_SOURCES}
|
||||
fileinputgui.cpp
|
||||
fileinputgui.ui
|
||||
)
|
||||
set(fileinput_HEADERS
|
||||
${fileinput_HEADERS}
|
||||
fileinputgui.h
|
||||
)
|
||||
set(TARGET_NAME inputfileinput)
|
||||
set(TARGET_LIB "Qt5::Widgets")
|
||||
set(TARGET_LIB_GUI "sdrgui")
|
||||
set(INSTALL_FOLDER ${INSTALL_PLUGINS_DIR})
|
||||
else()
|
||||
set(TARGET_NAME inputfileinputsrv)
|
||||
set(TARGET_LIB "")
|
||||
set(TARGET_LIB_GUI "")
|
||||
set(INSTALL_FOLDER ${INSTALL_PLUGINSSRV_DIR})
|
||||
endif()
|
||||
|
||||
add_library(${TARGET_NAME} SHARED
|
||||
${fileinput_SOURCES}
|
||||
)
|
||||
|
||||
target_link_libraries(${TARGET_NAME}
|
||||
Qt5::Core
|
||||
${TARGET_LIB}
|
||||
sdrbase
|
||||
${TARGET_LIB_GUI}
|
||||
swagger
|
||||
)
|
||||
|
||||
install(TARGETS ${TARGET_NAME} DESTINATION ${INSTALL_FOLDER})
|
||||
+130
-130
@@ -1,5 +1,5 @@
|
||||
///////////////////////////////////////////////////////////////////////////////////
|
||||
// Copyright (C) 2015 Edouard Griffiths, F4EXB //
|
||||
// Copyright (C) 2015-2019 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 //
|
||||
@@ -23,7 +23,7 @@
|
||||
#include <QBuffer>
|
||||
|
||||
#include "SWGDeviceSettings.h"
|
||||
#include "SWGFileSourceInputSettings.h"
|
||||
#include "SWGFileInputSettings.h"
|
||||
#include "SWGDeviceState.h"
|
||||
#include "SWGDeviceReport.h"
|
||||
|
||||
@@ -34,25 +34,25 @@
|
||||
#include "dsp/filerecord.h"
|
||||
#include "device/deviceapi.h"
|
||||
|
||||
#include "filesourceinput.h"
|
||||
#include "filesourcethread.h"
|
||||
#include "fileinput.h"
|
||||
#include "fileinputthread.h"
|
||||
|
||||
MESSAGE_CLASS_DEFINITION(FileSourceInput::MsgConfigureFileSource, Message)
|
||||
MESSAGE_CLASS_DEFINITION(FileSourceInput::MsgConfigureFileSourceName, Message)
|
||||
MESSAGE_CLASS_DEFINITION(FileSourceInput::MsgConfigureFileSourceWork, Message)
|
||||
MESSAGE_CLASS_DEFINITION(FileSourceInput::MsgConfigureFileSourceSeek, Message)
|
||||
MESSAGE_CLASS_DEFINITION(FileSourceInput::MsgConfigureFileSourceStreamTiming, Message)
|
||||
MESSAGE_CLASS_DEFINITION(FileSourceInput::MsgStartStop, Message)
|
||||
MESSAGE_CLASS_DEFINITION(FileSourceInput::MsgPlayPause, Message)
|
||||
MESSAGE_CLASS_DEFINITION(FileSourceInput::MsgReportFileSourceAcquisition, Message)
|
||||
MESSAGE_CLASS_DEFINITION(FileSourceInput::MsgReportFileSourceStreamData, Message)
|
||||
MESSAGE_CLASS_DEFINITION(FileSourceInput::MsgReportFileSourceStreamTiming, Message)
|
||||
MESSAGE_CLASS_DEFINITION(FileSourceInput::MsgReportHeaderCRC, Message)
|
||||
MESSAGE_CLASS_DEFINITION(FileInput::MsgConfigureFileInput, Message)
|
||||
MESSAGE_CLASS_DEFINITION(FileInput::MsgConfigureFileSourceName, Message)
|
||||
MESSAGE_CLASS_DEFINITION(FileInput::MsgConfigureFileInputWork, Message)
|
||||
MESSAGE_CLASS_DEFINITION(FileInput::MsgConfigureFileSourceSeek, Message)
|
||||
MESSAGE_CLASS_DEFINITION(FileInput::MsgConfigureFileInputStreamTiming, Message)
|
||||
MESSAGE_CLASS_DEFINITION(FileInput::MsgStartStop, Message)
|
||||
MESSAGE_CLASS_DEFINITION(FileInput::MsgPlayPause, Message)
|
||||
MESSAGE_CLASS_DEFINITION(FileInput::MsgReportFileSourceAcquisition, Message)
|
||||
MESSAGE_CLASS_DEFINITION(FileInput::MsgReportFileInputStreamData, Message)
|
||||
MESSAGE_CLASS_DEFINITION(FileInput::MsgReportFileInputStreamTiming, Message)
|
||||
MESSAGE_CLASS_DEFINITION(FileInput::MsgReportHeaderCRC, Message)
|
||||
|
||||
FileSourceInput::FileSourceInput(DeviceAPI *deviceAPI) :
|
||||
FileInput::FileInput(DeviceAPI *deviceAPI) :
|
||||
m_deviceAPI(deviceAPI),
|
||||
m_settings(),
|
||||
m_fileSourceThread(NULL),
|
||||
m_fileInputThread(nullptr),
|
||||
m_deviceDescription(),
|
||||
m_fileName("..."),
|
||||
m_sampleRate(0),
|
||||
@@ -62,16 +62,16 @@ FileSourceInput::FileSourceInput(DeviceAPI *deviceAPI) :
|
||||
m_startingTimeStamp(0)
|
||||
{
|
||||
m_deviceAPI->setNbSourceStreams(1);
|
||||
qDebug("FileSourceInput::FileSourceInput: device source engine: %p", m_deviceAPI->getDeviceSourceEngine());
|
||||
qDebug("FileSourceInput::FileSourceInput: device source engine message queue: %p", m_deviceAPI->getDeviceEngineInputMessageQueue());
|
||||
qDebug("FileSourceInput::FileSourceInput: device source: %p", m_deviceAPI->getDeviceSourceEngine()->getSource());
|
||||
qDebug("FileInput::FileInput: device source engine: %p", m_deviceAPI->getDeviceSourceEngine());
|
||||
qDebug("FileInput::FileInput: device source engine message queue: %p", m_deviceAPI->getDeviceEngineInputMessageQueue());
|
||||
qDebug("FileInput::FileInput: device source: %p", m_deviceAPI->getDeviceSourceEngine()->getSource());
|
||||
m_networkManager = new QNetworkAccessManager();
|
||||
connect(m_networkManager, SIGNAL(finished(QNetworkReply*)), this, SLOT(networkManagerFinished(QNetworkReply*)));
|
||||
m_masterTimer.setTimerType(Qt::PreciseTimer);
|
||||
m_masterTimer.start(50);
|
||||
}
|
||||
|
||||
FileSourceInput::~FileSourceInput()
|
||||
FileInput::~FileInput()
|
||||
{
|
||||
m_masterTimer.stop();
|
||||
disconnect(m_networkManager, SIGNAL(finished(QNetworkReply*)), this, SLOT(networkManagerFinished(QNetworkReply*)));
|
||||
@@ -80,12 +80,12 @@ FileSourceInput::~FileSourceInput()
|
||||
stop();
|
||||
}
|
||||
|
||||
void FileSourceInput::destroy()
|
||||
void FileInput::destroy()
|
||||
{
|
||||
delete this;
|
||||
}
|
||||
|
||||
void FileSourceInput::openFileStream()
|
||||
void FileInput::openFileStream()
|
||||
{
|
||||
//stopInput();
|
||||
|
||||
@@ -113,12 +113,12 @@ void FileSourceInput::openFileStream()
|
||||
|
||||
if (crcOK)
|
||||
{
|
||||
qDebug("FileSourceInput::openFileStream: CRC32 OK for header: %s", qPrintable(crcHex));
|
||||
qDebug("FileInput::openFileStream: CRC32 OK for header: %s", qPrintable(crcHex));
|
||||
m_recordLength = (fileSize - sizeof(FileRecord::Header)) / ((m_sampleSize == 24 ? 8 : 4) * m_sampleRate);
|
||||
}
|
||||
else
|
||||
{
|
||||
qCritical("FileSourceInput::openFileStream: bad CRC32 for header: %s", qPrintable(crcHex));
|
||||
qCritical("FileInput::openFileStream: bad CRC32 for header: %s", qPrintable(crcHex));
|
||||
m_recordLength = 0;
|
||||
}
|
||||
|
||||
@@ -132,7 +132,7 @@ void FileSourceInput::openFileStream()
|
||||
m_recordLength = 0;
|
||||
}
|
||||
|
||||
qDebug() << "FileSourceInput::openFileStream: " << m_fileName.toStdString().c_str()
|
||||
qDebug() << "FileInput::openFileStream: " << m_fileName.toStdString().c_str()
|
||||
<< " fileSize: " << fileSize << " bytes"
|
||||
<< " length: " << m_recordLength << " seconds"
|
||||
<< " sample rate: " << m_sampleRate << " S/s"
|
||||
@@ -140,7 +140,7 @@ void FileSourceInput::openFileStream()
|
||||
<< " sample size: " << m_sampleSize << " bits";
|
||||
|
||||
if (getMessageQueueToGUI()) {
|
||||
MsgReportFileSourceStreamData *report = MsgReportFileSourceStreamData::create(m_sampleRate,
|
||||
MsgReportFileInputStreamData *report = MsgReportFileInputStreamData::create(m_sampleRate,
|
||||
m_sampleSize,
|
||||
m_centerFrequency,
|
||||
m_startingTimeStamp,
|
||||
@@ -153,36 +153,36 @@ void FileSourceInput::openFileStream()
|
||||
}
|
||||
}
|
||||
|
||||
void FileSourceInput::seekFileStream(int seekMillis)
|
||||
void FileInput::seekFileStream(int seekMillis)
|
||||
{
|
||||
QMutexLocker mutexLocker(&m_mutex);
|
||||
|
||||
if ((m_ifstream.is_open()) && m_fileSourceThread && !m_fileSourceThread->isRunning())
|
||||
if ((m_ifstream.is_open()) && m_fileInputThread && !m_fileInputThread->isRunning())
|
||||
{
|
||||
quint64 seekPoint = ((m_recordLength * seekMillis) / 1000) * m_sampleRate;
|
||||
m_fileSourceThread->setSamplesCount(seekPoint);
|
||||
m_fileInputThread->setSamplesCount(seekPoint);
|
||||
seekPoint *= (m_sampleSize == 24 ? 8 : 4); // + sizeof(FileSink::Header)
|
||||
m_ifstream.clear();
|
||||
m_ifstream.seekg(seekPoint + sizeof(FileRecord::Header), std::ios::beg);
|
||||
}
|
||||
}
|
||||
|
||||
void FileSourceInput::init()
|
||||
void FileInput::init()
|
||||
{
|
||||
DSPSignalNotification *notif = new DSPSignalNotification(m_settings.m_sampleRate, m_settings.m_centerFrequency);
|
||||
m_deviceAPI->getDeviceEngineInputMessageQueue()->push(notif);
|
||||
}
|
||||
|
||||
bool FileSourceInput::start()
|
||||
bool FileInput::start()
|
||||
{
|
||||
if (!m_ifstream.is_open())
|
||||
{
|
||||
qWarning("FileSourceInput::start: file not open. not starting");
|
||||
qWarning("FileInput::start: file not open. not starting");
|
||||
return false;
|
||||
}
|
||||
|
||||
QMutexLocker mutexLocker(&m_mutex);
|
||||
qDebug() << "FileSourceInput::start";
|
||||
qDebug() << "FileInput::start";
|
||||
|
||||
if (m_ifstream.tellg() != (std::streampos)0) {
|
||||
m_ifstream.clear();
|
||||
@@ -194,13 +194,13 @@ bool FileSourceInput::start()
|
||||
return false;
|
||||
}
|
||||
|
||||
m_fileSourceThread = new FileSourceThread(&m_ifstream, &m_sampleFifo, m_masterTimer, &m_inputMessageQueue);
|
||||
m_fileSourceThread->setSampleRateAndSize(m_settings.m_accelerationFactor * m_sampleRate, m_sampleSize); // Fast Forward: 1 corresponds to live. 1/2 is half speed, 2 is double speed
|
||||
m_fileSourceThread->startWork();
|
||||
m_deviceDescription = "FileSource";
|
||||
m_fileInputThread = new FileInputThread(&m_ifstream, &m_sampleFifo, m_masterTimer, &m_inputMessageQueue);
|
||||
m_fileInputThread->setSampleRateAndSize(m_settings.m_accelerationFactor * m_sampleRate, m_sampleSize); // Fast Forward: 1 corresponds to live. 1/2 is half speed, 2 is double speed
|
||||
m_fileInputThread->startWork();
|
||||
m_deviceDescription = "FileInput";
|
||||
|
||||
mutexLocker.unlock();
|
||||
qDebug("FileSourceInput::startInput: started");
|
||||
qDebug("FileInput::startInput: started");
|
||||
|
||||
if (getMessageQueueToGUI()) {
|
||||
MsgReportFileSourceAcquisition *report = MsgReportFileSourceAcquisition::create(true); // acquisition on
|
||||
@@ -210,16 +210,16 @@ bool FileSourceInput::start()
|
||||
return true;
|
||||
}
|
||||
|
||||
void FileSourceInput::stop()
|
||||
void FileInput::stop()
|
||||
{
|
||||
qDebug() << "FileSourceInput::stop";
|
||||
qDebug() << "FileInput::stop";
|
||||
QMutexLocker mutexLocker(&m_mutex);
|
||||
|
||||
if(m_fileSourceThread != 0)
|
||||
if (m_fileInputThread)
|
||||
{
|
||||
m_fileSourceThread->stopWork();
|
||||
delete m_fileSourceThread;
|
||||
m_fileSourceThread = 0;
|
||||
m_fileInputThread->stopWork();
|
||||
delete m_fileInputThread;
|
||||
m_fileInputThread = nullptr;
|
||||
}
|
||||
|
||||
m_deviceDescription.clear();
|
||||
@@ -230,12 +230,12 @@ void FileSourceInput::stop()
|
||||
}
|
||||
}
|
||||
|
||||
QByteArray FileSourceInput::serialize() const
|
||||
QByteArray FileInput::serialize() const
|
||||
{
|
||||
return m_settings.serialize();
|
||||
}
|
||||
|
||||
bool FileSourceInput::deserialize(const QByteArray& data)
|
||||
bool FileInput::deserialize(const QByteArray& data)
|
||||
{
|
||||
bool success = true;
|
||||
|
||||
@@ -245,59 +245,59 @@ bool FileSourceInput::deserialize(const QByteArray& data)
|
||||
success = false;
|
||||
}
|
||||
|
||||
MsgConfigureFileSource* message = MsgConfigureFileSource::create(m_settings, true);
|
||||
MsgConfigureFileInput* message = MsgConfigureFileInput::create(m_settings, true);
|
||||
m_inputMessageQueue.push(message);
|
||||
|
||||
if (getMessageQueueToGUI())
|
||||
{
|
||||
MsgConfigureFileSource* messageToGUI = MsgConfigureFileSource::create(m_settings, true);
|
||||
MsgConfigureFileInput* messageToGUI = MsgConfigureFileInput::create(m_settings, true);
|
||||
getMessageQueueToGUI()->push(messageToGUI);
|
||||
}
|
||||
|
||||
return success;
|
||||
}
|
||||
|
||||
const QString& FileSourceInput::getDeviceDescription() const
|
||||
const QString& FileInput::getDeviceDescription() const
|
||||
{
|
||||
return m_deviceDescription;
|
||||
}
|
||||
|
||||
int FileSourceInput::getSampleRate() const
|
||||
int FileInput::getSampleRate() const
|
||||
{
|
||||
return m_sampleRate;
|
||||
}
|
||||
|
||||
quint64 FileSourceInput::getCenterFrequency() const
|
||||
quint64 FileInput::getCenterFrequency() const
|
||||
{
|
||||
return m_centerFrequency;
|
||||
}
|
||||
|
||||
void FileSourceInput::setCenterFrequency(qint64 centerFrequency)
|
||||
void FileInput::setCenterFrequency(qint64 centerFrequency)
|
||||
{
|
||||
FileSourceInputSettings settings = m_settings;
|
||||
FileInputSettings settings = m_settings;
|
||||
settings.m_centerFrequency = centerFrequency;
|
||||
|
||||
MsgConfigureFileSource* message = MsgConfigureFileSource::create(m_settings, false);
|
||||
MsgConfigureFileInput* message = MsgConfigureFileInput::create(m_settings, false);
|
||||
m_inputMessageQueue.push(message);
|
||||
|
||||
if (getMessageQueueToGUI())
|
||||
{
|
||||
MsgConfigureFileSource* messageToGUI = MsgConfigureFileSource::create(m_settings, false);
|
||||
MsgConfigureFileInput* messageToGUI = MsgConfigureFileInput::create(m_settings, false);
|
||||
getMessageQueueToGUI()->push(messageToGUI);
|
||||
}
|
||||
}
|
||||
|
||||
quint64 FileSourceInput::getStartingTimeStamp() const
|
||||
quint64 FileInput::getStartingTimeStamp() const
|
||||
{
|
||||
return m_startingTimeStamp;
|
||||
}
|
||||
|
||||
bool FileSourceInput::handleMessage(const Message& message)
|
||||
bool FileInput::handleMessage(const Message& message)
|
||||
{
|
||||
if (MsgConfigureFileSource::match(message))
|
||||
if (MsgConfigureFileInput::match(message))
|
||||
{
|
||||
MsgConfigureFileSource& conf = (MsgConfigureFileSource&) message;
|
||||
FileSourceInputSettings settings = conf.getSettings();
|
||||
MsgConfigureFileInput& conf = (MsgConfigureFileInput&) message;
|
||||
FileInputSettings settings = conf.getSettings();
|
||||
applySettings(settings);
|
||||
return true;
|
||||
}
|
||||
@@ -308,17 +308,17 @@ bool FileSourceInput::handleMessage(const Message& message)
|
||||
openFileStream();
|
||||
return true;
|
||||
}
|
||||
else if (MsgConfigureFileSourceWork::match(message))
|
||||
else if (MsgConfigureFileInputWork::match(message))
|
||||
{
|
||||
MsgConfigureFileSourceWork& conf = (MsgConfigureFileSourceWork&) message;
|
||||
MsgConfigureFileInputWork& conf = (MsgConfigureFileInputWork&) message;
|
||||
bool working = conf.isWorking();
|
||||
|
||||
if (m_fileSourceThread != 0)
|
||||
if (m_fileInputThread != 0)
|
||||
{
|
||||
if (working) {
|
||||
m_fileSourceThread->startWork();
|
||||
m_fileInputThread->startWork();
|
||||
} else {
|
||||
m_fileSourceThread->stopWork();
|
||||
m_fileInputThread->stopWork();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -332,15 +332,15 @@ bool FileSourceInput::handleMessage(const Message& message)
|
||||
|
||||
return true;
|
||||
}
|
||||
else if (MsgConfigureFileSourceStreamTiming::match(message))
|
||||
else if (MsgConfigureFileInputStreamTiming::match(message))
|
||||
{
|
||||
MsgReportFileSourceStreamTiming *report;
|
||||
MsgReportFileInputStreamTiming *report;
|
||||
|
||||
if (m_fileSourceThread != 0)
|
||||
if (m_fileInputThread != 0)
|
||||
{
|
||||
if (getMessageQueueToGUI())
|
||||
{
|
||||
report = MsgReportFileSourceStreamTiming::create(m_fileSourceThread->getSamplesCount());
|
||||
report = MsgReportFileInputStreamTiming::create(m_fileInputThread->getSamplesCount());
|
||||
getMessageQueueToGUI()->push(report);
|
||||
}
|
||||
}
|
||||
@@ -350,7 +350,7 @@ bool FileSourceInput::handleMessage(const Message& message)
|
||||
else if (MsgStartStop::match(message))
|
||||
{
|
||||
MsgStartStop& cmd = (MsgStartStop&) message;
|
||||
qDebug() << "FileSourceInput::handleMessage: MsgStartStop: " << (cmd.getStartStop() ? "start" : "stop");
|
||||
qDebug() << "FileInput::handleMessage: MsgStartStop: " << (cmd.getStartStop() ? "start" : "stop");
|
||||
|
||||
if (cmd.getStartStop())
|
||||
{
|
||||
@@ -370,21 +370,21 @@ bool FileSourceInput::handleMessage(const Message& message)
|
||||
|
||||
return true;
|
||||
}
|
||||
else if (FileSourceThread::MsgReportEOF::match(message))
|
||||
else if (FileInputThread::MsgReportEOF::match(message))
|
||||
{
|
||||
qDebug() << "FileSourceInput::handleMessage: MsgReportEOF";
|
||||
m_fileSourceThread->stopWork();
|
||||
qDebug() << "FileInput::handleMessage: MsgReportEOF";
|
||||
m_fileInputThread->stopWork();
|
||||
|
||||
if (getMessageQueueToGUI())
|
||||
{
|
||||
MsgReportFileSourceStreamTiming *report = MsgReportFileSourceStreamTiming::create(m_fileSourceThread->getSamplesCount());
|
||||
MsgReportFileInputStreamTiming *report = MsgReportFileInputStreamTiming::create(m_fileInputThread->getSamplesCount());
|
||||
getMessageQueueToGUI()->push(report);
|
||||
}
|
||||
|
||||
if (m_settings.m_loop)
|
||||
{
|
||||
seekFileStream(0);
|
||||
m_fileSourceThread->startWork();
|
||||
m_fileInputThread->startWork();
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -403,7 +403,7 @@ bool FileSourceInput::handleMessage(const Message& message)
|
||||
}
|
||||
}
|
||||
|
||||
bool FileSourceInput::applySettings(const FileSourceInputSettings& settings, bool force)
|
||||
bool FileInput::applySettings(const FileInputSettings& settings, bool force)
|
||||
{
|
||||
QList<QString> reverseAPIKeys;
|
||||
|
||||
@@ -415,14 +415,14 @@ bool FileSourceInput::applySettings(const FileSourceInputSettings& settings, boo
|
||||
{
|
||||
reverseAPIKeys.append("accelerationFactor");
|
||||
|
||||
if (m_fileSourceThread)
|
||||
if (m_fileInputThread)
|
||||
{
|
||||
QMutexLocker mutexLocker(&m_mutex);
|
||||
if (!m_sampleFifo.setSize(m_settings.m_accelerationFactor * m_sampleRate * sizeof(Sample))) {
|
||||
qCritical("FileSourceInput::applySettings: could not reallocate sample FIFO size to %lu",
|
||||
qCritical("FileInput::applySettings: could not reallocate sample FIFO size to %lu",
|
||||
m_settings.m_accelerationFactor * m_sampleRate * sizeof(Sample));
|
||||
}
|
||||
m_fileSourceThread->setSampleRateAndSize(settings.m_accelerationFactor * m_sampleRate, m_sampleSize); // Fast Forward: 1 corresponds to live. 1/2 is half speed, 2 is double speed
|
||||
m_fileInputThread->setSampleRateAndSize(settings.m_accelerationFactor * m_sampleRate, m_sampleSize); // Fast Forward: 1 corresponds to live. 1/2 is half speed, 2 is double speed
|
||||
}
|
||||
}
|
||||
|
||||
@@ -446,54 +446,54 @@ bool FileSourceInput::applySettings(const FileSourceInputSettings& settings, boo
|
||||
return true;
|
||||
}
|
||||
|
||||
int FileSourceInput::webapiSettingsGet(
|
||||
int FileInput::webapiSettingsGet(
|
||||
SWGSDRangel::SWGDeviceSettings& response,
|
||||
QString& errorMessage)
|
||||
{
|
||||
(void) errorMessage;
|
||||
response.setFileSourceInputSettings(new SWGSDRangel::SWGFileSourceInputSettings());
|
||||
response.getFileSourceInputSettings()->init();
|
||||
response.setFileInputSettings(new SWGSDRangel::SWGFileInputSettings());
|
||||
response.getFileInputSettings()->init();
|
||||
webapiFormatDeviceSettings(response, m_settings);
|
||||
return 200;
|
||||
}
|
||||
|
||||
int FileSourceInput::webapiSettingsPutPatch(
|
||||
int FileInput::webapiSettingsPutPatch(
|
||||
bool force,
|
||||
const QStringList& deviceSettingsKeys,
|
||||
SWGSDRangel::SWGDeviceSettings& response, // query + response
|
||||
QString& errorMessage)
|
||||
{
|
||||
(void) errorMessage;
|
||||
FileSourceInputSettings settings = m_settings;
|
||||
FileInputSettings settings = m_settings;
|
||||
|
||||
if (deviceSettingsKeys.contains("fileName")) {
|
||||
settings.m_fileName = *response.getFileSourceInputSettings()->getFileName();
|
||||
settings.m_fileName = *response.getFileInputSettings()->getFileName();
|
||||
}
|
||||
if (deviceSettingsKeys.contains("accelerationFactor")) {
|
||||
settings.m_accelerationFactor = response.getFileSourceInputSettings()->getAccelerationFactor();
|
||||
settings.m_accelerationFactor = response.getFileInputSettings()->getAccelerationFactor();
|
||||
}
|
||||
if (deviceSettingsKeys.contains("loop")) {
|
||||
settings.m_loop = response.getFileSourceInputSettings()->getLoop() != 0;
|
||||
settings.m_loop = response.getFileInputSettings()->getLoop() != 0;
|
||||
}
|
||||
if (deviceSettingsKeys.contains("useReverseAPI")) {
|
||||
settings.m_useReverseAPI = response.getFileSourceInputSettings()->getUseReverseApi() != 0;
|
||||
settings.m_useReverseAPI = response.getFileInputSettings()->getUseReverseApi() != 0;
|
||||
}
|
||||
if (deviceSettingsKeys.contains("reverseAPIAddress")) {
|
||||
settings.m_reverseAPIAddress = *response.getFileSourceInputSettings()->getReverseApiAddress();
|
||||
settings.m_reverseAPIAddress = *response.getFileInputSettings()->getReverseApiAddress();
|
||||
}
|
||||
if (deviceSettingsKeys.contains("reverseAPIPort")) {
|
||||
settings.m_reverseAPIPort = response.getFileSourceInputSettings()->getReverseApiPort();
|
||||
settings.m_reverseAPIPort = response.getFileInputSettings()->getReverseApiPort();
|
||||
}
|
||||
if (deviceSettingsKeys.contains("reverseAPIDeviceIndex")) {
|
||||
settings.m_reverseAPIDeviceIndex = response.getFileSourceInputSettings()->getReverseApiDeviceIndex();
|
||||
settings.m_reverseAPIDeviceIndex = response.getFileInputSettings()->getReverseApiDeviceIndex();
|
||||
}
|
||||
|
||||
MsgConfigureFileSource *msg = MsgConfigureFileSource::create(settings, force);
|
||||
MsgConfigureFileInput *msg = MsgConfigureFileInput::create(settings, force);
|
||||
m_inputMessageQueue.push(msg);
|
||||
|
||||
if (m_guiMessageQueue) // forward to GUI if any
|
||||
{
|
||||
MsgConfigureFileSource *msgToGUI = MsgConfigureFileSource::create(settings, force);
|
||||
MsgConfigureFileInput *msgToGUI = MsgConfigureFileInput::create(settings, force);
|
||||
m_guiMessageQueue->push(msgToGUI);
|
||||
}
|
||||
|
||||
@@ -501,7 +501,7 @@ int FileSourceInput::webapiSettingsPutPatch(
|
||||
return 200;
|
||||
}
|
||||
|
||||
int FileSourceInput::webapiRunGet(
|
||||
int FileInput::webapiRunGet(
|
||||
SWGSDRangel::SWGDeviceState& response,
|
||||
QString& errorMessage)
|
||||
{
|
||||
@@ -510,7 +510,7 @@ int FileSourceInput::webapiRunGet(
|
||||
return 200;
|
||||
}
|
||||
|
||||
int FileSourceInput::webapiRun(
|
||||
int FileInput::webapiRun(
|
||||
bool run,
|
||||
SWGSDRangel::SWGDeviceState& response,
|
||||
QString& errorMessage)
|
||||
@@ -529,43 +529,43 @@ int FileSourceInput::webapiRun(
|
||||
return 200;
|
||||
}
|
||||
|
||||
int FileSourceInput::webapiReportGet(
|
||||
int FileInput::webapiReportGet(
|
||||
SWGSDRangel::SWGDeviceReport& response,
|
||||
QString& errorMessage)
|
||||
{
|
||||
(void) errorMessage;
|
||||
response.setFileSourceInputReport(new SWGSDRangel::SWGFileSourceInputReport());
|
||||
response.getFileSourceInputReport()->init();
|
||||
response.setFileInputReport(new SWGSDRangel::SWGFileInputReport());
|
||||
response.getFileInputReport()->init();
|
||||
webapiFormatDeviceReport(response);
|
||||
return 200;
|
||||
}
|
||||
|
||||
void FileSourceInput::webapiFormatDeviceSettings(SWGSDRangel::SWGDeviceSettings& response, const FileSourceInputSettings& settings)
|
||||
void FileInput::webapiFormatDeviceSettings(SWGSDRangel::SWGDeviceSettings& response, const FileInputSettings& settings)
|
||||
{
|
||||
response.getFileSourceInputSettings()->setFileName(new QString(settings.m_fileName));
|
||||
response.getFileSourceInputSettings()->setAccelerationFactor(settings.m_accelerationFactor);
|
||||
response.getFileSourceInputSettings()->setLoop(settings.m_loop ? 1 : 0);
|
||||
response.getFileInputSettings()->setFileName(new QString(settings.m_fileName));
|
||||
response.getFileInputSettings()->setAccelerationFactor(settings.m_accelerationFactor);
|
||||
response.getFileInputSettings()->setLoop(settings.m_loop ? 1 : 0);
|
||||
|
||||
response.getFileSourceInputSettings()->setUseReverseApi(settings.m_useReverseAPI ? 1 : 0);
|
||||
response.getFileInputSettings()->setUseReverseApi(settings.m_useReverseAPI ? 1 : 0);
|
||||
|
||||
if (response.getFileSourceInputSettings()->getReverseApiAddress()) {
|
||||
*response.getFileSourceInputSettings()->getReverseApiAddress() = settings.m_reverseAPIAddress;
|
||||
if (response.getFileInputSettings()->getReverseApiAddress()) {
|
||||
*response.getFileInputSettings()->getReverseApiAddress() = settings.m_reverseAPIAddress;
|
||||
} else {
|
||||
response.getFileSourceInputSettings()->setReverseApiAddress(new QString(settings.m_reverseAPIAddress));
|
||||
response.getFileInputSettings()->setReverseApiAddress(new QString(settings.m_reverseAPIAddress));
|
||||
}
|
||||
|
||||
response.getFileSourceInputSettings()->setReverseApiPort(settings.m_reverseAPIPort);
|
||||
response.getFileSourceInputSettings()->setReverseApiDeviceIndex(settings.m_reverseAPIDeviceIndex);
|
||||
response.getFileInputSettings()->setReverseApiPort(settings.m_reverseAPIPort);
|
||||
response.getFileInputSettings()->setReverseApiDeviceIndex(settings.m_reverseAPIDeviceIndex);
|
||||
}
|
||||
|
||||
void FileSourceInput::webapiFormatDeviceReport(SWGSDRangel::SWGDeviceReport& response)
|
||||
void FileInput::webapiFormatDeviceReport(SWGSDRangel::SWGDeviceReport& response)
|
||||
{
|
||||
qint64 t_sec = 0;
|
||||
qint64 t_msec = 0;
|
||||
quint64 samplesCount = 0;
|
||||
|
||||
if (m_fileSourceThread) {
|
||||
samplesCount = m_fileSourceThread->getSamplesCount();
|
||||
if (m_fileInputThread) {
|
||||
samplesCount = m_fileInputThread->getSamplesCount();
|
||||
}
|
||||
|
||||
if (m_sampleRate > 0)
|
||||
@@ -577,42 +577,42 @@ void FileSourceInput::webapiFormatDeviceReport(SWGSDRangel::SWGDeviceReport& res
|
||||
QTime t(0, 0, 0, 0);
|
||||
t = t.addSecs(t_sec);
|
||||
t = t.addMSecs(t_msec);
|
||||
response.getFileSourceInputReport()->setElapsedTime(new QString(t.toString("HH:mm:ss.zzz")));
|
||||
response.getFileInputReport()->setElapsedTime(new QString(t.toString("HH:mm:ss.zzz")));
|
||||
|
||||
qint64 startingTimeStampMsec = m_startingTimeStamp * 1000LL;
|
||||
QDateTime dt = QDateTime::fromMSecsSinceEpoch(startingTimeStampMsec);
|
||||
dt = dt.addSecs(t_sec);
|
||||
dt = dt.addMSecs(t_msec);
|
||||
response.getFileSourceInputReport()->setAbsoluteTime(new QString(dt.toString("yyyy-MM-dd HH:mm:ss.zzz")));
|
||||
response.getFileInputReport()->setAbsoluteTime(new QString(dt.toString("yyyy-MM-dd HH:mm:ss.zzz")));
|
||||
|
||||
QTime recordLength(0, 0, 0, 0);
|
||||
recordLength = recordLength.addSecs(m_recordLength);
|
||||
response.getFileSourceInputReport()->setDurationTime(new QString(recordLength.toString("HH:mm:ss")));
|
||||
response.getFileInputReport()->setDurationTime(new QString(recordLength.toString("HH:mm:ss")));
|
||||
|
||||
response.getFileSourceInputReport()->setFileName(new QString(m_fileName));
|
||||
response.getFileSourceInputReport()->setSampleRate(m_sampleRate);
|
||||
response.getFileSourceInputReport()->setSampleSize(m_sampleSize);
|
||||
response.getFileInputReport()->setFileName(new QString(m_fileName));
|
||||
response.getFileInputReport()->setSampleRate(m_sampleRate);
|
||||
response.getFileInputReport()->setSampleSize(m_sampleSize);
|
||||
}
|
||||
|
||||
void FileSourceInput::webapiReverseSendSettings(QList<QString>& deviceSettingsKeys, const FileSourceInputSettings& settings, bool force)
|
||||
void FileInput::webapiReverseSendSettings(QList<QString>& deviceSettingsKeys, const FileInputSettings& settings, bool force)
|
||||
{
|
||||
SWGSDRangel::SWGDeviceSettings *swgDeviceSettings = new SWGSDRangel::SWGDeviceSettings();
|
||||
swgDeviceSettings->setDirection(0); // single Rx
|
||||
swgDeviceSettings->setOriginatorIndex(m_deviceAPI->getDeviceSetIndex());
|
||||
swgDeviceSettings->setDeviceHwType(new QString("FileSource"));
|
||||
swgDeviceSettings->setFileSourceInputSettings(new SWGSDRangel::SWGFileSourceInputSettings());
|
||||
SWGSDRangel::SWGFileSourceInputSettings *swgFileSourceInputSettings = swgDeviceSettings->getFileSourceInputSettings();
|
||||
swgDeviceSettings->setDeviceHwType(new QString("FileInput"));
|
||||
swgDeviceSettings->setFileInputSettings(new SWGSDRangel::SWGFileInputSettings());
|
||||
SWGSDRangel::SWGFileInputSettings *swgFileInputSettings = swgDeviceSettings->getFileInputSettings();
|
||||
|
||||
// transfer data that has been modified. When force is on transfer all data except reverse API data
|
||||
|
||||
if (deviceSettingsKeys.contains("accelerationFactor") || force) {
|
||||
swgFileSourceInputSettings->setAccelerationFactor(settings.m_accelerationFactor);
|
||||
swgFileInputSettings->setAccelerationFactor(settings.m_accelerationFactor);
|
||||
}
|
||||
if (deviceSettingsKeys.contains("loop") || force) {
|
||||
swgFileSourceInputSettings->setLoop(settings.m_loop);
|
||||
swgFileInputSettings->setLoop(settings.m_loop);
|
||||
}
|
||||
if (deviceSettingsKeys.contains("fileName") || force) {
|
||||
swgFileSourceInputSettings->setFileName(new QString(settings.m_fileName));
|
||||
swgFileInputSettings->setFileName(new QString(settings.m_fileName));
|
||||
}
|
||||
|
||||
QString deviceSettingsURL = QString("http://%1:%2/sdrangel/deviceset/%3/device/settings")
|
||||
@@ -633,12 +633,12 @@ void FileSourceInput::webapiReverseSendSettings(QList<QString>& deviceSettingsKe
|
||||
delete swgDeviceSettings;
|
||||
}
|
||||
|
||||
void FileSourceInput::webapiReverseSendStartStop(bool start)
|
||||
void FileInput::webapiReverseSendStartStop(bool start)
|
||||
{
|
||||
SWGSDRangel::SWGDeviceSettings *swgDeviceSettings = new SWGSDRangel::SWGDeviceSettings();
|
||||
swgDeviceSettings->setDirection(0); // single Rx
|
||||
swgDeviceSettings->setOriginatorIndex(m_deviceAPI->getDeviceSetIndex());
|
||||
swgDeviceSettings->setDeviceHwType(new QString("FileSource"));
|
||||
swgDeviceSettings->setDeviceHwType(new QString("FileInput"));
|
||||
|
||||
QString deviceSettingsURL = QString("http://%1:%2/sdrangel/deviceset/%3/device/run")
|
||||
.arg(m_settings.m_reverseAPIAddress)
|
||||
@@ -661,13 +661,13 @@ void FileSourceInput::webapiReverseSendStartStop(bool start)
|
||||
delete swgDeviceSettings;
|
||||
}
|
||||
|
||||
void FileSourceInput::networkManagerFinished(QNetworkReply *reply)
|
||||
void FileInput::networkManagerFinished(QNetworkReply *reply)
|
||||
{
|
||||
QNetworkReply::NetworkError replyError = reply->error();
|
||||
|
||||
if (replyError)
|
||||
{
|
||||
qWarning() << "FileSourceInput::networkManagerFinished:"
|
||||
qWarning() << "FileInput::networkManagerFinished:"
|
||||
<< " error(" << (int) replyError
|
||||
<< "): " << replyError
|
||||
<< ": " << reply->errorString();
|
||||
@@ -676,5 +676,5 @@ void FileSourceInput::networkManagerFinished(QNetworkReply *reply)
|
||||
|
||||
QString answer = reply->readAll();
|
||||
answer.chop(1); // remove last \n
|
||||
qDebug("FileSourceInput::networkManagerFinished: reply:\n%s", answer.toStdString().c_str());
|
||||
qDebug("FileInput::networkManagerFinished: reply:\n%s", answer.toStdString().c_str());
|
||||
}
|
||||
+35
-35
@@ -1,5 +1,5 @@
|
||||
///////////////////////////////////////////////////////////////////////////////////
|
||||
// Copyright (C) 2015 Edouard Griffiths, F4EXB //
|
||||
// Copyright (C) 2015-2019 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 //
|
||||
@@ -15,8 +15,8 @@
|
||||
// along with this program. If not, see <http://www.gnu.org/licenses/>. //
|
||||
///////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#ifndef INCLUDE_FILESOURCEINPUT_H
|
||||
#define INCLUDE_FILESOURCEINPUT_H
|
||||
#ifndef INCLUDE_FILEINPUT_H
|
||||
#define INCLUDE_FILEINPUT_H
|
||||
|
||||
#include <ctime>
|
||||
#include <iostream>
|
||||
@@ -28,33 +28,33 @@
|
||||
#include <QNetworkRequest>
|
||||
|
||||
#include "dsp/devicesamplesource.h"
|
||||
#include "filesourceinputsettings.h"
|
||||
#include "fileinputsettings.h"
|
||||
|
||||
class QNetworkAccessManager;
|
||||
class QNetworkReply;
|
||||
class FileSourceThread;
|
||||
class FileInputThread;
|
||||
class DeviceAPI;
|
||||
|
||||
class FileSourceInput : public DeviceSampleSource {
|
||||
class FileInput : public DeviceSampleSource {
|
||||
Q_OBJECT
|
||||
public:
|
||||
class MsgConfigureFileSource : public Message {
|
||||
class MsgConfigureFileInput : public Message {
|
||||
MESSAGE_CLASS_DECLARATION
|
||||
|
||||
public:
|
||||
const FileSourceInputSettings& getSettings() const { return m_settings; }
|
||||
const FileInputSettings& getSettings() const { return m_settings; }
|
||||
bool getForce() const { return m_force; }
|
||||
|
||||
static MsgConfigureFileSource* create(const FileSourceInputSettings& settings, bool force)
|
||||
static MsgConfigureFileInput* create(const FileInputSettings& settings, bool force)
|
||||
{
|
||||
return new MsgConfigureFileSource(settings, force);
|
||||
return new MsgConfigureFileInput(settings, force);
|
||||
}
|
||||
|
||||
private:
|
||||
FileSourceInputSettings m_settings;
|
||||
FileInputSettings m_settings;
|
||||
bool m_force;
|
||||
|
||||
MsgConfigureFileSource(const FileSourceInputSettings& settings, bool force) :
|
||||
MsgConfigureFileInput(const FileInputSettings& settings, bool force) :
|
||||
Message(),
|
||||
m_settings(settings),
|
||||
m_force(force)
|
||||
@@ -81,39 +81,39 @@ public:
|
||||
{ }
|
||||
};
|
||||
|
||||
class MsgConfigureFileSourceWork : public Message {
|
||||
class MsgConfigureFileInputWork : public Message {
|
||||
MESSAGE_CLASS_DECLARATION
|
||||
|
||||
public:
|
||||
bool isWorking() const { return m_working; }
|
||||
|
||||
static MsgConfigureFileSourceWork* create(bool working)
|
||||
static MsgConfigureFileInputWork* create(bool working)
|
||||
{
|
||||
return new MsgConfigureFileSourceWork(working);
|
||||
return new MsgConfigureFileInputWork(working);
|
||||
}
|
||||
|
||||
private:
|
||||
bool m_working;
|
||||
|
||||
MsgConfigureFileSourceWork(bool working) :
|
||||
MsgConfigureFileInputWork(bool working) :
|
||||
Message(),
|
||||
m_working(working)
|
||||
{ }
|
||||
};
|
||||
|
||||
class MsgConfigureFileSourceStreamTiming : public Message {
|
||||
class MsgConfigureFileInputStreamTiming : public Message {
|
||||
MESSAGE_CLASS_DECLARATION
|
||||
|
||||
public:
|
||||
|
||||
static MsgConfigureFileSourceStreamTiming* create()
|
||||
static MsgConfigureFileInputStreamTiming* create()
|
||||
{
|
||||
return new MsgConfigureFileSourceStreamTiming();
|
||||
return new MsgConfigureFileInputStreamTiming();
|
||||
}
|
||||
|
||||
private:
|
||||
|
||||
MsgConfigureFileSourceStreamTiming() :
|
||||
MsgConfigureFileInputStreamTiming() :
|
||||
Message()
|
||||
{ }
|
||||
};
|
||||
@@ -196,7 +196,7 @@ public:
|
||||
{ }
|
||||
};
|
||||
|
||||
class MsgReportFileSourceStreamData : public Message {
|
||||
class MsgReportFileInputStreamData : public Message {
|
||||
MESSAGE_CLASS_DECLARATION
|
||||
|
||||
public:
|
||||
@@ -206,13 +206,13 @@ public:
|
||||
quint64 getStartingTimeStamp() const { return m_startingTimeStamp; }
|
||||
quint64 getRecordLength() const { return m_recordLength; }
|
||||
|
||||
static MsgReportFileSourceStreamData* create(int sampleRate,
|
||||
static MsgReportFileInputStreamData* create(int sampleRate,
|
||||
quint32 sampleSize,
|
||||
quint64 centerFrequency,
|
||||
quint64 startingTimeStamp,
|
||||
quint64 recordLength)
|
||||
{
|
||||
return new MsgReportFileSourceStreamData(sampleRate, sampleSize, centerFrequency, startingTimeStamp, recordLength);
|
||||
return new MsgReportFileInputStreamData(sampleRate, sampleSize, centerFrequency, startingTimeStamp, recordLength);
|
||||
}
|
||||
|
||||
protected:
|
||||
@@ -222,7 +222,7 @@ public:
|
||||
quint64 m_startingTimeStamp;
|
||||
quint64 m_recordLength;
|
||||
|
||||
MsgReportFileSourceStreamData(int sampleRate,
|
||||
MsgReportFileInputStreamData(int sampleRate,
|
||||
quint32 sampleSize,
|
||||
quint64 centerFrequency,
|
||||
quint64 startingTimeStamp,
|
||||
@@ -236,21 +236,21 @@ public:
|
||||
{ }
|
||||
};
|
||||
|
||||
class MsgReportFileSourceStreamTiming : public Message {
|
||||
class MsgReportFileInputStreamTiming : public Message {
|
||||
MESSAGE_CLASS_DECLARATION
|
||||
|
||||
public:
|
||||
quint64 getSamplesCount() const { return m_samplesCount; }
|
||||
|
||||
static MsgReportFileSourceStreamTiming* create(quint64 samplesCount)
|
||||
static MsgReportFileInputStreamTiming* create(quint64 samplesCount)
|
||||
{
|
||||
return new MsgReportFileSourceStreamTiming(samplesCount);
|
||||
return new MsgReportFileInputStreamTiming(samplesCount);
|
||||
}
|
||||
|
||||
protected:
|
||||
quint64 m_samplesCount;
|
||||
|
||||
MsgReportFileSourceStreamTiming(quint64 samplesCount) :
|
||||
MsgReportFileInputStreamTiming(quint64 samplesCount) :
|
||||
Message(),
|
||||
m_samplesCount(samplesCount)
|
||||
{ }
|
||||
@@ -275,8 +275,8 @@ public:
|
||||
{ }
|
||||
};
|
||||
|
||||
FileSourceInput(DeviceAPI *deviceAPI);
|
||||
virtual ~FileSourceInput();
|
||||
FileInput(DeviceAPI *deviceAPI);
|
||||
virtual ~FileInput();
|
||||
virtual void destroy();
|
||||
|
||||
virtual void init();
|
||||
@@ -322,9 +322,9 @@ public:
|
||||
private:
|
||||
DeviceAPI *m_deviceAPI;
|
||||
QMutex m_mutex;
|
||||
FileSourceInputSettings m_settings;
|
||||
FileInputSettings m_settings;
|
||||
std::ifstream m_ifstream;
|
||||
FileSourceThread* m_fileSourceThread;
|
||||
FileInputThread* m_fileInputThread;
|
||||
QString m_deviceDescription;
|
||||
QString m_fileName;
|
||||
int m_sampleRate;
|
||||
@@ -338,10 +338,10 @@ public:
|
||||
|
||||
void openFileStream();
|
||||
void seekFileStream(int seekMillis);
|
||||
bool applySettings(const FileSourceInputSettings& settings, bool force = false);
|
||||
void webapiFormatDeviceSettings(SWGSDRangel::SWGDeviceSettings& response, const FileSourceInputSettings& settings);
|
||||
bool applySettings(const FileInputSettings& settings, bool force = false);
|
||||
void webapiFormatDeviceSettings(SWGSDRangel::SWGDeviceSettings& response, const FileInputSettings& settings);
|
||||
void webapiFormatDeviceReport(SWGSDRangel::SWGDeviceReport& response);
|
||||
void webapiReverseSendSettings(QList<QString>& deviceSettingsKeys, const FileSourceInputSettings& settings, bool force);
|
||||
void webapiReverseSendSettings(QList<QString>& deviceSettingsKeys, const FileInputSettings& settings, bool force);
|
||||
void webapiReverseSendStartStop(bool start);
|
||||
|
||||
private slots:
|
||||
+63
-63
@@ -23,7 +23,7 @@
|
||||
#include <QFileDialog>
|
||||
#include <QMessageBox>
|
||||
|
||||
#include "ui_filesourcegui.h"
|
||||
#include "ui_fileinputgui.h"
|
||||
#include "plugin/pluginapi.h"
|
||||
#include "gui/colormapper.h"
|
||||
#include "gui/glspectrum.h"
|
||||
@@ -34,13 +34,13 @@
|
||||
|
||||
#include "mainwindow.h"
|
||||
|
||||
#include "filesourcegui.h"
|
||||
#include "fileinputgui.h"
|
||||
#include "device/deviceapi.h"
|
||||
#include "device/deviceuiset.h"
|
||||
|
||||
FileSourceGui::FileSourceGui(DeviceUISet *deviceUISet, QWidget* parent) :
|
||||
FileInputGUI::FileInputGUI(DeviceUISet *deviceUISet, QWidget* parent) :
|
||||
QWidget(parent),
|
||||
ui(new Ui::FileSourceGui),
|
||||
ui(new Ui::FileInputGUI),
|
||||
m_deviceUISet(deviceUISet),
|
||||
m_settings(),
|
||||
m_doApplySettings(true),
|
||||
@@ -81,51 +81,51 @@ FileSourceGui::FileSourceGui(DeviceUISet *deviceUISet, QWidget* parent) :
|
||||
m_sampleSource->setMessageQueueToGUI(&m_inputMessageQueue);
|
||||
}
|
||||
|
||||
FileSourceGui::~FileSourceGui()
|
||||
FileInputGUI::~FileInputGUI()
|
||||
{
|
||||
delete ui;
|
||||
}
|
||||
|
||||
void FileSourceGui::destroy()
|
||||
void FileInputGUI::destroy()
|
||||
{
|
||||
delete this;
|
||||
}
|
||||
|
||||
void FileSourceGui::setName(const QString& name)
|
||||
void FileInputGUI::setName(const QString& name)
|
||||
{
|
||||
setObjectName(name);
|
||||
}
|
||||
|
||||
QString FileSourceGui::getName() const
|
||||
QString FileInputGUI::getName() const
|
||||
{
|
||||
return objectName();
|
||||
}
|
||||
|
||||
void FileSourceGui::resetToDefaults()
|
||||
void FileInputGUI::resetToDefaults()
|
||||
{
|
||||
m_settings.resetToDefaults();
|
||||
displaySettings();
|
||||
sendSettings();
|
||||
}
|
||||
|
||||
qint64 FileSourceGui::getCenterFrequency() const
|
||||
qint64 FileInputGUI::getCenterFrequency() const
|
||||
{
|
||||
return m_centerFrequency;
|
||||
}
|
||||
|
||||
void FileSourceGui::setCenterFrequency(qint64 centerFrequency)
|
||||
void FileInputGUI::setCenterFrequency(qint64 centerFrequency)
|
||||
{
|
||||
m_centerFrequency = centerFrequency;
|
||||
displaySettings();
|
||||
sendSettings();
|
||||
}
|
||||
|
||||
QByteArray FileSourceGui::serialize() const
|
||||
QByteArray FileInputGUI::serialize() const
|
||||
{
|
||||
return m_settings.serialize();
|
||||
}
|
||||
|
||||
bool FileSourceGui::deserialize(const QByteArray& data)
|
||||
bool FileInputGUI::deserialize(const QByteArray& data)
|
||||
{
|
||||
if(m_settings.deserialize(data)) {
|
||||
displaySettings();
|
||||
@@ -137,7 +137,7 @@ bool FileSourceGui::deserialize(const QByteArray& data)
|
||||
}
|
||||
}
|
||||
|
||||
void FileSourceGui::handleInputMessages()
|
||||
void FileInputGUI::handleInputMessages()
|
||||
{
|
||||
Message* message;
|
||||
|
||||
@@ -148,7 +148,7 @@ void FileSourceGui::handleInputMessages()
|
||||
DSPSignalNotification* notif = (DSPSignalNotification*) message;
|
||||
m_deviceSampleRate = notif->getSampleRate();
|
||||
m_deviceCenterFrequency = notif->getCenterFrequency();
|
||||
qDebug("FileSourceGui::handleInputMessages: DSPSignalNotification: SampleRate:%d, CenterFrequency:%llu", notif->getSampleRate(), notif->getCenterFrequency());
|
||||
qDebug("FileInputGUI::handleInputMessages: DSPSignalNotification: SampleRate:%d, CenterFrequency:%llu", notif->getSampleRate(), notif->getCenterFrequency());
|
||||
updateSampleRateAndFrequency();
|
||||
|
||||
delete message;
|
||||
@@ -163,49 +163,49 @@ void FileSourceGui::handleInputMessages()
|
||||
}
|
||||
}
|
||||
|
||||
bool FileSourceGui::handleMessage(const Message& message)
|
||||
bool FileInputGUI::handleMessage(const Message& message)
|
||||
{
|
||||
if (FileSourceInput::MsgConfigureFileSource::match(message))
|
||||
if (FileInput::MsgConfigureFileInput::match(message))
|
||||
{
|
||||
const FileSourceInput::MsgConfigureFileSource& cfg = (FileSourceInput::MsgConfigureFileSource&) message;
|
||||
const FileInput::MsgConfigureFileInput& cfg = (FileInput::MsgConfigureFileInput&) message;
|
||||
m_settings = cfg.getSettings();
|
||||
displaySettings();
|
||||
return true;
|
||||
}
|
||||
else if (FileSourceInput::MsgReportFileSourceAcquisition::match(message))
|
||||
else if (FileInput::MsgReportFileSourceAcquisition::match(message))
|
||||
{
|
||||
m_acquisition = ((FileSourceInput::MsgReportFileSourceAcquisition&)message).getAcquisition();
|
||||
m_acquisition = ((FileInput::MsgReportFileSourceAcquisition&)message).getAcquisition();
|
||||
updateWithAcquisition();
|
||||
return true;
|
||||
}
|
||||
else if (FileSourceInput::MsgReportFileSourceStreamData::match(message))
|
||||
else if (FileInput::MsgReportFileInputStreamData::match(message))
|
||||
{
|
||||
m_sampleRate = ((FileSourceInput::MsgReportFileSourceStreamData&)message).getSampleRate();
|
||||
m_sampleSize = ((FileSourceInput::MsgReportFileSourceStreamData&)message).getSampleSize();
|
||||
m_centerFrequency = ((FileSourceInput::MsgReportFileSourceStreamData&)message).getCenterFrequency();
|
||||
m_startingTimeStamp = ((FileSourceInput::MsgReportFileSourceStreamData&)message).getStartingTimeStamp();
|
||||
m_recordLength = ((FileSourceInput::MsgReportFileSourceStreamData&)message).getRecordLength();
|
||||
m_sampleRate = ((FileInput::MsgReportFileInputStreamData&)message).getSampleRate();
|
||||
m_sampleSize = ((FileInput::MsgReportFileInputStreamData&)message).getSampleSize();
|
||||
m_centerFrequency = ((FileInput::MsgReportFileInputStreamData&)message).getCenterFrequency();
|
||||
m_startingTimeStamp = ((FileInput::MsgReportFileInputStreamData&)message).getStartingTimeStamp();
|
||||
m_recordLength = ((FileInput::MsgReportFileInputStreamData&)message).getRecordLength();
|
||||
updateWithStreamData();
|
||||
return true;
|
||||
}
|
||||
else if (FileSourceInput::MsgReportFileSourceStreamTiming::match(message))
|
||||
else if (FileInput::MsgReportFileInputStreamTiming::match(message))
|
||||
{
|
||||
m_samplesCount = ((FileSourceInput::MsgReportFileSourceStreamTiming&)message).getSamplesCount();
|
||||
m_samplesCount = ((FileInput::MsgReportFileInputStreamTiming&)message).getSamplesCount();
|
||||
updateWithStreamTime();
|
||||
return true;
|
||||
}
|
||||
else if (FileSourceInput::MsgStartStop::match(message))
|
||||
else if (FileInput::MsgStartStop::match(message))
|
||||
{
|
||||
FileSourceInput::MsgStartStop& notif = (FileSourceInput::MsgStartStop&) message;
|
||||
FileInput::MsgStartStop& notif = (FileInput::MsgStartStop&) message;
|
||||
blockApplySettings(true);
|
||||
ui->startStop->setChecked(notif.getStartStop());
|
||||
blockApplySettings(false);
|
||||
|
||||
return true;
|
||||
}
|
||||
else if (FileSourceInput::MsgPlayPause::match(message))
|
||||
else if (FileInput::MsgPlayPause::match(message))
|
||||
{
|
||||
FileSourceInput::MsgPlayPause& notif = (FileSourceInput::MsgPlayPause&) message;
|
||||
FileInput::MsgPlayPause& notif = (FileInput::MsgPlayPause&) message;
|
||||
bool checked = notif.getPlayPause();
|
||||
ui->play->setChecked(checked);
|
||||
ui->navTimeSlider->setEnabled(!checked);
|
||||
@@ -214,9 +214,9 @@ bool FileSourceGui::handleMessage(const Message& message)
|
||||
|
||||
return true;
|
||||
}
|
||||
else if (FileSourceInput::MsgReportHeaderCRC::match(message))
|
||||
else if (FileInput::MsgReportHeaderCRC::match(message))
|
||||
{
|
||||
FileSourceInput::MsgReportHeaderCRC& notif = (FileSourceInput::MsgReportHeaderCRC&) message;
|
||||
FileInput::MsgReportHeaderCRC& notif = (FileInput::MsgReportHeaderCRC&) message;
|
||||
if (notif.isOK()) {
|
||||
ui->crcLabel->setStyleSheet("QLabel { background-color : green; }");
|
||||
} else {
|
||||
@@ -231,45 +231,45 @@ bool FileSourceGui::handleMessage(const Message& message)
|
||||
}
|
||||
}
|
||||
|
||||
void FileSourceGui::updateSampleRateAndFrequency()
|
||||
void FileInputGUI::updateSampleRateAndFrequency()
|
||||
{
|
||||
m_deviceUISet->getSpectrum()->setSampleRate(m_deviceSampleRate);
|
||||
m_deviceUISet->getSpectrum()->setCenterFrequency(m_deviceCenterFrequency);
|
||||
ui->deviceRateText->setText(tr("%1k").arg((float)m_deviceSampleRate / 1000));
|
||||
}
|
||||
|
||||
void FileSourceGui::displaySettings()
|
||||
void FileInputGUI::displaySettings()
|
||||
{
|
||||
blockApplySettings(true);
|
||||
ui->playLoop->setChecked(m_settings.m_loop);
|
||||
ui->acceleration->setCurrentIndex(FileSourceInputSettings::getAccelerationIndex(m_settings.m_accelerationFactor));
|
||||
ui->acceleration->setCurrentIndex(FileInputSettings::getAccelerationIndex(m_settings.m_accelerationFactor));
|
||||
blockApplySettings(false);
|
||||
}
|
||||
|
||||
void FileSourceGui::sendSettings()
|
||||
void FileInputGUI::sendSettings()
|
||||
{
|
||||
}
|
||||
|
||||
void FileSourceGui::on_playLoop_toggled(bool checked)
|
||||
void FileInputGUI::on_playLoop_toggled(bool checked)
|
||||
{
|
||||
if (m_doApplySettings)
|
||||
{
|
||||
m_settings.m_loop = checked;
|
||||
FileSourceInput::MsgConfigureFileSource *message = FileSourceInput::MsgConfigureFileSource::create(m_settings, false);
|
||||
FileInput::MsgConfigureFileInput *message = FileInput::MsgConfigureFileInput::create(m_settings, false);
|
||||
m_sampleSource->getInputMessageQueue()->push(message);
|
||||
}
|
||||
}
|
||||
|
||||
void FileSourceGui::on_startStop_toggled(bool checked)
|
||||
void FileInputGUI::on_startStop_toggled(bool checked)
|
||||
{
|
||||
if (m_doApplySettings)
|
||||
{
|
||||
FileSourceInput::MsgStartStop *message = FileSourceInput::MsgStartStop::create(checked);
|
||||
FileInput::MsgStartStop *message = FileInput::MsgStartStop::create(checked);
|
||||
m_sampleSource->getInputMessageQueue()->push(message);
|
||||
}
|
||||
}
|
||||
|
||||
void FileSourceGui::updateStatus()
|
||||
void FileInputGUI::updateStatus()
|
||||
{
|
||||
int state = m_deviceUISet->m_deviceAPI->state();
|
||||
|
||||
@@ -298,25 +298,25 @@ void FileSourceGui::updateStatus()
|
||||
}
|
||||
}
|
||||
|
||||
void FileSourceGui::on_play_toggled(bool checked)
|
||||
void FileInputGUI::on_play_toggled(bool checked)
|
||||
{
|
||||
FileSourceInput::MsgConfigureFileSourceWork* message = FileSourceInput::MsgConfigureFileSourceWork::create(checked);
|
||||
FileInput::MsgConfigureFileInputWork* message = FileInput::MsgConfigureFileInputWork::create(checked);
|
||||
m_sampleSource->getInputMessageQueue()->push(message);
|
||||
ui->navTimeSlider->setEnabled(!checked);
|
||||
ui->acceleration->setEnabled(!checked);
|
||||
m_enableNavTime = !checked;
|
||||
}
|
||||
|
||||
void FileSourceGui::on_navTimeSlider_valueChanged(int value)
|
||||
void FileInputGUI::on_navTimeSlider_valueChanged(int value)
|
||||
{
|
||||
if (m_enableNavTime && ((value >= 0) && (value <= 1000)))
|
||||
{
|
||||
FileSourceInput::MsgConfigureFileSourceSeek* message = FileSourceInput::MsgConfigureFileSourceSeek::create(value);
|
||||
FileInput::MsgConfigureFileSourceSeek* message = FileInput::MsgConfigureFileSourceSeek::create(value);
|
||||
m_sampleSource->getInputMessageQueue()->push(message);
|
||||
}
|
||||
}
|
||||
|
||||
void FileSourceGui::on_showFileDialog_clicked(bool checked)
|
||||
void FileInputGUI::on_showFileDialog_clicked(bool checked)
|
||||
{
|
||||
(void) checked;
|
||||
QString fileName = QFileDialog::getOpenFileName(this,
|
||||
@@ -331,31 +331,31 @@ void FileSourceGui::on_showFileDialog_clicked(bool checked)
|
||||
}
|
||||
}
|
||||
|
||||
void FileSourceGui::on_acceleration_currentIndexChanged(int index)
|
||||
void FileInputGUI::on_acceleration_currentIndexChanged(int index)
|
||||
{
|
||||
if (m_doApplySettings)
|
||||
{
|
||||
m_settings.m_accelerationFactor = FileSourceInputSettings::getAccelerationValue(index);
|
||||
FileSourceInput::MsgConfigureFileSource *message = FileSourceInput::MsgConfigureFileSource::create(m_settings, false);
|
||||
m_settings.m_accelerationFactor = FileInputSettings::getAccelerationValue(index);
|
||||
FileInput::MsgConfigureFileInput *message = FileInput::MsgConfigureFileInput::create(m_settings, false);
|
||||
m_sampleSource->getInputMessageQueue()->push(message);
|
||||
}
|
||||
}
|
||||
|
||||
void FileSourceGui::configureFileName()
|
||||
void FileInputGUI::configureFileName()
|
||||
{
|
||||
qDebug() << "FileSourceGui::configureFileName: " << m_fileName.toStdString().c_str();
|
||||
FileSourceInput::MsgConfigureFileSourceName* message = FileSourceInput::MsgConfigureFileSourceName::create(m_fileName);
|
||||
qDebug() << "FileInputGUI::configureFileName: " << m_fileName.toStdString().c_str();
|
||||
FileInput::MsgConfigureFileSourceName* message = FileInput::MsgConfigureFileSourceName::create(m_fileName);
|
||||
m_sampleSource->getInputMessageQueue()->push(message);
|
||||
}
|
||||
|
||||
void FileSourceGui::updateWithAcquisition()
|
||||
void FileInputGUI::updateWithAcquisition()
|
||||
{
|
||||
ui->play->setEnabled(m_acquisition);
|
||||
ui->play->setChecked(m_acquisition);
|
||||
ui->showFileDialog->setEnabled(!m_acquisition);
|
||||
}
|
||||
|
||||
void FileSourceGui::updateWithStreamData()
|
||||
void FileInputGUI::updateWithStreamData()
|
||||
{
|
||||
ui->centerFrequency->setValue(m_centerFrequency/1000);
|
||||
ui->sampleRateText->setText(tr("%1k").arg((float)m_sampleRate / 1000));
|
||||
@@ -368,7 +368,7 @@ void FileSourceGui::updateWithStreamData()
|
||||
updateWithStreamTime();
|
||||
}
|
||||
|
||||
void FileSourceGui::updateWithStreamTime()
|
||||
void FileInputGUI::updateWithStreamTime()
|
||||
{
|
||||
qint64 t_sec = 0;
|
||||
qint64 t_msec = 0;
|
||||
@@ -398,21 +398,21 @@ void FileSourceGui::updateWithStreamTime()
|
||||
}
|
||||
}
|
||||
|
||||
void FileSourceGui::tick()
|
||||
void FileInputGUI::tick()
|
||||
{
|
||||
if ((++m_tickCount & 0xf) == 0) {
|
||||
FileSourceInput::MsgConfigureFileSourceStreamTiming* message = FileSourceInput::MsgConfigureFileSourceStreamTiming::create();
|
||||
FileInput::MsgConfigureFileInputStreamTiming* message = FileInput::MsgConfigureFileInputStreamTiming::create();
|
||||
m_sampleSource->getInputMessageQueue()->push(message);
|
||||
}
|
||||
}
|
||||
|
||||
void FileSourceGui::setAccelerationCombo()
|
||||
void FileInputGUI::setAccelerationCombo()
|
||||
{
|
||||
ui->acceleration->blockSignals(true);
|
||||
ui->acceleration->clear();
|
||||
ui->acceleration->addItem(QString("1"));
|
||||
|
||||
for (unsigned int i = 0; i <= FileSourceInputSettings::m_accelerationMaxScale; i++)
|
||||
for (unsigned int i = 0; i <= FileInputSettings::m_accelerationMaxScale; i++)
|
||||
{
|
||||
QString s;
|
||||
int m = pow(10.0, i);
|
||||
@@ -430,7 +430,7 @@ void FileSourceGui::setAccelerationCombo()
|
||||
ui->acceleration->blockSignals(false);
|
||||
}
|
||||
|
||||
void FileSourceGui::setNumberStr(int n, QString& s)
|
||||
void FileInputGUI::setNumberStr(int n, QString& s)
|
||||
{
|
||||
if (n < 1000) {
|
||||
s = tr("%1").arg(n);
|
||||
@@ -445,7 +445,7 @@ void FileSourceGui::setNumberStr(int n, QString& s)
|
||||
}
|
||||
}
|
||||
|
||||
void FileSourceGui::openDeviceSettingsDialog(const QPoint& p)
|
||||
void FileInputGUI::openDeviceSettingsDialog(const QPoint& p)
|
||||
{
|
||||
BasicDeviceSettingsDialog dialog(this);
|
||||
dialog.setUseReverseAPI(m_settings.m_useReverseAPI);
|
||||
+12
-12
@@ -1,5 +1,5 @@
|
||||
///////////////////////////////////////////////////////////////////////////////////
|
||||
// Copyright (C) 2015 Edouard Griffiths, F4EXB //
|
||||
// Copyright (C) 2015-2019 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 //
|
||||
@@ -15,8 +15,8 @@
|
||||
// along with this program. If not, see <http://www.gnu.org/licenses/>. //
|
||||
///////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#ifndef INCLUDE_FILESOURCEGUI_H
|
||||
#define INCLUDE_FILESOURCEGUI_H
|
||||
#ifndef INCLUDE_FILEINPUTGUI_H
|
||||
#define INCLUDE_FILEINPUTGUI_H
|
||||
|
||||
#include <plugin/plugininstancegui.h>
|
||||
#include <QTimer>
|
||||
@@ -24,21 +24,21 @@
|
||||
|
||||
#include "util/messagequeue.h"
|
||||
|
||||
#include "filesourceinputsettings.h"
|
||||
#include "filesourceinput.h"
|
||||
#include "fileinputsettings.h"
|
||||
#include "fileinput.h"
|
||||
|
||||
class DeviceUISet;
|
||||
|
||||
namespace Ui {
|
||||
class FileSourceGui;
|
||||
class FileInputGUI;
|
||||
}
|
||||
|
||||
class FileSourceGui : public QWidget, public PluginInstanceGUI {
|
||||
class FileInputGUI : public QWidget, public PluginInstanceGUI {
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit FileSourceGui(DeviceUISet *deviceUISet, QWidget* parent = 0);
|
||||
virtual ~FileSourceGui();
|
||||
explicit FileInputGUI(DeviceUISet *deviceUISet, QWidget* parent = 0);
|
||||
virtual ~FileInputGUI();
|
||||
virtual void destroy();
|
||||
|
||||
void setName(const QString& name);
|
||||
@@ -53,10 +53,10 @@ public:
|
||||
virtual bool handleMessage(const Message& message);
|
||||
|
||||
private:
|
||||
Ui::FileSourceGui* ui;
|
||||
Ui::FileInputGUI* ui;
|
||||
|
||||
DeviceUISet* m_deviceUISet;
|
||||
FileSourceInputSettings m_settings;
|
||||
FileInputSettings m_settings;
|
||||
bool m_doApplySettings;
|
||||
QTimer m_statusTimer;
|
||||
std::vector<int> m_gains;
|
||||
@@ -101,4 +101,4 @@ private slots:
|
||||
void openDeviceSettingsDialog(const QPoint& p);
|
||||
};
|
||||
|
||||
#endif // INCLUDE_FILESOURCEGUI_H
|
||||
#endif // INCLUDE_FILEINPUTGUI_H
|
||||
+3
-3
@@ -1,7 +1,7 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<ui version="4.0">
|
||||
<class>FileSourceGui</class>
|
||||
<widget class="QWidget" name="FileSourceGui">
|
||||
<class>FileInputGUI</class>
|
||||
<widget class="QWidget" name="FileInputGUI">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
@@ -32,7 +32,7 @@
|
||||
</font>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
<string>FileSource</string>
|
||||
<string>FileInput</string>
|
||||
</property>
|
||||
<layout class="QVBoxLayout" name="verticalLayout">
|
||||
<property name="spacing">
|
||||
+18
-18
@@ -1,5 +1,5 @@
|
||||
///////////////////////////////////////////////////////////////////////////////////
|
||||
// Copyright (C) 2015 Edouard Griffiths, F4EXB //
|
||||
// Copyright (C) 2015-2019 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 //
|
||||
@@ -21,14 +21,14 @@
|
||||
#include "util/simpleserializer.h"
|
||||
|
||||
#ifdef SERVER_MODE
|
||||
#include "filesourceinput.h"
|
||||
#include "fileinput.h"
|
||||
#else
|
||||
#include "filesourcegui.h"
|
||||
#include "fileinputgui.h"
|
||||
#endif
|
||||
#include "filesourceplugin.h"
|
||||
#include "fileinputplugin.h"
|
||||
|
||||
const PluginDescriptor FileSourcePlugin::m_pluginDescriptor = {
|
||||
QString("File source input"),
|
||||
const PluginDescriptor FileInputPlugin::m_pluginDescriptor = {
|
||||
QString("File input"),
|
||||
QString("4.11.0"),
|
||||
QString("(c) Edouard Griffiths, F4EXB"),
|
||||
QString("https://github.com/f4exb/sdrangel"),
|
||||
@@ -36,30 +36,30 @@ const PluginDescriptor FileSourcePlugin::m_pluginDescriptor = {
|
||||
QString("https://github.com/f4exb/sdrangel")
|
||||
};
|
||||
|
||||
const QString FileSourcePlugin::m_hardwareID = "FileSource";
|
||||
const QString FileSourcePlugin::m_deviceTypeID = FILESOURCE_DEVICE_TYPE_ID;
|
||||
const QString FileInputPlugin::m_hardwareID = "FileInput";
|
||||
const QString FileInputPlugin::m_deviceTypeID = FILEINPUT_DEVICE_TYPE_ID;
|
||||
|
||||
FileSourcePlugin::FileSourcePlugin(QObject* parent) :
|
||||
FileInputPlugin::FileInputPlugin(QObject* parent) :
|
||||
QObject(parent)
|
||||
{
|
||||
}
|
||||
|
||||
const PluginDescriptor& FileSourcePlugin::getPluginDescriptor() const
|
||||
const PluginDescriptor& FileInputPlugin::getPluginDescriptor() const
|
||||
{
|
||||
return m_pluginDescriptor;
|
||||
}
|
||||
|
||||
void FileSourcePlugin::initPlugin(PluginAPI* pluginAPI)
|
||||
void FileInputPlugin::initPlugin(PluginAPI* pluginAPI)
|
||||
{
|
||||
pluginAPI->registerSampleSource(m_deviceTypeID, this);
|
||||
}
|
||||
|
||||
PluginInterface::SamplingDevices FileSourcePlugin::enumSampleSources()
|
||||
PluginInterface::SamplingDevices FileInputPlugin::enumSampleSources()
|
||||
{
|
||||
SamplingDevices result;
|
||||
|
||||
result.append(SamplingDevice(
|
||||
"FileSource",
|
||||
"FileInput",
|
||||
m_hardwareID,
|
||||
m_deviceTypeID,
|
||||
QString::null,
|
||||
@@ -73,7 +73,7 @@ PluginInterface::SamplingDevices FileSourcePlugin::enumSampleSources()
|
||||
}
|
||||
|
||||
#ifdef SERVER_MODE
|
||||
PluginInstanceGUI* FileSourcePlugin::createSampleSourcePluginInstanceGUI(
|
||||
PluginInstanceGUI* FileInputPlugin::createSampleSourcePluginInstanceGUI(
|
||||
const QString& sourceId,
|
||||
QWidget **widget,
|
||||
DeviceUISet *deviceUISet)
|
||||
@@ -84,14 +84,14 @@ PluginInstanceGUI* FileSourcePlugin::createSampleSourcePluginInstanceGUI(
|
||||
return 0;
|
||||
}
|
||||
#else
|
||||
PluginInstanceGUI* FileSourcePlugin::createSampleSourcePluginInstanceGUI(
|
||||
PluginInstanceGUI* FileInputPlugin::createSampleSourcePluginInstanceGUI(
|
||||
const QString& sourceId,
|
||||
QWidget **widget,
|
||||
DeviceUISet *deviceUISet)
|
||||
{
|
||||
if(sourceId == m_deviceTypeID)
|
||||
{
|
||||
FileSourceGui* gui = new FileSourceGui(deviceUISet);
|
||||
FileInputGUI* gui = new FileInputGUI(deviceUISet);
|
||||
*widget = gui;
|
||||
return gui;
|
||||
}
|
||||
@@ -102,11 +102,11 @@ PluginInstanceGUI* FileSourcePlugin::createSampleSourcePluginInstanceGUI(
|
||||
}
|
||||
#endif
|
||||
|
||||
DeviceSampleSource *FileSourcePlugin::createSampleSourcePluginInstance(const QString& sourceId, DeviceAPI *deviceAPI)
|
||||
DeviceSampleSource *FileInputPlugin::createSampleSourcePluginInstance(const QString& sourceId, DeviceAPI *deviceAPI)
|
||||
{
|
||||
if (sourceId == m_deviceTypeID)
|
||||
{
|
||||
FileSourceInput* input = new FileSourceInput(deviceAPI);
|
||||
FileInput* input = new FileInput(deviceAPI);
|
||||
return input;
|
||||
}
|
||||
else
|
||||
+7
-7
@@ -1,5 +1,5 @@
|
||||
///////////////////////////////////////////////////////////////////////////////////
|
||||
// Copyright (C) 2015 Edouard Griffiths, F4EXB //
|
||||
// Copyright (C) 2015-2019 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 //
|
||||
@@ -15,23 +15,23 @@
|
||||
// along with this program. If not, see <http://www.gnu.org/licenses/>. //
|
||||
///////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#ifndef INCLUDE_FILESOURCEPLUGIN_H
|
||||
#define INCLUDE_FILESOURCEPLUGIN_H
|
||||
#ifndef INCLUDE_FILEINPUTPLUGIN_H
|
||||
#define INCLUDE_FILEINPUTPLUGIN_H
|
||||
|
||||
#include <QObject>
|
||||
#include "plugin/plugininterface.h"
|
||||
|
||||
#define FILESOURCE_DEVICE_TYPE_ID "sdrangel.samplesource.filesource"
|
||||
#define FILEINPUT_DEVICE_TYPE_ID "sdrangel.samplesource.fileinput"
|
||||
|
||||
class PluginAPI;
|
||||
|
||||
class FileSourcePlugin : public QObject, public PluginInterface {
|
||||
class FileInputPlugin : public QObject, public PluginInterface {
|
||||
Q_OBJECT
|
||||
Q_INTERFACES(PluginInterface)
|
||||
Q_PLUGIN_METADATA(IID FILESOURCE_DEVICE_TYPE_ID)
|
||||
Q_PLUGIN_METADATA(IID FILEINPUT_DEVICE_TYPE_ID)
|
||||
|
||||
public:
|
||||
explicit FileSourcePlugin(QObject* parent = NULL);
|
||||
explicit FileInputPlugin(QObject* parent = nullptr);
|
||||
|
||||
const PluginDescriptor& getPluginDescriptor() const;
|
||||
void initPlugin(PluginAPI* pluginAPI);
|
||||
+9
-9
@@ -1,5 +1,5 @@
|
||||
///////////////////////////////////////////////////////////////////////////////////
|
||||
// Copyright (C) 2017 Edouard Griffiths, F4EXB //
|
||||
// Copyright (C) 2017-2019 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 //
|
||||
@@ -17,16 +17,16 @@
|
||||
|
||||
#include "util/simpleserializer.h"
|
||||
|
||||
#include "filesourceinputsettings.h"
|
||||
#include "fileinputsettings.h"
|
||||
|
||||
const unsigned int FileSourceInputSettings::m_accelerationMaxScale = 2;
|
||||
const unsigned int FileInputSettings::m_accelerationMaxScale = 2;
|
||||
|
||||
FileSourceInputSettings::FileSourceInputSettings()
|
||||
FileInputSettings::FileInputSettings()
|
||||
{
|
||||
resetToDefaults();
|
||||
}
|
||||
|
||||
void FileSourceInputSettings::resetToDefaults()
|
||||
void FileInputSettings::resetToDefaults()
|
||||
{
|
||||
m_centerFrequency = 435000000;
|
||||
m_sampleRate = 48000;
|
||||
@@ -39,7 +39,7 @@ void FileSourceInputSettings::resetToDefaults()
|
||||
m_reverseAPIDeviceIndex = 0;
|
||||
}
|
||||
|
||||
QByteArray FileSourceInputSettings::serialize() const
|
||||
QByteArray FileInputSettings::serialize() const
|
||||
{
|
||||
SimpleSerializer s(1);
|
||||
s.writeString(1, m_fileName);
|
||||
@@ -53,7 +53,7 @@ QByteArray FileSourceInputSettings::serialize() const
|
||||
return s.final();
|
||||
}
|
||||
|
||||
bool FileSourceInputSettings::deserialize(const QByteArray& data)
|
||||
bool FileInputSettings::deserialize(const QByteArray& data)
|
||||
{
|
||||
SimpleDeserializer d(data);
|
||||
|
||||
@@ -91,7 +91,7 @@ bool FileSourceInputSettings::deserialize(const QByteArray& data)
|
||||
}
|
||||
}
|
||||
|
||||
int FileSourceInputSettings::getAccelerationIndex(int accelerationValue)
|
||||
int FileInputSettings::getAccelerationIndex(int accelerationValue)
|
||||
{
|
||||
if (accelerationValue <= 1) {
|
||||
return 0;
|
||||
@@ -123,7 +123,7 @@ int FileSourceInputSettings::getAccelerationIndex(int accelerationValue)
|
||||
return 3*m_accelerationMaxScale + 3;
|
||||
}
|
||||
|
||||
int FileSourceInputSettings::getAccelerationValue(int accelerationIndex)
|
||||
int FileInputSettings::getAccelerationValue(int accelerationIndex)
|
||||
{
|
||||
if (accelerationIndex <= 0) {
|
||||
return 1;
|
||||
+7
-7
@@ -1,5 +1,5 @@
|
||||
///////////////////////////////////////////////////////////////////////////////////
|
||||
// Copyright (C) 2017 Edouard Griffiths, F4EXB //
|
||||
// Copyright (C) 2017-2019 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 //
|
||||
@@ -15,13 +15,13 @@
|
||||
// along with this program. If not, see <http://www.gnu.org/licenses/>. //
|
||||
///////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#ifndef PLUGINS_SAMPLESOURCE_FILESOURCE_FILESOURCEINPUTSETTINGS_H_
|
||||
#define PLUGINS_SAMPLESOURCE_FILESOURCE_FILESOURCEINPUTSETTINGS_H_
|
||||
#ifndef PLUGINS_SAMPLESOURCE_FILEINPUT_FILEINPUTSETTINGS_H_
|
||||
#define PLUGINS_SAMPLESOURCE_FILEINPUT_FILEINPUTSETTINGS_H_
|
||||
|
||||
#include <QString>
|
||||
#include <QByteArray>
|
||||
|
||||
struct FileSourceInputSettings {
|
||||
struct FileInputSettings {
|
||||
quint64 m_centerFrequency;
|
||||
qint32 m_sampleRate;
|
||||
QString m_fileName;
|
||||
@@ -34,8 +34,8 @@ struct FileSourceInputSettings {
|
||||
|
||||
static const unsigned int m_accelerationMaxScale; //!< Max power of 10 multiplier to 2,5,10 base ex: 2 -> 2,5,10,20,50,100,200,500,1000
|
||||
|
||||
FileSourceInputSettings();
|
||||
~FileSourceInputSettings() {}
|
||||
FileInputSettings();
|
||||
~FileInputSettings() {}
|
||||
|
||||
void resetToDefaults();
|
||||
QByteArray serialize() const;
|
||||
@@ -44,4 +44,4 @@ struct FileSourceInputSettings {
|
||||
static int getAccelerationValue(int averagingIndex);
|
||||
};
|
||||
|
||||
#endif /* PLUGINS_SAMPLESOURCE_FILESOURCE_FILESOURCEINPUTSETTINGS_H_ */
|
||||
#endif /* PLUGINS_SAMPLESOURCE_FILEINPUT_FILEINPUTSETTINGS_H_ */
|
||||
+22
-22
@@ -1,5 +1,5 @@
|
||||
///////////////////////////////////////////////////////////////////////////////////
|
||||
// Copyright (C) 2015 Edouard Griffiths, F4EXB //
|
||||
// Copyright (C) 2015-2019 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 //
|
||||
@@ -21,13 +21,13 @@
|
||||
#include <QDebug>
|
||||
|
||||
#include "dsp/filerecord.h"
|
||||
#include "filesourcethread.h"
|
||||
#include "fileinputthread.h"
|
||||
#include "dsp/samplesinkfifo.h"
|
||||
#include "util/messagequeue.h"
|
||||
|
||||
MESSAGE_CLASS_DEFINITION(FileSourceThread::MsgReportEOF, Message)
|
||||
MESSAGE_CLASS_DEFINITION(FileInputThread::MsgReportEOF, Message)
|
||||
|
||||
FileSourceThread::FileSourceThread(std::ifstream *samplesStream,
|
||||
FileInputThread::FileInputThread(std::ifstream *samplesStream,
|
||||
SampleSinkFifo* sampleFifo,
|
||||
const QTimer& timer,
|
||||
MessageQueue *fileInputMessageQueue,
|
||||
@@ -52,7 +52,7 @@ FileSourceThread::FileSourceThread(std::ifstream *samplesStream,
|
||||
assert(m_ifstream != 0);
|
||||
}
|
||||
|
||||
FileSourceThread::~FileSourceThread()
|
||||
FileInputThread::~FileInputThread()
|
||||
{
|
||||
if (m_running) {
|
||||
stopWork();
|
||||
@@ -67,13 +67,13 @@ FileSourceThread::~FileSourceThread()
|
||||
}
|
||||
}
|
||||
|
||||
void FileSourceThread::startWork()
|
||||
void FileInputThread::startWork()
|
||||
{
|
||||
qDebug() << "FileSourceThread::startWork: ";
|
||||
qDebug() << "FileInputThread::startWork: ";
|
||||
|
||||
if (m_ifstream->is_open())
|
||||
{
|
||||
qDebug() << "FileSourceThread::startWork: file stream open, starting...";
|
||||
qDebug() << "FileInputThread::startWork: file stream open, starting...";
|
||||
m_startWaitMutex.lock();
|
||||
m_elapsedTimer.start();
|
||||
start();
|
||||
@@ -84,21 +84,21 @@ void FileSourceThread::startWork()
|
||||
}
|
||||
else
|
||||
{
|
||||
qDebug() << "FileSourceThread::startWork: file stream closed, not starting.";
|
||||
qDebug() << "FileInputThread::startWork: file stream closed, not starting.";
|
||||
}
|
||||
}
|
||||
|
||||
void FileSourceThread::stopWork()
|
||||
void FileInputThread::stopWork()
|
||||
{
|
||||
qDebug() << "FileSourceThread::stopWork";
|
||||
qDebug() << "FileInputThread::stopWork";
|
||||
disconnect(&m_timer, SIGNAL(timeout()), this, SLOT(tick()));
|
||||
m_running = false;
|
||||
wait();
|
||||
}
|
||||
|
||||
void FileSourceThread::setSampleRateAndSize(int samplerate, quint32 samplesize)
|
||||
void FileInputThread::setSampleRateAndSize(int samplerate, quint32 samplesize)
|
||||
{
|
||||
qDebug() << "FileSourceThread::setSampleRateAndSize:"
|
||||
qDebug() << "FileInputThread::setSampleRateAndSize:"
|
||||
<< " new rate:" << samplerate
|
||||
<< " new size:" << samplesize
|
||||
<< " old rate:" << m_samplerate
|
||||
@@ -121,7 +121,7 @@ void FileSourceThread::setSampleRateAndSize(int samplerate, quint32 samplesize)
|
||||
//m_samplerate = samplerate;
|
||||
}
|
||||
|
||||
void FileSourceThread::setBuffers(std::size_t chunksize)
|
||||
void FileInputThread::setBuffers(std::size_t chunksize)
|
||||
{
|
||||
if (chunksize > m_bufsize)
|
||||
{
|
||||
@@ -130,12 +130,12 @@ void FileSourceThread::setBuffers(std::size_t chunksize)
|
||||
|
||||
if (m_fileBuf == 0)
|
||||
{
|
||||
qDebug() << "FileSourceThread::setBuffers: Allocate file buffer";
|
||||
qDebug() << "FileInputThread::setBuffers: Allocate file buffer";
|
||||
m_fileBuf = (quint8*) malloc(m_bufsize);
|
||||
}
|
||||
else
|
||||
{
|
||||
qDebug() << "FileSourceThread::setBuffers: Re-allocate file buffer";
|
||||
qDebug() << "FileInputThread::setBuffers: Re-allocate file buffer";
|
||||
quint8 *buf = m_fileBuf;
|
||||
m_fileBuf = (quint8*) realloc((void*) m_fileBuf, m_bufsize);
|
||||
if (!m_fileBuf) free(buf);
|
||||
@@ -143,23 +143,23 @@ void FileSourceThread::setBuffers(std::size_t chunksize)
|
||||
|
||||
if (m_convertBuf == 0)
|
||||
{
|
||||
qDebug() << "FileSourceThread::setBuffers: Allocate conversion buffer";
|
||||
qDebug() << "FileInputThread::setBuffers: Allocate conversion buffer";
|
||||
m_convertBuf = (quint8*) malloc(nbSamples*sizeof(Sample));
|
||||
}
|
||||
else
|
||||
{
|
||||
qDebug() << "FileSourceThread::setBuffers: Re-allocate conversion buffer";
|
||||
qDebug() << "FileInputThread::setBuffers: Re-allocate conversion buffer";
|
||||
quint8 *buf = m_convertBuf;
|
||||
m_convertBuf = (quint8*) realloc((void*) m_convertBuf, nbSamples*sizeof(Sample));
|
||||
if (!m_convertBuf) free(buf);
|
||||
}
|
||||
|
||||
qDebug() << "FileSourceThread::setBuffers: size: " << m_bufsize
|
||||
qDebug() << "FileInputThread::setBuffers: size: " << m_bufsize
|
||||
<< " #samples: " << nbSamples;
|
||||
}
|
||||
}
|
||||
|
||||
void FileSourceThread::run()
|
||||
void FileInputThread::run()
|
||||
{
|
||||
m_running = true;
|
||||
m_startWaiter.wakeAll();
|
||||
@@ -172,7 +172,7 @@ void FileSourceThread::run()
|
||||
m_running = false;
|
||||
}
|
||||
|
||||
void FileSourceThread::tick()
|
||||
void FileInputThread::tick()
|
||||
{
|
||||
if (m_running)
|
||||
{
|
||||
@@ -203,7 +203,7 @@ void FileSourceThread::tick()
|
||||
}
|
||||
}
|
||||
|
||||
void FileSourceThread::writeToSampleFifo(const quint8* buf, qint32 nbBytes)
|
||||
void FileInputThread::writeToSampleFifo(const quint8* buf, qint32 nbBytes)
|
||||
{
|
||||
if (m_samplesize == 16)
|
||||
{
|
||||
+9
-11
@@ -1,5 +1,5 @@
|
||||
///////////////////////////////////////////////////////////////////////////////////
|
||||
// Copyright (C) 2015 Edouard Griffiths, F4EXB //
|
||||
// Copyright (C) 2015-2019 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 //
|
||||
@@ -15,8 +15,8 @@
|
||||
// along with this program. If not, see <http://www.gnu.org/licenses/>. //
|
||||
///////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#ifndef INCLUDE_FILESOURCETHREAD_H
|
||||
#define INCLUDE_FILESOURCETHREAD_H
|
||||
#ifndef INCLUDE_FILEINPUTTHREAD_H
|
||||
#define INCLUDE_FILEINPUTTHREAD_H
|
||||
|
||||
#include <QThread>
|
||||
#include <QMutex>
|
||||
@@ -35,7 +35,7 @@
|
||||
class SampleSinkFifo;
|
||||
class MessageQueue;
|
||||
|
||||
class FileSourceThread : public QThread {
|
||||
class FileInputThread : public QThread {
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
@@ -43,25 +43,22 @@ public:
|
||||
MESSAGE_CLASS_DECLARATION
|
||||
|
||||
public:
|
||||
|
||||
static MsgReportEOF* create()
|
||||
{
|
||||
static MsgReportEOF* create() {
|
||||
return new MsgReportEOF();
|
||||
}
|
||||
|
||||
private:
|
||||
|
||||
MsgReportEOF() :
|
||||
Message()
|
||||
{ }
|
||||
};
|
||||
|
||||
FileSourceThread(std::ifstream *samplesStream,
|
||||
FileInputThread(std::ifstream *samplesStream,
|
||||
SampleSinkFifo* sampleFifo,
|
||||
const QTimer& timer,
|
||||
MessageQueue *fileInputMessageQueue,
|
||||
QObject* parent = NULL);
|
||||
~FileSourceThread();
|
||||
~FileInputThread();
|
||||
|
||||
void startWork();
|
||||
void stopWork();
|
||||
@@ -96,8 +93,9 @@ private:
|
||||
void run();
|
||||
//void decimate1(SampleVector::iterator* it, const qint16* buf, qint32 len);
|
||||
void writeToSampleFifo(const quint8* buf, qint32 nbBytes);
|
||||
|
||||
private slots:
|
||||
void tick();
|
||||
};
|
||||
|
||||
#endif // INCLUDE_FILESOURCETHREAD_H
|
||||
#endif // INCLUDE_FILEINPUTTHREAD_H
|
||||
+4
-5
@@ -1,4 +1,4 @@
|
||||
<h1>File source input plugin</h1>
|
||||
<h1>File input plugin</h1>
|
||||
|
||||
<h2>Introduction</h2>
|
||||
|
||||
@@ -46,16 +46,16 @@ The header takes an integer number of 16 (4 bytes) or 24 (8 bytes) bits samples.
|
||||
|
||||
<h2>Interface</h2>
|
||||
|
||||

|
||||

|
||||
|
||||
<h3>1: Start/Stop</h3>
|
||||
|
||||
Device start / stop button.
|
||||
Device start / stop button.
|
||||
|
||||
- Blue triangle icon: ready to be started
|
||||
- Green square icon: currently running and can be stopped
|
||||
- Magenta (or pink) square icon: an error occurred. The file may not be found or this can be a header CRC error or the file is too small (less than the header length). You may stop and choose another file.
|
||||
|
||||
|
||||
<h3>2: Stream sample rate</h3>
|
||||
|
||||
Baseband I/Q sample rate in kS/s. This is the sample rate present in the header.
|
||||
@@ -111,4 +111,3 @@ Left is the relative timestamp of the current pointer from the start of the reco
|
||||
<h3>14: Current pointer gauge</h3>
|
||||
|
||||
This represents the position of the current pointer position in the complete recording. It can be used it paused mode to position the current pointer by moving the slider.
|
||||
|
||||
Reference in New Issue
Block a user