1
0
mirror of https://github.com/f4exb/sdrangel.git synced 2024-12-23 01:55:48 -05:00

Copy audio to UDP/RTP: Opus environment setting

This commit is contained in:
f4exb 2019-02-18 02:30:43 +01:00
parent ef27776a48
commit c1fb4bb46c
10 changed files with 43 additions and 11 deletions

4
debian/control vendored
View File

@ -10,13 +10,13 @@ Homepage: https://github.com/f4exb/sdrangel
Package: sdrangel
Architecture: any
Depends: libc6, libasound2, libfftw3-single3, libgcc1, libgl1-mesa-glx, libqt5core5a, libqt5gui5, libqt5multimedia5, libqt5network5, libqt5opengl5, libqt5widgets5, libqt5multimedia5-plugins, libstdc++6, libusb-1.0-0, libopencv-dev, pulseaudio, libxml2, ffmpeg, libavcodec-dev, libavformat-dev, ${shlibs:Depends}, ${misc:Depends}
Depends: libc6, libasound2, libfftw3-single3, libgcc1, libgl1-mesa-glx, libqt5core5a, libqt5gui5, libqt5multimedia5, libqt5network5, libqt5opengl5, libqt5widgets5, libqt5multimedia5-plugins, libstdc++6, libusb-1.0-0, libopencv-dev, pulseaudio, libxml2, ffmpeg, libavcodec-dev, libavformat-dev, libopus-dev, ${shlibs:Depends}, ${misc:Depends}
Description: SDR/Analyzer/Generator front-end for various hardware
SDR/Analyzer/Generator front-end for Airspy, BladeRF, HackRF, RTL-SDR, FunCube, LimeSDR, PlutoSDR.
Also File source and sink for I/Q samples, network I/Q sources with remote instance.
Based on Qt5 framework and OpenGL for the spectrum and scope rendering.
Builds on Linux, Windows and Mac O/S
Reception modes supported:
Reception modes supported:
Analog: AM, ATV, NFM, WFM, SSB, broadcast FM
Digital: D-Star, Yaesu SF, DMR, dPMR, LoRa
Analyzer: Generic channel

View File

@ -136,6 +136,9 @@ void AudioNetSink::setParameters(Codec codec, bool stereo, int sampleRate)
case CodecG722:
m_rtpBufferAudio->setPayloadInformation(RTPSink::PayloadG722, sampleRate/2);
break;
case CodecOpus:
m_rtpBufferAudio->setPayloadInformation(RTPSink::PayloadOpus, sampleRate);
break;
case CodecL16: // actually no codec
default:
m_rtpBufferAudio->setPayloadInformation(stereo ? RTPSink::PayloadL16Stereo : RTPSink::PayloadL16Mono, sampleRate);
@ -165,6 +168,7 @@ void AudioNetSink::setDecimationFilters()
case CodecG722:
m_audioFilter.setDecimFilters(m_sampleRate, decimatedSampleRate, 7000.0, 50.0);
break;
case CodecOpus:
case CodecL8:
case CodecL16:
default:

View File

@ -46,7 +46,8 @@ public:
CodecL8, //!< Linear 8 bit samples
CodecPCMA, //!< PCM A-law 8 bit samples
CodecPCMU, //!< PCM Mu-law 8 bit samples
CodecG722 //!< G722 compressed 8 bit samples 16kS/s in 8kS/s out
CodecG722, //!< G722 compressed 8 bit samples 16kS/s in 8kS/s out
CodecOpus //!< Opus compressed 8 bit samples at 64kbits/s (8kS/s out). Various input sample rates
} Codec;
AudioNetSink(QObject *parent); //!< without RTP
@ -70,6 +71,7 @@ public:
static const int m_udpBlockSize;
static const int m_dataBlockSize = 65536; // room for G722 conversion (64000 = 12800*5 largest to date)
static const int m_g722BlockSize = 12800; // number of resulting G722 bytes (80*20ms frames)
static const int m_opusBlockSize = 960*4; // provision for 20ms of 2 int16 channels at 48 kS/s
protected:
void setDecimationFilters();

View File

@ -47,7 +47,8 @@ public:
UDPCodecL8, //!< Linear 8 bit
UDPCodecALaw, //!< PCM A-law 8 bit
UDPCodecULaw, //!< PCM Mu-law 8 bit
UDPCodecG722 //!< G722 compression
UDPCodecG722, //!< G722 compression
UDPCodecOpus //!< Opus compression
};
AudioOutput();

View File

@ -110,6 +110,12 @@ void RTPSink::setPayloadInformation(PayloadType payloadType, int sampleRate)
m_packetSamples = m_sampleRate / 50; // 20ms packet samples
timestampinc = m_sampleRate / 50; // 1 channel
break;
case PayloadOpus:
m_sampleBytes = 1;
m_rtpSession.SetDefaultPayloadType(101);
m_packetSamples = 160; // Fixed 20ms @ 64 kbits/s packet samples
timestampinc = 160; // 1 channel
break;
case PayloadL16Mono:
default:
m_sampleBytes = 2;

View File

