20 #if (defined _WIN32_) || (defined _MSC_VER) 27 #include <boost/crc.hpp> 28 #include <boost/cstdint.hpp> 31 #include <QNetworkAccessManager> 32 #include <QNetworkReply> 56 m_deviceAPI(deviceAPI),
59 m_nbCorrectableErrors(0),
60 m_nbUncorrectableErrors(0)
99 qDebug(
"RemoteSource::start");
113 qDebug(
"RemoteSource::stop");
140 qDebug() <<
"RemoteSource::handleMessage: MsgChannelizerNotification:" 156 qDebug() <<
"MsgConfigureRemoteSource::handleMessage: MsgConfigureRemoteSource";
166 gettimeofday(&tv, 0);
213 qDebug() <<
"RemoteSource::applySettings:" 216 <<
" force: " << force;
219 QList<QString> reverseAPIKeys;
223 reverseAPIKeys.append(
"dataAddress");
229 reverseAPIKeys.append(
"dataPort");
235 reverseAPIKeys.append(
"sourceThread");
257 qWarning(
"RemoteSource::handleDataBlock: incomplete data block: not processing");
263 for (
int blockIndex = 0; blockIndex < 256; blockIndex++)
285 CM256::cm256_encoder_params paramsCM256;
287 paramsCM256.OriginalCount = RemoteNbOrginalBlocks;
304 qWarning() <<
"RemoteSource::handleDataBlock: decode CM256 error:" 328 boost::crc_32_type
crc32;
331 if (crc32.checksum() == metaData->
m_crc32)
335 printMeta(
"RemoteSource::handleDataBlock", metaData);
348 qWarning() <<
"RemoteSource::handleDataBlock: recovered meta: invalid CRC32";
367 qDebug().noquote() << header <<
": " 382 uint32_t maxSize = sampleRate / 2400;
383 maxSize = (maxSize % 2 == 0) ? maxSize : maxSize + 1;
384 qDebug(
"RemoteSource::calculateDataReadQueueSize: set max queue size to %u blocks", maxSize);
390 QString& errorMessage)
401 const QStringList& channelSettingsKeys,
403 QString& errorMessage)
408 if (channelSettingsKeys.contains(
"dataAddress")) {
411 if (channelSettingsKeys.contains(
"dataPort"))
415 if ((dataPort < 1024) || (dataPort > 65535)) {
421 if (channelSettingsKeys.contains(
"rgbColor")) {
424 if (channelSettingsKeys.contains(
"title")) {
427 if (channelSettingsKeys.contains(
"useReverseAPI")) {
430 if (channelSettingsKeys.contains(
"reverseAPIAddress")) {
433 if (channelSettingsKeys.contains(
"reverseAPIPort")) {
436 if (channelSettingsKeys.contains(
"reverseAPIDeviceIndex")) {
439 if (channelSettingsKeys.contains(
"reverseAPIChannelIndex")) {
446 qDebug(
"RemoteSource::webapiSettingsPutPatch: forward to GUI: %p",
m_guiMessageQueue);
460 QString& errorMessage)
502 gettimeofday(&tv, 0);
531 if (channelSettingsKeys.contains(
"dataAddress") || force) {
534 if (channelSettingsKeys.contains(
"dataPort") || force) {
537 if (channelSettingsKeys.contains(
"rgbColor") || force) {
540 if (channelSettingsKeys.contains(
"title") || force) {
544 QString channelSettingsURL = QString(
"http://%1:%2/sdrangel/deviceset/%3/channel/%4/settings")
550 m_networkRequest.setHeader(QNetworkRequest::ContentTypeHeader,
"application/json");
552 QBuffer *buffer=
new QBuffer();
553 buffer->open((QBuffer::ReadWrite));
554 buffer->write(swgChannelSettings->
asJson().toUtf8());
560 delete swgChannelSettings;
565 QNetworkReply::NetworkError replyError = reply->error();
569 qWarning() <<
"RemoteSource::networkManagerFinished:" 570 <<
" error(" << (int) replyError
571 <<
"): " << replyError
572 <<
": " << reply->errorString();
576 QString answer = reply->readAll();
578 qDebug(
"RemoteSource::networkManagerFinished: reply:\n%s", answer.toStdString().c_str());
void setQueueLength(qint32 queue_length)
void setOriginatorChannelIndex(qint32 originator_channel_index)
RemoteSourceThread * m_sourceThread
void setDeviceCenterFreq(qint32 device_center_freq)
virtual bool deserialize(const QByteArray &data)
void setReverseApiPort(qint32 reverse_api_port)
QNetworkAccessManager * m_networkManager
RemoteDataBlock * pop()
Pop message from queue.
void setSamplesCount(qint32 samples_count)
uint32_t size() const
Returns queue size (max length)
uint32_t m_nbCorrectableErrors
count of correctable errors in number of blocks
void push(Message *message, bool emitSignal=true)
Push message onto queue.
void removeChannelSourceAPI(ChannelAPI *channelAPI, int streamIndex=0)
void setQueueSize(qint32 queue_size)
RemoteSuperBlock * m_superBlocks
RemoteDataReadQueue m_dataReadQueue
void setCorrectableErrorsCount(qint32 correctable_errors_count)
void setRemoteSourceReport(SWGRemoteSourceReport *remote_source_report)
void webapiReverseSendSettings(QList< QString > &channelSettingsKeys, const RemoteSourceSettings &settings, bool force)
int getDeviceSetIndex() const
void setUseReverseApi(qint32 use_reverse_api)
bool deserialize(const QByteArray &data)
virtual QByteArray serialize() const
void removeChannelSource(ThreadedBasebandSampleSource *sink, int streamIndex=0)
Remove a channel source (Tx)
void handleDataBlock(RemoteDataBlock *dataBlock)
void setDataPort(qint32 data_port)
qint32 getReverseApiPort()
MessageQueue * getInputMessageQueue()
Get the queue for asynchronous inbound communication.
RemoteProtectedBlock m_protectedBlock
qint32 getReverseApiDeviceIndex()
void webapiFormatChannelSettings(SWGSDRangel::SWGChannelSettings &response, const RemoteSourceSettings &settings)
QString m_reverseAPIAddress
int m_recoveryCount
number of recovery blocks received
void setDataLink(const QString &dataAddress, uint16_t dataPort)
void setChannelType(QString *channel_type)
void addChannelSource(ThreadedBasebandSampleSource *sink, int streamIndex=0)
Add a channel source (Tx)
void setOriginatorDeviceSetIndex(qint32 originator_device_set_index)
void applySettings(const RemoteSourceSettings &settings, bool force=false)
DeviceSampleSink * getSampleSink()
Return pointer to the device sample sink (single Tx) or nullptr.
void readSample(Sample &s, bool scaleForTx=false)
Read sample from queue possibly scaling to Tx size.
void setReverseApiAddress(QString *reverse_api_address)
void setCenterFreq(qint32 center_freq)
uint16_t m_reverseAPIPort
void setRemoteSourceSettings(SWGRemoteSourceSettings *remote_source_settings)
QString * getDataAddress()
void setTitle(QString *title)
uint32_t readSampleCount() const
Returns the absolute number of samples read.
virtual void pullAudio(int nbSamples)
QString * getReverseApiAddress()
int getBasebandSampleRate() const
qint32 getUseReverseApi()
virtual quint64 getCenterFrequency() const =0
Center frequency exposed by the sink.
#define MESSAGE_CLASS_DEFINITION(Name, BaseClass)
RemoteRxControlBlock m_rxControlBlock
int m_originalCount
number of original blocks received
void setSize(uint32_t size)
Sets the queue size (max length)
uint16_t m_dataPort
Listening data port.
void setUncorrectableErrorsCount(qint32 uncorrectable_errors_count)
ThreadedBasebandSampleSource * m_threadedChannelizer
RemoteDataQueue m_dataQueue
SWGRemoteSourceReport * getRemoteSourceReport()
static bool match(const Message *message)
uint32_t m_nbUncorrectableErrors
count of uncorrectable errors in number of blocks
QString m_dataAddress
Listening (local) data address.
void setReverseApiDeviceIndex(qint32 reverse_api_device_index)
uint32_t length() const
Returns queue length.
QByteArray serialize() const
void setDirection(qint32 direction)
virtual bool handleMessage(const Message &cmd)
Processing of a message. Returns true if message has actually been processed.
static MsgSampleRateNotification * create(int sampleRate)
void printMeta(const QString &header, RemoteMetaDataFEC *metaData)
virtual QString asJson() override
CM256::cm256_block m_cm256DescriptorBlocks[2 *RemoteNbOrginalBlocks]
CM256 decoder descriptors (block addresses and block indexes)
void setTvSec(qint32 tv_sec)
void setNbOriginalBlocks(qint32 nb_original_blocks)
qint64 getFrequencyOffset() const
void dataBind(const QString &address, uint16_t port)
RemoteSourceSettings m_settings
void networkManagerFinished(QNetworkReply *reply)
MessageQueue * m_guiMessageQueue
Input message queue to the GUI.
void setReverseApiChannelIndex(qint32 reverse_api_channel_index)
void setNbFecBlocks(qint32 nb_fec_blocks)
MessageQueue m_inputMessageQueue
Queue for asynchronous inbound communication.
static MsgReportStreamData * create(uint32_t tv_sec, uint32_t tv_usec, uint32_t queueSize, uint32_t queueLength, uint32_t readSamplesCount, uint32_t nbCorrectableErrors, uint32_t nbUncorrectableErrors, uint32_t nbOriginalBlocks, uint32_t nbFECBlocks, uint32_t centerFreq, uint32_t sampleRate)
void setRgbColor(qint32 rgb_color)
virtual int webapiSettingsGet(SWGSDRangel::SWGChannelSettings &response, QString &errorMessage)
RemoteMetaDataFEC m_currentMeta
void startStop(bool start)
int getSampleRate() const
uint16_t m_reverseAPIDeviceIndex
virtual int webapiSettingsPutPatch(bool force, const QStringList &channelSettingsKeys, SWGSDRangel::SWGChannelSettings &response, QString &errorMessage)
static const QString m_channelIdURI
void addChannelSourceAPI(ChannelAPI *channelAPI, int streamIndex=0)
virtual int getSampleRate() const =0
Sample rate exposed by the sink.
uint32_t crc32(const uint8_t *buf, int len)
virtual void pull(Sample &sample)
UpChannelizer * m_channelizer
int getIndexInDeviceSet() const
static const QString m_channelId
void push(RemoteDataBlock *dataBlock)
push block on the queue
void setDeviceSampleRate(qint32 device_sample_rate)
void setTvUSec(qint32 tv_u_sec)
void setDataAddress(QString *data_address)
RemoteSource(DeviceAPI *deviceAPI)
virtual int webapiReportGet(SWGSDRangel::SWGChannelReport &response, QString &errorMessage)
uint16_t m_reverseAPIChannelIndex
void setSampleRate(qint32 sample_rate)
uint32_t calculateDataReadQueueSize(int sampleRate)
SWGRemoteSourceSettings * getRemoteSourceSettings()
QNetworkRequest m_networkRequest
void webapiFormatChannelReport(SWGSDRangel::SWGChannelReport &response)
int m_blockCount
number of blocks received for this frame
bool m_metaRetrieved
true if meta data (block zero) was retrieved
void configure(MessageQueue *messageQueue, int sampleRate, int centerFrequency)
qint32 getReverseApiChannelIndex()