forked from OpenShield/DudeShield
-
Notifications
You must be signed in to change notification settings - Fork 0
/
iaxcodec.h
122 lines (115 loc) · 3.66 KB
/
iaxcodec.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
/*
Copyright (C) 2019-2021 Doug McLain
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, see <https://www.gnu.org/licenses/>.
*/
#ifndef IAXCODEC_H
#define IAXCODEC_H
#include <QObject>
#include <QtNetwork>
#include "audioengine.h"
#ifdef USE_FLITE
#include <flite/flite.h>
#endif
class IAXCodec : public QObject
{
Q_OBJECT
public:
IAXCodec(QString callsign, QString username, QString password, QString node, QString host, int port, QString audioin, QString audioout);
~IAXCodec();
uint8_t get_status(){ return m_status; }
QString get_host() { return m_host; }
int get_port() { return m_port; }
int get_cnt() { return m_cnt; }
void set_input_src(uint8_t s, QString t) { m_ttsid = s; m_ttstext = t; }
signals:
void update();
void update_output_level(unsigned short);
private slots:
void deleteLater();
void process_udp();
void send_connect();
void send_disconnect();
void hostname_lookup(QHostInfo i);
void send_registration(uint16_t dcall = 0);
void send_call();
void send_call_auth();
void send_ack(uint16_t, uint16_t, uint8_t, uint8_t);
void send_lag_response();
void send_ping();
void send_pong();
void start_tx();
void stop_tx();
void transmit();
void process_rx_data();
void send_voice_frame(int16_t *);
void send_dtmf(QByteArray);
void input_src_changed(int id, QString t) { m_ttsid = id; m_ttstext = t; }
void in_audio_vol_changed(qreal);
void out_audio_vol_changed(qreal);
void decoder_gain_changed(qreal);
private:
enum{
DISCONNECTED,
CONNECTING,
DMR_AUTH,
DMR_CONF,
DMR_OPTS,
CONNECTED_RW,
CONNECTED_RO
} m_status;
QUdpSocket *m_udp = nullptr;
QHostAddress m_address;
QString m_callsign;
QString m_username;
QString m_password;
QString m_node;
QString m_context;
QString m_host;
int m_port;
uint16_t m_scallno;
uint16_t m_dcallno;
uint16_t m_regscallno;
uint16_t m_regdcallno;
int m_id;
QString m_audioin;
QString m_audioout;
qint64 m_timestamp;
uint8_t m_regstat;
QByteArray m_md5seed;
QTimer *m_regtimer;
QTimer *m_pingtimer;
QTimer *m_rxtimer;
QTimer *m_txtimer;
AudioEngine *m_audio;
uint8_t m_iseq;
uint8_t m_oseq;
QQueue<int16_t> m_audioq;
bool m_tx;
uint32_t m_rxjitter;
uint32_t m_rxloss;
uint32_t m_rxframes;
uint16_t m_rxdelay;
uint32_t m_rxdropped;
uint32_t m_rxooo;
uint8_t m_ttsid;
QString m_ttstext;
uint16_t m_ttscnt;
int m_cnt;
qreal m_rxgain;
#ifdef USE_FLITE
cst_voice *voice_slt;
cst_voice *voice_kal;
cst_voice *voice_awb;
cst_wave *tts_audio;
#endif
};
#endif // IAXCODEC_H