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
|
/*
(c) Copyright 2012 - 2018 Anton Sviridenko
https://picapica.im
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, version 3.
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 SETTINGSDIALOG_H
#define SETTINGSDIALOG_H
#include <QDialog>
#include <QLineEdit>
#include <QPushButton>
#include <QSpinBox>
#include <QRadioButton>
#include <QComboBox>
#include <QCheckBox>
#include <QLabel>
#include <QThread>
#include <QImage>
#include <QList>
#include <QTimer>
#include "../mediadevice.h"
#include "../audiodevice.h"
#include "../videodevice.h"
#include "../toneplayer/toneplayer.h"
class SettingsDialog : public QDialog
{
Q_OBJECT
public:
explicit SettingsDialog(QWidget *parent = 0);
~SettingsDialog();
signals:
public slots:
private slots:
private:
QRadioButton *rbDisableDirectConns;
QRadioButton *rbEnableOutgoingConns;
QRadioButton *rbEnableIncomingConns;
#ifdef HAVE_LIBMINIUPNPC
QCheckBox *cbEnableUPnP;
#endif
QComboBox *addr;
QSpinBox *publicPort;
QSpinBox *localPort;
QRadioButton *rbMLPProhibit;
QRadioButton *rbMLPReplace;
QRadioButton *rbMLPAllowMultiple;
QComboBox *audioCaptureDev;
QComboBox *audioPlaybackDev;
QComboBox *audioRingDev;
QComboBox *videoDev;
QPushButton *videoDevRefresh;
// Local audio pipeline test: a few seconds of the selected microphone are
// captured and encoded, then decoded again and played back through the
// selected playback device - the same path a call takes, minus the
// network. Recording and playback are deliberately kept apart in time
// rather than looped back live, which would howl with acoustic feedback
// when the test runs on speakers.
QPushButton *btAudioTest;
QLabel *audioTestStatus;
AudioDevice *testMic;
AudioDevice *testSpeaker;
QThread testMicThread;
QThread testSpeakerThread;
enum AudioTestState
{
AudioTestIdle,
AudioTestRecording,
AudioTestPlaying
};
AudioTestState audioTestState;
// The recording, as encoded packets, and how far playback has fed it.
QList<QByteArray> audioTestPackets;
int audioTestPlaybackPos;
// Members rather than QTimer::singleShot() calls so that stopping a test
// cancels them - otherwise a timer left over from an aborted run would
// fire into the next one.
QTimer *audioTestRecordTimer;
QTimer *audioTestPlaybackTimer;
QTimer *audioTestDrainTimer;
void stopAudioTest();
void startAudioTestPlayback();
// Ring device test: plays the incoming call bell through the selected
// ring device, using the same TonePlayer an actual incoming call uses.
// TonePlayer::play() blocks its thread for the length of the tone
// sequence, hence the dedicated thread.
QPushButton *btRingTest;
QLabel *ringTestStatus;
TonePlayer *ringTestPlayer;
QThread ringTestPlayerThread;
bool ringTestRunning;
// Local video pipeline test: frames from the selected camera are
// encoded, split into protocol sized fragments, reassembled and decoded
// again, then shown in videoPreview - the same path a call takes, minus
// the network, so the whole chain can be checked from this dialog.
QPushButton *btVideoTest;
QLabel *videoPreview;
VideoDevice *testCam;
VideoDevice *testDecoder;
QThread testCamThread;
QThread testDecoderThread;
VideoFrameAssembler testAssembler;
bool videoTestRunning;
void stopVideoTest();
QPushButton *btOk;
QPushButton *btCancel;
void loadSettings();
void storeSettings();
void fillDevicesComboBox(QComboBox *cb, MediaDevice *dev, enum MediaDeviceStreamDirection dir);
private slots:
void OK();
void Cancel();
void toggleIncomingConnections(bool checked);
void toggleMultipleLogins(bool checked);
void fillVideoDevices();
void fillAudioCaptureDevices();
void fillAudioPlaybackDevices();
void fillAudioRingDevices();
void toggleRingTest();
void ringTestFinished();
void ringTestError(QString message);
void toggleAudioTest();
void audioTestPacket(QByteArray data);
void audioTestRecordingFinished();
void audioTestFeedPacket();
void audioTestPlaybackFinished();
void audioTestError(QString message);
void toggleVideoTest();
void videoTestFragment(QByteArray data, bool is_last_fragment);
void videoTestFrame(QImage frame);
void videoTestError(QString message);
};
#endif // SETTINGSDIALOG_H
|