Copy audio to UDP/RTP: Opus implementation (3)

pull/295/head
f4exb 2019-02-18 22:06:43 +01:00
rodzic 4c85516741
commit 297dcce2d3
3 zmienionych plików z 3 dodań i 71 usunięć

Wyświetl plik

@ -269,19 +269,6 @@ void AudioNetSink::write(qint16 isample)
}
}
break;
case CodecOpus:
{
if (m_codecInputIndex == m_codecInputSize)
{
int nbBytes = m_opus.encode(m_codecInputSize, m_opusIn, (uint8_t *) m_data);
nbBytes = nbBytes > m_udpBlockSize ? m_udpBlockSize : nbBytes;
m_udpSocket->writeDatagram((const char*) m_data, (qint64 ) nbBytes, m_address, m_port);
m_codecInputIndex = 0;
}
m_opusIn[m_codecInputIndex++] = sample;
}
break;
case CodecL16:
default:
{
@ -327,25 +314,6 @@ void AudioNetSink::write(qint16 isample)
m_bufferIndex += 1;
}
break;
case CodecOpus:
{
if (m_codecInputIndex == m_codecInputSize)
{
int nbBytes = m_opus.encode(m_codecInputSize, m_opusIn, (uint8_t *) m_data);
if (nbBytes != AudioOpus::m_bitrate/400) { // 8 bits for 1/50s (20ms)
qWarning("AudioNetSink::write: CodecOpus mono: unexpected output frame size: %d bytes", nbBytes);
}
m_bufferIndex = 0;
m_codecInputIndex = 0;
}
if (m_codecInputIndex % m_codecRatio == 0) {
m_rtpBufferAudio->write((uint8_t *) &m_data[m_bufferIndex++]);
}
m_opusIn[m_codecInputIndex++] = sample;
}
break;
case CodecL16:
default:
m_rtpBufferAudio->write((uint8_t *) &sample);
@ -391,21 +359,6 @@ void AudioNetSink::write(qint16 ilSample, qint16 irSample)
case CodecPCMU:
case CodecG722:
break; // mono modes - do nothing
case CodecOpus:
{
if (m_codecInputIndex == m_codecInputSize)
{
int nbBytes = m_opus.encode(m_codecInputSize, m_opusIn, (uint8_t *) m_data);
nbBytes = nbBytes > m_udpBlockSize ? m_udpBlockSize : nbBytes;
m_udpSocket->writeDatagram((const char*) m_data, (qint64 ) nbBytes, m_address, m_port);
m_codecInputIndex = 0;
}
m_opusIn[2*m_codecInputIndex] = lSample;
m_opusIn[2*m_codecInputIndex+1] = rSample;
m_codecInputIndex++;
}
break;
case CodecL8:
{
qint8 *p = (qint8*) &m_data[m_bufferIndex];
@ -437,27 +390,6 @@ void AudioNetSink::write(qint16 ilSample, qint16 irSample)
case CodecPCMU:
case CodecG722:
break; // mono modes - do nothing
case CodecOpus:
{
if (m_codecInputIndex == m_codecInputSize)
{
int nbBytes = m_opus.encode(m_codecInputSize, m_opusIn, (uint8_t *) m_data);
if (nbBytes != AudioOpus::m_bitrate/400) { // 8 bits for 1/50s (20ms)
qWarning("AudioNetSink::write: CodecOpus stereo: unexpected output frame size: %d bytes", nbBytes);
}
m_bufferIndex = 0;
m_codecInputIndex = 0;
}
if (m_codecInputIndex % m_codecRatio == 0) {
m_rtpBufferAudio->write((uint8_t *) &m_data[m_bufferIndex++]);
}
m_opusIn[2*m_codecInputIndex] = lSample;
m_opusIn[2*m_codecInputIndex+1] = rSample;
m_codecInputIndex++;
}
break;
case CodecL8:
{
qint8 pl = lSample / 256;

Wyświetl plik

@ -107,8 +107,8 @@ void RTPSink::setPayloadInformation(PayloadType payloadType, int sampleRate)
case PayloadG722:
m_sampleBytes = 1;
m_rtpSession.SetDefaultPayloadType(9);
m_packetSamples = m_sampleRate / 50; // 20ms packet samples
timestampinc = m_sampleRate / 50; // 1 channel
m_packetSamples = 160; // Fixed 8 kB/s 20ms packet samples
timestampinc = 160; // 1 channel
break;
case PayloadOpus:
m_sampleBytes = 1;

Wyświetl plik

@ -353,7 +353,7 @@ void AudioDialogX::check()
else if (m_outputDeviceInfo.udpChannelCodec == AudioOutput::UDPCodecOpus)
{
int effectiveSampleRate = m_outputDeviceInfo.sampleRate/decimationFactor;
if ((effectiveSampleRate != 48000) || (effectiveSampleRate != 24000) || (effectiveSampleRate != 16000) || (effectiveSampleRate != 12000)) {
if ((effectiveSampleRate != 48000) && (effectiveSampleRate != 24000) && (effectiveSampleRate != 16000) && (effectiveSampleRate != 12000)) {
QMessageBox::information(this, tr("Message"), tr("Opus takes only 48, 24, 16 or 12 kHz sample rates"));
}
}