SDRAngel  4.11.5
Developer docs for <a href="https://github.com/f4exb/sdrangel">SDRangel<\a>, an Open Source Qt5 / OpenGL 3.0+ SDR and signal analyzer frontend to various hardware.
audionetsink.h
Go to the documentation of this file.
1 // Copyright (C) 2018 F4EXB //
3 // written by Edouard Griffiths //
4 // //
5 // This program is free software; you can redistribute it and/or modify //
6 // it under the terms of the GNU General Public License as published by //
7 // the Free Software Foundation as version 3 of the License, or //
8 // (at your option) any later version. //
9 // //
10 // This program is distributed in the hope that it will be useful, //
11 // but WITHOUT ANY WARRANTY; without even the implied warranty of //
12 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the //
13 // GNU General Public License V3 for more details. //
14 // //
15 // You should have received a copy of the GNU General Public License //
16 // along with this program. If not, see <http://www.gnu.org/licenses/>. //
18 
19 #ifndef SDRBASE_AUDIO_AUDIONETSINK_H_
20 #define SDRBASE_AUDIO_AUDIONETSINK_H_
21 
22 #include "dsp/dsptypes.h"
23 #include "audiofilter.h"
24 #include "audiocompressor.h"
25 #include "audiog722.h"
26 #include "audioopus.h"
27 #include "export.h"
28 
29 #include <QObject>
30 #include <QHostAddress>
31 #include <stdint.h>
32 
33 class QUdpSocket;
34 class RTPSink;
35 class QThread;
36 
38 public:
39  typedef enum
40  {
42  SinkRTP
43  } SinkType;
44 
45  typedef enum
46  {
52  CodecOpus
53  } Codec;
54 
55  AudioNetSink(QObject *parent);
56  AudioNetSink(QObject *parent, int sampleRate, bool stereo);
57  ~AudioNetSink();
58 
59  void setDestination(const QString& address, uint16_t port);
60  void addDestination(const QString& address, uint16_t port);
61  void deleteDestination(const QString& address, uint16_t port);
62  void setParameters(Codec codec, bool stereo, int sampleRate);
63  void setDecimation(uint32_t decimation);
64 
65  void write(qint16 sample);
66  void write(qint16 lSample, qint16 rSample);
67 
68  bool isRTPCapable() const;
69  bool selectType(SinkType type);
70 
71  void moveToThread(QThread *thread);
72 
73  static const int m_udpBlockSize;
74  static const int m_dataBlockSize = 65536; // room for G722 conversion (64000 = 12800*5 largest to date)
75  static const int m_g722BlockSize = 12800; // number of resulting G722 bytes (80*20ms frames)
76  static const int m_opusBlockSize = 960*2; // provision for 20ms of 2 int16 channels at 48 kS/s
77  static const int m_opusOutputSize = 160; // output frame: 20ms of 8 bit data @ 64 kbits/s = 160 bytes
78 
79 protected:
80  void setNewCodecData(); // actions to take when changes affecting codec dependent data occurs
81  void setDecimationFilters(); // set decimation filters limits depending on effective sample rate and codec
82 
83  SinkType m_type;
84  Codec m_codec;
85  QUdpSocket *m_udpSocket;
92  bool m_stereo;
95  char m_data[m_dataBlockSize];
96  int16_t m_opusIn[m_opusBlockSize];
97  int m_codecInputSize; // codec input block size - for codecs with actual encoding (Opus only for now)
98  int m_codecInputIndex; // codec input block fill index
99  int m_codecRatio; // codec compression ratio
100  unsigned int m_bufferIndex;
101  QHostAddress m_address;
102  unsigned int m_port;
103 };
104 
105 #endif /* SDRBASE_AUDIO_AUDIONETSINK_H_ */
short int16_t
Definition: rtptypes_win.h:43
Linear 16 bit samples (no formatting)
Definition: audionetsink.h:47
PCM Mu-law 8 bit samples.
Definition: audionetsink.h:50
RTPSink * m_rtpBufferAudio
Definition: audionetsink.h:86
int decimation(float Fin, float Fout)
Definition: datvdemod.h:66
AudioCompressor m_audioCompressor
Definition: audionetsink.h:87
PCM A-law 8 bit samples.
Definition: audionetsink.h:49
uint32_t m_decimation
Definition: audionetsink.h:93
Linear 8 bit samples.
Definition: audionetsink.h:48
unsigned int m_bufferIndex
Definition: audionetsink.h:100
int m_codecInputIndex
Definition: audionetsink.h:98
static const int m_udpBlockSize
Definition: audionetsink.h:73
unsigned int uint32_t
Definition: rtptypes_win.h:46
unsigned int m_port
Definition: audionetsink.h:102
unsigned short uint16_t
Definition: rtptypes_win.h:44
QHostAddress m_address
Definition: audionetsink.h:101
AudioG722 m_g722
Definition: audionetsink.h:88
G722 compressed 8 bit samples 16kS/s in 8kS/s out.
Definition: audionetsink.h:51
QUdpSocket * m_udpSocket
Definition: audionetsink.h:85
AudioOpus m_opus
Definition: audionetsink.h:89
#define SDRBASE_API
Definition: export.h:40
uint32_t m_decimationCount
Definition: audionetsink.h:94
AudioFilter m_audioFilter
Definition: audionetsink.h:90
int m_codecInputSize
Definition: audionetsink.h:97
SinkType m_type
Definition: audionetsink.h:83