1
0
mirror of https://github.com/f4exb/sdrangel.git synced 2024-11-17 13:51:47 -05:00

RTP fixes

This commit is contained in:
f4exb 2018-03-27 09:04:10 +02:00
parent e64ed09308
commit ebf3b1fc4b
10 changed files with 34 additions and 25 deletions

View File

@ -65,7 +65,7 @@ AMDemod::AMDemod(DeviceSourceAPI *deviceAPI) :
DSPEngine::instance()->getAudioDeviceManager()->addAudioSink(&m_audioFifo, getInputMessageQueue());
m_audioSampleRate = DSPEngine::instance()->getAudioDeviceManager()->getOutputSampleRate();
m_audioNetSink = new AudioNetSink(0, false, false); // parent thread allocated dynamically
m_audioNetSink = new AudioNetSink(0); // parent thread allocated dynamically - no RTP
m_audioNetSink->setDestination(m_settings.m_udpAddress, m_settings.m_udpPort);
applyChannelSettings(m_inputSampleRate, m_inputFrequencyOffset, true);

View File

@ -42,7 +42,6 @@
class DeviceSourceAPI;
class ThreadedBasebandSampleSink;
class DownChannelizer;
class AudioNetSink;
class BFMDemod : public BasebandSampleSink, public ChannelSinkAPI {
public:

View File

@ -81,7 +81,7 @@ NFMDemod::NFMDemod(DeviceSourceAPI *devieAPI) :
m_afSquelch.setCoefficients(24, 600, 48000.0, 200, 0); // 0.5ms test period, 300ms average span, 48kS/s SR, 100ms attack, no decay
DSPEngine::instance()->getAudioDeviceManager()->addAudioSink(&m_audioFifo, getInputMessageQueue());
m_audioNetSink = new AudioNetSink(0); // parent thread allocated dynamically
m_audioNetSink = new AudioNetSink(0); // parent thread allocated dynamically - no RTP
m_audioNetSink->setDestination(m_settings.m_udpAddress, m_settings.m_udpPort);
applyChannelSettings(m_inputSampleRate, m_inputFrequencyOffset, true);

View File

@ -66,7 +66,9 @@ SSBDemod::SSBDemod(DeviceSourceAPI *deviceAPI) :
m_spanLog2 = 3;
m_inputSampleRate = 48000;
m_inputFrequencyOffset = 0;
m_audioSampleRate = DSPEngine::instance()->getDefaultAudioSampleRate();
DSPEngine::instance()->getAudioDeviceManager()->addAudioSink(&m_audioFifo, getInputMessageQueue());
m_audioSampleRate = DSPEngine::instance()->getAudioDeviceManager()->getOutputSampleRate();
m_audioBuffer.resize(1<<14);
m_audioBufferFill = 0;
@ -86,7 +88,7 @@ SSBDemod::SSBDemod(DeviceSourceAPI *deviceAPI) :
DSBFilter = new fftfilt((2.0f * m_Bandwidth) / m_audioSampleRate, 2 * ssbFftLen);
DSPEngine::instance()->getAudioDeviceManager()->addAudioSink(&m_audioFifo, getInputMessageQueue());
m_audioNetSink = new AudioNetSink(0); // parent thread allocated dynamically
m_audioNetSink = new AudioNetSink(0); // parent thread allocated dynamically - no RTP
m_audioNetSink->setDestination(m_settings.m_udpAddress, m_settings.m_udpPort);
applyChannelSettings(m_inputSampleRate, m_inputFrequencyOffset, true);

View File

@ -60,7 +60,7 @@ WFMDemod::WFMDemod(DeviceSourceAPI* deviceAPI) :
m_audioBufferFill = 0;
DSPEngine::instance()->getAudioDeviceManager()->addAudioSink(&m_audioFifo, getInputMessageQueue());
m_audioNetSink = new AudioNetSink(0); // parent thread allocated dynamically
m_audioNetSink = new AudioNetSink(0); // parent thread allocated dynamically - no RTP
m_audioNetSink->setDestination(m_settings.m_udpAddress, m_settings.m_udpPort);
applyChannelSettings(m_inputSampleRate, m_inputFrequencyOffset, true);

View File

@ -23,17 +23,23 @@
const int AudioNetSink::m_udpBlockSize = 512;
AudioNetSink::AudioNetSink(QObject *parent, bool stereo, bool useRTP) :
AudioNetSink::AudioNetSink(QObject *parent) :
m_type(SinkUDP),
m_rtpBufferAudio(0),
m_bufferIndex(0),
m_port(9998)
{
m_udpSocket = new QUdpSocket(parent);
if (useRTP) {
m_rtpBufferAudio = new RTPSink(m_udpSocket, stereo);
}
AudioNetSink::AudioNetSink(QObject *parent, int sampleRate, bool stereo) :
m_type(SinkUDP),
m_rtpBufferAudio(0),
m_bufferIndex(0),
m_port(9998)
{
m_udpSocket = new QUdpSocket(parent);
m_rtpBufferAudio = new RTPSink(m_udpSocket, sampleRate, stereo);
}
AudioNetSink::~AudioNetSink()

View File

@ -37,7 +37,8 @@ public:
SinkRTP
} SinkType;
AudioNetSink(QObject *parent, bool stereo = false, bool useRTP = true);
AudioNetSink(QObject *parent); //!< without RTP
AudioNetSink(QObject *parent, int sampleRate, bool stereo); //!< with RTP
~AudioNetSink();
void setDestination(const QString& address, uint16_t port);

View File

@ -111,7 +111,7 @@ bool AudioOutput::start(int device, int rate)
}
m_audioOutput = new QAudioOutput(devInfo, m_audioFormat);
m_audioNetSink = new AudioNetSink(0);
m_audioNetSink = new AudioNetSink(0, m_audioFormat.sampleRate(), false);
QIODevice::open(QIODevice::ReadOnly);

