Apply volume_by_admin flag in voice chats.

This commit is contained in:
John Preston 2021-02-09 12:58:19 +04:00
parent d60a89f354
commit 39742d22d9
4 changed files with 18 additions and 2 deletions

View file

@ -377,10 +377,15 @@ void GroupCall::applySelfInCallLocally() {
const auto lastActive = (i != end(participants))
? i->lastActive
: TimeId(0);
const auto volume = (i != end(participants))
? i->volume
: Group::kDefaultVolume;
const auto canSelfUnmute = (muted() != MuteState::ForceMuted);
const auto flags = (canSelfUnmute ? Flag::f_can_self_unmute : Flag(0))
| (lastActive ? Flag::f_active_date : Flag(0))
| (_mySsrc ? Flag(0) : Flag::f_left)
| Flag::f_volume // Without flag the volume is reset to 100%.
| Flag::f_volume_by_admin // Self volume can only be set by admin.
| ((muted() != MuteState::Active) ? Flag::f_muted : Flag(0));
call->applyUpdateChecked(
MTP_updateGroupCallParticipants(
@ -393,7 +398,7 @@ void GroupCall::applySelfInCallLocally() {
MTP_int(date),
MTP_int(lastActive),
MTP_int(_mySsrc),
MTP_int(Group::kDefaultVolume))), // volume
MTP_int(volume))),
MTP_int(0)).c_updateGroupCallParticipants());
}
@ -410,6 +415,9 @@ void GroupCall::applyParticipantLocally(
using Flag = MTPDgroupCallParticipant::Flag;
const auto flags = (canSelfUnmute ? Flag::f_can_self_unmute : Flag(0))
| Flag::f_volume // Without flag the volume is reset to 100%.
| ((participant->applyVolumeFromMin && !volume)
? Flag::f_volume_by_admin
: Flag(0))
| (participant->lastActive ? Flag::f_active_date : Flag(0))
| (!mute
? Flag(0)

View file

@ -19,6 +19,7 @@ struct MuteRequest {
bool mute = false;
bool locallyOnly = false;
};
struct VolumeRequest {
not_null<UserData*> user;
int volume = kDefaultVolume;

View file

@ -276,9 +276,14 @@ void GroupCall::applyParticipantsSlice(
&& ((was ? was->speaking : false)
|| (!amInCall
&& (lastActive + speakingAfterActive > now)));
const auto volume = (was && data.is_min())
const auto volume = (was
&& !was->applyVolumeFromMin
&& data.is_min())
? was->volume
: data.vvolume().value_or(Calls::Group::kDefaultVolume);
const auto applyVolumeFromMin = (was && data.is_min())
? was->applyVolumeFromMin
: (data.is_min() || data.is_volume_by_admin());
const auto mutedByMe = (was && data.is_min())
? was->mutedByMe
: data.is_muted_by_you();
@ -290,6 +295,7 @@ void GroupCall::applyParticipantsSlice(
.lastActive = lastActive,
.ssrc = uint32(data.vsource().v),
.volume = volume,
.applyVolumeFromMin = applyVolumeFromMin,
.speaking = canSelfUnmute && (was ? was->speaking : false),
.muted = data.is_muted(),
.mutedByMe = mutedByMe,

View file

@ -38,6 +38,7 @@ public:
TimeId lastActive = 0;
uint32 ssrc = 0;
int volume = 0;
bool applyVolumeFromMin = true;
bool sounding = false;
bool speaking = false;
bool muted = false;