Add "Enable noise suppression" setting to group calls.

This commit is contained in:
John Preston 2021-06-15 12:32:47 +04:00
parent 4e0355d09f
commit b2bf8244dd
6 changed files with 41 additions and 1 deletions

View File

@ -2057,6 +2057,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
"lng_group_call_ptt_delay_s" = "{amount}s";
"lng_group_call_ptt_delay" = "Push to Talk release delay: {delay}";
"lng_group_call_share" = "Share Invite Link";
"lng_group_call_noise_suppression" = "Enable Noise Suppression";
"lng_group_call_share_speaker" = "Users with this link can speak";
"lng_group_call_copy_speaker_link" = "Copy Speaker Link";
"lng_group_call_copy_listener_link" = "Copy Listener Link";

View File

@ -1606,6 +1606,12 @@ void GroupCall::toggleScheduleStartSubscribed(bool subscribed) {
}).send();
}
void GroupCall::setNoiseSuppression(bool enabled) {
if (_instance) {
_instance->setIsNoiseSuppressionEnabled(enabled);
}
}
void GroupCall::addVideoOutput(
const std::string &endpoint,
not_null<Webrtc::VideoTrack*> track) {
@ -2171,6 +2177,8 @@ bool GroupCall::tryCreateController() {
return result;
},
.videoContentType = tgcalls::VideoContentType::Generic,
.initialEnableNoiseSuppression
= settings.groupCallNoiseSuppression(),
.requestMediaChannelDescriptions = [=, call = base::make_weak(this)](
const std::vector<uint32_t> &ssrcs,
std::function<void(

View File

@ -235,6 +235,7 @@ public:
}
void startScheduledNow();
void toggleScheduleStartSubscribed(bool subscribed);
void setNoiseSuppression(bool enabled);
bool emitShareScreenError();
bool emitShareCameraError();

View File

@ -306,6 +306,20 @@ void SettingsBox(
//AddDivider(layout);
//AddSkip(layout);
AddButton(
layout,
tr::lng_group_call_noise_suppression(),
st::groupCallSettingsButton
)->toggleOn(rpl::single(
settings.groupCallNoiseSuppression()
))->toggledChanges(
) | rpl::start_with_next([=](bool enabled) {
Core::App().settings().setGroupCallNoiseSuppression(enabled);
call->setNoiseSuppression(enabled);
Core::App().saveSettingsDelayed();
}, layout->lifetime());
using GlobalShortcut = base::GlobalShortcut;
struct PushToTalkState {
rpl::variable<QString> recordText = tr::lng_group_call_ptt_shortcut();

View File

@ -195,7 +195,9 @@ QByteArray Settings::serialize() const {
for (const auto &[id, variant] : _emojiVariants) {
stream << id << quint8(variant);
}
stream << qint32(_disableOpenGL ? 1 : 0);
stream
<< qint32(_disableOpenGL ? 1 : 0)
<< qint32(_groupCallNoiseSuppression ? 1 : 0);
}
return result;
}
@ -272,6 +274,7 @@ void Settings::addFromSerialized(const QByteArray &serialized) {
std::vector<RecentEmojiId> recentEmojiPreload;
base::flat_map<QString, uint8> emojiVariants;
qint32 disableOpenGL = _disableOpenGL ? 1 : 0;
qint32 groupCallNoiseSuppression = _groupCallNoiseSuppression ? 1 : 0;
stream >> themesAccentColors;
if (!stream.atEnd()) {
@ -403,6 +406,9 @@ void Settings::addFromSerialized(const QByteArray &serialized) {
if (!stream.atEnd()) {
stream >> disableOpenGL;
}
if (!stream.atEnd()) {
stream >> groupCallNoiseSuppression;
}
if (stream.status() != QDataStream::Ok) {
LOG(("App Error: "
"Bad data for Core::Settings::constructFromSerialized()"));
@ -513,6 +519,7 @@ void Settings::addFromSerialized(const QByteArray &serialized) {
Ui::GL::ForceDisable(_disableOpenGL
|| Ui::Integration::Instance().openglLastCheckFailed());
}
_groupCallNoiseSuppression = (groupCallNoiseSuppression == 1);
}
bool Settings::chatWide() const {
@ -741,6 +748,8 @@ void Settings::resetOnLastLogout() {
_groupCallPushToTalkShortcut = QByteArray();
_groupCallPushToTalkDelay = 20;
_groupCallNoiseSuppression = true;
//_themesAccentColors = Window::Theme::AccentColors();
_lastSeenWarningSeen = false;

View File

@ -265,6 +265,12 @@ public:
void setGroupCallPushToTalkDelay(crl::time delay) {
_groupCallPushToTalkDelay = delay;
}
[[nodiscard]] bool groupCallNoiseSuppression() const {
return _groupCallNoiseSuppression;
}
void setGroupCallNoiseSuppression(bool value) {
_groupCallNoiseSuppression = value;
}
[[nodiscard]] Window::Theme::AccentColors &themesAccentColors() {
return _themesAccentColors;
}
@ -594,6 +600,7 @@ private:
bool _callAudioDuckingEnabled = true;
bool _disableCalls = false;
bool _groupCallPushToTalk = false;
bool _groupCallNoiseSuppression = true;
QByteArray _groupCallPushToTalkShortcut;
crl::time _groupCallPushToTalkDelay = 20;
Window::Theme::AccentColors _themesAccentColors;