-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathAudioObject.h
More file actions
122 lines (101 loc) · 2.67 KB
/
AudioObject.h
File metadata and controls
122 lines (101 loc) · 2.67 KB
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
#ifndef __AUDIOOBJECT_H
#define __AUDIOOBJECT_H
#include <stdarg.h>
#ifdef _WIN32
#include <windows.h>
#include <fcntl.h>
#endif
#include "AnsiString.h"
#include "semhh.h"
#include <unistd.h>
#include <stdio.h>
#ifndef NO_SPEEX
#include <speex/speex.h>
#endif
#ifndef NO_OPUS
#include <opus/opus.h>
#endif
#include "AES/aes.h"
#include "BasicMessages.h"
#include <QAudioInput>
#include <QAudioOutput>
#include "ConceptClient.h"
#define P_BITRATE 3725
#define P_BANDWIDTH 1009
#define P_ADDBUFFER 1003
#define P_ADDBUFFER2 1007
#define P_CLEAR 1008
#define SAMPLE short
int AesRoundSize(int iSize, int iAlignSize);
class AudioObject;
class AudioInfo : public QIODevice {
Q_OBJECT
AudioObject *owner;
public:
AudioInfo(AudioObject *owner, const QAudioFormat &format, QObject *parent);
~AudioInfo();
void start(bool recording);
void stop();
qint64 readData(char *data, qint64 maxlen);
qint64 writeData(const char *data, qint64 len);
};
class AudioObject {
public:
QObject *stream;
AudioInfo *audioInfo;
int stream_type;
int err;
int SAMPLE_RATE;
int NUM_CHANNELS;
int finished;
int quality;
int speex_frame_size;
bool on_buffer_full;
#ifndef NO_SPEEX
SpeexBits bits;
#endif
void *enc_state;
void *dec_state;
AnsiString audio_buf;
SAMPLE propagation[0xFFF];
int propagation_size;
int use_compression;
int bitrate;
int bandwidth;
bool quality_changed;
HHSEM lock;
int maxbuffers;
int framesize;
char DRM;
AnsiString key;
#ifndef NO_OPUS
OpusDecoder *dec;
OpusEncoder *enc;
opus_int16 *out;
#endif
AES *encrypt;
AES *decrypt;
AnsiString ID;
CConceptClient *owner;
AudioObject(CConceptClient *owner, long ID);
~AudioObject();
void InitEncryption();
void Encrypt(char *buf, int len);
void Decrypt(AnsiString *result, char *buf, int len);
void InitDecryption();
bool IsActive();
bool Stop();
#ifndef NO_SPEEX
void SpeexDeBuffer(char *buf, int buf_size, int use_int_instead_of_char = 0);
int SpeexBuffer2(const SAMPLE *buf, int buf_size);
#endif
#ifndef NO_OPUS
void OpusDeBuffer(char *buf, int buf_size, int use_int_instead_of_char = 0);
int OpusBuffer2(const SAMPLE *buf, int buf_size);
#endif
bool Record(int device = -1);
bool Play(int device = -1);
void ClearBuffer();
void AddBuffer(void *str_buffer, int buf_len, int _use_int = 0);
};
#endif