2018-01-28 19:59:03 -05:00
|
|
|
///////////////////////////////////////////////////////////////////////////////////
|
|
|
|
// Copyright (C) 2018 F4EXB //
|
|
|
|
// written by Edouard Griffiths //
|
|
|
|
// //
|
|
|
|
// This program is free software; you can redistribute it and/or modify //
|
|
|
|
// it under the terms of the GNU General Public License as published by //
|
|
|
|
// the Free Software Foundation as version 3 of the License, or //
|
2019-04-11 08:32:15 -04:00
|
|
|
// (at your option) any later version. //
|
2018-01-28 19:59:03 -05:00
|
|
|
// //
|
|
|
|
// This program is distributed in the hope that it will be useful, //
|
|
|
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of //
|
|
|
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the //
|
|
|
|
// GNU General Public License V3 for more details. //
|
|
|
|
// //
|
|
|
|
// You should have received a copy of the GNU General Public License //
|
|
|
|
// along with this program. If not, see <http://www.gnu.org/licenses/>. //
|
|
|
|
///////////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
|
|
|
#ifndef SDRBASE_UTIL_RTPSINK_H_
|
|
|
|
#define SDRBASE_UTIL_RTPSINK_H_
|
|
|
|
|
|
|
|
#include <QString>
|
2022-09-15 15:59:42 -04:00
|
|
|
#include <QRecursiveMutex>
|
2018-02-20 18:28:14 -05:00
|
|
|
#include <QDebug>
|
2018-03-05 20:23:47 -05:00
|
|
|
#include <QHostAddress>
|
2018-01-28 19:59:03 -05:00
|
|
|
#include <stdint.h>
|
|
|
|
|
2018-03-05 20:23:47 -05:00
|
|
|
// qrtplib includes
|
2018-01-28 19:59:03 -05:00
|
|
|
#include "rtpsession.h"
|
2018-03-05 20:23:47 -05:00
|
|
|
#include "rtpudptransmitter.h"
|
|
|
|
#include "rtpaddress.h"
|
2018-01-28 19:59:03 -05:00
|
|
|
#include "rtpsessionparams.h"
|
|
|
|
#include "rtperrors.h"
|
|
|
|
|
2018-03-20 08:49:21 -04:00
|
|
|
#include "export.h"
|
2018-03-03 14:23:38 -05:00
|
|
|
|
2018-03-07 18:16:24 -05:00
|
|
|
class QUdpSocket;
|
|
|
|
|
2018-01-28 19:59:03 -05:00
|
|
|
class RTPSink
|
|
|
|
{
|
|
|
|
public:
|
2018-01-30 18:40:54 -05:00
|
|
|
typedef enum
|
2018-01-28 19:59:03 -05:00
|
|
|
{
|
2018-01-30 18:40:54 -05:00
|
|
|
PayloadL16Mono,
|
|
|
|
PayloadL16Stereo,
|
2019-02-13 04:34:36 -05:00
|
|
|
PayloadL8,
|
2019-02-13 01:53:38 -05:00
|
|
|
PayloadPCMA8,
|
2019-02-16 21:40:11 -05:00
|
|
|
PayloadPCMU8,
|
2019-02-17 20:30:43 -05:00
|
|
|
PayloadG722,
|
|
|
|
PayloadOpus
|
2018-01-30 18:40:54 -05:00
|
|
|
} PayloadType;
|
2018-01-28 19:59:03 -05:00
|
|
|
|
2018-03-27 03:04:10 -04:00
|
|
|
RTPSink(QUdpSocket *udpSocket, int sampleRate, bool stereo);
|
2018-01-30 18:40:54 -05:00
|
|
|
~RTPSink();
|
2018-01-28 19:59:03 -05:00
|
|
|
|
2018-02-20 08:50:21 -05:00
|
|
|
bool isValid() const { return m_valid; }
|
2018-03-26 18:09:52 -04:00
|
|
|
void setPayloadInformation(PayloadType payloadType, int sampleRate);
|
2018-01-28 19:59:03 -05:00
|
|
|
|
2018-01-30 18:40:54 -05:00
|
|
|
void setDestination(const QString& address, uint16_t port);
|
|
|
|
void deleteDestination(const QString& address, uint16_t port);
|
|
|
|
void addDestination(const QString& address, uint16_t port);
|
2018-01-28 19:59:03 -05:00
|
|
|
|
2018-01-30 20:03:23 -05:00
|
|
|
void write(const uint8_t *sampleByte);
|
2018-03-29 19:19:02 -04:00
|
|
|
void write(const uint8_t *sampleByteL, const uint8_t *sampleByteR);
|
2018-01-30 20:03:23 -05:00
|
|
|
void write(const uint8_t *sampleByte, int nbSamples);
|
2018-01-28 19:59:03 -05:00
|
|
|
|
|
|
|
protected:
|
2018-01-30 20:03:23 -05:00
|
|
|
/** Reverse endianess in destination buffer */
|
|
|
|
static void writeNetBuf(uint8_t *dest, const uint8_t *src, unsigned int elemLen, unsigned int bytesLen, bool endianReverse);
|
|
|
|
static unsigned int elemLength(PayloadType payloadType);
|
|
|
|
|
2018-02-20 08:50:21 -05:00
|
|
|
bool m_valid;
|
2018-01-30 18:40:54 -05:00
|
|
|
PayloadType m_payloadType;
|
|
|
|
int m_sampleRate;
|
|
|
|
int m_sampleBytes;
|
|
|
|
int m_packetSamples;
|
|
|
|
int m_bufferSize;
|
|
|
|
int m_sampleBufferIndex;
|
|
|
|
uint8_t *m_byteBuffer;
|
2018-03-05 20:23:47 -05:00
|
|
|
QHostAddress m_destip;
|
2018-01-28 19:59:03 -05:00
|
|
|
uint16_t m_destport;
|
2018-03-05 20:23:47 -05:00
|
|
|
qrtplib::RTPSession m_rtpSession;
|
|
|
|
qrtplib::RTPSessionParams m_rtpSessionParams;
|
|
|
|
qrtplib::RTPUDPTransmissionParams m_rtpTransmissionParams;
|
|
|
|
qrtplib::RTPUDPTransmitter m_rtpTransmitter;
|
2018-01-30 20:03:23 -05:00
|
|
|
bool m_endianReverse;
|
2022-09-15 15:59:42 -04:00
|
|
|
QRecursiveMutex m_mutex;
|
2018-01-28 19:59:03 -05:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
#endif /* SDRBASE_UTIL_RTPSINK_H_ */
|