mirror of
https://github.com/f4exb/sdrangel.git
synced 2025-04-01 09:08:51 -04:00
Copy audio to UDP/RTP: added a 8 bit linear option
This commit is contained in:
parent
1de6ea4e60
commit
ef564cdb4f
@ -119,6 +119,9 @@ void AudioNetSink::setParameters(Codec codec, bool stereo, int sampleRate)
|
||||
m_audioCompressor.fillULaw();
|
||||
m_rtpBufferAudio->setPayloadInformation(RTPSink::PayloadPCMU8, sampleRate);
|
||||
break;
|
||||
case CodecL8:
|
||||
m_rtpBufferAudio->setPayloadInformation(RTPSink::PayloadL8, sampleRate);
|
||||
break;
|
||||
case CodecL16: // actually no codec
|
||||
default:
|
||||
m_rtpBufferAudio->setPayloadInformation(stereo ? RTPSink::PayloadL16Stereo : RTPSink::PayloadL16Mono, sampleRate);
|
||||
@ -148,6 +151,13 @@ void AudioNetSink::write(qint16 sample)
|
||||
m_bufferIndex += sizeof(qint8);
|
||||
}
|
||||
break;
|
||||
case CodecL8:
|
||||
{
|
||||
qint8 *p = (qint8*) &m_data[m_bufferIndex];
|
||||
*p = sample / 256;
|
||||
m_bufferIndex += sizeof(qint8);
|
||||
}
|
||||
break;
|
||||
case CodecL16:
|
||||
default:
|
||||
{
|
||||
@ -170,6 +180,12 @@ void AudioNetSink::write(qint16 sample)
|
||||
m_rtpBufferAudio->write((uint8_t *) &p);
|
||||
}
|
||||
break;
|
||||
case CodecL8:
|
||||
{
|
||||
qint8 p = sample / 256;
|
||||
m_rtpBufferAudio->write((uint8_t *) &p);
|
||||
}
|
||||
break;
|
||||
case CodecL16:
|
||||
default:
|
||||
m_rtpBufferAudio->write((uint8_t *) &sample);
|
||||
|
@ -40,9 +40,10 @@ public:
|
||||
|
||||
typedef enum
|
||||
{
|
||||
CodecL16,
|
||||
CodecPCMA,
|
||||
CodecPCMU
|
||||
CodecL16, //!< Linear 16 bit samples (no formatting)
|
||||
CodecL8, //!< Linear 8 bit samples
|
||||
CodecPCMA, //!< PCM A-law 8 bit samples
|
||||
CodecPCMU //!< PCM Mu-law 8 bit samples
|
||||
} Codec;
|
||||
|
||||
AudioNetSink(QObject *parent); //!< without RTP
|
||||
|
@ -43,9 +43,10 @@ public:
|
||||
|
||||
enum UDPChannelCodec
|
||||
{
|
||||
UDPCodecL16, //!< Linear 16 bit (no codec)
|
||||
UDPCodecALaw,
|
||||
UDPCodecULaw
|
||||
UDPCodecL16, //!< Linear 16 bit (no codec)
|
||||
UDPCodecL8, //!< Linear 8 bit
|
||||
UDPCodecALaw, //!< PCM A-law 8 bit
|
||||
UDPCodecULaw //!< PCM Mu-law 8 bit
|
||||
};
|
||||
|
||||
AudioOutput();
|
||||
|
@ -84,26 +84,32 @@ void RTPSink::setPayloadInformation(PayloadType payloadType, int sampleRate)
|
||||
m_sampleBytes = 1;
|
||||
m_rtpSession.SetDefaultPayloadType(8);
|
||||
m_packetSamples = m_sampleRate / 50; // 20ms packet samples
|
||||
timestampinc = m_sampleRate / 50; // 8k -> 160 packets in 20ms
|
||||
timestampinc = m_sampleRate / 50; // 1 channel
|
||||
break;
|
||||
case PayloadPCMU8:
|
||||
m_sampleBytes = 1;
|
||||
m_rtpSession.SetDefaultPayloadType(0);
|
||||
m_packetSamples = m_sampleRate / 50; // 20ms packet samples
|
||||
timestampinc = m_sampleRate / 50; // 8k -> 160 packets in 20ms
|
||||
timestampinc = m_sampleRate / 50; // 1 channel
|
||||
break;
|
||||
case PayloadL8:
|
||||
m_sampleBytes = 1;
|
||||
m_rtpSession.SetDefaultPayloadType(96);
|
||||
m_packetSamples = m_sampleRate / 50; // 20ms packet samples
|
||||
timestampinc = m_sampleRate / 50; // 1 channel
|
||||
break;
|
||||
case PayloadL16Stereo:
|
||||
m_sampleBytes = 4;
|
||||
m_rtpSession.SetDefaultPayloadType(96);
|
||||
m_packetSamples = m_sampleRate / 50; // 20ms packet samples
|
||||
timestampinc = m_sampleRate / 100;
|
||||
timestampinc = m_sampleRate / 100; // 2 channels
|
||||
break;
|
||||
case PayloadL16Mono:
|
||||
default:
|
||||
m_sampleBytes = 2;
|
||||
m_rtpSession.SetDefaultPayloadType(96);
|
||||
m_packetSamples = m_sampleRate / 50; // 20ms packet samples
|
||||
timestampinc = m_sampleRate / 50;
|
||||
timestampinc = m_sampleRate / 50; // 1 channel
|
||||
break;
|
||||
}
|
||||
|
||||
@ -220,7 +226,11 @@ void RTPSink::write(const uint8_t *sampleByte)
|
||||
qCritical("RTPSink::write: cannot write packet: %s", qrtplib::RTPGetErrorString(status).c_str());
|
||||
}
|
||||
|
||||
writeNetBuf(&m_byteBuffer[0], sampleByte, elemLength(m_payloadType), m_sampleBytes, m_endianReverse);
|
||||
writeNetBuf(&m_byteBuffer[0],
|
||||
sampleByte,
|
||||
elemLength(m_payloadType),
|
||||
m_sampleBytes,
|
||||
m_endianReverse);
|
||||
m_sampleBufferIndex = 1;
|
||||
}
|
||||
}
|
||||
|
@ -42,6 +42,7 @@ public:
|
||||
{
|
||||
PayloadL16Mono,
|
||||
PayloadL16Stereo,
|
||||
PayloadL8,
|
||||
PayloadPCMA8,
|
||||
PayloadPCMU8
|
||||
} PayloadType;
|
||||
|
@ -253,6 +253,11 @@
|
||||
<string>L16</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>L8</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>PCMA/8k</string>
|
||||
@ -540,6 +545,39 @@
|
||||
</tabstops>
|
||||
<resources>
|
||||
<include location="../resources/res.qrc"/>
|
||||
<include location="../resources/res.qrc"/>
|
||||
<include location="../resources/res.qrc"/>
|
||||
<include location="../resources/res.qrc"/>
|
||||
<include location="../resources/res.qrc"/>
|
||||
<include location="../resources/res.qrc"/>
|
||||
<include location="../resources/res.qrc"/>
|
||||
<include location="../resources/res.qrc"/>
|
||||
<include location="../resources/res.qrc"/>
|
||||
<include location="../resources/res.qrc"/>
|
||||
<include location="../resources/res.qrc"/>
|
||||
<include location="../resources/res.qrc"/>
|
||||
<include location="../resources/res.qrc"/>
|
||||
<include location="../resources/res.qrc"/>
|
||||
<include location="../resources/res.qrc"/>
|
||||
<include location="../resources/res.qrc"/>
|
||||
<include location="../resources/res.qrc"/>
|
||||
<include location="../resources/res.qrc"/>
|
||||
<include location="../resources/res.qrc"/>
|
||||
<include location="../resources/res.qrc"/>
|
||||
<include location="../resources/res.qrc"/>
|
||||
<include location="../resources/res.qrc"/>
|
||||
<include location="../resources/res.qrc"/>
|
||||
<include location="../resources/res.qrc"/>
|
||||
<include location="../resources/res.qrc"/>
|
||||
<include location="../resources/res.qrc"/>
|
||||
<include location="../resources/res.qrc"/>
|
||||
<include location="../resources/res.qrc"/>
|
||||
<include location="../resources/res.qrc"/>
|
||||
<include location="../resources/res.qrc"/>
|
||||
<include location="../resources/res.qrc"/>
|
||||
<include location="../resources/res.qrc"/>
|
||||
<include location="../resources/res.qrc"/>
|
||||
<include location="../resources/res.qrc"/>
|
||||
</resources>
|
||||
<connections>
|
||||
<connection>
|
||||
|
Loading…
Reference in New Issue
Block a user