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