1
0
mirror of https://github.com/f4exb/sdrangel.git synced 2025-03-06 19:38:47 -05:00

DATV modulator: API enhancements and GUI cosmetic fixes

This commit is contained in:
f4exb 2021-10-20 23:01:44 +02:00
parent ed4a1532d4
commit 9f42957585
11 changed files with 235 additions and 35 deletions

View File

@ -498,7 +498,22 @@ void DATVMod::webapiFormatChannelSettings(SWGSDRangel::SWGChannelSettings& respo
void DATVMod::webapiFormatChannelReport(SWGSDRangel::SWGChannelReport& response) void DATVMod::webapiFormatChannelReport(SWGSDRangel::SWGChannelReport& response)
{ {
response.getDatvModReport()->setChannelPowerDb(CalcDb::dbPower(getMagSq())); 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<QString>& channelSettingsKeys, const DATVModSettings& settings, bool force) void DATVMod::webapiReverseSendSettings(QList<QString>& channelSettingsKeys, const DATVModSettings& settings, bool force)

View File

@ -45,8 +45,10 @@ public:
MessageQueue *getInputMessageQueue() { return &m_inputMessageQueue; } MessageQueue *getInputMessageQueue() { return &m_inputMessageQueue; }
void setMessageQueueToGUI(MessageQueue *messageQueue) { m_source.setMessageQueueToGUI(messageQueue); } void setMessageQueueToGUI(MessageQueue *messageQueue) { m_source.setMessageQueueToGUI(messageQueue); }
double getMagSq() const { return m_source.getMagSq(); } 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 getChannelSampleRate() const;
int getEffectiveSampleRate() const { return m_source.getEffectiveSampleRate(); } int getEffectiveSampleRate() const { return m_source.getEffectiveSampleRate(); }
signals: signals:

View File

@ -6,7 +6,7 @@
<rect> <rect>
<x>0</x> <x>0</x>
<y>0</y> <y>0</y>
<width>463</width> <width>543</width>
<height>235</height> <height>235</height>
</rect> </rect>
</property> </property>
@ -39,7 +39,7 @@
<rect> <rect>
<x>0</x> <x>0</x>
<y>10</y> <y>10</y>
<width>451</width> <width>541</width>
<height>221</height> <height>221</height>
</rect> </rect>
</property> </property>
@ -363,13 +363,6 @@
</item> </item>
</widget> </widget>
</item> </item>
<item>
<widget class="Line" name="line_4">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
</widget>
</item>
<item> <item>
<widget class="QLabel" name="fecLabel"> <widget class="QLabel" name="fecLabel">
<property name="text"> <property name="text">
@ -379,6 +372,12 @@
</item> </item>
<item> <item>
<widget class="QComboBox" name="fec"> <widget class="QComboBox" name="fec">
<property name="minimumSize">
<size>
<width>60</width>
<height>0</height>
</size>
</property>
<property name="toolTip"> <property name="toolTip">
<string>Forward error correction code rate</string> <string>Forward error correction code rate</string>
</property> </property>
@ -409,15 +408,14 @@
</item> </item>
</widget> </widget>
</item> </item>
<item>
<widget class="Line" name="line_13">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
</widget>
</item>
<item> <item>
<widget class="QLabel" name="modulationLabel"> <widget class="QLabel" name="modulationLabel">
<property name="minimumSize">
<size>
<width>70</width>
<height>0</height>
</size>
</property>
<property name="text"> <property name="text">
<string>Modulation</string> <string>Modulation</string>
</property> </property>
@ -425,6 +423,12 @@
</item> </item>
<item> <item>
<widget class="QComboBox" name="modulation"> <widget class="QComboBox" name="modulation">
<property name="minimumSize">
<size>
<width>70</width>
<height>0</height>
</size>
</property>
<property name="toolTip"> <property name="toolTip">
<string>Modulation type</string> <string>Modulation type</string>
</property> </property>
@ -440,15 +444,14 @@
</item> </item>
</widget> </widget>
</item> </item>
<item>
<widget class="Line" name="line_14">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
</widget>
</item>
<item> <item>
<widget class="QLabel" name="rollOffLabel"> <widget class="QLabel" name="rollOffLabel">
<property name="minimumSize">
<size>
<width>45</width>
<height>0</height>
</size>
</property>
<property name="text"> <property name="text">
<string>Roll off</string> <string>Roll off</string>
</property> </property>
@ -458,7 +461,7 @@
<widget class="QComboBox" name="rollOff"> <widget class="QComboBox" name="rollOff">
<property name="minimumSize"> <property name="minimumSize">
<size> <size>
<width>50</width> <width>60</width>
<height>0</height> <height>0</height>
</size> </size>
</property> </property>

View File

@ -77,7 +77,7 @@ int DATVModSource::getTSBitrate(const QString& filename)
} }
// Get data bitrate (i.e. excluding FEC overhead) // Get data bitrate (i.e. excluding FEC overhead)
int DATVModSource::getDVBSDataBitrate(const DATVModSettings& settings) int DATVModSource::getDVBSDataBitrate(const DATVModSettings& settings) const
{ {
float fecFactor; float fecFactor;
float plFactor; float plFactor;
@ -216,6 +216,8 @@ void DATVModSource::checkBitrates()
} }
DATVModSource::DATVModSource() : DATVModSource::DATVModSource() :
m_mpegTSBitrate(0),
m_mpegTSSize(0),
m_sampleIdx(0), m_sampleIdx(0),
m_frameIdx(0), m_frameIdx(0),
m_frameCount(0), m_frameCount(0),
@ -226,6 +228,7 @@ DATVModSource::DATVModSource() :
m_samplesPerSymbol(1), m_samplesPerSymbol(1),
m_udpSocket(nullptr), m_udpSocket(nullptr),
m_udpByteCount(0), m_udpByteCount(0),
m_udpAbsByteCount(0),
m_udpBufferIdx(0), m_udpBufferIdx(0),
m_udpBufferCount(0), m_udpBufferCount(0),
m_udpMaxBufferUtilization(0), m_udpMaxBufferUtilization(0),
@ -372,6 +375,7 @@ void DATVModSource::modulateSample()
} }
m_udpByteCount += ba.size(); m_udpByteCount += ba.size();
m_udpAbsByteCount += ba.size();
} }
else else
{ {
@ -579,10 +583,12 @@ void DATVModSource::reportUDPBitrate()
boost::chrono::duration<double> sec = boost::chrono::steady_clock::now() - m_udpTimingStart; boost::chrono::duration<double> sec = boost::chrono::steady_clock::now() - m_udpTimingStart;
double seconds = sec.count(); double seconds = sec.count();
int bitrate = seconds > 0.0 ? m_udpByteCount * 8 / seconds : 0; 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_udpTimingStart = boost::chrono::steady_clock::now();
m_udpByteCount = 0; m_udpByteCount = 0;
if (getMessageQueueToGUI()) {
getMessageQueueToGUI()->push(DATVModReport::MsgReportUDPBitrate::create(bitrate));
}
} }
void DATVModSource::updateUDPBufferUtilization() void DATVModSource::updateUDPBufferUtilization()
@ -602,8 +608,13 @@ void DATVModSource::reportUDPBufferUtilization()
{ {
// Report maximum utilization since last call // Report maximum utilization since last call
updateUDPBufferUtilization(); updateUDPBufferUtilization();
if (getMessageQueueToGUI()) 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; m_udpMaxBufferUtilization = 0;
} }
@ -635,8 +646,9 @@ void DATVModSource::applyChannelSettings(int channelSampleRate, int channelFrequ
if (getMessageQueueToGUI()) if (getMessageQueueToGUI())
{ {
getMessageQueueToGUI()->push(DATVModReport::MsgReportRates::create( getMessageQueueToGUI()->push(DATVModReport::MsgReportRates::create(
channelSampleRate, m_sampleRate, channelSampleRate,
getDVBSDataBitrate(m_settings))); 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_udpSocket->setSocketOption(QAbstractSocket::ReceiveBufferSizeSocketOption, DATVModSettings::m_udpBufferSize);
m_udpTimingStart = boost::chrono::steady_clock::now(); m_udpTimingStart = boost::chrono::steady_clock::now();
m_udpByteCount = 0; m_udpByteCount = 0;
m_udpAbsByteCount = 0;
} }
} }

View File

@ -63,6 +63,12 @@ public:
peakLevel = m_peakLevelOut; peakLevel = m_peakLevelOut;
numSamples = m_levelNbSamples; 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 applyChannelSettings(int channelSampleRate, int channelFrequencyOffset, bool force = false);
void applySettings(const DATVModSettings& settings, 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 QUdpSocket *m_udpSocket; //!< UDP socket to receive MPEG transport stream via
int m_udpByteCount; //!< Count of bytes received via UDP for bitrate calculation 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 boost::chrono::steady_clock::time_point m_udpTimingStart; //!< When we last started counting UDP bytes
uint8_t m_udpBuffer[188*10]; uint8_t m_udpBuffer[188*10];
int m_udpBufferIdx; //!< TS frame index into buffer int m_udpBufferIdx; //!< TS frame index into buffer
@ -131,7 +138,7 @@ private:
void modulateSample(); void modulateSample();
int getTSBitrate(const QString& filename); int getTSBitrate(const QString& filename);
int getDVBSDataBitrate(const DATVModSettings& settings); int getDVBSDataBitrate(const DATVModSettings& settings) const;
void checkBitrates(); void checkBitrates();
void updateUDPBufferUtilization(); void updateUDPBufferUtilization();

View File

@ -3892,6 +3892,19 @@ margin-bottom: 20px;
}, },
"channelSampleRate" : { "channelSampleRate" : {
"type" : "integer" "type" : "integer"
},
"dataRate" : {
"type" : "integer"
},
"tsFileBitrate" : {
"type" : "integer"
},
"tsFileLength" : {
"type" : "integer"
},
"udpByteCount" : {
"type" : "integer",
"format" : "int64"
} }
}, },
"description" : "DATVMod" "description" : "DATVMod"
@ -51005,7 +51018,7 @@ except ApiException as e:
</div> </div>
<div id="generator"> <div id="generator">
<div class="content"> <div class="content">
Generated 2021-10-12T21:36:57.091+02:00 Generated 2021-10-19T22:10:34.002+02:00
</div> </div>
</div> </div>
</div> </div>

