1
0
mirror of https://github.com/qTox/qTox.git synced 2024-03-22 14:00:36 +08:00

feat(settings): Add audio quality setting

Fixes #4693
This commit is contained in:
tox-user 2017-09-28 16:11:10 +02:00
parent ce0c102011
commit 61eddc1f6b
5 changed files with 67 additions and 5 deletions

View File

@ -48,7 +48,7 @@
* @brief Sent when a call was ended by the peer.
* @param friendId Id of friend in call list.
*
* @var CoreAV::AUDIO_DEFAULT_BITRATE
* @var CoreAV::audioBitrate
* @brief In kb/s. More than enough for Opus.
*
* @var CoreAV::VIDEO_DEFAULT_BITRATE
@ -236,7 +236,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, audioBitrate, VIDEO_DEFAULT_BITRATE, &err)) {
calls[friendNum].inactive = false;
return true;
} else {
@ -271,7 +271,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, audioBitrate, videoBitrate, nullptr))
return false;
auto call = calls.insert({friendNum, video, *this});

View File

@ -81,6 +81,7 @@ public:
uint8_t channels, unsigned sample_rate, void* core);
static void invalidateGroupCallPeerSource(int group, int peer);
uint32_t audioBitrate = 64;
public slots:
bool startCall(uint32_t friendNum, bool video = false);
bool answerCall(uint32_t friendNum);
@ -111,7 +112,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:

View File

@ -121,6 +121,7 @@ void AVForm::showEvent(QShowEvent* event)
getAudioInDevices();
createVideoSurface();
getVideoDevices();
fillAudioQualityComboBox();
if (!subscribedToAudioIn) {
// TODO: This should not be done in show/hide events
@ -333,6 +334,24 @@ void AVForm::fillScreenModesComboBox()
videoModescomboBox->blockSignals(previouslyBlocked);
}
void AVForm::fillAudioQualityComboBox()
{
bool previouslyBlocked = audioQualityComboBox->blockSignals(true);
audioQualityComboBox->clear();
QString name;
name = tr("High (64 kbps)");
audioQualityComboBox->addItem(name);
name = tr("Medium (32 kbps)");
audioQualityComboBox->addItem(name);
name = tr("Low (16 kbps)");
audioQualityComboBox->addItem(name);
name = tr("Very Low (8 kbps)");
audioQualityComboBox->addItem(name);
audioQualityComboBox->blockSignals(previouslyBlocked);
}
void AVForm::updateVideoModes(int curIndex)
{
if (curIndex < 0 || curIndex >= videoDeviceList.size()) {
@ -408,6 +427,27 @@ void AVForm::on_videoDevCombobox_currentIndexChanged(int index)
Core::getInstance()->getAv()->sendNoVideo();
}
void AVForm::on_audioQualityComboBox_currentIndexChanged(int index)
{
uint32_t bitrate;
switch (index) {
case 1:
bitrate = 32;
break;
case 2:
bitrate = 16;
break;
case 3:
bitrate = 8;
break;
default:
bitrate = 64;
break;
}
Core::getInstance()->getAv()->audioBitrate = bitrate;
}
void AVForm::getVideoDevices()
{
QString settingsInDev = Settings::getInstance().getVideoDev();

View File

@ -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);

View File

@ -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>