From 9f42957585759a4ecf9de834b75a1fb619223dc1 Mon Sep 17 00:00:00 2001 From: f4exb Date: Wed, 20 Oct 2021 23:01:44 +0200 Subject: [PATCH] DATV modulator: API enhancements and GUI cosmetic fixes --- plugins/channeltx/moddatv/datvmod.cpp | 17 +++- plugins/channeltx/moddatv/datvmodbaseband.h | 4 +- plugins/channeltx/moddatv/datvmodgui.ui | 51 +++++----- plugins/channeltx/moddatv/datvmodsource.cpp | 25 +++-- plugins/channeltx/moddatv/datvmodsource.h | 9 +- sdrbase/resources/webapi/doc/html2/index.html | 15 ++- .../webapi/doc/swagger/include/DATVMod.yaml | 9 ++ .../sdrangel/api/swagger/include/DATVMod.yaml | 9 ++ swagger/sdrangel/code/html2/index.html | 15 ++- .../code/qt5/client/SWGDATVModReport.cpp | 92 +++++++++++++++++++ .../code/qt5/client/SWGDATVModReport.h | 24 +++++ 11 files changed, 235 insertions(+), 35 deletions(-) diff --git a/plugins/channeltx/moddatv/datvmod.cpp b/plugins/channeltx/moddatv/datvmod.cpp index 9ec7d1e71..7f970cd47 100644 --- a/plugins/channeltx/moddatv/datvmod.cpp +++ b/plugins/channeltx/moddatv/datvmod.cpp @@ -498,7 +498,22 @@ void DATVMod::webapiFormatChannelSettings(SWGSDRangel::SWGChannelSettings& respo void DATVMod::webapiFormatChannelReport(SWGSDRangel::SWGChannelReport& response) { response.getDatvModReport()->setChannelPowerDb(CalcDb::dbPower(getMagSq())); - response.getDatvModReport()->setChannelSampleRate(m_basebandSource->getChannelSampleRate()); + int tsBitrate = 0, tsSize = 0, channelSampleRate = 0, dataRate = 0; + int64_t udpBytes = 0; + + if (m_basebandSource) + { + channelSampleRate = m_basebandSource->getChannelSampleRate(); + m_basebandSource->geTsFileInfos(tsBitrate, tsSize); + udpBytes = m_basebandSource->getUdpByteCount(); + dataRate = m_basebandSource->getDataRate(); + } + + response.getDatvModReport()->setChannelSampleRate(channelSampleRate); + response.getDatvModReport()->setDataRate(dataRate); + response.getDatvModReport()->setTsFileBitrate(tsBitrate); + response.getDatvModReport()->setTsFileLength(tsSize); + response.getDatvModReport()->setUdpByteCount(udpBytes); } void DATVMod::webapiReverseSendSettings(QList& channelSettingsKeys, const DATVModSettings& settings, bool force) diff --git a/plugins/channeltx/moddatv/datvmodbaseband.h b/plugins/channeltx/moddatv/datvmodbaseband.h index ed7baf46e..4b7a85dcf 100644 --- a/plugins/channeltx/moddatv/datvmodbaseband.h +++ b/plugins/channeltx/moddatv/datvmodbaseband.h @@ -45,8 +45,10 @@ public: MessageQueue *getInputMessageQueue() { return &m_inputMessageQueue; } void setMessageQueueToGUI(MessageQueue *messageQueue) { m_source.setMessageQueueToGUI(messageQueue); } double getMagSq() const { return m_source.getMagSq(); } + void geTsFileInfos(int& mpegTSBitrate, int& mpegTSSize) const { m_source.geTsFileInfos(mpegTSBitrate, mpegTSSize); } + int64_t getUdpByteCount() const { return m_source.getUdpByteCount(); } + int getDataRate() const { return m_source.getDataRate(); } int getChannelSampleRate() const; - int getEffectiveSampleRate() const { return m_source.getEffectiveSampleRate(); } signals: diff --git a/plugins/channeltx/moddatv/datvmodgui.ui b/plugins/channeltx/moddatv/datvmodgui.ui index f33e011ab..a64f1e701 100644 --- a/plugins/channeltx/moddatv/datvmodgui.ui +++ b/plugins/channeltx/moddatv/datvmodgui.ui @@ -6,7 +6,7 @@ 0 0 - 463 + 543 235 @@ -39,7 +39,7 @@ 0 10 - 451 + 541 221 @@ -363,13 +363,6 @@ - - - - Qt::Vertical - - - @@ -379,6 +372,12 @@ + + + 60 + 0 + + Forward error correction code rate @@ -409,15 +408,14 @@ - - - - Qt::Vertical - - - + + + 70 + 0 + + Modulation @@ -425,6 +423,12 @@ + + + 70 + 0 + + Modulation type @@ -440,15 +444,14 @@ - - - - Qt::Vertical - - - + + + 45 + 0 + + Roll off @@ -458,7 +461,7 @@ - 50 + 60 0 diff --git a/plugins/channeltx/moddatv/datvmodsource.cpp b/plugins/channeltx/moddatv/datvmodsource.cpp index bfbb4b4dd..e0bfa29db 100644 --- a/plugins/channeltx/moddatv/datvmodsource.cpp +++ b/plugins/channeltx/moddatv/datvmodsource.cpp @@ -77,7 +77,7 @@ int DATVModSource::getTSBitrate(const QString& filename) } // Get data bitrate (i.e. excluding FEC overhead) -int DATVModSource::getDVBSDataBitrate(const DATVModSettings& settings) +int DATVModSource::getDVBSDataBitrate(const DATVModSettings& settings) const { float fecFactor; float plFactor; @@ -216,6 +216,8 @@ void DATVModSource::checkBitrates() } DATVModSource::DATVModSource() : + m_mpegTSBitrate(0), + m_mpegTSSize(0), m_sampleIdx(0), m_frameIdx(0), m_frameCount(0), @@ -226,6 +228,7 @@ DATVModSource::DATVModSource() : m_samplesPerSymbol(1), m_udpSocket(nullptr), m_udpByteCount(0), + m_udpAbsByteCount(0), m_udpBufferIdx(0), m_udpBufferCount(0), m_udpMaxBufferUtilization(0), @@ -372,6 +375,7 @@ void DATVModSource::modulateSample() } m_udpByteCount += ba.size(); + m_udpAbsByteCount += ba.size(); } else { @@ -579,10 +583,12 @@ void DATVModSource::reportUDPBitrate() boost::chrono::duration sec = boost::chrono::steady_clock::now() - m_udpTimingStart; double seconds = sec.count(); int bitrate = seconds > 0.0 ? m_udpByteCount * 8 / seconds : 0; - if (getMessageQueueToGUI()) - getMessageQueueToGUI()->push(DATVModReport::MsgReportUDPBitrate::create(bitrate)); m_udpTimingStart = boost::chrono::steady_clock::now(); m_udpByteCount = 0; + + if (getMessageQueueToGUI()) { + getMessageQueueToGUI()->push(DATVModReport::MsgReportUDPBitrate::create(bitrate)); + } } void DATVModSource::updateUDPBufferUtilization() @@ -602,8 +608,13 @@ void DATVModSource::reportUDPBufferUtilization() { // Report maximum utilization since last call updateUDPBufferUtilization(); + if (getMessageQueueToGUI()) - getMessageQueueToGUI()->push(DATVModReport::MsgReportUDPBufferUtilization::create(m_udpMaxBufferUtilization / (float)DATVModSettings::m_udpBufferSize * 100.0)); + { + getMessageQueueToGUI()->push(DATVModReport::MsgReportUDPBufferUtilization::create( + m_udpMaxBufferUtilization / (float)DATVModSettings::m_udpBufferSize * 100.0)); + } + m_udpMaxBufferUtilization = 0; } @@ -635,8 +646,9 @@ void DATVModSource::applyChannelSettings(int channelSampleRate, int channelFrequ if (getMessageQueueToGUI()) { getMessageQueueToGUI()->push(DATVModReport::MsgReportRates::create( - channelSampleRate, m_sampleRate, - getDVBSDataBitrate(m_settings))); + channelSampleRate, + m_sampleRate, + getDVBSDataBitrate(m_settings))); } } } @@ -713,6 +725,7 @@ void DATVModSource::applySettings(const DATVModSettings& settings, bool force) m_udpSocket->setSocketOption(QAbstractSocket::ReceiveBufferSizeSocketOption, DATVModSettings::m_udpBufferSize); m_udpTimingStart = boost::chrono::steady_clock::now(); m_udpByteCount = 0; + m_udpAbsByteCount = 0; } } diff --git a/plugins/channeltx/moddatv/datvmodsource.h b/plugins/channeltx/moddatv/datvmodsource.h index 95ccc4052..2e92c6381 100644 --- a/plugins/channeltx/moddatv/datvmodsource.h +++ b/plugins/channeltx/moddatv/datvmodsource.h @@ -63,6 +63,12 @@ public: peakLevel = m_peakLevelOut; numSamples = m_levelNbSamples; } + void geTsFileInfos(int& mpegTSBitrate, int& mpegTSSize) const { + mpegTSBitrate = m_mpegTSBitrate; + mpegTSSize = (int) m_mpegTSSize; + } + int64_t getUdpByteCount() const { return m_udpAbsByteCount; } + int getDataRate() const { return getDVBSDataBitrate(m_settings); } void applyChannelSettings(int channelSampleRate, int channelFrequencyOffset, bool force = false); void applySettings(const DATVModSettings& settings, bool force = false); @@ -96,6 +102,7 @@ private: QUdpSocket *m_udpSocket; //!< UDP socket to receive MPEG transport stream via int m_udpByteCount; //!< Count of bytes received via UDP for bitrate calculation + int64_t m_udpAbsByteCount; //!< Count of bytes received via UDP since the begining boost::chrono::steady_clock::time_point m_udpTimingStart; //!< When we last started counting UDP bytes uint8_t m_udpBuffer[188*10]; int m_udpBufferIdx; //!< TS frame index into buffer @@ -131,7 +138,7 @@ private: void modulateSample(); int getTSBitrate(const QString& filename); - int getDVBSDataBitrate(const DATVModSettings& settings); + int getDVBSDataBitrate(const DATVModSettings& settings) const; void checkBitrates(); void updateUDPBufferUtilization(); diff --git a/sdrbase/resources/webapi/doc/html2/index.html b/sdrbase/resources/webapi/doc/html2/index.html index c1bac6e96..8f1b80c20 100644 --- a/sdrbase/resources/webapi/doc/html2/index.html +++ b/sdrbase/resources/webapi/doc/html2/index.html @@ -3892,6 +3892,19 @@ margin-bottom: 20px; }, "channelSampleRate" : { "type" : "integer" + }, + "dataRate" : { + "type" : "integer" + }, + "tsFileBitrate" : { + "type" : "integer" + }, + "tsFileLength" : { + "type" : "integer" + }, + "udpByteCount" : { + "type" : "integer", + "format" : "int64" } }, "description" : "DATVMod" @@ -51005,7 +51018,7 @@ except ApiException as e:
- Generated 2021-10-12T21:36:57.091+02:00 + Generated 2021-10-19T22:10:34.002+02:00
diff --git a/sdrbase/resources/webapi/doc/swagger/include/DATVMod.yaml b/sdrbase/resources/webapi/doc/swagger/include/DATVMod.yaml index e751c2822..012b08f06 100644 --- a/sdrbase/resources/webapi/doc/swagger/include/DATVMod.yaml +++ b/sdrbase/resources/webapi/doc/swagger/include/DATVMod.yaml @@ -68,3 +68,12 @@ DATVModReport: format: float channelSampleRate: type: integer + dataRate: + type: integer + tsFileBitrate: + type: integer + tsFileLength: + type: integer + udpByteCount: + type: integer + format: int64 diff --git a/swagger/sdrangel/api/swagger/include/DATVMod.yaml b/swagger/sdrangel/api/swagger/include/DATVMod.yaml index e751c2822..012b08f06 100644 --- a/swagger/sdrangel/api/swagger/include/DATVMod.yaml +++ b/swagger/sdrangel/api/swagger/include/DATVMod.yaml @@ -68,3 +68,12 @@ DATVModReport: format: float channelSampleRate: type: integer + dataRate: + type: integer + tsFileBitrate: + type: integer + tsFileLength: + type: integer + udpByteCount: + type: integer + format: int64 diff --git a/swagger/sdrangel/code/html2/index.html b/swagger/sdrangel/code/html2/index.html index c1bac6e96..8f1b80c20 100644 --- a/swagger/sdrangel/code/html2/index.html +++ b/swagger/sdrangel/code/html2/index.html @@ -3892,6 +3892,19 @@ margin-bottom: 20px; }, "channelSampleRate" : { "type" : "integer" + }, + "dataRate" : { + "type" : "integer" + }, + "tsFileBitrate" : { + "type" : "integer" + }, + "tsFileLength" : { + "type" : "integer" + }, + "udpByteCount" : { + "type" : "integer", + "format" : "int64" } }, "description" : "DATVMod" @@ -51005,7 +51018,7 @@ except ApiException as e:
- Generated 2021-10-12T21:36:57.091+02:00 + Generated 2021-10-19T22:10:34.002+02:00
diff --git a/swagger/sdrangel/code/qt5/client/SWGDATVModReport.cpp b/swagger/sdrangel/code/qt5/client/SWGDATVModReport.cpp index 09653b9e3..08ccef520 100644 --- a/swagger/sdrangel/code/qt5/client/SWGDATVModReport.cpp +++ b/swagger/sdrangel/code/qt5/client/SWGDATVModReport.cpp @@ -32,6 +32,14 @@ SWGDATVModReport::SWGDATVModReport() { m_channel_power_db_isSet = false; channel_sample_rate = 0; m_channel_sample_rate_isSet = false; + data_rate = 0; + m_data_rate_isSet = false; + ts_file_bitrate = 0; + m_ts_file_bitrate_isSet = false; + ts_file_length = 0; + m_ts_file_length_isSet = false; + udp_byte_count = 0L; + m_udp_byte_count_isSet = false; } SWGDATVModReport::~SWGDATVModReport() { @@ -44,12 +52,24 @@ SWGDATVModReport::init() { m_channel_power_db_isSet = false; channel_sample_rate = 0; m_channel_sample_rate_isSet = false; + data_rate = 0; + m_data_rate_isSet = false; + ts_file_bitrate = 0; + m_ts_file_bitrate_isSet = false; + ts_file_length = 0; + m_ts_file_length_isSet = false; + udp_byte_count = 0L; + m_udp_byte_count_isSet = false; } void SWGDATVModReport::cleanup() { + + + + } SWGDATVModReport* @@ -67,6 +87,14 @@ SWGDATVModReport::fromJsonObject(QJsonObject &pJson) { ::SWGSDRangel::setValue(&channel_sample_rate, pJson["channelSampleRate"], "qint32", ""); + ::SWGSDRangel::setValue(&data_rate, pJson["dataRate"], "qint32", ""); + + ::SWGSDRangel::setValue(&ts_file_bitrate, pJson["tsFileBitrate"], "qint32", ""); + + ::SWGSDRangel::setValue(&ts_file_length, pJson["tsFileLength"], "qint32", ""); + + ::SWGSDRangel::setValue(&udp_byte_count, pJson["udpByteCount"], "qint64", ""); + } QString @@ -89,6 +117,18 @@ SWGDATVModReport::asJsonObject() { if(m_channel_sample_rate_isSet){ obj->insert("channelSampleRate", QJsonValue(channel_sample_rate)); } + if(m_data_rate_isSet){ + obj->insert("dataRate", QJsonValue(data_rate)); + } + if(m_ts_file_bitrate_isSet){ + obj->insert("tsFileBitrate", QJsonValue(ts_file_bitrate)); + } + if(m_ts_file_length_isSet){ + obj->insert("tsFileLength", QJsonValue(ts_file_length)); + } + if(m_udp_byte_count_isSet){ + obj->insert("udpByteCount", QJsonValue(udp_byte_count)); + } return obj; } @@ -113,6 +153,46 @@ SWGDATVModReport::setChannelSampleRate(qint32 channel_sample_rate) { this->m_channel_sample_rate_isSet = true; } +qint32 +SWGDATVModReport::getDataRate() { + return data_rate; +} +void +SWGDATVModReport::setDataRate(qint32 data_rate) { + this->data_rate = data_rate; + this->m_data_rate_isSet = true; +} + +qint32 +SWGDATVModReport::getTsFileBitrate() { + return ts_file_bitrate; +} +void +SWGDATVModReport::setTsFileBitrate(qint32 ts_file_bitrate) { + this->ts_file_bitrate = ts_file_bitrate; + this->m_ts_file_bitrate_isSet = true; +} + +qint32 +SWGDATVModReport::getTsFileLength() { + return ts_file_length; +} +void +SWGDATVModReport::setTsFileLength(qint32 ts_file_length) { + this->ts_file_length = ts_file_length; + this->m_ts_file_length_isSet = true; +} + +qint64 +SWGDATVModReport::getUdpByteCount() { + return udp_byte_count; +} +void +SWGDATVModReport::setUdpByteCount(qint64 udp_byte_count) { + this->udp_byte_count = udp_byte_count; + this->m_udp_byte_count_isSet = true; +} + bool SWGDATVModReport::isSet(){ @@ -124,6 +204,18 @@ SWGDATVModReport::isSet(){ if(m_channel_sample_rate_isSet){ isObjectUpdated = true; break; } + if(m_data_rate_isSet){ + isObjectUpdated = true; break; + } + if(m_ts_file_bitrate_isSet){ + isObjectUpdated = true; break; + } + if(m_ts_file_length_isSet){ + isObjectUpdated = true; break; + } + if(m_udp_byte_count_isSet){ + isObjectUpdated = true; break; + } }while(false); return isObjectUpdated; } diff --git a/swagger/sdrangel/code/qt5/client/SWGDATVModReport.h b/swagger/sdrangel/code/qt5/client/SWGDATVModReport.h index ae6f106e5..df94b535c 100644 --- a/swagger/sdrangel/code/qt5/client/SWGDATVModReport.h +++ b/swagger/sdrangel/code/qt5/client/SWGDATVModReport.h @@ -47,6 +47,18 @@ public: qint32 getChannelSampleRate(); void setChannelSampleRate(qint32 channel_sample_rate); + qint32 getDataRate(); + void setDataRate(qint32 data_rate); + + qint32 getTsFileBitrate(); + void setTsFileBitrate(qint32 ts_file_bitrate); + + qint32 getTsFileLength(); + void setTsFileLength(qint32 ts_file_length); + + qint64 getUdpByteCount(); + void setUdpByteCount(qint64 udp_byte_count); + virtual bool isSet() override; @@ -57,6 +69,18 @@ private: qint32 channel_sample_rate; bool m_channel_sample_rate_isSet; + qint32 data_rate; + bool m_data_rate_isSet; + + qint32 ts_file_bitrate; + bool m_ts_file_bitrate_isSet; + + qint32 ts_file_length; + bool m_ts_file_length_isSet; + + qint64 udp_byte_count; + bool m_udp_byte_count_isSet; + }; }