View File

@ -68,3 +68,12 @@ DATVModReport:
format: float format: float
channelSampleRate: channelSampleRate:
type: integer type: integer
dataRate:
type: integer
tsFileBitrate:
type: integer
tsFileLength:
type: integer
udpByteCount:
type: integer
format: int64

View File

@ -68,3 +68,12 @@ DATVModReport:
format: float format: float
channelSampleRate: channelSampleRate:
type: integer type: integer
dataRate:
type: integer
tsFileBitrate:
type: integer
tsFileLength:
type: integer
udpByteCount:
type: integer
format: int64

View File

@ -3892,6 +3892,19 @@ margin-bottom: 20px;
}, },
"channelSampleRate" : { "channelSampleRate" : {
"type" : "integer" "type" : "integer"
},
"dataRate" : {
"type" : "integer"
},
"tsFileBitrate" : {
"type" : "integer"
},
"tsFileLength" : {
"type" : "integer"
},
"udpByteCount" : {
"type" : "integer",
"format" : "int64"
} }
}, },
"description" : "DATVMod" "description" : "DATVMod"
@ -51005,7 +51018,7 @@ except ApiException as e:
</div> </div>
<div id="generator"> <div id="generator">
<div class="content"> <div class="content">
Generated 2021-10-12T21:36:57.091+02:00 Generated 2021-10-19T22:10:34.002+02:00
</div> </div>
</div> </div>
</div> </div>