@ -45,7 +45,8 @@ public:
PayloadL8,
PayloadPCMA8,
PayloadPCMU8,
PayloadG722
PayloadG722,
PayloadOpus
} PayloadType;
RTPSink(QUdpSocket *udpSocket, int sampleRate, bool stereo);

View File

@ -67,10 +67,11 @@ This is the codec applied before sending the stream via UDP. The following are a
- `PCMA`: A-law 8 bit PCM (requires 8000 Hz sample rate mono)
- `PCMU`: Mu-law 8 bit PCM (requires 8000 Hz sample rate mono)
- `G722`: G722 64 kbit/s (requires 16000 Hz sample rate mono)
- `OPUS` : Opus 64 kbit/s
<h3>1.10 SDP string</h3>
This is the SDP string representatiopn of the stream sent via UDP (RTP). In SDP files it is used on the `a=rtpmap`line (See 1.14). It can be used to check the effect of settings 1.5, 1.8 and 1.9.
This is the SDP string representatiopn of the stream sent via UDP (RTP). In SDP files it is used on the `a=rtpmap`line (See 1.14). It can be used to check the effect of settings 1.5, 1.8 and 1.9.
<h3>1.11 UDP address</h3>
@ -88,18 +89,19 @@ Use this button to activate or de-activate the copy of the audio stream to UDP s
Check this box to activate the RTP protocol over UDP. RTP parameters are as follows:
- Payload type:
- Payload type:
- codec `L16`, `L8`: 96
- codec `OPUS`: 101
- codec `PCMA`: 8
- codec `PCMU`: 0
- codec `G722`: 9
- Sample rate: the resulting stream sample rate after decimation and possible compression:
- codec `PCMA`, `PCMU`: must be 8000 S/s
- codec `G722`: must be 8000 S/s (16000 S/s input before compression)
- codec `G722`: must be 8000 S/s (16000 S/s input before compression)
- Sample format:
- codec `L16`: 16 bit integer signed (S16LE)
- codec `L8`, `PCMA`, `PCMU`: 8 bit integer signed (S8)
- codec `G722`: 8 bit unsigned integer. Note that this is the stream compressed to 64 kbits/s.
- codec `G722`, `OPUS`: 8 bit unsigned integer. Note that this is the stream compressed to 64 kbits/s.
- Channels: 1 for mono (Left, Right and Mixed copy channels mode); 2 for stereo (Stereo copy channels mode)
- Address and port: destination address and port (local on the client machine)
@ -127,6 +129,14 @@ m=audio 9998 RTP/AVP 9
a=rtpmap:9 G722/8000/1
```
For Opus mono:
```
c=IN IP4 192.168.0.34
m=audio 9998 RTP/AVP 101
a=rtpmap:101 opus/48000/1
```
&#9758; Note that on Android clients VLC has trouble working with the RTP stream (choppy audio, hanging unexpectedly...) therefore [MX player](https://play.google.com/store/apps/details?id=com.mxtech.videoplayer.ad&hl=en) is recommended.
&#9758; With PCMA and PCMU and more recently G722 codecs it is possible to listen to the RTP stream directly in the browser using a [Janus WebRTC server](https://janus.conf.meetecho.com/). Please refer to the Wiki page "Networking audio" for detailed instructions.

View File

@ -315,6 +315,9 @@ void AudioDialogX::updateOutputSDPString()
case AudioOutput::UDPCodecL8:
format = "L8";
break;
case AudioOutput::UDPCodecOpus:
format = "opus";
break;
case AudioOutput::UDPCodecL16:
default:
format = "L16";

View File

@ -260,6 +260,11 @@
<string>G722</string>
</property>
</item>
<item>
<property name="text">
<string>Opus</string>
</property>
</item>
</widget>
</item>
<item>

View File

@ -46,7 +46,7 @@ def getInputOptions():
parser.add_option("--audio-address", dest="audio_address", help="Audio: UDP destination address", metavar="IP_ADDRESS", type="string")
parser.add_option("--audio-port", dest="audio_port", help="Audio: UDP destination port", metavar="IP_PORT", type="int")
parser.add_option("--audio-channels", dest="audio_channels", help="Audio: UDP mode (0: L only 1: R only 2: L+R mono 3: LR stereo)", metavar="ENUM_INT", type="int")
parser.add_option("--audio-codec", dest="audio_codec", help="Audio: codec to use for UDP (0: L16, 1: L8, 2: PCMA, 3: PCMU, 4: G722)", metavar="ENUM_INT", type="int")
parser.add_option("--audio-codec", dest="audio_codec", help="Audio: codec to use for UDP (0: L16, 1: L8, 2: PCMA, 3: PCMU, 4: G722, 5: Opus)", metavar="ENUM_INT", type="int")
parser.add_option("--audio-decim", dest="audio_decim", help="Audio. decimation to apply for UDP (1 to 6)", metavar="INT", type="int")
parser.add_option("--baud-rate", dest="baud_rate", help="DSD: baud rate in Baud", metavar="BAUD", type="int", default=4800)
parser.add_option("--fm-dev", dest="fm_deviation", help="DSD: expected FM deviation", metavar="FREQ", type="int", default=5400)