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.
rtpsink.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_UTIL_RTPSINK_H_
20 #define SDRBASE_UTIL_RTPSINK_H_
21 
22 #include <QString>
23 #include <QMutex>
24 #include <QDebug>
25 #include <QHostAddress>
26 #include <stdint.h>
27 
28 // qrtplib includes
29 #include "rtpsession.h"
30 #include "rtpudptransmitter.h"
31 #include "rtpaddress.h"
32 #include "rtpsessionparams.h"
33 #include "rtperrors.h"
34 
35 #include "export.h"
36 
37 class QUdpSocket;
38 
39 class RTPSink
40 {
41 public:
42  typedef enum
43  {
51  } PayloadType;
52 
53  RTPSink(QUdpSocket *udpSocket, int sampleRate, bool stereo);
54  ~RTPSink();
55 
56  bool isValid() const { return m_valid; }
57  void setPayloadInformation(PayloadType payloadType, int sampleRate);
58 
59  void setDestination(const QString& address, uint16_t port);
60  void deleteDestination(const QString& address, uint16_t port);
61  void addDestination(const QString& address, uint16_t port);
62 
63  void write(const uint8_t *sampleByte);
64  void write(const uint8_t *sampleByteL, const uint8_t *sampleByteR);
65  void write(const uint8_t *sampleByte, int nbSamples);
66 
67 protected:
69  static void writeNetBuf(uint8_t *dest, const uint8_t *src, unsigned int elemLen, unsigned int bytesLen, bool endianReverse);
70  static unsigned int elemLength(PayloadType payloadType);
71 
72  bool m_valid;
73  PayloadType m_payloadType;
80  QHostAddress m_destip;
87  QMutex m_mutex;
88 };
89 
90 
91 #endif /* SDRBASE_UTIL_RTPSINK_H_ */
void setDestination(const QString &address, uint16_t port)
Definition: rtpsink.cpp:180
int m_bufferSize
Definition: rtpsink.h:77
static void writeNetBuf(uint8_t *dest, const uint8_t *src, unsigned int elemLen, unsigned int bytesLen, bool endianReverse)
Definition: rtpsink.cpp:322
PayloadType
Definition: rtpsink.h:42
qrtplib::RTPUDPTransmitter m_rtpTransmitter
Definition: rtpsink.h:85
int m_packetSamples
Definition: rtpsink.h:76
uint8_t * m_byteBuffer
Definition: rtpsink.h:79
void deleteDestination(const QString &address, uint16_t port)
Definition: rtpsink.cpp:194
uint16_t m_destport
Definition: rtpsink.h:81
unsigned char uint8_t
Definition: rtptypes_win.h:42
PayloadType m_payloadType
Definition: rtpsink.h:73
unsigned short uint16_t
Definition: rtptypes_win.h:44
RTPSink(QUdpSocket *udpSocket, int sampleRate, bool stereo)
Definition: rtpsink.cpp:23
int m_sampleBytes
Definition: rtpsink.h:75
int m_sampleRate
Definition: rtpsink.h:74
qrtplib::RTPSession m_rtpSession
Definition: rtpsink.h:82
bool m_endianReverse
Definition: rtpsink.h:86
void addDestination(const QString &address, uint16_t port)
Definition: rtpsink.cpp:205
void write(const uint8_t *sampleByte)
Definition: rtpsink.cpp:221
qrtplib::RTPUDPTransmissionParams m_rtpTransmissionParams
Definition: rtpsink.h:84
QHostAddress m_destip
Definition: rtpsink.h:80
qrtplib::RTPSessionParams m_rtpSessionParams
Definition: rtpsink.h:83
bool m_valid
Definition: rtpsink.h:72
QMutex m_mutex
Definition: rtpsink.h:87
int m_sampleBufferIndex
Definition: rtpsink.h:78
bool isValid() const
Definition: rtpsink.h:56
static unsigned int elemLength(PayloadType payloadType)
Definition: rtpsink.cpp:334
~RTPSink()
Definition: rtpsink.cpp:65
void setPayloadInformation(PayloadType payloadType, int sampleRate)
Definition: rtpsink.cpp:75