20 #if (defined _WIN32_) || (defined _MSC_VER) 29 #include <QNetworkAccessManager> 30 #include <QNetworkReply> 64 m_deviceAPI(deviceAPI),
72 m_deviceSampleRate(0),
74 m_startingTimeStamp(0),
129 m_ifstream.read(reinterpret_cast<char*>(&sample16),
sizeof(Sample16));
144 m_ifstream.read(reinterpret_cast<char*>(&sample24),
sizeof(Sample24));
170 sample.
setReal(re * 8388608.0f);
171 sample.
setImag(im * 8388608.0f);
179 Real magsq = re*re + im*im;
198 qDebug(
"FileSource::start");
210 qDebug(
"FileSource::stop");
227 qDebug() <<
"FileSource::handleMessage: MsgChannelizerNotification:" 228 <<
" channelSampleRate: " << sampleRate
231 if (sampleRate > 0) {
241 qDebug() <<
"FileSource::handleMessage: DSPSignalNotification:" 265 qDebug() <<
"FileSource::handleMessage: MsgConfigureFileSource";
275 qDebug() <<
"FileSource::handleMessage: MsgConfigureChannelizer:" 380 QString crcHex = QString(
"%1").arg(header.
crc32 , 0, 16);
384 qDebug(
"FileSource::openFileStream: CRC32 OK for header: %s", qPrintable(crcHex));
389 qCritical(
"FileSource::openFileStream: bad CRC32 for header: %s", qPrintable(crcHex));
403 qDebug() <<
"FileSource::openFileStream: " <<
m_fileName.toStdString().c_str()
404 <<
" fileSize: " << fileSize <<
" bytes" 427 QMutexLocker mutexLocker(&
m_mutex);
467 qDebug() <<
"FileSource::applySettings:" 468 <<
" force: " << force;
470 QList<QString> reverseAPIKeys;
473 reverseAPIKeys.append(
"loop");
476 reverseAPIKeys.append(
"fileName");
482 reverseAPIKeys.append(
"gainDB");
517 QString& errorMessage)
528 const QStringList& channelSettingsKeys,
530 QString& errorMessage)
535 if (channelSettingsKeys.contains(
"log2Interp")) {
539 if (channelSettingsKeys.contains(
"filterChainHash"))
545 if (channelSettingsKeys.contains(
"rgbColor")) {
548 if (channelSettingsKeys.contains(
"title")) {
551 if (channelSettingsKeys.contains(
"gainDB")) {
554 if (channelSettingsKeys.contains(
"useReverseAPI")) {
557 if (channelSettingsKeys.contains(
"reverseAPIAddress")) {
560 if (channelSettingsKeys.contains(
"reverseAPIPort")) {
563 if (channelSettingsKeys.contains(
"reverseAPIDeviceIndex")) {
566 if (channelSettingsKeys.contains(
"reverseAPIChannelIndex")) {
573 qDebug(
"FileSource::webapiSettingsPutPatch: forward to GUI: %p",
m_guiMessageQueue);
587 QString& errorMessage)
635 t = t.addSecs(t_sec);
636 t = t.addMSecs(t_msec);
640 QDateTime dt = QDateTime::fromMSecsSinceEpoch(startingTimeStampMsec);
641 dt = dt.addSecs(t_sec);
642 dt = dt.addMSecs(t_msec);
645 QTime recordLength(0, 0, 0, 0);
668 if (channelSettingsKeys.contains(
"log2Interp") || force) {
671 if (channelSettingsKeys.contains(
"filterChainHash") || force) {
674 if (channelSettingsKeys.contains(
"gainDB") || force) {
677 if (channelSettingsKeys.contains(
"rgbColor") || force) {
680 if (channelSettingsKeys.contains(
"title") || force) {
684 QString channelSettingsURL = QString(
"http://%1:%2/sdrangel/deviceset/%3/channel/%4/settings")
690 m_networkRequest.setHeader(QNetworkRequest::ContentTypeHeader,
"application/json");
692 QBuffer *buffer=
new QBuffer();
693 buffer->open((QBuffer::ReadWrite));
694 buffer->write(swgChannelSettings->
asJson().toUtf8());
700 delete swgChannelSettings;
705 QNetworkReply::NetworkError replyError = reply->error();
709 qWarning() <<
"FileSource::networkManagerFinished:" 710 <<
" error(" << (int) replyError
711 <<
"): " << replyError
712 <<
": " << reply->errorString();
716 QString answer = reply->readAll();
718 qDebug(
"FileSource::networkManagerFinished: reply:\n%s", answer.toStdString().c_str());
void applySettings(const FileSourceSettings &settings, bool force=false)
void setSampleRate(qint32 sample_rate)
quint64 m_startingTimeStamp
void setOriginatorChannelIndex(qint32 originator_channel_index)
void setCenterFrequency(uint64_t centerFrequency)
void setDurationTime(QString *duration_time)
QNetworkAccessManager * m_networkManager
void webapiFormatChannelSettings(SWGSDRangel::SWGChannelSettings &response, const FileSourceSettings &settings)
bool deserialize(const QByteArray &data)
void push(Message *message, bool emitSignal=true)
Push message onto queue.
void setFileName(QString *file_name)
void removeChannelSourceAPI(ChannelAPI *channelAPI, int streamIndex=0)
static double dbPower(double magsq, double floor=1e-12)
qint32 getReverseApiChannelIndex()
static MsgReportFileSourceAcquisition * create(bool acquisition)
SWGFileSourceReport * getFileSourceReport()
SWGFileSourceSettings * getFileSourceSettings()
void setLog2Interp(qint32 log2_interp)
QString m_reverseAPIAddress
int getDeviceSetIndex() const
void setSampleRate(uint32_t sampleRate)
quint64 getSamplesCount() const
void removeChannelSource(ThreadedBasebandSampleSource *sink, int streamIndex=0)
Remove a channel source (Tx)
void networkManagerFinished(QNetworkReply *reply)
uint32_t m_fileSampleRate
MessageQueue * getInputMessageQueue()
Get the queue for asynchronous inbound communication.
uint32_t m_filterChainHash
virtual QByteArray serialize() const
virtual int webapiReportGet(SWGSDRangel::SWGChannelReport &response, QString &errorMessage)
void calculateFrequencyOffset()
UpChannelizer * m_channelizer
void setChannelType(QString *channel_type)
void addChannelSource(ThreadedBasebandSampleSource *sink, int streamIndex=0)
Add a channel source (Tx)
void validateFilterChainHash(FileSourceSettings &settings)
void setOriginatorDeviceSetIndex(qint32 originator_device_set_index)
virtual void pull(Sample &sample)
QNetworkRequest m_networkRequest
void set(MessageQueue *messageQueue, unsigned int log2Interp, unsigned int filterChainHash)
void setFileSourceSettings(SWGFileSourceSettings *file_source_settings)
qint32 getReverseApiPort()
void setFilterChainHash(qint32 filter_chain_hash)
QByteArray serialize() const
qint64 getCenterFrequency() const
void setFileSampleRate(qint32 file_sample_rate)
qint32 getUseReverseApi()
#define MESSAGE_CLASS_DEFINITION(Name, BaseClass)
void setReverseApiPort(qint32 reverse_api_port)
void seekFileStream(int seekMillis)
static const QString m_channelId
virtual int webapiSettingsPutPatch(bool force, const QStringList &channelSettingsKeys, SWGSDRangel::SWGChannelSettings &response, QString &errorMessage)
static MsgReportFileSourceStreamTiming * create(quint64 samplesCount)
virtual bool deserialize(const QByteArray &data)
static MsgPlayPause * create(bool playPause)
static bool match(const Message *message)
void setRgbColor(qint32 rgb_color)
void setChannelPowerDb(float channel_power_db)
quint64 m_recordLength
record length in seconds computed from file size
uint16_t m_reverseAPIChannelIndex
void setGainDb(qint32 gain_db)
void setFileSourceReport(SWGFileSourceReport *file_source_report)
void setDirection(qint32 direction)
void setReverseApiAddress(QString *reverse_api_address)
virtual QString asJson() override
uint16_t m_reverseAPIDeviceIndex
void setElapsedTime(QString *elapsed_time)
QString * getReverseApiAddress()
int64_t m_frequencyOffset
ThreadedBasebandSampleSource * m_threadedChannelizer
qint64 getFrequencyOffset() const
void setAbsoluteTime(QString *absolute_time)
void setUseReverseApi(qint32 use_reverse_api)
quint64 m_centerFrequency
MessageQueue * getMessageQueueToGUI()
MessageQueue * m_guiMessageQueue
Input message queue to the GUI.
virtual bool handleMessage(const Message &cmd)
Processing of a message. Returns true if message has actually been processed.
int getSampleRate() const
uint16_t m_reverseAPIPort
MessageQueue m_inputMessageQueue
Queue for asynchronous inbound communication.
qint32 getReverseApiDeviceIndex()
virtual void pullAudio(int nbSamples)
static MsgSampleRateNotification * create(int sampleRate)
int getSampleRate() const
qint32 getFilterChainHash()
FileSourceSettings m_settings
void setReverseApiDeviceIndex(qint32 reverse_api_device_index)
void addChannelSourceAPI(ChannelAPI *channelAPI, int streamIndex=0)
uint32_t m_deviceSampleRate
virtual int webapiSettingsGet(SWGSDRangel::SWGChannelSettings &response, QString &errorMessage)
int getIndexInDeviceSet() const
static bool readHeader(std::ifstream &samplefile, Header &header)
returns true if CRC checksum is correct else false
static MsgReportFileSourceStreamData * create(int sampleRate, quint32 sampleSize, quint64 centerFrequency, quint64 startingTimeStamp, quint64 recordLength)
void setReverseApiChannelIndex(qint32 reverse_api_channel_index)
void webapiReverseSendSettings(QList< QString > &channelSettingsKeys, const FileSourceSettings &settings, bool force)
static double getShiftFactor(unsigned int log2, unsigned int chainHash)
MovingAverageUtil< Real, double, 16 > m_movingAverage
static double powerFromdB(double powerdB)
static const QString m_channelIdURI
void webapiFormatChannelReport(SWGSDRangel::SWGChannelReport &response)
FileSource(DeviceAPI *deviceAPI)
void setFileSampleSize(qint32 file_sample_size)
void setTitle(QString *title)