View File

@ -19,9 +19,9 @@
#include "dsp/dsptypes.h"
#include <algorithm>
RTPSink::RTPSink(QUdpSocket *udpSocket, bool stereo) :
RTPSink::RTPSink(QUdpSocket *udpSocket, int sampleRate, bool stereo) :
m_payloadType(stereo ? RTPSink::PayloadL16Stereo : RTPSink::PayloadL16Mono),
m_sampleRate(48000),
m_sampleRate(sampleRate),
m_sampleBytes(0),
m_packetSamples(0),
m_bufferSize(0),
@ -76,7 +76,7 @@ void RTPSink::setPayloadInformation(PayloadType payloadType, int sampleRate)
uint32_t timestampinc;
QMutexLocker locker(&m_mutex);
qDebug("RTPSink::setPayloadType: %d sampleRate: %d", payloadType, sampleRate);
qDebug("RTPSink::setPayloadInformation: %d sampleRate: %d", payloadType, sampleRate);
switch (payloadType)
{
@ -107,9 +107,9 @@ void RTPSink::setPayloadInformation(PayloadType payloadType, int sampleRate)
int status = m_rtpSession.SetTimestampUnit(1.0 / (double) m_sampleRate);
if (status < 0) {
qCritical("RTPSink::setPayloadType: cannot set timestamp unit: %s", qrtplib::RTPGetErrorString(status).c_str());
qCritical("RTPSink::setPayloadInformation: cannot set timestamp unit: %s", qrtplib::RTPGetErrorString(status).c_str());
} else {
qDebug("RTPSink::setPayloadType: timestamp unit set to %f: %s",
qDebug("RTPSink::setPayloadInformation: timestamp unit set to %f: %s",
1.0 / (double) m_sampleRate,
qrtplib::RTPGetErrorString(status).c_str());
}
@ -117,25 +117,26 @@ void RTPSink::setPayloadInformation(PayloadType payloadType, int sampleRate)
status = m_rtpSession.SetDefaultMark(false);
if (status < 0) {
qCritical("RTPSink::setPayloadType: cannot set default mark: %s", qrtplib::RTPGetErrorString(status).c_str());
qCritical("RTPSink::setPayloadInformation: cannot set default mark: %s", qrtplib::RTPGetErrorString(status).c_str());
} else {
qDebug("RTPSink::setPayloadType: set default mark to false: %s", qrtplib::RTPGetErrorString(status).c_str());
qDebug("RTPSink::setPayloadInformation: set default mark to false: %s", qrtplib::RTPGetErrorString(status).c_str());
}
status = m_rtpSession.SetDefaultTimestampIncrement(timestampinc);
if (status < 0) {
qCritical("RTPSink::setPayloadType: cannot set default timestamp increment: %s", qrtplib::RTPGetErrorString(status).c_str());
qCritical("RTPSink::setPayloadInformation: cannot set default timestamp increment: %s", qrtplib::RTPGetErrorString(status).c_str());
} else {
qDebug("RTPSink::setPayloadType: set default timestamp increment to %d: %s", timestampinc, qrtplib::RTPGetErrorString(status).c_str());
qDebug("RTPSink::setPayloadInformation: set default timestamp increment to %d: %s", timestampinc, qrtplib::RTPGetErrorString(status).c_str());
}
status = m_rtpSession.SetMaximumPacketSize(m_bufferSize+40);
int maximumPacketSize = std::max(m_bufferSize+40, RTP_MINPACKETSIZE);
status = m_rtpSession.SetMaximumPacketSize(maximumPacketSize);
if (status < 0) {
qCritical("RTPSink::setPayloadType: cannot set maximum packet size: %s", qrtplib::RTPGetErrorString(status).c_str());
qCritical("RTPSink::setPayloadInformation: cannot set maximum packet size: %s", qrtplib::RTPGetErrorString(status).c_str());
} else {
qDebug("RTPSink::setPayloadType: set maximum packet size to %d bytes: %s", m_bufferSize+40, qrtplib::RTPGetErrorString(status).c_str());
qDebug("RTPSink::setPayloadInformation: set maximum packet size to %d bytes: %s", maximumPacketSize, qrtplib::RTPGetErrorString(status).c_str());
}
}

View File

@ -44,7 +44,7 @@ public:
PayloadL16Stereo,
} PayloadType;
RTPSink(QUdpSocket *udpSocket, bool stereo);
RTPSink(QUdpSocket *udpSocket, int sampleRate, bool stereo);
~RTPSink();
bool isValid() const { return m_valid; }