mirror of
https://github.com/qTox/qTox.git
synced 2024-03-22 14:00:36 +08:00
Merge pull request #4697
tox-user (5): feat(settings): Add audio quality setting feat(settings): make audio quality setting persistent refactor(settings): use constants in audio quality setting refactor(settings): use a cleaner way to read and set audio bitrate style(settings): change names of local constants to camel case
This commit is contained in:
commit
b609a8f99a
|
@ -48,9 +48,6 @@
|
|||
* @brief Sent when a call was ended by the peer.
|
||||
* @param friendId Id of friend in call list.
|
||||
*
|
||||
* @var CoreAV::AUDIO_DEFAULT_BITRATE
|
||||
* @brief In kb/s. More than enough for Opus.
|
||||
*
|
||||
* @var CoreAV::VIDEO_DEFAULT_BITRATE
|
||||
* @brief Picked at random by fair dice roll.
|
||||
*/
|
||||
|
@ -236,7 +233,7 @@ bool CoreAV::answerCall(uint32_t friendNum)
|
|||
qDebug() << QString("answering call %1").arg(friendNum);
|
||||
assert(calls.contains(friendNum));
|
||||
TOXAV_ERR_ANSWER err;
|
||||
if (toxav_answer(toxav, friendNum, AUDIO_DEFAULT_BITRATE, VIDEO_DEFAULT_BITRATE, &err)) {
|
||||
if (toxav_answer(toxav, friendNum, Settings::getInstance().getAudioBitrate(), VIDEO_DEFAULT_BITRATE, &err)) {
|
||||
calls[friendNum].inactive = false;
|
||||
return true;
|
||||
} else {
|
||||
|
@ -271,7 +268,7 @@ bool CoreAV::startCall(uint32_t friendNum, bool video)
|
|||
}
|
||||
|
||||
uint32_t videoBitrate = video ? VIDEO_DEFAULT_BITRATE : 0;
|
||||
if (!toxav_call(toxav, friendNum, AUDIO_DEFAULT_BITRATE, videoBitrate, nullptr))
|
||||
if (!toxav_call(toxav, friendNum, Settings::getInstance().getAudioBitrate(), videoBitrate, nullptr))
|
||||
return false;
|
||||
|
||||
auto call = calls.insert({friendNum, video, *this});
|
||||
|
|
|
@ -111,7 +111,6 @@ private:
|
|||
int32_t ystride, int32_t ustride, int32_t vstride, void* self);
|
||||
|
||||
private:
|
||||
static constexpr uint32_t AUDIO_DEFAULT_BITRATE = 64;
|
||||
static constexpr uint32_t VIDEO_DEFAULT_BITRATE = 6144;
|
||||
|
||||
private:
|
||||
|
|
|
@ -265,6 +265,7 @@ void Settings::loadGlobal()
|
|||
audioOutDevEnabled = s.value("audioOutDevEnabled", true).toBool();
|
||||
audioInGainDecibel = s.value("inGain", 0).toReal();
|
||||
outVolume = s.value("outVolume", 100).toInt();
|
||||
audioBitrate = s.value("audioBitrate", 64).toInt();
|
||||
enableBackend2 = false;
|
||||
#ifdef USE_FILTERAUDIO
|
||||
enableBackend2 = s.value("enableBackend2", false).toBool();
|
||||
|
@ -566,6 +567,7 @@ void Settings::saveGlobal()
|
|||
s.setValue("audioOutDevEnabled", audioOutDevEnabled);
|
||||
s.setValue("inGain", audioInGainDecibel);
|
||||
s.setValue("outVolume", outVolume);
|
||||
s.setValue("audioBitrate", audioBitrate);
|
||||
s.setValue("enableBackend2", enableBackend2);
|
||||
}
|
||||
s.endGroup();
|
||||
|
@ -1882,6 +1884,22 @@ void Settings::setOutVolume(int volume)
|
|||
}
|
||||
}
|
||||
|
||||
int Settings::getAudioBitrate() const
|
||||
{
|
||||
const QMutexLocker locker{&bigLock};
|
||||
return audioBitrate;
|
||||
}
|
||||
|
||||
void Settings::setAudioBitrate(int bitrate)
|
||||
{
|
||||
const QMutexLocker locker{&bigLock};
|
||||
|
||||
if (bitrate != audioBitrate) {
|
||||
audioBitrate = bitrate;
|
||||
emit audioBitrateChanged(audioBitrate);
|
||||
}
|
||||
}
|
||||
|
||||
bool Settings::getEnableBackend2() const
|
||||
{
|
||||
QMutexLocker locker{&bigLock};
|
||||
|
|
|
@ -101,6 +101,7 @@ class Settings : public QObject
|
|||
Q_PROPERTY(bool audioOutDevEnabled READ getAudioOutDevEnabled WRITE setAudioOutDevEnabled NOTIFY
|
||||
audioOutDevEnabledChanged FINAL)
|
||||
Q_PROPERTY(int outVolume READ getOutVolume WRITE setOutVolume NOTIFY outVolumeChanged FINAL)
|
||||
Q_PROPERTY(int audioBitrate READ getAudioBitrate WRITE setAudioBitrate NOTIFY audioBitrateChanged FINAL)
|
||||
Q_PROPERTY(bool enableBackend2 READ getEnableBackend2 WRITE setEnableBackend2 NOTIFY
|
||||
enableBackend2Changed FINAL)
|
||||
|
||||
|
@ -241,6 +242,7 @@ signals:
|
|||
void outDevChanged(const QString& name);
|
||||
void audioOutDevEnabledChanged(bool enabled);
|
||||
void outVolumeChanged(int volume);
|
||||
void audioBitrateChanged(int bitrate);
|
||||
void enableTestSoundChanged(bool enabled);
|
||||
void enableBackend2Changed(bool enabled);
|
||||
|
||||
|
@ -369,6 +371,9 @@ public:
|
|||
int getOutVolume() const;
|
||||
void setOutVolume(int volume);
|
||||
|
||||
int getAudioBitrate() const;
|
||||
void setAudioBitrate(int bitrate);
|
||||
|
||||
bool getEnableTestSound() const;
|
||||
void setEnableTestSound(bool newValue);
|
||||
|
||||
|
@ -631,6 +636,7 @@ private:
|
|||
QString outDev;
|
||||
bool audioOutDevEnabled;
|
||||
int outVolume;
|
||||
int audioBitrate;
|
||||
bool enableTestSound;
|
||||
bool enableBackend2;
|
||||
|
||||
|
|
|
@ -83,6 +83,8 @@ AVForm::AVForm()
|
|||
microphoneSlider->setTracking(false);
|
||||
microphoneSlider->installEventFilter(this);
|
||||
|
||||
fillAudioQualityComboBox();
|
||||
|
||||
eventsInit();
|
||||
|
||||
QDesktopWidget* desktop = QApplication::desktop();
|
||||
|
@ -333,6 +335,22 @@ void AVForm::fillScreenModesComboBox()
|
|||
videoModescomboBox->blockSignals(previouslyBlocked);
|
||||
}
|
||||
|
||||
void AVForm::fillAudioQualityComboBox()
|
||||
{
|
||||
const bool previouslyBlocked = audioQualityComboBox->blockSignals(true);
|
||||
|
||||
audioQualityComboBox->addItem(tr("High (64 kbps)"), 64);
|
||||
audioQualityComboBox->addItem(tr("Medium (32 kbps)"), 32);
|
||||
audioQualityComboBox->addItem(tr("Low (16 kbps)"), 16);
|
||||
audioQualityComboBox->addItem(tr("Very low (8 kbps)"), 8);
|
||||
|
||||
const int currentBitrate = Settings::getInstance().getAudioBitrate();
|
||||
const int index = audioQualityComboBox->findData(currentBitrate);
|
||||
|
||||
audioQualityComboBox->setCurrentIndex(index);
|
||||
audioQualityComboBox->blockSignals(previouslyBlocked);
|
||||
}
|
||||
|
||||
void AVForm::updateVideoModes(int curIndex)
|
||||
{
|
||||
if (curIndex < 0 || curIndex >= videoDeviceList.size()) {
|
||||
|
@ -408,6 +426,11 @@ void AVForm::on_videoDevCombobox_currentIndexChanged(int index)
|
|||
Core::getInstance()->getAv()->sendNoVideo();
|
||||
}
|
||||
|
||||
void AVForm::on_audioQualityComboBox_currentIndexChanged(int index)
|
||||
{
|
||||
Settings::getInstance().setAudioBitrate(audioQualityComboBox->currentData().toInt());
|
||||
}
|
||||
|
||||
void AVForm::getVideoDevices()
|
||||
{
|
||||
QString settingsInDev = Settings::getInstance().getVideoDev();
|
||||
|
|
|
@ -52,6 +52,7 @@ private:
|
|||
void selectBestModes(QVector<VideoMode>& allVideoModes);
|
||||
void fillCameraModesComboBox();
|
||||
void fillScreenModesComboBox();
|
||||
void fillAudioQualityComboBox();
|
||||
int searchPreferredIndex();
|
||||
|
||||
void createVideoSurface();
|
||||
|
@ -66,6 +67,7 @@ private slots:
|
|||
void on_playbackSlider_valueChanged(int value);
|
||||
void on_cbEnableTestSound_stateChanged();
|
||||
void on_microphoneSlider_valueChanged(int value);
|
||||
void on_audioQualityComboBox_currentIndexChanged(int index);
|
||||
|
||||
// camera
|
||||
void on_videoDevCombobox_currentIndexChanged(int index);
|
||||
|
|
|
@ -108,7 +108,27 @@
|
|||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="4" column="0" colspan="3">
|
||||
<item row="4" column="0">
|
||||
<widget class="QLabel" name="audioQualityLabel">
|
||||
<property name="text">
|
||||
<string>Audio quality</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="4" column="1" colspan="2">
|
||||
<widget class="QComboBox" name="audioQualityComboBox">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Expanding" vsizetype="Fixed">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="toolTip">
|
||||
<string>Transmitted audio quality. Lower this setting if your bandwidth is not high enough or if you want to lower the internet usage.</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="5" column="0" colspan="3">
|
||||
<widget class="QCheckBox" name="cbEnableBackend2">
|
||||
<property name="enabled">
|
||||
<bool>true</bool>
|
||||
|
|
Loading…
Reference in New Issue
Block a user