View File

@ -32,6 +32,14 @@ SWGDATVModReport::SWGDATVModReport() {
m_channel_power_db_isSet = false; m_channel_power_db_isSet = false;
channel_sample_rate = 0; channel_sample_rate = 0;
m_channel_sample_rate_isSet = false; 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() { SWGDATVModReport::~SWGDATVModReport() {
@ -44,12 +52,24 @@ SWGDATVModReport::init() {
m_channel_power_db_isSet = false; m_channel_power_db_isSet = false;
channel_sample_rate = 0; channel_sample_rate = 0;
m_channel_sample_rate_isSet = false; 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 void
SWGDATVModReport::cleanup() { SWGDATVModReport::cleanup() {
} }
SWGDATVModReport* SWGDATVModReport*
@ -67,6 +87,14 @@ SWGDATVModReport::fromJsonObject(QJsonObject &pJson) {
::SWGSDRangel::setValue(&channel_sample_rate, pJson["channelSampleRate"], "qint32", ""); ::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 QString
@ -89,6 +117,18 @@ SWGDATVModReport::asJsonObject() {
if(m_channel_sample_rate_isSet){ if(m_channel_sample_rate_isSet){
obj->insert("channelSampleRate", QJsonValue(channel_sample_rate)); 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; return obj;
} }
@ -113,6 +153,46 @@ SWGDATVModReport::setChannelSampleRate(qint32 channel_sample_rate) {
this->m_channel_sample_rate_isSet = true; 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 bool
SWGDATVModReport::isSet(){ SWGDATVModReport::isSet(){
@ -124,6 +204,18 @@ SWGDATVModReport::isSet(){
if(m_channel_sample_rate_isSet){ if(m_channel_sample_rate_isSet){
isObjectUpdated = true; break; 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); }while(false);
return isObjectUpdated; return isObjectUpdated;
} }

View File

@ -47,6 +47,18 @@ public:
qint32 getChannelSampleRate(); qint32 getChannelSampleRate();
void setChannelSampleRate(qint32 channel_sample_rate); 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; virtual bool isSet() override;
@ -57,6 +69,18 @@ private:
qint32 channel_sample_rate; qint32 channel_sample_rate;
bool m_channel_sample_rate_isSet; 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;
}; };
} }