2018-01-29 00:59:03 +00: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 12:32:15 +00:00
|
|
|
// (at your option) any later version. //
|
2018-01-29 00:59:03 +00: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 19:59:42 +00:00
|
|
|
#include <QRecursiveMutex>
|
2018-02-20 23:28:14 +00:00
|
|
|
#include <QDebug>
|
2018-03-06 01:23:47 +00:00
|
|
|
#include <QHostAddress>
|
2018-01-29 00:59:03 +00:00
|
|
|
#include <stdint.h>
|
|
|
|
|
2018-03-06 01:23:47 +00:00
|
|
|
// qrtplib includes
|
2018-01-29 00:59:03 +00:00
|
|
|
#include "rtpsession.h"
|
2018-03-06 01:23:47 +00:00
|
|
|
#include "rtpudptransmitter.h"
|
|
|
|
#include "rtpaddress.h"
|
2018-01-29 00:59:03 +00:00
|
|
|
#include "rtpsessionparams.h"
|
|
|
|
#include "rtperrors.h"
|
|
|
|
|
2018-03-20 12:49:21 +00:00
|
|
|
#include "export.h"
|
2018-03-03 19:23:38 +00:00
|
|
|
|
2018-03-07 23:16:24 +00:00
|
|
|
class QUdpSocket;
|
|
|
|
|
2018-01-29 00:59:03 +00:00
|
|
|
class RTPSink
|
|
|
|
{
|
|
|
|
public:
|
2018-01-30 23:40:54 +00:00
|
|
|
typedef enum
|
2018-01-29 00:59:03 +00:00
|
|
|
{
|
2018-01-30 23:40:54 +00:00
|
|
|
PayloadL16Mono,
|
|
|
|
PayloadL16Stereo,
|
2019-02-13 09:34:36 +00:00
|
|
|
PayloadL8,
|
2019-02-13 06:53:38 +00:00
|
|
|
PayloadPCMA8,
|
2019-02-17 02:40:11 +00:00
|
|
|
PayloadPCMU8,
|
2019-02-18 01:30:43 +00:00
|
|
|
PayloadG722,
|
|
|
|
PayloadOpus
|
2018-01-30 23:40:54 +00:00
|
|
|
} PayloadType;
|
2018-01-29 00:59:03 +00:00
|
|
|
|
2018-03-27 07:04:10 +00:00
|
|
|
RTPSink(QUdpSocket *udpSocket, int sampleRate, bool stereo);
|
2018-01-30 23:40:54 +00:00
|
|
|
~RTPSink();
|
2018-01-29 00:59:03 +00:00
|
|
|
|
2018-02-20 13:50:21 +00:00
|
|
|
bool isValid() const { return m_valid; }
|
2018-03-26 22:09:52 +00:00
|
|
|
void setPayloadInformation(PayloadType payloadType, int sampleRate);
|
2018-01-29 00:59:03 +00:00
|
|
|
|
2018-01-30 23:40:54 +00: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-29 00:59:03 +00:00
|
|
|
|
2018-01-31 01:03:23 +00:00
|
|
|
void write(const uint8_t *sampleByte);
|
2018-03-29 23:19:02 +00:00
|
|
|
void write(const uint8_t *sampleByteL, const uint8_t *sampleByteR);
|
2018-01-31 01:03:23 +00:00
|
|
|
void write(const uint8_t *sampleByte, int nbSamples);
|
2018-01-29 00:59:03 +00:00
|
|
|
|
|
|
|
protected:
|
2018-01-31 01:03:23 +00: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 13:50:21 +00:00
|
|
|
bool m_valid;
|
2018-01-30 23:40:54 +00: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-06 01:23:47 +00:00
|
|
|
QHostAddress m_destip;
|
2018-01-29 00:59:03 +00:00
|
|
|
uint16_t m_destport;
|
2018-03-06 01:23:47 +00:00
|
|
|
qrtplib::RTPSession m_rtpSession;
|
|
|
|
qrtplib::RTPSessionParams m_rtpSessionParams;
|
|
|
|
qrtplib::RTPUDPTransmissionParams m_rtpTransmissionParams;
|
|
|
|
qrtplib::RTPUDPTransmitter m_rtpTransmitter;
|
2018-01-31 01:03:23 +00:00
|
|
|
bool m_endianReverse;
|
2022-09-15 19:59:42 +00:00
|
|
|
QRecursiveMutex m_mutex;
|
2018-01-29 00:59:03 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
#endif /* SDRBASE_UTIL_RTPSINK_H_ */
|