-
Notifications
You must be signed in to change notification settings - Fork 11
/
call.h
187 lines (156 loc) · 4.15 KB
/
call.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
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
/*
Skype Call Recorder
Copyright 2008-2010, 2013, 2015 by jlh (jlh at gmx dot ch)
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, 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 St, Fifth Floor, Boston, MA 02110-1301 USA
The GNU General Public License version 2 is included with the source of
this program under the file name COPYING. You can also get a copy on
http://www.fsf.org/
*/
#ifndef CALL_H
#define CALL_H
#include <QObject>
#include <QString>
#include <QByteArray>
#include <QMap>
#include <QSet>
#include <QPointer>
#include <QDateTime>
#include <QTime>
#include <QFile>
#include "common.h"
class QStringList;
class Skype;
class AudioFileWriter;
class QTcpServer;
class QTcpSocket;
class LegalInformationDialog;
class CallHandler;
typedef int CallID;
class AutoSync {
public:
AutoSync(int, long);
~AutoSync();
void add(long);
long getSync();
void reset();
private:
long *delays;
int size;
int index;
long sum;
qint64 sum2;
long precision;
int suppress;
DISABLE_COPY_AND_ASSIGNMENT(AutoSync);
};
class Call : public QObject {
Q_OBJECT
public:
Call(CallHandler *, Skype *, CallID);
~Call();
void startRecording(bool = false);
void stopRecording(bool = true);
void updateConfID();
bool okToDelete() const;
void setStatus(const QString &);
QString getStatus() const { return status; }
bool statusDone() const;
bool statusActive() const;
CallID getID() const { return id; }
CallID getConfID() const { return confID; }
void removeFile();
void hideConfirmation(int);
bool getIsRecording() const { return isRecording; }
signals:
void startedCall(int, const QString &);
void stoppedCall(int);
void startedRecording(int);
void stoppedRecording(int);
void showLegalInformation();
private:
QString constructFileName() const;
QString constructCommentTag() const;
void mixToMono(long);
void mixToStereo(long, int);
void setShouldRecord();
void ask();
void doSync(long);
private:
Skype *skype;
CallHandler *handler;
CallID id;
QString status;
QString skypeName;
QString displayName;
CallID confID;
AudioFileWriter *writer;
bool isRecording;
int stereo;
int stereoMix;
int shouldRecord;
QString fileName;
QPointer<QObject> confirmation;
QDateTime timeStartRecording;
QTime syncTime;
QFile syncFile;
AutoSync sync;
QTcpServer *serverLocal, *serverRemote;
QTcpSocket *socketLocal, *socketRemote;
QByteArray bufferLocal, bufferRemote;
private slots:
void acceptLocal();
void acceptRemote();
void readLocal();
void readRemote();
void checkConnections();
long padBuffers();
void tryToWrite(bool = false);
void confirmRecording();
void denyRecording();
private: // moc gets confused without this private:
DISABLE_COPY_AND_ASSIGNMENT(Call);
};
class CallHandler : public QObject {
Q_OBJECT
public:
CallHandler(QObject *, Skype *);
~CallHandler();
void updateConfIDs();
bool isConferenceRecording(CallID) const;
void callCmd(const QStringList &);
signals:
// note that {start,stop}Recording signals are not guaranteed to always
// happen within a {start,stop}Call block. Especially,
// stoppedRecording will usually happen *after* stoppedCall
void startedCall(int, const QString &);
void stoppedCall(int);
void startedRecording(int);
void stoppedRecording(int);
public slots:
void startRecording(int);
void stopRecording(int);
void stopRecordingAndDelete(int);
private slots:
void showLegalInformation();
private:
void prune();
private:
typedef QMap<CallID, Call *> CallMap;
typedef QSet<CallID> CallSet;
CallMap calls;
CallSet ignore;
Skype *skype;
QPointer<LegalInformationDialog> legalInformationDialog;
DISABLE_COPY_AND_ASSIGNMENT(CallHandler);
};
#endif