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 //
|
|
|
|
// //
|
|
|
|
// 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_AUDIO_AUDIONETSINK_H_
|
|
|
|
#define SDRBASE_AUDIO_AUDIONETSINK_H_
|
|
|
|
|
|
|
|
#include "dsp/dsptypes.h"
|
|
|
|
#include "util/export.h"
|
2018-01-28 23:19:59 -05:00
|
|
|
|
2018-03-06 19:15:59 -05:00
|
|
|
#include <QObject>
|
2018-03-07 18:16:24 -05:00
|
|
|
#include <QHostAddress>
|
|
|
|
#include <stdint.h>
|
2018-03-06 19:15:59 -05:00
|
|
|
|
2018-03-07 18:16:24 -05:00
|
|
|
class QUdpSocket;
|
2018-01-30 18:40:54 -05:00
|
|
|
class RTPSink;
|
2018-03-05 20:23:47 -05:00
|
|
|
class QThread;
|
2018-01-28 19:59:03 -05:00
|
|
|
|
2018-03-03 14:23:38 -05:00
|
|
|
class SDRBASE_API AudioNetSink {
|
2018-01-28 19:59:03 -05:00
|
|
|
public:
|
|
|
|
typedef enum
|
|
|
|
{
|
|
|
|
SinkUDP,
|
|
|
|
SinkRTP
|
|
|
|
} SinkType;
|
|
|
|
|
|
|
|
AudioNetSink(QObject *parent, bool stereo = false);
|
|
|
|
~AudioNetSink();
|
|
|
|
|
|
|
|
void setDestination(const QString& address, uint16_t port);
|
|
|
|
void addDestination(const QString& address, uint16_t port);
|
|
|
|
void deleteDestination(const QString& address, uint16_t port);
|
2018-03-08 02:59:17 -05:00
|
|
|
void setStereo(bool stereo);
|
2018-01-28 19:59:03 -05:00
|
|
|
|
|
|
|
void write(qint16 sample);
|
2018-03-08 02:59:17 -05:00
|
|
|
void write(AudioSample* samples, uint32_t numSamples);
|
2018-01-28 19:59:03 -05:00
|
|
|
|
2018-03-07 18:16:24 -05:00
|
|
|
bool isRTPCapable() const;
|
2018-01-28 19:59:03 -05:00
|
|
|
bool selectType(SinkType type);
|
|
|
|
|
2018-03-05 20:23:47 -05:00
|
|
|
void moveToThread(QThread *thread);
|
|
|
|
|
2018-01-28 19:59:03 -05:00
|
|
|
static const int m_udpBlockSize;
|
|
|
|
|
|
|
|
protected:
|
|
|
|
SinkType m_type;
|
2018-03-07 18:16:24 -05:00
|
|
|
QUdpSocket *m_udpSocket;
|
2018-01-30 18:40:54 -05:00
|
|
|
RTPSink *m_rtpBufferAudio;
|
2018-03-07 18:16:24 -05:00
|
|
|
char m_data[65536];
|
|
|
|
unsigned int m_bufferIndex;
|
|
|
|
QHostAddress m_address;
|
|
|
|
unsigned int m_port;
|
2018-01-28 19:59:03 -05:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#endif /* SDRBASE_AUDIO_AUDIONETSINK_H_ */
|