mirror of
https://github.com/f4exb/sdrangel.git
synced 2024-11-17 05:41:56 -05:00
RTP support: fixed RTPSink (2) and use in NFM Demod
This commit is contained in:
parent
ec262caa33
commit
175c3ab61e
@ -82,12 +82,6 @@ NFMDemod::NFMDemod(DeviceSourceAPI *devieAPI) :
|
||||
m_audioNetSink = new AudioNetSink(this);
|
||||
m_audioNetSink->setDestination(m_settings.m_udpAddress, m_settings.m_udpPort);
|
||||
|
||||
if (m_audioNetSink->selectType(AudioNetSink::SinkRTP)) {
|
||||
qDebug("NFMDemod::NFMDemod: set audio sink to RTP mode");
|
||||
} else {
|
||||
qWarning("NFMDemod::NFMDemod: RTP support for audio sink not available. Fall back too UDP");
|
||||
}
|
||||
|
||||
m_channelizer = new DownChannelizer(this);
|
||||
m_threadedChannelizer = new ThreadedBasebandSampleSink(m_channelizer, this);
|
||||
m_deviceAPI->addThreadedSink(m_threadedChannelizer);
|
||||
@ -107,6 +101,11 @@ NFMDemod::~NFMDemod()
|
||||
delete m_channelizer;
|
||||
}
|
||||
|
||||
bool NFMDemod::isAudioNetSinkRTPCapable() const
|
||||
{
|
||||
return m_audioNetSink && m_audioNetSink->isRTPCapable();
|
||||
}
|
||||
|
||||
float arctan2(Real y, Real x)
|
||||
{
|
||||
Real coeff_1 = M_PI / 4;
|
||||
@ -491,6 +490,26 @@ void NFMDemod::applySettings(const NFMDemodSettings& settings, bool force)
|
||||
setSelectedCtcssIndex(settings.m_ctcssIndex);
|
||||
}
|
||||
|
||||
if ((settings.m_copyAudioUseRTP != m_settings.m_copyAudioUseRTP) || force)
|
||||
{
|
||||
if (settings.m_copyAudioUseRTP)
|
||||
{
|
||||
if (m_audioNetSink->selectType(AudioNetSink::SinkRTP)) {
|
||||
qDebug("NFMDemod::applySettings: set audio sink to RTP mode");
|
||||
} else {
|
||||
qWarning("NFMDemod::applySettings: RTP support for audio sink not available. Fall back too UDP");
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (m_audioNetSink->selectType(AudioNetSink::SinkUDP)) {
|
||||
qDebug("NFMDemod::applySettings: set audio sink to UDP mode");
|
||||
} else {
|
||||
qWarning("NFMDemod::applySettings: failed to set audio sink to UDP mode");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
m_settings = settings;
|
||||
}
|
||||
|
||||
@ -549,6 +568,9 @@ int NFMDemod::webapiSettingsPutPatch(
|
||||
if (channelSettingsKeys.contains("copyAudioToUDP")) {
|
||||
settings.m_copyAudioToUDP = response.getNfmDemodSettings()->getCopyAudioToUdp() != 0;
|
||||
}
|
||||
// if (channelSettingsKeys.contains("copyAudioUseRTP")) {
|
||||
// settings.m_copyAudioUseRTP = response.getNfmDemodSettings()->getCopyAudioUseRtp() != 0;
|
||||
// }
|
||||
if (channelSettingsKeys.contains("ctcssIndex")) {
|
||||
settings.m_ctcssIndex = response.getNfmDemodSettings()->getCtcssIndex();
|
||||
}
|
||||
@ -618,6 +640,7 @@ void NFMDemod::webapiFormatChannelSettings(SWGSDRangel::SWGChannelSettings& resp
|
||||
response.getNfmDemodSettings()->setAudioMute(settings.m_audioMute ? 1 : 0);
|
||||
response.getNfmDemodSettings()->setAudioSampleRate(settings.m_audioSampleRate);
|
||||
response.getNfmDemodSettings()->setCopyAudioToUdp(settings.m_copyAudioToUDP ? 1 : 0);
|
||||
// response.getNfmDemodSettings()->setCopyAudioUseRtp(settings.m_copyAudioUseRTP ? 1 : 0);
|
||||
response.getNfmDemodSettings()->setCtcssIndex(settings.m_ctcssIndex);
|
||||
response.getNfmDemodSettings()->setCtcssOn(settings.m_ctcssOn ? 1 : 0);
|
||||
response.getNfmDemodSettings()->setDeltaSquelch(settings.m_deltaSquelch ? 1 : 0);
|
||||
|
@ -159,6 +159,8 @@ public:
|
||||
m_magsqCount = 0;
|
||||
}
|
||||
|
||||
bool isAudioNetSinkRTPCapable() const;
|
||||
|
||||
static const QString m_channelIdURI;
|
||||
static const QString m_channelId;
|
||||
|
||||
|
@ -211,6 +211,12 @@ void NFMDemodGUI::on_copyAudioToUDP_toggled(bool checked)
|
||||
applySettings();
|
||||
}
|
||||
|
||||
void NFMDemodGUI::on_useRTP_toggled(bool checked)
|
||||
{
|
||||
m_settings.m_copyAudioUseRTP = checked;
|
||||
applySettings();
|
||||
}
|
||||
|
||||
void NFMDemodGUI::on_ctcss_currentIndexChanged(int index)
|
||||
{
|
||||
m_settings.m_ctcssIndex = index;
|
||||
@ -314,6 +320,7 @@ NFMDemodGUI::NFMDemodGUI(PluginAPI* pluginAPI, DeviceUISet *deviceUISet, Baseban
|
||||
|
||||
QChar delta = QChar(0x94, 0x03);
|
||||
ui->deltaSquelch->setText(delta);
|
||||
ui->useRTP->setEnabled(m_nfmDemod->isAudioNetSinkRTPCapable());
|
||||
|
||||
connect(getInputMessageQueue(), SIGNAL(messageEnqueued()), this, SLOT(handleInputMessages()));
|
||||
|
||||
@ -393,6 +400,10 @@ void NFMDemodGUI::displaySettings()
|
||||
|
||||
ui->ctcss->setCurrentIndex(m_settings.m_ctcssIndex);
|
||||
|
||||
if (m_nfmDemod->isAudioNetSinkRTPCapable()) {
|
||||
ui->useRTP->setChecked(m_settings.m_copyAudioUseRTP);
|
||||
}
|
||||
|
||||
blockApplySettings(false);
|
||||
}
|
||||
|
||||
|
@ -79,6 +79,7 @@ private slots:
|
||||
void on_ctcssOn_toggled(bool checked);
|
||||
void on_audioMute_toggled(bool checked);
|
||||
void on_copyAudioToUDP_toggled(bool checked);
|
||||
void on_useRTP_toggled(bool checked);
|
||||
void onWidgetRolled(QWidget* widget, bool rollDown);
|
||||
void onMenuDialogCalled(const QPoint& p);
|
||||
void handleInputMessages();
|
||||
|
@ -611,6 +611,19 @@
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="ButtonSwitch" name="useRTP">
|
||||
<property name="toolTip">
|
||||
<string>Use RTP protocol for sending audio via UDP</string>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>R</string>
|
||||
</property>
|
||||
<property name="checkable">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
</layout>
|
||||
|
@ -51,6 +51,7 @@ void NFMDemodSettings::resetToDefaults()
|
||||
m_ctcssIndex = 0;
|
||||
m_audioSampleRate = DSPEngine::instance()->getAudioSampleRate();
|
||||
m_copyAudioToUDP = false;
|
||||
m_copyAudioUseRTP = false;
|
||||
m_udpAddress = "127.0.0.1";
|
||||
m_udpPort = 9998;
|
||||
m_rgbColor = QColor(255, 0, 0).rgb();
|
||||
@ -77,6 +78,7 @@ QByteArray NFMDemodSettings::serialize() const
|
||||
}
|
||||
|
||||
s.writeString(14, m_title);
|
||||
s.writeBool(15, m_copyAudioUseRTP);
|
||||
|
||||
return s.final();
|
||||
}
|
||||
@ -120,6 +122,7 @@ bool NFMDemodSettings::deserialize(const QByteArray& data)
|
||||
d.readS32(11, &m_squelchGate, 5);
|
||||
d.readBool(12, &m_deltaSquelch, false);
|
||||
d.readString(14, &m_title, "NFM Demodulator");
|
||||
d.readBool(15, &m_copyAudioUseRTP, false);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
@ -40,6 +40,7 @@ struct NFMDemodSettings
|
||||
int m_ctcssIndex;
|
||||
uint32_t m_audioSampleRate;
|
||||
bool m_copyAudioToUDP;
|
||||
bool m_copyAudioUseRTP;
|
||||
QString m_udpAddress;
|
||||
uint16_t m_udpPort;
|
||||
quint32 m_rgbColor;
|
||||
|
@ -56,6 +56,15 @@ AudioNetSink::~AudioNetSink()
|
||||
#endif
|
||||
}
|
||||
|
||||
bool AudioNetSink::isRTPCapable() const
|
||||
{
|
||||
#ifdef HAS_JRTPLIB
|
||||
return m_rtpBufferAudio->isValid();
|
||||
#else
|
||||
return false;
|
||||
#endif
|
||||
}
|
||||
|
||||
bool AudioNetSink::selectType(SinkType type)
|
||||
{
|
||||
if (type == SinkUDP)
|
||||
|
@ -43,6 +43,7 @@ public:
|
||||
void write(qint16 sample);
|
||||
void write(const AudioSample& sample);
|
||||
|
||||
bool isRTPCapable() const;
|
||||
bool selectType(SinkType type);
|
||||
|
||||
static const int m_udpBlockSize;
|
||||
|
@ -69,13 +69,11 @@ RTPSink::RTPSink(const QString& address, uint16_t port, PayloadType payloadType)
|
||||
RTPSink::~RTPSink()
|
||||
{
|
||||
jrtplib::RTPTime delay = jrtplib::RTPTime(10.0);
|
||||
m_rtpSession.sDestroy(delay, "Time's up", 9);
|
||||
m_rtpSession.BYEDestroy(delay, "Time's up", 9);
|
||||
|
||||
if (m_byteBuffer) {
|
||||
delete[] m_byteBuffer;
|
||||
}
|
||||
|
||||
close(m_rtpsock);
|
||||
}
|
||||
|
||||
void RTPSink::setPayloadType(PayloadType payloadType)
|
||||
|
@ -32,6 +32,8 @@ NFMDemodSettings:
|
||||
type: integer
|
||||
copyAudioToUDP:
|
||||
type: integer
|
||||
copyAudioUseRTP:
|
||||
type: integer
|
||||
udpAddress:
|
||||
type: string
|
||||
udpPort:
|
||||
|
Loading…
Reference in New Issue
Block a user