Skip to content

Commit

Permalink
Merge pull request #230 from docsteer/multicast_ttl
Browse files Browse the repository at this point in the history
Multicast TTL
  • Loading branch information
docsteer authored Nov 19, 2020
2 parents 214c6a2 + 1afaf1f commit 3c81d31
Show file tree
Hide file tree
Showing 5 changed files with 66 additions and 32 deletions.
3 changes: 3 additions & 0 deletions src/preferences.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -283,6 +283,8 @@ void Preferences::savePreferences()
settings.setValue(S_PRIORITYPRESET.arg(i), QVariant(m_priorityPresets[i]));
}

settings.setValue(S_MULTICASTTTL, m_multicastTtl);

settings.sync();
}

Expand Down Expand Up @@ -318,6 +320,7 @@ void Preferences::loadPreferences()
m_txrateoverride = settings.value(S_TX_RATE_OVERRIDE, QVariant(false)).toBool();
m_locale = settings.value(S_LOCALE, QLocale::system()).toLocale();
m_universesListed = settings.value(S_UNIVERSESLISTED, QVariant(20)).toUInt();
m_multicastTtl = settings.value(S_MULTICASTTTL, QVariant(1)).toUInt();

m_windowInfo.clear();
int size = settings.beginReadArray(S_SUBWINDOWLIST);
Expand Down
4 changes: 4 additions & 0 deletions src/preferences.h
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ static const QString S_TX_RATE_OVERRIDE("TX Rate Override");
static const QString S_LOCALE("LOCALE");
static const QString S_UNIVERSESLISTED("Universe List Count");
static const QString S_PRIORITYPRESET("PriorityPreset %1");
static const QString S_MULTICASTTTL("Multicast TTL");

struct MDIWindowInfo
{
Expand Down Expand Up @@ -125,6 +126,7 @@ class Preferences
void SetLocale(QLocale locale);
void SetUniversesListed(quint8 count) { m_universesListed = (std::max)(count, (quint8)1); }
void SetPriorityPreset(const QByteArray &data, int index);
void SetMulticastTtl(quint8 ttl) { m_multicastTtl = ttl;}

unsigned int GetDisplayFormat();
unsigned int GetMaxLevel();
Expand All @@ -142,6 +144,7 @@ class Preferences
bool GetTXRateOverride() { return m_txrateoverride; }
QLocale GetLocale();
quint8 GetUniversesListed() { return m_universesListed; }
quint8 GetMulticastTtl() { return m_multicastTtl; }

QString GetFormattedValue(unsigned int nLevelInDecimal, bool decorated = false);
QByteArray GetPriorityPreset(int index);
Expand Down Expand Up @@ -173,6 +176,7 @@ public slots:
QLocale m_locale;
quint8 m_universesListed;
QByteArray m_priorityPresets[PRIORITYPRESET_COUNT];
quint8 m_multicastTtl;

void loadPreferences();
};
Expand Down
9 changes: 9 additions & 0 deletions src/preferencesdialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,8 @@ PreferencesDialog::PreferencesDialog(QWidget *parent) :
ui->cbTheme->clear();
ui->cbTheme->addItems(Preferences::ThemeDescriptions());
ui->cbTheme->setCurrentIndex(static_cast<int>(Preferences::getInstance()->GetTheme()));

ui->sbMulticastTtl->setValue(Preferences::getInstance()->GetMulticastTtl());
}

PreferencesDialog::~PreferencesDialog()
Expand Down Expand Up @@ -180,6 +182,13 @@ void PreferencesDialog::on_buttonBox_accepted()
requiresRestart = true;
}

// Multicast TTL
if(p->GetMulticastTtl() != ui->sbMulticastTtl->value())
{
p->SetMulticastTtl(ui->sbMulticastTtl->value());
requiresRestart = true;
}

// Resstart to apply?
if (requiresRestart) {
QMessageBox::information(this, tr("Restart requied"),
Expand Down
3 changes: 3 additions & 0 deletions src/sacn/sacnsocket.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
#include "streamcommon.h"
#include "streamingacn.h"
#include "sacnlistener.h"
#include "preferences.h"

sACNRxSocket::sACNRxSocket(QNetworkInterface iface, QObject *parent) :
QUdpSocket(parent),
Expand Down Expand Up @@ -98,6 +99,8 @@ bool sACNTxSocket::bind()
setSocketOption(QAbstractSocket::MulticastLoopbackOption, QVariant(0));
#endif

setSocketOption(QAbstractSocket::MulticastTtlOption, QVariant(Preferences::getInstance()->GetMulticastTtl()));

setMulticastInterface(m_interface);
qDebug() << "sACNTxSocket " << QThread::currentThreadId() << ": Bound to interface:" << multicastInterface().name();
}
Expand Down
79 changes: 47 additions & 32 deletions ui/preferencesdialog.ui
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@
<rect>
<x>0</x>
<y>0</y>
<width>639</width>
<height>452</height>
<width>653</width>
<height>491</height>
</rect>
</property>
<property name="sizePolicy">
Expand Down Expand Up @@ -256,52 +256,54 @@
<property name="title">
<string>Transmit Options</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout_6" stretch="1,0,0">
<item>
<widget class="QGroupBox" name="gbTransmitName">
<layout class="QGridLayout" name="gridLayout">
<item row="0" column="0">
<widget class="QLabel" name="label_6">
<property name="text">
<string>Default Source Name</string>
</property>
</widget>
</item>
<item row="2" column="0">
<widget class="QLabel" name="label_5">
<property name="text">
<string>Multicast TTL*</string>
</property>
</widget>
</item>
<item row="2" column="2">
<widget class="QSpinBox" name="sbMulticastTtl">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Expanding">
<sizepolicy hsizetype="MinimumExpanding" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="title">
<string>Default Source Name</string>
<property name="minimum">
<number>0</number>
</property>
<property name="maximum">
<number>255</number>
</property>
<layout class="QVBoxLayout" name="verticalLayout_5">
<item>
<widget class="QLineEdit" name="leDefaultSourceName">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Expanding">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="maxLength">
<number>63</number>
</property>
<property name="alignment">
<set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter</set>
</property>
</widget>
</item>
</layout>
</widget>
</item>
<item>
<widget class="QCheckBox" name="cbTxRateOverride">
<item row="0" column="1" colspan="2">
<widget class="QLineEdit" name="leDefaultSourceName">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Expanding">
<sizepolicy hsizetype="Expanding" vsizetype="Minimum">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>Allow rates to exceed E1.11 (E1.31:2016 6.6.1)*</string>
<property name="maxLength">
<number>63</number>
</property>
<property name="alignment">
<set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter</set>
</property>
</widget>
</item>
<item>
<item row="4" column="0" colspan="3">
<widget class="QGroupBox" name="gbTransmitTimeout">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Expanding">
Expand Down Expand Up @@ -437,6 +439,19 @@
</layout>
</widget>
</item>
<item row="1" column="0" colspan="3">
<widget class="QCheckBox" name="cbTxRateOverride">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Expanding">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>Allow rates to exceed E1.11 (E1.31:2016 6.6.1)*</string>
</property>
</widget>
</item>
</layout>
</widget>
</item>
Expand Down

0 comments on commit 3c81d31

Please sign in to comment.