refactored the UI of VOIP config panel and added list of available devices (not used yet)

This commit is contained in:
csoler 2021-05-15 21:37:11 +02:00
parent d3f75234a7
commit 7b5be347bf
4 changed files with 303 additions and 234 deletions

View File

@ -71,14 +71,34 @@ void QVideoInputDevice::stop()
_image_capture = NULL ;
}
}
void QVideoInputDevice::start()
void QVideoInputDevice::getAvailableDevices(QList<QString>& device_desc)
{
device_desc.clear();
QList<QCameraInfo> dev_list = QCameraInfo::availableCameras();
for(auto& cam:dev_list)
device_desc.push_back(cam.deviceName());
}
void QVideoInputDevice::start(const QString& description)
{
// make sure everything is re-initialised
//
stop() ;
// Initialise la capture
QCameraInfo caminfo = QCameraInfo::defaultCamera();
QCameraInfo caminfo ;
if(description.isNull())
caminfo = QCameraInfo::defaultCamera();
else
{
auto cam_list = QCameraInfo::availableCameras();
for(auto& s:cam_list)
if(s.deviceName() == description)
caminfo = s;
}
if(caminfo.isNull())
{

View File

@ -49,7 +49,7 @@ class QVideoInputDevice: public QObject
Q_OBJECT
public:
QVideoInputDevice(QWidget *parent = 0) ;
QVideoInputDevice(QWidget *parent = 0) ;
~QVideoInputDevice() ;
// Captured images are sent to this encoder. Can be NULL.
@ -71,7 +71,7 @@ class QVideoInputDevice: public QObject
// control
void start() ;
void start(const QString &description = QString()) ;
void stop() ;
bool stopped();
@ -81,6 +81,10 @@ class QVideoInputDevice: public QObject
CAMERA_CANNOT_GRAB_FRAMES = 0x02
};
// Gets the list of available devices. The id string for each device can be used when creating a QVideoDevice
static void getAvailableDevices(QList<QString>& device_desc);
protected slots:
void grabFrame(int id, QVideoFrame f) ;
void errorHandling(CameraStatus status,QCamera::Error error);

View File

@ -101,10 +101,17 @@ VOIPConfigPanel::VOIPConfigPanel(QWidget * parent, Qt::WindowFlags flags)
ui.abSpeech->qcInside = Qt::yellow;
ui.abSpeech->qcAbove = Qt::green;
QList<QString> input_devices;
QVideoInputDevice::getAvailableDevices(input_devices);
ui.inputDevice_CB->clear();
for(auto& s:input_devices)
ui.inputDevice_CB->addItem(s,QVariant(s));
connect( ui.qsTransmitHold, SIGNAL( valueChanged ( int ) ), this, SLOT( on_qsTransmitHold_valueChanged(int) ) );
connect( ui.qsNoise, SIGNAL( valueChanged ( int ) ), this, SLOT( on_qsNoise_valueChanged(int) ) );
connect( ui.qsAmp, SIGNAL( valueChanged ( int ) ), this, SLOT( on_qsAmp_valueChanged(int) ) );
connect( ui.qcbTransmit, SIGNAL( currentIndexChanged ( int ) ), this, SLOT( on_qcbTransmit_currentIndexChanged(int) ) );
connect( ui.inputDevice_CB, SIGNAL( currentIndexChanged ( int ) ), this, SLOT( on_changedCurrentInputDevice(int) ) );
}
void VOIPConfigPanel::showEvent(QShowEvent *)

View File

