mirror of
https://github.com/AyuGram/AyuGramDesktop.git
synced 2025-06-05 06:33:57 +02:00
Cancel outgoing video when muted by admin.
This commit is contained in:
parent
c6f44e7928
commit
f3e6f5e772
5 changed files with 37 additions and 15 deletions
|
@ -280,8 +280,7 @@ void TopBar::initControls() {
|
||||||
if (const auto call = _call.get()) {
|
if (const auto call = _call.get()) {
|
||||||
call->setMuted(!call->muted());
|
call->setMuted(!call->muted());
|
||||||
} else if (const auto group = _groupCall.get()) {
|
} else if (const auto group = _groupCall.get()) {
|
||||||
if (group->muted() == MuteState::ForceMuted
|
if (group->mutedByAdmin()) {
|
||||||
|| group->muted() == MuteState::RaisedHand) {
|
|
||||||
Ui::Toast::Show(tr::lng_group_call_force_muted_sub(tr::now));
|
Ui::Toast::Show(tr::lng_group_call_force_muted_sub(tr::now));
|
||||||
} else {
|
} else {
|
||||||
group->setMuted((group->muted() == MuteState::Muted)
|
group->setMuted((group->muted() == MuteState::Muted)
|
||||||
|
|
|
@ -467,8 +467,16 @@ QString GroupCall::screenSharingDeviceId() const {
|
||||||
return isSharingScreen() ? _screenDeviceId : QString();
|
return isSharingScreen() ? _screenDeviceId : QString();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool GroupCall::mutedByAdmin() const {
|
||||||
|
const auto mute = muted();
|
||||||
|
return mute == MuteState::ForceMuted || mute == MuteState::RaisedHand;
|
||||||
|
}
|
||||||
|
|
||||||
void GroupCall::toggleVideo(bool active) {
|
void GroupCall::toggleVideo(bool active) {
|
||||||
if (!_instance || !_id) {
|
if (!_instance
|
||||||
|
|| !_id
|
||||||
|
|| (active && mutedByAdmin())
|
||||||
|
|| (!active && !_cameraOutgoing)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
ensureOutgoingVideo();
|
ensureOutgoingVideo();
|
||||||
|
@ -481,6 +489,12 @@ void GroupCall::toggleVideo(bool active) {
|
||||||
}
|
}
|
||||||
|
|
||||||
void GroupCall::toggleScreenSharing(std::optional<QString> uniqueId) {
|
void GroupCall::toggleScreenSharing(std::optional<QString> uniqueId) {
|
||||||
|
if (!_instance
|
||||||
|
|| !_id
|
||||||
|
|| (uniqueId && mutedByAdmin())
|
||||||
|
|| (!uniqueId && !_screenOutgoing)) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
ensureOutgoingVideo();
|
ensureOutgoingVideo();
|
||||||
if (!uniqueId) {
|
if (!uniqueId) {
|
||||||
_screenOutgoing->setState(Webrtc::VideoState::Inactive);
|
_screenOutgoing->setState(Webrtc::VideoState::Inactive);
|
||||||
|
@ -853,9 +867,7 @@ void GroupCall::rejoin() {
|
||||||
}
|
}
|
||||||
|
|
||||||
void GroupCall::rejoinWithHash(const QString &hash) {
|
void GroupCall::rejoinWithHash(const QString &hash) {
|
||||||
if (!hash.isEmpty()
|
if (!hash.isEmpty() && mutedByAdmin()) {
|
||||||
&& (muted() == MuteState::ForceMuted
|
|
||||||
|| muted() == MuteState::RaisedHand)) {
|
|
||||||
_joinHash = hash;
|
_joinHash = hash;
|
||||||
rejoin();
|
rejoin();
|
||||||
}
|
}
|
||||||
|
@ -1060,8 +1072,7 @@ void GroupCall::applyMeInCallLocally() {
|
||||||
const auto volume = participant
|
const auto volume = participant
|
||||||
? participant->volume
|
? participant->volume
|
||||||
: Group::kDefaultVolume;
|
: Group::kDefaultVolume;
|
||||||
const auto canSelfUnmute = (muted() != MuteState::ForceMuted)
|
const auto canSelfUnmute = !mutedByAdmin();
|
||||||
&& (muted() != MuteState::RaisedHand);
|
|
||||||
const auto raisedHandRating = (muted() != MuteState::RaisedHand)
|
const auto raisedHandRating = (muted() != MuteState::RaisedHand)
|
||||||
? uint64(0)
|
? uint64(0)
|
||||||
: participant
|
: participant
|
||||||
|
@ -1282,6 +1293,10 @@ void GroupCall::setMuted(MuteState mute) {
|
||||||
if (wasMuted != nowMuted || wasRaiseHand != nowRaiseHand) {
|
if (wasMuted != nowMuted || wasRaiseHand != nowRaiseHand) {
|
||||||
applyMeInCallLocally();
|
applyMeInCallLocally();
|
||||||
}
|
}
|
||||||
|
if (mutedByAdmin()) {
|
||||||
|
toggleVideo(false);
|
||||||
|
toggleScreenSharing(std::nullopt);
|
||||||
|
}
|
||||||
};
|
};
|
||||||
if (mute == MuteState::Active || mute == MuteState::PushToTalk) {
|
if (mute == MuteState::Active || mute == MuteState::PushToTalk) {
|
||||||
_delegate->groupCallRequestPermissionsOrFail(crl::guard(this, set));
|
_delegate->groupCallRequestPermissionsOrFail(crl::guard(this, set));
|
||||||
|
@ -1484,8 +1499,7 @@ void GroupCall::applySelfUpdate(const MTPDgroupCallParticipant &data) {
|
||||||
LOG(("Call Info: Rejoin after unforcemute in stream mode."));
|
LOG(("Call Info: Rejoin after unforcemute in stream mode."));
|
||||||
setState(State::Joining);
|
setState(State::Joining);
|
||||||
rejoin();
|
rejoin();
|
||||||
} else if (muted() == MuteState::ForceMuted
|
} else if (mutedByAdmin()) {
|
||||||
|| muted() == MuteState::RaisedHand) {
|
|
||||||
setMuted(MuteState::Muted);
|
setMuted(MuteState::Muted);
|
||||||
if (!_instanceTransitioning) {
|
if (!_instanceTransitioning) {
|
||||||
notifyAboutAllowedToSpeak();
|
notifyAboutAllowedToSpeak();
|
||||||
|
@ -2508,9 +2522,7 @@ void GroupCall::applyGlobalShortcutChanges() {
|
||||||
}
|
}
|
||||||
|
|
||||||
void GroupCall::pushToTalk(bool pressed, crl::time delay) {
|
void GroupCall::pushToTalk(bool pressed, crl::time delay) {
|
||||||
if (muted() == MuteState::ForceMuted
|
if (mutedByAdmin() || muted() == MuteState::Active) {
|
||||||
|| muted() == MuteState::RaisedHand
|
|
||||||
|| muted() == MuteState::Active) {
|
|
||||||
return;
|
return;
|
||||||
} else if (pressed) {
|
} else if (pressed) {
|
||||||
_pushToTalkCancelTimer.cancel();
|
_pushToTalkCancelTimer.cancel();
|
||||||
|
|
|
@ -327,6 +327,7 @@ public:
|
||||||
}
|
}
|
||||||
static constexpr auto kSpeakLevelThreshold = 0.2;
|
static constexpr auto kSpeakLevelThreshold = 0.2;
|
||||||
|
|
||||||
|
[[nodiscard]] bool mutedByAdmin() const;
|
||||||
void setCurrentAudioDevice(bool input, const QString &deviceId);
|
void setCurrentAudioDevice(bool input, const QString &deviceId);
|
||||||
void setCurrentVideoDevice(const QString &deviceId);
|
void setCurrentVideoDevice(const QString &deviceId);
|
||||||
[[nodiscard]] bool isSharingScreen() const;
|
[[nodiscard]] bool isSharingScreen() const;
|
||||||
|
|
|
@ -774,6 +774,10 @@ void Panel::refreshVideoButtons(std::optional<bool> overrideWideMode) {
|
||||||
) | rpl::start_with_next([=](bool sharing) {
|
) | rpl::start_with_next([=](bool sharing) {
|
||||||
_video->setProgress(sharing ? 1. : 0.);
|
_video->setProgress(sharing ? 1. : 0.);
|
||||||
}, _video->lifetime());
|
}, _video->lifetime());
|
||||||
|
_call->mutedValue(
|
||||||
|
) | rpl::start_with_next([=] {
|
||||||
|
updateButtonsGeometry();
|
||||||
|
}, _video->lifetime());
|
||||||
}
|
}
|
||||||
if (!_screenShare) {
|
if (!_screenShare) {
|
||||||
_screenShare.create(widget(), st::groupCallScreenShareSmall);
|
_screenShare.create(widget(), st::groupCallScreenShareSmall);
|
||||||
|
@ -2040,13 +2044,14 @@ void Panel::updateButtonsGeometry() {
|
||||||
if (_callShare) {
|
if (_callShare) {
|
||||||
_callShare->moveToLeft(leftButtonLeft, buttonsTop);
|
_callShare->moveToLeft(leftButtonLeft, buttonsTop);
|
||||||
}
|
}
|
||||||
|
const auto showVideoButton = videoButtonInNarrowMode();
|
||||||
if (_video) {
|
if (_video) {
|
||||||
_video->setVisible(!_callShare);
|
_video->setVisible(!_callShare && showVideoButton);
|
||||||
_video->setStyle(st::groupCallVideo, &st::groupCallVideoActive);
|
_video->setStyle(st::groupCallVideo, &st::groupCallVideoActive);
|
||||||
_video->moveToLeft(leftButtonLeft, buttonsTop);
|
_video->moveToLeft(leftButtonLeft, buttonsTop);
|
||||||
}
|
}
|
||||||
if (_settings) {
|
if (_settings) {
|
||||||
_settings->setVisible(!_callShare && !_video);
|
_settings->setVisible(!_callShare && !showVideoButton);
|
||||||
_settings->moveToLeft(leftButtonLeft, buttonsTop);
|
_settings->moveToLeft(leftButtonLeft, buttonsTop);
|
||||||
}
|
}
|
||||||
_hangup->moveToRight(leftButtonLeft, buttonsTop);
|
_hangup->moveToRight(leftButtonLeft, buttonsTop);
|
||||||
|
@ -2073,6 +2078,10 @@ void Panel::updateButtonsGeometry() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool Panel::videoButtonInNarrowMode() const {
|
||||||
|
return (_video != nullptr) && !_call->mutedByAdmin();
|
||||||
|
}
|
||||||
|
|
||||||
void Panel::updateMembersGeometry() {
|
void Panel::updateMembersGeometry() {
|
||||||
if (!_members) {
|
if (!_members) {
|
||||||
return;
|
return;
|
||||||
|
|
|
@ -113,6 +113,7 @@ private:
|
||||||
std::optional<bool> overrideWideMode = std::nullopt);
|
std::optional<bool> overrideWideMode = std::nullopt);
|
||||||
void refreshTilesGeometry();
|
void refreshTilesGeometry();
|
||||||
void toggleWideControls(bool shown);
|
void toggleWideControls(bool shown);
|
||||||
|
[[nodiscard]] bool videoButtonInNarrowMode() const;
|
||||||
|
|
||||||
void endCall();
|
void endCall();
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue