SDRAngel  4.11.5
Developer docs for <a href="https://github.com/f4exb/sdrangel">SDRangel<\a>, an Open Source Qt5 / OpenGL 3.0+ SDR and signal analyzer frontend to various hardware.
Classes | Public Member Functions | Private Slots | Private Member Functions | Private Attributes | List of all members
FileInput Class Reference

#include <fileinput.h>

+ Inheritance diagram for FileInput:
+ Collaboration diagram for FileInput:

Classes

class  MsgConfigureFileInput
 
class  MsgConfigureFileInputStreamTiming
 
class  MsgConfigureFileInputWork
 
class  MsgConfigureFileSourceName
 
class  MsgConfigureFileSourceSeek
 
class  MsgPlayPause
 
class  MsgReportFileInputStreamData
 
class  MsgReportFileInputStreamTiming
 
class  MsgReportFileSourceAcquisition
 
class  MsgReportHeaderCRC
 
class  MsgStartStop
 

Public Member Functions

 FileInput (DeviceAPI *deviceAPI)
 
virtual ~FileInput ()
 
virtual void destroy ()
 
virtual void init ()
 initializations to be done when all collaborating objects are created and possibly connected More...
 
virtual bool start ()
 
virtual void stop ()
 
virtual QByteArray serialize () const
 
virtual bool deserialize (const QByteArray &data)
 
virtual void setMessageQueueToGUI (MessageQueue *queue)
 
virtual const QString & getDeviceDescription () const
 
virtual int getSampleRate () const
 Sample rate exposed by the source. More...
 
virtual void setSampleRate (int sampleRate)
 For when the source sample rate is set externally. More...
 
virtual quint64 getCenterFrequency () const
 Center frequency exposed by the source. More...
 
virtual void setCenterFrequency (qint64 centerFrequency)
 
quint64 getStartingTimeStamp () const
 
virtual bool handleMessage (const Message &message)
 
virtual int webapiSettingsGet (SWGSDRangel::SWGDeviceSettings &response, QString &errorMessage)
 
virtual int webapiSettingsPutPatch (bool force, const QStringList &deviceSettingsKeys, SWGSDRangel::SWGDeviceSettings &response, QString &errorMessage)
 
virtual int webapiRunGet (SWGSDRangel::SWGDeviceState &response, QString &errorMessage)
 
virtual int webapiRun (bool run, SWGSDRangel::SWGDeviceState &response, QString &errorMessage)
 
virtual int webapiReportGet (SWGSDRangel::SWGDeviceReport &response, QString &errorMessage)
 
- Public Member Functions inherited from DeviceSampleSource
 DeviceSampleSource ()
 
virtual ~DeviceSampleSource ()
 
MessageQueuegetInputMessageQueue ()
 
MessageQueuegetMessageQueueToGUI ()
 
SampleSinkFifogetSampleFifo ()
 

Private Slots

void networkManagerFinished (QNetworkReply *reply)
 

Private Member Functions

void openFileStream ()
 
void seekFileStream (int seekMillis)
 
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 FileInputSettings &settings, bool force)
 
void webapiReverseSendStartStop (bool start)
 

Private Attributes

DeviceAPIm_deviceAPI
 
QMutex m_mutex
 
FileInputSettings m_settings
 
std::ifstream m_ifstream
 
FileInputThreadm_fileInputThread
 
QString m_deviceDescription
 
QString m_fileName
 
int m_sampleRate
 
quint32 m_sampleSize
 
quint64 m_centerFrequency
 
quint64 m_recordLength
 record length in seconds computed from file size More...
 
quint64 m_startingTimeStamp
 
QTimer m_masterTimer
 
QNetworkAccessManager * m_networkManager
 
QNetworkRequest m_networkRequest
 

Additional Inherited Members

- Public Types inherited from DeviceSampleSource
enum  fcPos_t { FC_POS_INFRA = 0, FC_POS_SUPRA, FC_POS_CENTER }
 
enum  FrequencyShiftScheme { FSHIFT_STD = 0, FSHIFT_TXSYNC }
 
- Static Public Member Functions inherited from DeviceSampleSource
static qint64 calculateDeviceCenterFrequency (quint64 centerFrequency, qint64 transverterDeltaFrequency, int log2Decim, fcPos_t fcPos, quint32 devSampleRate, FrequencyShiftScheme frequencyShiftScheme, bool transverterMode=false)
 
static qint64 calculateCenterFrequency (quint64 deviceCenterFrequency, qint64 transverterDeltaFrequency, int log2Decim, fcPos_t fcPos, quint32 devSampleRate, FrequencyShiftScheme frequencyShiftScheme, bool transverterMode=false)
 
static qint32 calculateFrequencyShift (int log2Decim, fcPos_t fcPos, quint32 devSampleRate, FrequencyShiftScheme frequencyShiftScheme)
 
- Protected Slots inherited from DeviceSampleSource
void handleInputMessages ()
 
- Protected Attributes inherited from DeviceSampleSource
SampleSinkFifo m_sampleFifo
 
MessageQueue m_inputMessageQueue
 Input queue to the source. More...
 
MessageQueuem_guiMessageQueue
 Input message queue to the GUI. More...
 

Detailed Description

Definition at line 38 of file fileinput.h.

Constructor & Destructor Documentation

◆ FileInput()

FileInput::FileInput ( DeviceAPI deviceAPI)

Definition at line 52 of file fileinput.cpp.

Referenced by FileInput::MsgReportHeaderCRC::MsgReportHeaderCRC().

52  :
53  m_deviceAPI(deviceAPI),
54  m_settings(),
55  m_fileInputThread(nullptr),
57  m_fileName("..."),
58  m_sampleRate(0),
59  m_sampleSize(0),
61  m_recordLength(0),
63 {
65  qDebug("FileInput::FileInput: device source engine: %p", m_deviceAPI->getDeviceSourceEngine());
66  qDebug("FileInput::FileInput: device source engine message queue: %p", m_deviceAPI->getDeviceEngineInputMessageQueue());
67  qDebug("FileInput::FileInput: device source: %p", m_deviceAPI->getDeviceSourceEngine()->getSource());
68  m_networkManager = new QNetworkAccessManager();
69  connect(m_networkManager, SIGNAL(finished(QNetworkReply*)), this, SLOT(networkManagerFinished(QNetworkReply*)));
70  m_masterTimer.setTimerType(Qt::PreciseTimer);
71  m_masterTimer.start(50);
72 }
QString m_deviceDescription
Definition: fileinput.h:328
DeviceAPI * m_deviceAPI
Definition: fileinput.h:323
void setNbSourceStreams(uint32_t nbSourceStreams)
Definition: deviceapi.h:168
MessageQueue * getDeviceEngineInputMessageQueue()
Device engine message queue.
Definition: deviceapi.cpp:316
DeviceSampleSource * getSource()
QTimer m_masterTimer
Definition: fileinput.h:335
quint64 m_startingTimeStamp
Definition: fileinput.h:334
DSPDeviceSourceEngine * getDeviceSourceEngine()
Definition: deviceapi.h:153
int m_sampleRate
Definition: fileinput.h:330
FileInputSettings m_settings
Definition: fileinput.h:325
FileInputThread * m_fileInputThread
Definition: fileinput.h:327
quint64 m_centerFrequency
Definition: fileinput.h:332
quint64 m_recordLength
record length in seconds computed from file size
Definition: fileinput.h:333
quint32 m_sampleSize
Definition: fileinput.h:331
void networkManagerFinished(QNetworkReply *reply)
Definition: fileinput.cpp:664
QString m_fileName
Definition: fileinput.h:329
QNetworkAccessManager * m_networkManager
Definition: fileinput.h:336
+ Here is the caller graph for this function:

◆ ~FileInput()

FileInput::~FileInput ( )
virtual

Definition at line 74 of file fileinput.cpp.

References m_masterTimer, m_networkManager, networkManagerFinished(), and stop().

Referenced by FileInput::MsgReportHeaderCRC::MsgReportHeaderCRC().

75 {
76  m_masterTimer.stop();
77  disconnect(m_networkManager, SIGNAL(finished(QNetworkReply*)), this, SLOT(networkManagerFinished(QNetworkReply*)));
78  delete m_networkManager;
79 
80  stop();
81 }
QTimer m_masterTimer
Definition: fileinput.h:335
virtual void stop()
Definition: fileinput.cpp:213
void networkManagerFinished(QNetworkReply *reply)
Definition: fileinput.cpp:664
QNetworkAccessManager * m_networkManager
Definition: fileinput.h:336
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

Member Function Documentation

◆ applySettings()

bool FileInput::applySettings ( const FileInputSettings settings,
bool  force = false 
)
private

Definition at line 406 of file fileinput.cpp.

References FileInputSettings::m_accelerationFactor, FileInputSettings::m_centerFrequency, m_centerFrequency, m_fileInputThread, FileInputSettings::m_fileName, FileInputSettings::m_loop, m_mutex, FileInputSettings::m_reverseAPIAddress, FileInputSettings::m_reverseAPIDeviceIndex, FileInputSettings::m_reverseAPIPort, DeviceSampleSource::m_sampleFifo, m_sampleRate, m_sampleSize, m_settings, FileInputSettings::m_useReverseAPI, FileInputThread::setSampleRateAndSize(), SampleSinkFifo::setSize(), and webapiReverseSendSettings().

Referenced by handleMessage().

407 {
408  QList<QString> reverseAPIKeys;
409 
410  if ((m_settings.m_centerFrequency != settings.m_centerFrequency) || force) {
412  }
413 
414  if ((m_settings.m_accelerationFactor != settings.m_accelerationFactor) || force)
415  {
416  reverseAPIKeys.append("accelerationFactor");
417 
418  if (m_fileInputThread)
419  {
420  QMutexLocker mutexLocker(&m_mutex);
422  qCritical("FileInput::applySettings: could not reallocate sample FIFO size to %lu",
424  }
425  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
426  }
427  }
428 
429  if ((m_settings.m_loop != settings.m_loop)) {
430  reverseAPIKeys.append("loop");
431  }
432  if ((m_settings.m_fileName != settings.m_fileName)) {
433  reverseAPIKeys.append("fileName");
434  }
435 
436  if (settings.m_useReverseAPI)
437  {
438  bool fullUpdate = ((m_settings.m_useReverseAPI != settings.m_useReverseAPI) && settings.m_useReverseAPI) ||
442  webapiReverseSendSettings(reverseAPIKeys, settings, fullUpdate || force);
443  }
444 
445  m_settings = settings;
446  return true;
447 }
uint16_t m_reverseAPIDeviceIndex
SampleSinkFifo m_sampleFifo
bool setSize(int size)
int m_sampleRate
Definition: fileinput.h:330
FileInputSettings m_settings
Definition: fileinput.h:325
QMutex m_mutex
Definition: fileinput.h:324
void setSampleRateAndSize(int samplerate, quint32 samplesize)
FileInputThread * m_fileInputThread
Definition: fileinput.h:327
quint64 m_centerFrequency
Definition: fileinput.h:332
quint32 m_sampleSize
Definition: fileinput.h:331
void webapiReverseSendSettings(QList< QString > &deviceSettingsKeys, const FileInputSettings &settings, bool force)
Definition: fileinput.cpp:597
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ deserialize()

bool FileInput::deserialize ( const QByteArray &  data)
virtual

Implements DeviceSampleSource.

Definition at line 238 of file fileinput.cpp.

References FileInput::MsgConfigureFileInput::create(), FileInputSettings::deserialize(), DeviceSampleSource::getMessageQueueToGUI(), DeviceSampleSource::m_inputMessageQueue, m_settings, MessageQueue::push(), and FileInputSettings::resetToDefaults().

Referenced by FileInput::MsgReportHeaderCRC::MsgReportHeaderCRC().

239 {
240  bool success = true;
241 
242  if (!m_settings.deserialize(data))
243  {
245  success = false;
246  }
247 
248  MsgConfigureFileInput* message = MsgConfigureFileInput::create(m_settings, true);
249  m_inputMessageQueue.push(message);
250 
251  if (getMessageQueueToGUI())
252  {
253  MsgConfigureFileInput* messageToGUI = MsgConfigureFileInput::create(m_settings, true);
254  getMessageQueueToGUI()->push(messageToGUI);
255  }
256 
257  return success;
258 }
void push(Message *message, bool emitSignal=true)
Push message onto queue.
MessageQueue m_inputMessageQueue
Input queue to the source.
bool deserialize(const QByteArray &data)
MessageQueue * getMessageQueueToGUI()
static MsgConfigureFileInput * create(const FileInputSettings &settings, bool force)
Definition: fileinput.h:48
FileInputSettings m_settings
Definition: fileinput.h:325
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ destroy()

void FileInput::destroy ( )
virtual

Implements DeviceSampleSource.

Definition at line 83 of file fileinput.cpp.

Referenced by FileInput::MsgReportHeaderCRC::MsgReportHeaderCRC().

84 {
85  delete this;
86 }
+ Here is the caller graph for this function:

◆ getCenterFrequency()

quint64 FileInput::getCenterFrequency ( ) const
virtual

Center frequency exposed by the source.

Implements DeviceSampleSource.

Definition at line 270 of file fileinput.cpp.

References m_centerFrequency.

Referenced by setSampleRate().

271 {
272  return m_centerFrequency;
273 }
quint64 m_centerFrequency
Definition: fileinput.h:332
+ Here is the caller graph for this function:

◆ getDeviceDescription()

const QString & FileInput::getDeviceDescription ( ) const
virtual

Implements DeviceSampleSource.

Definition at line 260 of file fileinput.cpp.

References m_deviceDescription.

Referenced by setMessageQueueToGUI().

261 {
262  return m_deviceDescription;
263 }
QString m_deviceDescription
Definition: fileinput.h:328
+ Here is the caller graph for this function:

◆ getSampleRate()

int FileInput::getSampleRate ( ) const
virtual

Sample rate exposed by the source.

Implements DeviceSampleSource.

Definition at line 265 of file fileinput.cpp.

References m_sampleRate.

Referenced by setMessageQueueToGUI().

266 {
267  return m_sampleRate;
268 }
int m_sampleRate
Definition: fileinput.h:330
+ Here is the caller graph for this function:

◆ getStartingTimeStamp()

quint64 FileInput::getStartingTimeStamp ( ) const

Definition at line 290 of file fileinput.cpp.

References m_startingTimeStamp.

Referenced by setSampleRate().

291 {
292  return m_startingTimeStamp;
293 }
quint64 m_startingTimeStamp
Definition: fileinput.h:334
+ Here is the caller graph for this function:

◆ handleMessage()

bool FileInput::handleMessage ( const Message message)
virtual

Implements DeviceSampleSource.

Definition at line 295 of file fileinput.cpp.

References applySettings(), FileInput::MsgPlayPause::create(), FileInput::MsgReportFileInputStreamTiming::create(), FileInput::MsgConfigureFileSourceName::getFileName(), DeviceSampleSource::getMessageQueueToGUI(), FileInput::MsgConfigureFileSourceSeek::getMillis(), FileInputThread::getSamplesCount(), FileInput::MsgConfigureFileInput::getSettings(), FileInput::MsgStartStop::getStartStop(), DeviceAPI::initDeviceEngine(), FileInput::MsgConfigureFileInputWork::isWorking(), m_deviceAPI, m_fileInputThread, m_fileName, FileInputSettings::m_loop, m_settings, FileInputSettings::m_useReverseAPI, Message::match(), openFileStream(), MessageQueue::push(), seekFileStream(), DeviceAPI::startDeviceEngine(), FileInputThread::startWork(), DeviceAPI::stopDeviceEngine(), FileInputThread::stopWork(), and webapiReverseSendStartStop().

Referenced by setSampleRate().

296 {
297  if (MsgConfigureFileInput::match(message))
298  {
299  MsgConfigureFileInput& conf = (MsgConfigureFileInput&) message;
300  FileInputSettings settings = conf.getSettings();
301  applySettings(settings);
302  return true;
303  }
304  else if (MsgConfigureFileSourceName::match(message))
305  {
306  MsgConfigureFileSourceName& conf = (MsgConfigureFileSourceName&) message;
307  m_fileName = conf.getFileName();
308  openFileStream();
309  return true;
310  }
311  else if (MsgConfigureFileInputWork::match(message))
312  {
313  MsgConfigureFileInputWork& conf = (MsgConfigureFileInputWork&) message;
314  bool working = conf.isWorking();
315 
316  if (m_fileInputThread != 0)
317  {
318  if (working) {
320  } else {
322  }
323  }
324 
325  return true;
326  }
327  else if (MsgConfigureFileSourceSeek::match(message))
328  {
329  MsgConfigureFileSourceSeek& conf = (MsgConfigureFileSourceSeek&) message;
330  int seekMillis = conf.getMillis();
331  seekFileStream(seekMillis);
332 
333  return true;
334  }
336  {
337  MsgReportFileInputStreamTiming *report;
338 
339  if (m_fileInputThread != 0)
340  {
341  if (getMessageQueueToGUI())
342  {
344  getMessageQueueToGUI()->push(report);
345  }
346  }
347 
348  return true;
349  }
350  else if (MsgStartStop::match(message))
351  {
352  MsgStartStop& cmd = (MsgStartStop&) message;
353  qDebug() << "FileInput::handleMessage: MsgStartStop: " << (cmd.getStartStop() ? "start" : "stop");
354 
355  if (cmd.getStartStop())
356  {
358  {
360  }
361  }
362  else
363  {
365  }
366 
368  webapiReverseSendStartStop(cmd.getStartStop());
369  }
370 
371  return true;
372  }
373  else if (FileInputThread::MsgReportEOF::match(message))
374  {
375  qDebug() << "FileInput::handleMessage: MsgReportEOF";
377 
378  if (getMessageQueueToGUI())
379  {
380  MsgReportFileInputStreamTiming *report = MsgReportFileInputStreamTiming::create(m_fileInputThread->getSamplesCount());
381  getMessageQueueToGUI()->push(report);
382  }
383 
384  if (m_settings.m_loop)
385  {
386  seekFileStream(0);
388  }
389  else
390  {
391  if (getMessageQueueToGUI())
392  {
393  MsgPlayPause *report = MsgPlayPause::create(false);
394  getMessageQueueToGUI()->push(report);
395  }
396  }
397 
398  return true;
399  }
400  else
401  {
402  return false;
403  }
404 }
bool startDeviceEngine()
Start the device engine corresponding to the stream type.
Definition: deviceapi.cpp:253
DeviceAPI * m_deviceAPI
Definition: fileinput.h:323
void push(Message *message, bool emitSignal=true)
Push message onto queue.
void stopDeviceEngine()
Stop the device engine corresponding to the stream type.
Definition: deviceapi.cpp:266
bool initDeviceEngine()
Init the device engine corresponding to the stream type.
Definition: deviceapi.cpp:240
void openFileStream()
Definition: fileinput.cpp:88
static MsgReportFileInputStreamTiming * create(quint64 samplesCount)
Definition: fileinput.h:245
void webapiReverseSendStartStop(bool start)
Definition: fileinput.cpp:636
quint64 getSamplesCount() const
MessageQueue * getMessageQueueToGUI()
static bool match(const Message *message)
Definition: message.cpp:45
static MsgPlayPause * create(bool playPause)
Definition: fileinput.h:186
FileInputSettings m_settings
Definition: fileinput.h:325
FileInputThread * m_fileInputThread
Definition: fileinput.h:327
void seekFileStream(int seekMillis)
Definition: fileinput.cpp:156
QString m_fileName
Definition: fileinput.h:329
bool applySettings(const FileInputSettings &settings, bool force=false)
Definition: fileinput.cpp:406
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ init()

void FileInput::init ( )
virtual

initializations to be done when all collaborating objects are created and possibly connected

Implements DeviceSampleSource.

Definition at line 170 of file fileinput.cpp.

References DeviceAPI::getDeviceEngineInputMessageQueue(), FileInputSettings::m_centerFrequency, m_deviceAPI, FileInputSettings::m_sampleRate, m_settings, and MessageQueue::push().

Referenced by FileInput::MsgReportHeaderCRC::MsgReportHeaderCRC().

171 {
174 }
DeviceAPI * m_deviceAPI
Definition: fileinput.h:323
void push(Message *message, bool emitSignal=true)
Push message onto queue.
MessageQueue * getDeviceEngineInputMessageQueue()
Device engine message queue.
Definition: deviceapi.cpp:316
FileInputSettings m_settings
Definition: fileinput.h:325
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ networkManagerFinished

void FileInput::networkManagerFinished ( QNetworkReply *  reply)
privateslot

Definition at line 664 of file fileinput.cpp.

Referenced by ~FileInput().

665 {
666  QNetworkReply::NetworkError replyError = reply->error();
667 
668  if (replyError)
669  {
670  qWarning() << "FileInput::networkManagerFinished:"
671  << " error(" << (int) replyError
672  << "): " << replyError
673  << ": " << reply->errorString();
674  return;
675  }
676 
677  QString answer = reply->readAll();
678  answer.chop(1); // remove last \n
679  qDebug("FileInput::networkManagerFinished: reply:\n%s", answer.toStdString().c_str());
680 }
+ Here is the caller graph for this function:

◆ openFileStream()

void FileInput::openFileStream ( )
private

Definition at line 88 of file fileinput.cpp.

References FileRecord::Header::centerFrequency, FileRecord::Header::crc32, FileInput::MsgReportFileInputStreamData::create(), FileInput::MsgReportHeaderCRC::create(), DeviceSampleSource::getMessageQueueToGUI(), m_centerFrequency, m_fileName, m_ifstream, m_recordLength, m_sampleRate, m_sampleSize, m_startingTimeStamp, MessageQueue::push(), FileRecord::readHeader(), FileRecord::Header::sampleRate, FileRecord::Header::sampleSize, and FileRecord::Header::startTimeStamp.

Referenced by handleMessage().

89 {
90  //stopInput();
91 
92  if (m_ifstream.is_open()) {
93  m_ifstream.close();
94  }
95 
96 #ifdef Q_OS_WIN
97  m_ifstream.open(m_fileName.toStdWString().c_str(), std::ios::binary | std::ios::ate);
98 #else
99  m_ifstream.open(m_fileName.toStdString().c_str(), std::ios::binary | std::ios::ate);
100 #endif
101  quint64 fileSize = m_ifstream.tellg();
102 
103  if (fileSize > sizeof(FileRecord::Header))
104  {
105  FileRecord::Header header;
106  m_ifstream.seekg(0,std::ios_base::beg);
107  bool crcOK = FileRecord::readHeader(m_ifstream, header);
108  m_sampleRate = header.sampleRate;
111  m_sampleSize = header.sampleSize;
112  QString crcHex = QString("%1").arg(header.crc32 , 0, 16);
113 
114  if (crcOK)
115  {
116  qDebug("FileInput::openFileStream: CRC32 OK for header: %s", qPrintable(crcHex));
117  m_recordLength = (fileSize - sizeof(FileRecord::Header)) / ((m_sampleSize == 24 ? 8 : 4) * m_sampleRate);
118  }
119  else
120  {
121  qCritical("FileInput::openFileStream: bad CRC32 for header: %s", qPrintable(crcHex));
122  m_recordLength = 0;
123  }
124 
125  if (getMessageQueueToGUI()) {
126  MsgReportHeaderCRC *report = MsgReportHeaderCRC::create(crcOK);
127  getMessageQueueToGUI()->push(report);
128  }
129  }
130  else
131  {
132  m_recordLength = 0;
133  }
134 
135  qDebug() << "FileInput::openFileStream: " << m_fileName.toStdString().c_str()
136  << " fileSize: " << fileSize << " bytes"
137  << " length: " << m_recordLength << " seconds"
138  << " sample rate: " << m_sampleRate << " S/s"
139  << " center frequency: " << m_centerFrequency << " Hz"
140  << " sample size: " << m_sampleSize << " bits";
141 
142  if (getMessageQueueToGUI()) {
143  MsgReportFileInputStreamData *report = MsgReportFileInputStreamData::create(m_sampleRate,
144  m_sampleSize,
147  m_recordLength); // file stream data
148  getMessageQueueToGUI()->push(report);
149  }
150 
151  if (m_recordLength == 0) {
152  m_ifstream.close();
153  }
154 }
std::ifstream m_ifstream
Definition: fileinput.h:326
void push(Message *message, bool emitSignal=true)
Push message onto queue.
quint64 centerFrequency
Definition: filerecord.h:38
MessageQueue * getMessageQueueToGUI()
quint64 m_startingTimeStamp
Definition: fileinput.h:334
static MsgReportHeaderCRC * create(bool ok)
Definition: fileinput.h:265
int m_sampleRate
Definition: fileinput.h:330
quint32 sampleRate
Definition: filerecord.h:37
quint32 sampleSize
Definition: filerecord.h:40
quint64 m_centerFrequency
Definition: fileinput.h:332
quint64 m_recordLength
record length in seconds computed from file size
Definition: fileinput.h:333
quint32 m_sampleSize
Definition: fileinput.h:331
static bool readHeader(std::ifstream &samplefile, Header &header)
returns true if CRC checksum is correct else false
Definition: filerecord.cpp:168
quint64 startTimeStamp
Definition: filerecord.h:39
static MsgReportFileInputStreamData * create(int sampleRate, quint32 sampleSize, quint64 centerFrequency, quint64 startingTimeStamp, quint64 recordLength)
Definition: fileinput.h:209
QString m_fileName
Definition: fileinput.h:329
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ seekFileStream()

void FileInput::seekFileStream ( int  seekMillis)
private

Definition at line 156 of file fileinput.cpp.

References FileInputThread::isRunning(), m_fileInputThread, m_ifstream, m_mutex, m_recordLength, m_sampleRate, m_sampleSize, and FileInputThread::setSamplesCount().

Referenced by handleMessage().

157 {
158  QMutexLocker mutexLocker(&m_mutex);
159 
160  if ((m_ifstream.is_open()) && m_fileInputThread && !m_fileInputThread->isRunning())
161  {
162  quint64 seekPoint = ((m_recordLength * seekMillis) / 1000) * m_sampleRate;
164  seekPoint *= (m_sampleSize == 24 ? 8 : 4); // + sizeof(FileSink::Header)
165  m_ifstream.clear();
166  m_ifstream.seekg(seekPoint + sizeof(FileRecord::Header), std::ios::beg);
167  }
168 }
std::ifstream m_ifstream
Definition: fileinput.h:326
int m_sampleRate
Definition: fileinput.h:330
bool isRunning() const
QMutex m_mutex
Definition: fileinput.h:324
FileInputThread * m_fileInputThread
Definition: fileinput.h:327
quint64 m_recordLength
record length in seconds computed from file size
Definition: fileinput.h:333
quint32 m_sampleSize
Definition: fileinput.h:331
void setSamplesCount(quint64 samplesCount)
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ serialize()

QByteArray FileInput::serialize ( ) const
virtual

Implements DeviceSampleSource.

Definition at line 233 of file fileinput.cpp.

References m_settings, and FileInputSettings::serialize().

Referenced by FileInput::MsgReportHeaderCRC::MsgReportHeaderCRC().

234 {
235  return m_settings.serialize();
236 }
QByteArray serialize() const
FileInputSettings m_settings
Definition: fileinput.h:325
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ setCenterFrequency()

void FileInput::setCenterFrequency ( qint64  centerFrequency)
virtual

Implements DeviceSampleSource.

Definition at line 275 of file fileinput.cpp.

References FileInput::MsgConfigureFileInput::create(), DeviceSampleSource::getMessageQueueToGUI(), FileInputSettings::m_centerFrequency, DeviceSampleSource::m_inputMessageQueue, m_settings, and MessageQueue::push().

Referenced by setSampleRate().

276 {
277  FileInputSettings settings = m_settings;
278  settings.m_centerFrequency = centerFrequency;
279 
280  MsgConfigureFileInput* message = MsgConfigureFileInput::create(m_settings, false);
281  m_inputMessageQueue.push(message);
282 
283  if (getMessageQueueToGUI())
284  {
285  MsgConfigureFileInput* messageToGUI = MsgConfigureFileInput::create(m_settings, false);
286  getMessageQueueToGUI()->push(messageToGUI);
287  }
288 }
void push(Message *message, bool emitSignal=true)
Push message onto queue.
MessageQueue m_inputMessageQueue
Input queue to the source.
MessageQueue * getMessageQueueToGUI()
static MsgConfigureFileInput * create(const FileInputSettings &settings, bool force)
Definition: fileinput.h:48
FileInputSettings m_settings
Definition: fileinput.h:325
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ setMessageQueueToGUI()

virtual void FileInput::setMessageQueueToGUI ( MessageQueue queue)
inlinevirtual

Implements DeviceSampleSource.

Definition at line 289 of file fileinput.h.

References getDeviceDescription(), getSampleRate(), and DeviceSampleSource::m_guiMessageQueue.

289 { m_guiMessageQueue = queue; }
MessageQueue * m_guiMessageQueue
Input message queue to the GUI.
+ Here is the call graph for this function:

◆ setSampleRate()

virtual void FileInput::setSampleRate ( int  sampleRate)
inlinevirtual

For when the source sample rate is set externally.

Implements DeviceSampleSource.

Definition at line 292 of file fileinput.h.

References getCenterFrequency(), getStartingTimeStamp(), handleMessage(), setCenterFrequency(), webapiReportGet(), webapiRun(), webapiRunGet(), webapiSettingsGet(), and webapiSettingsPutPatch().

292 { (void) sampleRate; }
+ Here is the call graph for this function:

◆ start()

bool FileInput::start ( )
virtual

Implements DeviceSampleSource.

Definition at line 176 of file fileinput.cpp.

References FileInput::MsgReportFileSourceAcquisition::create(), DeviceSampleSource::getMessageQueueToGUI(), FileInputSettings::m_accelerationFactor, m_deviceDescription, m_fileInputThread, m_ifstream, DeviceSampleSource::m_inputMessageQueue, m_masterTimer, m_mutex, DeviceSampleSource::m_sampleFifo, m_sampleRate, m_sampleSize, m_settings, MessageQueue::push(), FileInputThread::setSampleRateAndSize(), SampleSinkFifo::setSize(), and FileInputThread::startWork().

Referenced by FileInput::MsgReportHeaderCRC::MsgReportHeaderCRC().

177 {
178  if (!m_ifstream.is_open())
179  {
180  qWarning("FileInput::start: file not open. not starting");
181  return false;
182  }
183 
184  QMutexLocker mutexLocker(&m_mutex);
185  qDebug() << "FileInput::start";
186 
187  if (m_ifstream.tellg() != (std::streampos)0) {
188  m_ifstream.clear();
189  m_ifstream.seekg(sizeof(FileRecord::Header), std::ios::beg);
190  }
191 
193  qCritical("Could not allocate SampleFifo");
194  return false;
195  }
196 
198  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
200  m_deviceDescription = "FileInput";
201 
202  mutexLocker.unlock();
203  qDebug("FileInput::startInput: started");
204 
205  if (getMessageQueueToGUI()) {
206  MsgReportFileSourceAcquisition *report = MsgReportFileSourceAcquisition::create(true); // acquisition on
207  getMessageQueueToGUI()->push(report);
208  }
209 
210  return true;
211 }
QString m_deviceDescription
Definition: fileinput.h:328
std::ifstream m_ifstream
Definition: fileinput.h:326
void push(Message *message, bool emitSignal=true)
Push message onto queue.
MessageQueue m_inputMessageQueue
Input queue to the source.
QTimer m_masterTimer
Definition: fileinput.h:335
SampleSinkFifo m_sampleFifo
bool setSize(int size)
MessageQueue * getMessageQueueToGUI()
int m_sampleRate
Definition: fileinput.h:330
FileInputSettings m_settings
Definition: fileinput.h:325
QMutex m_mutex
Definition: fileinput.h:324
void setSampleRateAndSize(int samplerate, quint32 samplesize)
FileInputThread * m_fileInputThread
Definition: fileinput.h:327
quint32 m_sampleSize
Definition: fileinput.h:331
static MsgReportFileSourceAcquisition * create(bool acquisition)
Definition: fileinput.h:147
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ stop()

void FileInput::stop ( )
virtual

Implements DeviceSampleSource.

Definition at line 213 of file fileinput.cpp.

References FileInput::MsgReportFileSourceAcquisition::create(), DeviceSampleSource::getMessageQueueToGUI(), m_deviceDescription, m_fileInputThread, m_mutex, MessageQueue::push(), and FileInputThread::stopWork().

Referenced by FileInput::MsgReportHeaderCRC::MsgReportHeaderCRC(), and ~FileInput().

214 {
215  qDebug() << "FileInput::stop";
216  QMutexLocker mutexLocker(&m_mutex);
217 
218  if (m_fileInputThread)
219  {
221  delete m_fileInputThread;
222  m_fileInputThread = nullptr;
223  }
224 
225  m_deviceDescription.clear();
226 
227  if (getMessageQueueToGUI()) {
228  MsgReportFileSourceAcquisition *report = MsgReportFileSourceAcquisition::create(false); // acquisition off
229  getMessageQueueToGUI()->push(report);
230  }
231 }
QString m_deviceDescription
Definition: fileinput.h:328
void push(Message *message, bool emitSignal=true)
Push message onto queue.
MessageQueue * getMessageQueueToGUI()
QMutex m_mutex
Definition: fileinput.h:324
FileInputThread * m_fileInputThread
Definition: fileinput.h:327
static MsgReportFileSourceAcquisition * create(bool acquisition)
Definition: fileinput.h:147
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ webapiFormatDeviceReport()

void FileInput::webapiFormatDeviceReport ( SWGSDRangel::SWGDeviceReport response)
private

Definition at line 561 of file fileinput.cpp.

References SWGSDRangel::SWGDeviceReport::getFileInputReport(), FileInputThread::getSamplesCount(), m_fileInputThread, m_fileName, m_recordLength, m_sampleRate, m_sampleSize, m_startingTimeStamp, SWGSDRangel::SWGFileInputReport::setAbsoluteTime(), SWGSDRangel::SWGFileInputReport::setDurationTime(), SWGSDRangel::SWGFileInputReport::setElapsedTime(), SWGSDRangel::SWGFileInputReport::setFileName(), SWGSDRangel::SWGFileInputReport::setSampleRate(), and SWGSDRangel::SWGFileInputReport::setSampleSize().

Referenced by webapiReportGet().

562 {
563  qint64 t_sec = 0;
564  qint64 t_msec = 0;
565  quint64 samplesCount = 0;
566 
567  if (m_fileInputThread) {
568  samplesCount = m_fileInputThread->getSamplesCount();
569  }
570 
571  if (m_sampleRate > 0)
572  {
573  t_sec = samplesCount / m_sampleRate;
574  t_msec = (samplesCount - (t_sec * m_sampleRate)) * 1000 / m_sampleRate;
575  }
576 
577  QTime t(0, 0, 0, 0);
578  t = t.addSecs(t_sec);
579  t = t.addMSecs(t_msec);
580  response.getFileInputReport()->setElapsedTime(new QString(t.toString("HH:mm:ss.zzz")));
581 
582  qint64 startingTimeStampMsec = m_startingTimeStamp * 1000LL;
583  QDateTime dt = QDateTime::fromMSecsSinceEpoch(startingTimeStampMsec);
584  dt = dt.addSecs(t_sec);
585  dt = dt.addMSecs(t_msec);
586  response.getFileInputReport()->setAbsoluteTime(new QString(dt.toString("yyyy-MM-dd HH:mm:ss.zzz")));
587 
588  QTime recordLength(0, 0, 0, 0);
589  recordLength = recordLength.addSecs(m_recordLength);
590  response.getFileInputReport()->setDurationTime(new QString(recordLength.toString("HH:mm:ss")));
591 
592  response.getFileInputReport()->setFileName(new QString(m_fileName));
595 }
void setFileName(QString *file_name)
SWGFileInputReport * getFileInputReport()
void setAbsoluteTime(QString *absolute_time)
void setSampleRate(qint32 sample_rate)
quint64 getSamplesCount() const
quint64 m_startingTimeStamp
Definition: fileinput.h:334
void setDurationTime(QString *duration_time)
void setElapsedTime(QString *elapsed_time)
int m_sampleRate
Definition: fileinput.h:330
FileInputThread * m_fileInputThread
Definition: fileinput.h:327
void setSampleSize(qint32 sample_size)
quint64 m_recordLength
record length in seconds computed from file size
Definition: fileinput.h:333
quint32 m_sampleSize
Definition: fileinput.h:331
QString m_fileName
Definition: fileinput.h:329
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ webapiFormatDeviceSettings()

void FileInput::webapiFormatDeviceSettings ( SWGSDRangel::SWGDeviceSettings response,
const FileInputSettings settings 
)
private

Definition at line 543 of file fileinput.cpp.

References SWGSDRangel::SWGDeviceSettings::getFileInputSettings(), SWGSDRangel::SWGFileInputSettings::getReverseApiAddress(), FileInputSettings::m_accelerationFactor, FileInputSettings::m_fileName, FileInputSettings::m_loop, FileInputSettings::m_reverseAPIAddress, FileInputSettings::m_reverseAPIDeviceIndex, FileInputSettings::m_reverseAPIPort, FileInputSettings::m_useReverseAPI, SWGSDRangel::SWGFileInputSettings::setAccelerationFactor(), SWGSDRangel::SWGFileInputSettings::setFileName(), SWGSDRangel::SWGFileInputSettings::setLoop(), SWGSDRangel::SWGFileInputSettings::setReverseApiAddress(), SWGSDRangel::SWGFileInputSettings::setReverseApiDeviceIndex(), SWGSDRangel::SWGFileInputSettings::setReverseApiPort(), and SWGSDRangel::SWGFileInputSettings::setUseReverseApi().

Referenced by webapiSettingsGet(), and webapiSettingsPutPatch().

544 {
545  response.getFileInputSettings()->setFileName(new QString(settings.m_fileName));
547  response.getFileInputSettings()->setLoop(settings.m_loop ? 1 : 0);
548 
549  response.getFileInputSettings()->setUseReverseApi(settings.m_useReverseAPI ? 1 : 0);
550 
551  if (response.getFileInputSettings()->getReverseApiAddress()) {
553  } else {
554  response.getFileInputSettings()->setReverseApiAddress(new QString(settings.m_reverseAPIAddress));
555  }
556 
559 }
void setReverseApiDeviceIndex(qint32 reverse_api_device_index)
uint16_t m_reverseAPIDeviceIndex
void setAccelerationFactor(qint32 acceleration_factor)
SWGFileInputSettings * getFileInputSettings()
void setReverseApiPort(qint32 reverse_api_port)
void setReverseApiAddress(QString *reverse_api_address)
void setUseReverseApi(qint32 use_reverse_api)
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ webapiReportGet()

int FileInput::webapiReportGet ( SWGSDRangel::SWGDeviceReport response,
QString &  errorMessage 
)
virtual

Reimplemented from DeviceSampleSource.

Definition at line 532 of file fileinput.cpp.

References SWGSDRangel::SWGDeviceReport::getFileInputReport(), SWGSDRangel::SWGFileInputReport::init(), SWGSDRangel::SWGDeviceReport::setFileInputReport(), and webapiFormatDeviceReport().

Referenced by setSampleRate().

535 {
536  (void) errorMessage;
538  response.getFileInputReport()->init();
539  webapiFormatDeviceReport(response);
540  return 200;
541 }
SWGFileInputReport * getFileInputReport()
void webapiFormatDeviceReport(SWGSDRangel::SWGDeviceReport &response)
Definition: fileinput.cpp:561
void setFileInputReport(SWGFileInputReport *file_input_report)
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ webapiReverseSendSettings()

void FileInput::webapiReverseSendSettings ( QList< QString > &  deviceSettingsKeys,
const FileInputSettings settings,
bool  force 
)
private

Definition at line 597 of file fileinput.cpp.

References SWGSDRangel::SWGDeviceSettings::asJson(), DeviceAPI::getDeviceSetIndex(), SWGSDRangel::SWGDeviceSettings::getFileInputSettings(), FileInputSettings::m_accelerationFactor, m_deviceAPI, FileInputSettings::m_fileName, FileInputSettings::m_loop, m_networkManager, m_networkRequest, FileInputSettings::m_reverseAPIAddress, FileInputSettings::m_reverseAPIDeviceIndex, FileInputSettings::m_reverseAPIPort, SWGSDRangel::SWGFileInputSettings::setAccelerationFactor(), SWGSDRangel::SWGDeviceSettings::setDeviceHwType(), SWGSDRangel::SWGDeviceSettings::setDirection(), SWGSDRangel::SWGDeviceSettings::setFileInputSettings(), SWGSDRangel::SWGFileInputSettings::setFileName(), SWGSDRangel::SWGFileInputSettings::setLoop(), and SWGSDRangel::SWGDeviceSettings::setOriginatorIndex().

Referenced by applySettings().

598 {
600  swgDeviceSettings->setDirection(0); // single Rx
601  swgDeviceSettings->setOriginatorIndex(m_deviceAPI->getDeviceSetIndex());
602  swgDeviceSettings->setDeviceHwType(new QString("FileInput"));
604  SWGSDRangel::SWGFileInputSettings *swgFileInputSettings = swgDeviceSettings->getFileInputSettings();
605 
606  // transfer data that has been modified. When force is on transfer all data except reverse API data
607 
608  if (deviceSettingsKeys.contains("accelerationFactor") || force) {
609  swgFileInputSettings->setAccelerationFactor(settings.m_accelerationFactor);
610  }
611  if (deviceSettingsKeys.contains("loop") || force) {
612  swgFileInputSettings->setLoop(settings.m_loop);
613  }
614  if (deviceSettingsKeys.contains("fileName") || force) {
615  swgFileInputSettings->setFileName(new QString(settings.m_fileName));
616  }
617 
618  QString deviceSettingsURL = QString("http://%1:%2/sdrangel/deviceset/%3/device/settings")
619  .arg(settings.m_reverseAPIAddress)
620  .arg(settings.m_reverseAPIPort)
621  .arg(settings.m_reverseAPIDeviceIndex);
622  m_networkRequest.setUrl(QUrl(deviceSettingsURL));
623  m_networkRequest.setHeader(QNetworkRequest::ContentTypeHeader, "application/json");
624 
625  QBuffer *buffer=new QBuffer();
626  buffer->open((QBuffer::ReadWrite));
627  buffer->write(swgDeviceSettings->asJson().toUtf8());
628  buffer->seek(0);
629 
630  // Always use PATCH to avoid passing reverse API settings
631  m_networkManager->sendCustomRequest(m_networkRequest, "PATCH", buffer);
632 
633  delete swgDeviceSettings;
634 }
DeviceAPI * m_deviceAPI
Definition: fileinput.h:323
virtual QString asJson() override
uint16_t m_reverseAPIDeviceIndex
void setOriginatorIndex(qint32 originator_index)
int getDeviceSetIndex() const
Definition: deviceapi.h:131
void setFileInputSettings(SWGFileInputSettings *file_input_settings)
void setAccelerationFactor(qint32 acceleration_factor)
SWGFileInputSettings * getFileInputSettings()
QNetworkRequest m_networkRequest
Definition: fileinput.h:337
void setDirection(qint32 direction)
void setDeviceHwType(QString *device_hw_type)
QNetworkAccessManager * m_networkManager
Definition: fileinput.h:336
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ webapiReverseSendStartStop()

void FileInput::webapiReverseSendStartStop ( bool  start)
private

Definition at line 636 of file fileinput.cpp.

References SWGSDRangel::SWGDeviceSettings::asJson(), DeviceAPI::getDeviceSetIndex(), m_deviceAPI, m_networkManager, m_networkRequest, FileInputSettings::m_reverseAPIAddress, FileInputSettings::m_reverseAPIDeviceIndex, FileInputSettings::m_reverseAPIPort, m_settings, SWGSDRangel::SWGDeviceSettings::setDeviceHwType(), SWGSDRangel::SWGDeviceSettings::setDirection(), and SWGSDRangel::SWGDeviceSettings::setOriginatorIndex().

Referenced by handleMessage().

637 {
639  swgDeviceSettings->setDirection(0); // single Rx
640  swgDeviceSettings->setOriginatorIndex(m_deviceAPI->getDeviceSetIndex());
641  swgDeviceSettings->setDeviceHwType(new QString("FileInput"));
642 
643  QString deviceSettingsURL = QString("http://%1:%2/sdrangel/deviceset/%3/device/run")
647  m_networkRequest.setUrl(QUrl(deviceSettingsURL));
648  m_networkRequest.setHeader(QNetworkRequest::ContentTypeHeader, "application/json");
649 
650  QBuffer *buffer=new QBuffer();
651  buffer->open((QBuffer::ReadWrite));
652  buffer->write(swgDeviceSettings->asJson().toUtf8());
653  buffer->seek(0);
654 
655  if (start) {
656  m_networkManager->sendCustomRequest(m_networkRequest, "POST", buffer);
657  } else {
658  m_networkManager->sendCustomRequest(m_networkRequest, "DELETE", buffer);
659  }
660 
661  delete swgDeviceSettings;
662 }
DeviceAPI * m_deviceAPI
Definition: fileinput.h:323
virtual QString asJson() override
uint16_t m_reverseAPIDeviceIndex
virtual bool start()
Definition: fileinput.cpp:176
void setOriginatorIndex(qint32 originator_index)
int getDeviceSetIndex() const
Definition: deviceapi.h:131
FileInputSettings m_settings
Definition: fileinput.h:325
QNetworkRequest m_networkRequest
Definition: fileinput.h:337
void setDirection(qint32 direction)
void setDeviceHwType(QString *device_hw_type)
QNetworkAccessManager * m_networkManager
Definition: fileinput.h:336
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ webapiRun()

int FileInput::webapiRun ( bool  run,
SWGSDRangel::SWGDeviceState response,
QString &  errorMessage 
)
virtual

Reimplemented from DeviceSampleSource.

Definition at line 513 of file fileinput.cpp.

References FileInput::MsgStartStop::create(), DeviceAPI::getDeviceEngineStateStr(), DeviceSampleSource::getMessageQueueToGUI(), SWGSDRangel::SWGDeviceState::getState(), m_deviceAPI, DeviceSampleSource::m_inputMessageQueue, and MessageQueue::push().

Referenced by setSampleRate().

517 {
518  (void) errorMessage;
520  MsgStartStop *message = MsgStartStop::create(run);
521  m_inputMessageQueue.push(message);
522 
523  if (getMessageQueueToGUI()) // forward to GUI if any
524  {
525  MsgStartStop *msgToGUI = MsgStartStop::create(run);
526  getMessageQueueToGUI()->push(msgToGUI);
527  }
528 
529  return 200;
530 }
DeviceAPI * m_deviceAPI
Definition: fileinput.h:323
void push(Message *message, bool emitSignal=true)
Push message onto queue.
MessageQueue m_inputMessageQueue
Input queue to the source.
MessageQueue * getMessageQueueToGUI()
void getDeviceEngineStateStr(QString &state)
Definition: deviceapi.cpp:389
static MsgStartStop * create(bool startStop)
Definition: fileinput.h:167
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ webapiRunGet()

int FileInput::webapiRunGet ( SWGSDRangel::SWGDeviceState response,
QString &  errorMessage 
)
virtual

Reimplemented from DeviceSampleSource.

Definition at line 504 of file fileinput.cpp.

References DeviceAPI::getDeviceEngineStateStr(), SWGSDRangel::SWGDeviceState::getState(), and m_deviceAPI.