@ -10,48 +10,287 @@
<height>832</height>
</rect>
</property>
<layout class="QVBoxLayout" name="verticalLayout">
<layout class="QVBoxLayout" name="verticalLayout_3">
<item>
<widget class="QPushButton" name="qpbAudioWizard">
<property name="text">
<string>Audio Wizard</string>
<widget class="QGroupBox" name="groupBox">
<property name="title">
<string>Video</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout_2">
<item>
<layout class="QHBoxLayout" name="horizontalLayout">
<item>
<widget class="QVideoOutputDevice" name="videoDisplay">
<property name="minimumSize">
<size>
<width>170</width>
<height>128</height>
</size>
</property>
<property name="frameShape">
<enum>QFrame::StyledPanel</enum>
</property>
<property name="frameShadow">
<enum>QFrame::Raised</enum>
</property>
</widget>
</item>
<item>
<widget class="voipGraph" name="voipBwGraph">
<property name="sizePolicy">
<sizepolicy hsizetype="MinimumExpanding" vsizetype="Expanding">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="frameShape">
<enum>QFrame::StyledPanel</enum>
</property>
<property name="frameShadow">
<enum>QFrame::Raised</enum>
</property>
</widget>
</item>
</layout>
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout_3">
<item>
<widget class="QLabel" name="label_3">
<property name="text">
<string>Input device:</string>
</property>
</widget>
</item>
<item>
<widget class="QComboBox" name="inputDevice_CB"/>
</item>
<item>
<widget class="QLabel" name="label_2">
<property name="sizePolicy">
<sizepolicy hsizetype="Maximum" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>Available bandwidth:</string>
</property>
</widget>
</item>
<item>
<widget class="QDoubleSpinBox" name="availableBW_SB">
<property name="toolTip">
<string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;Use this field to simulate the maximum bandwidth available so as to preview what the encoded video will look like with the corresponding compression rate.&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
</property>
<property name="suffix">
<string>KB/s</string>
</property>
<property name="decimals">
<number>1</number>
</property>
<property name="minimum">
<double>2.000000000000000</double>
</property>
<property name="maximum">
<double>200.000000000000000</double>
</property>
<property name="value">
<double>30.000000000000000</double>
</property>
</widget>
</item>
<item>
<widget class="QCheckBox" name="showEncoded_CB">
<property name="sizePolicy">
<sizepolicy hsizetype="MinimumExpanding" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="toolTip">
<string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;Display encoded (and then decoded) frame, to check the codec's quality. If not selected, the image above only shows the frame that is grabbed from your camera.&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
</property>
<property name="text">
<string>preview</string>
</property>
</widget>
</item>
</layout>
</item>
</layout>
</widget>
</item>
<item>
<widget class="QGroupBox" name="qgbTransmission">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Minimum">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<widget class="QGroupBox" name="qgbAudio">
<property name="title">
<string>Transmission</string>
<string>Audio</string>
</property>
<layout class="QGridLayout">
<item row="0" column="0">
<widget class="QLabel" name="qliTransmit">
<property name="text">
<string>&amp;Transmit</string>
<layout class="QVBoxLayout" name="verticalLayout">
<item>
<widget class="QLabel" name="qlNoise">
<property name="minimumSize">
<size>
<width>30</width>
<height>0</height>
</size>
</property>
<property name="buddy">
<cstring>qcbTransmit</cstring>
<property name="text">
<string/>
</property>
</widget>
</item>
<item row="0" column="1" colspan="2">
<widget class="QComboBox" name="qcbTransmit">
<item>
<widget class="QSlider" name="qsNoise">
<property name="enabled">
<bool>true</bool>
</property>
<property name="toolTip">
<string>When to transmit your speech</string>
<string>Noise suppression</string>
</property>
<property name="whatsThis">
<string>&lt;b&gt;This sets when speech should be transmitted.&lt;/b&gt;&lt;br /&gt;&lt;i&gt;Continuous&lt;/i&gt; - All the time&lt;br /&gt;&lt;i&gt;Voice Activity&lt;/i&gt; - When you are speaking clearly.&lt;br /&gt;&lt;i&gt;Push To Talk&lt;/i&gt; - When you hold down the hotkey set under &lt;i&gt;Shortcuts&lt;/i&gt;.</string>
<string>&lt;b&gt;This sets the amount of noise suppression to apply.&lt;/b&gt;&lt;br /&gt;The higher this value, the more aggressively stationary noise will be suppressed.</string>
</property>
<property name="minimum">
<number>14</number>
</property>
<property name="maximum">
<number>60</number>
</property>
<property name="pageStep">
<number>5</number>
</property>
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
</widget>
</item>
<item row="1" column="0" colspan="3">
<item>
<widget class="QLabel" name="qliNoise">
<property name="text">
<string>Noise Suppression</string>
</property>
<property name="buddy">
<cstring>qsNoise</cstring>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="qlAmp">
<property name="minimumSize">
<size>
<width>30</width>
<height>0</height>
</size>
</property>
<property name="text">
<string/>
</property>
</widget>
</item>
<item>
<widget class="QSlider" name="qsAmp">
<property name="toolTip">
<string>Maximum amplification of input sound</string>
</property>
<property name="whatsThis">
<string>&lt;b&gt;Maximum amplification of input.&lt;/b&gt;&lt;br /&gt;RetroShare normalizes the input volume before compressing, and this sets how much it's allowed to amplify.&lt;br /&gt;The actual level is continually updated based on your current speech pattern, but it will never go above the level specified here.&lt;br /&gt;If the &lt;i&gt;Microphone loudness&lt;/i&gt; level of the audio statistics hover around 100%, you probably want to set this to 2.0 or so, but if, like most people, you are unable to reach 100%, set this to something much higher.&lt;br /&gt;Ideally, set it so &lt;i&gt;Microphone Loudness * Amplification Factor &gt;= 100&lt;/i&gt;, even when you're speaking really soft.&lt;br /&gt;&lt;br /&gt;Note that there is no harm in setting this to maximum, but RetroShare will start picking up other conversations if you leave it to auto-tune to that level.</string>
</property>
<property name="maximum">
<number>19500</number>
</property>
<property name="singleStep">
<number>500</number>
</property>
<property name="pageStep">
<number>2000</number>
</property>
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="qliAmp">
<property name="text">
<string>Amplification</string>
</property>
<property name="buddy">
<cstring>qsAmp</cstring>
</property>
</widget>
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout_2">
<item>
<widget class="QCheckBox" name="qcbEchoCancel">
<property name="sizePolicy">
<sizepolicy hsizetype="Maximum" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>Echo Cancellation Processing</string>
</property>
<property name="tristate">
<bool>false</bool>
</property>
</widget>
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout_4">
<item>
<widget class="QLabel" name="qliTransmit">
<property name="sizePolicy">
<sizepolicy hsizetype="Maximum" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>&amp;Transmit:</string>
</property>
<property name="buddy">
<cstring>qcbTransmit</cstring>
</property>
</widget>
</item>
<item>
<widget class="QComboBox" name="qcbTransmit">
<property name="toolTip">
<string>When to transmit your speech</string>
</property>
<property name="whatsThis">
<string>&lt;b&gt;This sets when speech should be transmitted.&lt;/b&gt;&lt;br /&gt;&lt;i&gt;Continuous&lt;/i&gt; - All the time&lt;br /&gt;&lt;i&gt;Voice Activity&lt;/i&gt; - When you are speaking clearly.&lt;br /&gt;&lt;i&gt;Push To Talk&lt;/i&gt; - When you hold down the hotkey set under &lt;i&gt;Shortcuts&lt;/i&gt;.</string>
</property>
</widget>
</item>
</layout>
</item>
<item>
<widget class="QPushButton" name="qpbAudioWizard">
<property name="sizePolicy">
<sizepolicy hsizetype="Maximum" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>Audio Wizard</string>
</property>
</widget>
</item>
</layout>
</item>
<item>
<widget class="QStackedWidget" name="qswTransmit">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Maximum">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="currentIndex">
<number>1</number>
</property>
@ -231,221 +470,21 @@
<widget class="QWidget" name="qwContinuous"/>
</widget>
</item>
</layout>
</widget>
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout">
<item>
<widget class="QGroupBox" name="qgbAudio">
<property name="title">
<string>Audio</string>
</property>
<layout class="QGridLayout">
<item row="1" column="2">
<widget class="QLabel" name="qlAmp">
<property name="minimumSize">
<size>
<width>30</width>
<height>0</height>
</size>
</property>
<property name="text">
<string/>
</property>
</widget>
</item>
<item row="1" column="0">
<widget class="QLabel" name="qliAmp">
<property name="text">
<string>Amplification</string>
</property>
<property name="buddy">
<cstring>qsAmp</cstring>
</property>
</widget>
</item>
<item row="0" column="2">
<widget class="QLabel" name="qlNoise">
<property name="minimumSize">
<size>
<width>30</width>
<height>0</height>
</size>
</property>
<property name="text">
<string/>
</property>
</widget>
</item>
<item row="0" column="1">
<widget class="QSlider" name="qsNoise">
<property name="enabled">
<bool>true</bool>
</property>
<property name="toolTip">
<string>Noise suppression</string>
</property>
<property name="whatsThis">
<string>&lt;b&gt;This sets the amount of noise suppression to apply.&lt;/b&gt;&lt;br /&gt;The higher this value, the more aggressively stationary noise will be suppressed.</string>
</property>
<property name="minimum">
<number>14</number>
</property>
<property name="maximum">
<number>60</number>
</property>
<property name="pageStep">
<number>5</number>
</property>
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
</widget>
</item>
<item row="2" column="0">
<widget class="QCheckBox" name="qcbEchoCancel">
<property name="text">
<string>Echo Cancellation Processing</string>
</property>
<property name="tristate">
<bool>false</bool>
</property>
</widget>
</item>
<item row="0" column="0">
<widget class="QLabel" name="qliNoise">
<property name="text">
<string>Noise Suppression</string>
</property>
<property name="buddy">
<cstring>qsNoise</cstring>
</property>
</widget>
</item>
<item row="1" column="1">
<widget class="QSlider" name="qsAmp">
<property name="toolTip">
<string>Maximum amplification of input sound</string>
</property>
<property name="whatsThis">
<string>&lt;b&gt;Maximum amplification of input.&lt;/b&gt;&lt;br /&gt;RetroShare normalizes the input volume before compressing, and this sets how much it's allowed to amplify.&lt;br /&gt;The actual level is continually updated based on your current speech pattern, but it will never go above the level specified here.&lt;br /&gt;If the &lt;i&gt;Microphone loudness&lt;/i&gt; level of the audio statistics hover around 100%, you probably want to set this to 2.0 or so, but if, like most people, you are unable to reach 100%, set this to something much higher.&lt;br /&gt;Ideally, set it so &lt;i&gt;Microphone Loudness * Amplification Factor &gt;= 100&lt;/i&gt;, even when you're speaking really soft.&lt;br /&gt;&lt;br /&gt;Note that there is no harm in setting this to maximum, but RetroShare will start picking up other conversations if you leave it to auto-tune to that level.</string>
</property>
<property name="maximum">
<number>19500</number>
</property>
<property name="singleStep">
<number>500</number>
</property>
<property name="pageStep">
<number>2000</number>
</property>
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
</widget>
</item>
<item row="3" column="0" colspan="2">
<widget class="AudioBar" name="abSpeech" native="true"/>
</item>
</layout>
</widget>
</item>
</layout>
</item>
<item>
<widget class="QGroupBox" name="groupBox">
<property name="title">
<string>Video</string>
</property>
<layout class="QHBoxLayout" name="horizontalLayout_2">
<item>
<widget class="QVideoOutputDevice" name="videoDisplay">
<property name="minimumSize">
<size>
<width>170</width>
<height>128</height>
</size>
</property>
<property name="frameShape">
<enum>QFrame::StyledPanel</enum>
</property>
<property name="frameShadow">
<enum>QFrame::Raised</enum>
</property>
</widget>
</item>
<item>
<widget class="voipGraph" name="voipBwGraph">
<property name="sizePolicy">
<sizepolicy hsizetype="MinimumExpanding" vsizetype="Expanding">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="frameShape">
<enum>QFrame::StyledPanel</enum>
</property>
<property name="frameShadow">
<enum>QFrame::Raised</enum>
</property>
</widget>
<widget class="AudioBar" name="abSpeech" native="true"/>
</item>
</layout>
</widget>
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout_3">
<item>
<widget class="QLabel" name="label_2">
<property name="text">
<string>Available bandwidth:</string>
</property>
</widget>
</item>
<item>
<widget class="QDoubleSpinBox" name="availableBW_SB">
<property name="toolTip">
<string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;Use this field to simulate the maximum bandwidth available so as to preview what the encoded video will look like with the corresponding compression rate.&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
</property>
<property name="suffix">
<string>KB/s</string>
</property>
<property name="decimals">
<number>1</number>
</property>
<property name="minimum">
<double>2.000000000000000</double>
</property>
<property name="maximum">
<double>200.000000000000000</double>
</property>
<property name="value">
<double>30.000000000000000</double>
</property>
</widget>
</item>
</layout>
</item>
<item>
<widget class="QCheckBox" name="showEncoded_CB">
<property name="toolTip">
<string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;Display encoded (and then decoded) frame, to check the codec's quality. If not selected, the image above only shows the frame that is grabbed from your camera.&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
</property>
<property name="text">
<string>preview</string>
</property>
</widget>
</item>
<item>
<spacer>
<spacer name="verticalSpacer_2">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>1</width>
<height>151</height>
<width>20</width>
<height>40</height>
</size>
</property>
</spacer>
@ -473,7 +512,6 @@
</customwidget>
</customwidgets>
<tabstops>
<tabstop>qcbTransmit</tabstop>
<tabstop>qsDoublePush</tabstop>
<tabstop>qsTransmitHold</tabstop>
<tabstop>qsTransmitMin</tabstop>