Rev 460 | Rev 466 | Go to most recent revision | Blame | Compare with Previous | Last modification | View Log | RSS feed
/*
* Copyright (C) 2024 by Andreas Theofilu <andreas@theosys.at>
*
* 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; either version 3 of the License, or
* (at your option) any later version.
*
* 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 for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software Foundation,
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
#ifndef TQINTERCOM_H
#define TQINTERCOM_H
#include <string>
#include <QObject>
#include <QAudioFormat>
#include <QAbstractSocket>
typedef struct INTERCOM_t
{
std::string ip; // IP address of panel to connect to
long rxPort{0}; // Network port number for receiver
long txPort{0}; // Network port number for transmitter
int mode{0}; // The mode (0 = talk, 1 = listen, 2 = both)
}INTERCOM_t;
class QUdpSocket;
class QAudioSource;
class QAudioSink;
class TQIntercom : public QObject
{
Q_OBJECT
public:
TQIntercom(QObject *parent);
TQIntercom(QObject *parent, INTERCOM_t ic);
~TQIntercom();
void start();
void stop();
void setMicrophoneLevel(int level);
void setSpeakerLevel(int level);
void setMute(bool mute);
void setIntercom(INTERCOM_t ic);
protected:
bool connectTalker(); // Talker
bool spawnServer(); // Listener
void onStateChanged(QAbstractSocket::SocketState socketState);
private:
INTERCOM_t mIntercom;
int mMicLevel{80};
int mSpkLevel{80};
bool mInitialized{false};
QUdpSocket *mUdpTalker{nullptr};
QUdpSocket *mUdpListener{nullptr};
QAudioFormat mAudioFormat;
QAudioSource *mMicrophone{nullptr}; // Talk --> from mic to remote
QAudioSink *mRemote{nullptr}; // Listen --> from remote to speaker
};
#endif // TQINTERCOM_H