-
Notifications
You must be signed in to change notification settings - Fork 1
/
AudioUnit.h
125 lines (101 loc) · 3.18 KB
/
AudioUnit.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
123
124
/*
* Copyright (C) 2011,2012,2013 by Jonathan Naylor G4KLX
* Copyright (c) 2017 by Thomas A. Early N7TAE
*
* 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 2 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., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
#pragma once
#include <string>
#include <map>
#include <chrono>
#include "G2ProtocolHandler.h"
#include "SlowDataEncoder.h"
#include "AMBEData.h"
#include "Timer.h"
#include "Defs.h"
class CIndexRecord {
public:
CIndexRecord(const std::string& name, unsigned int start, unsigned int length) :
m_name(name),
m_start(start),
m_length(length)
{
}
std::string getName() const
{
return m_name;
}
unsigned int getStart() const
{
return m_start;
}
unsigned int getLength() const
{
return m_length;
}
private:
std::string m_name;
unsigned int m_start;
unsigned int m_length;
};
enum AUDIO_STATUS {
AS_IDLE,
AS_WAIT,
AS_TRANSMIT
};
enum ACK_TYPE
{
AT_LOGIN,
AT_LOGOFF
};
class CAudioUnit {
public:
CAudioUnit(CG2ProtocolHandler* handler);
~CAudioUnit();
void sendAck();
// void setStatus(LINK_STATUS status, const std::string& reflector, const std::string& text);
// void setTempStatus(LINK_STATUS status, const std::string& reflector, const std::string& text);
void setAck(ACK_TYPE ackType, const std::string& groupeName, const std::string& user, const std::string& repeater, const std::string& gateway, const in_addr& destination);
void cancel();
void clock(unsigned int ms);
static void initialise();
static void setLanguage(TEXT_LANG language);
static void finalise();
private:
static std::map<std::string, CIndexRecord *> m_index;
static unsigned char* m_ambe;
static unsigned int m_ambeLength;
static TEXT_LANG m_language;
CG2ProtocolHandler* m_handler;
CSlowDataEncoder m_encoder;
AUDIO_STATUS m_status;
ACK_TYPE m_ackType;
std::string m_groupName;
std::string m_user;
std::string m_repeater;
std::string m_gateway;
in_addr m_destination;
CTimer m_timer;
CAMBEData** m_data;
unsigned int m_in;
unsigned int m_out;
unsigned int m_seqNo;
std::chrono::high_resolution_clock::time_point m_time;
bool lookup(unsigned int id, const std::string& name, const in_addr& destination);
void sendAck(ACK_TYPE ackType, const std::string& groupeName, const std::string& user, const std::string& repeater, const std::string& gateway, const in_addr& destination);
void spellGroup(unsigned int id, const std::string& groupName, const in_addr& destination);
static bool readAMBE(const std::string& name);
static bool readIndex(const std::string& name);
};