Referenced by setSampleRate().

507 {
508  (void) errorMessage;
510  return 200;
511 }
DeviceAPI * m_deviceAPI
Definition: fileinput.h:323
void getDeviceEngineStateStr(QString &state)
Definition: deviceapi.cpp:389
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ webapiSettingsGet()

int FileInput::webapiSettingsGet ( SWGSDRangel::SWGDeviceSettings response,
QString &  errorMessage 
)
virtual

Reimplemented from DeviceSampleSource.

Definition at line 449 of file fileinput.cpp.

References SWGSDRangel::SWGDeviceSettings::getFileInputSettings(), SWGSDRangel::SWGFileInputSettings::init(), m_settings, SWGSDRangel::SWGDeviceSettings::setFileInputSettings(), and webapiFormatDeviceSettings().

Referenced by setSampleRate().

452 {
453  (void) errorMessage;
455  response.getFileInputSettings()->init();
457  return 200;
458 }
void webapiFormatDeviceSettings(SWGSDRangel::SWGDeviceSettings &response, const FileInputSettings &settings)
Definition: fileinput.cpp:543
void setFileInputSettings(SWGFileInputSettings *file_input_settings)
FileInputSettings m_settings
Definition: fileinput.h:325
SWGFileInputSettings * getFileInputSettings()
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ webapiSettingsPutPatch()

int FileInput::webapiSettingsPutPatch ( bool  force,
const QStringList &  deviceSettingsKeys,
SWGSDRangel::SWGDeviceSettings response,
QString &  errorMessage 
)
virtual

Reimplemented from DeviceSampleSource.

Definition at line 460 of file fileinput.cpp.

References FileInput::MsgConfigureFileInput::create(), SWGSDRangel::SWGFileInputSettings::getAccelerationFactor(), SWGSDRangel::SWGDeviceSettings::getFileInputSettings(), SWGSDRangel::SWGFileInputSettings::getFileName(), SWGSDRangel::SWGFileInputSettings::getLoop(), SWGSDRangel::SWGFileInputSettings::getReverseApiAddress(), SWGSDRangel::SWGFileInputSettings::getReverseApiDeviceIndex(), SWGSDRangel::SWGFileInputSettings::getReverseApiPort(), SWGSDRangel::SWGFileInputSettings::getUseReverseApi(), FileInputSettings::m_accelerationFactor, FileInputSettings::m_fileName, DeviceSampleSource::m_guiMessageQueue, DeviceSampleSource::m_inputMessageQueue, FileInputSettings::m_loop, FileInputSettings::m_reverseAPIAddress, FileInputSettings::m_reverseAPIDeviceIndex, FileInputSettings::m_reverseAPIPort, m_settings, FileInputSettings::m_useReverseAPI, MessageQueue::push(), and webapiFormatDeviceSettings().

Referenced by setSampleRate().

465 {
466  (void) errorMessage;
467  FileInputSettings settings = m_settings;
468 
469  if (deviceSettingsKeys.contains("fileName")) {
470  settings.m_fileName = *response.getFileInputSettings()->getFileName();
471  }
472  if (deviceSettingsKeys.contains("accelerationFactor")) {
474  }
475  if (deviceSettingsKeys.contains("loop")) {
476  settings.m_loop = response.getFileInputSettings()->getLoop() != 0;
477  }
478  if (deviceSettingsKeys.contains("useReverseAPI")) {
479  settings.m_useReverseAPI = response.getFileInputSettings()->getUseReverseApi() != 0;
480  }
481  if (deviceSettingsKeys.contains("reverseAPIAddress")) {
483  }
484  if (deviceSettingsKeys.contains("reverseAPIPort")) {
486  }
487  if (deviceSettingsKeys.contains("reverseAPIDeviceIndex")) {
489  }
490 
491  MsgConfigureFileInput *msg = MsgConfigureFileInput::create(settings, force);
493 
494  if (m_guiMessageQueue) // forward to GUI if any
495  {
496  MsgConfigureFileInput *msgToGUI = MsgConfigureFileInput::create(settings, force);
497  m_guiMessageQueue->push(msgToGUI);
498  }
499 
500  webapiFormatDeviceSettings(response, settings);
501  return 200;
502 }
void webapiFormatDeviceSettings(SWGSDRangel::SWGDeviceSettings &response, const FileInputSettings &settings)
Definition: fileinput.cpp:543
void push(Message *message, bool emitSignal=true)
Push message onto queue.
MessageQueue m_inputMessageQueue
Input queue to the source.
uint16_t m_reverseAPIDeviceIndex
static MsgConfigureFileInput * create(const FileInputSettings &settings, bool force)
Definition: fileinput.h:48
MessageQueue * m_guiMessageQueue
Input message queue to the GUI.
FileInputSettings m_settings
Definition: fileinput.h:325
SWGFileInputSettings * getFileInputSettings()
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

Member Data Documentation

◆ m_centerFrequency

quint64 FileInput::m_centerFrequency
private

◆ m_deviceAPI

DeviceAPI* FileInput::m_deviceAPI
private

◆ m_deviceDescription

QString FileInput::m_deviceDescription
private

Definition at line 328 of file fileinput.h.

Referenced by getDeviceDescription(), start(), and stop().

◆ m_fileInputThread

FileInputThread* FileInput::m_fileInputThread
private

◆ m_fileName

QString FileInput::m_fileName
private

◆ m_ifstream

std::ifstream FileInput::m_ifstream
private

Definition at line 326 of file fileinput.h.

Referenced by openFileStream(), seekFileStream(), and start().

◆ m_masterTimer

QTimer FileInput::m_masterTimer
private

Definition at line 335 of file fileinput.h.

Referenced by start(), and ~FileInput().

◆ m_mutex

QMutex FileInput::m_mutex
private

Definition at line 324 of file fileinput.h.

Referenced by applySettings(), seekFileStream(), start(), and stop().

◆ m_networkManager

QNetworkAccessManager* FileInput::m_networkManager
private

Definition at line 336 of file fileinput.h.

Referenced by webapiReverseSendSettings(), webapiReverseSendStartStop(), and ~FileInput().

◆ m_networkRequest

QNetworkRequest FileInput::m_networkRequest
private

Definition at line 337 of file fileinput.h.

Referenced by webapiReverseSendSettings(), and webapiReverseSendStartStop().

◆ m_recordLength

quint64 FileInput::m_recordLength
private

record length in seconds computed from file size

Definition at line 333 of file fileinput.h.

Referenced by FileInput::MsgReportFileInputStreamData::getRecordLength(), openFileStream(), seekFileStream(), and webapiFormatDeviceReport().

◆ m_sampleRate

int FileInput::m_sampleRate
private

◆ m_sampleSize

quint32 FileInput::m_sampleSize
private

◆ m_settings

FileInputSettings FileInput::m_settings
private

◆ m_startingTimeStamp

quint64 FileInput::m_startingTimeStamp
private

The documentation for this class was generated from the following files: