From 25e29d3dd5ec14704b4ab194fe54202bc15b2723 Mon Sep 17 00:00:00 2001 From: John Preston Date: Mon, 28 Feb 2022 13:52:49 +0300 Subject: [PATCH] Hide members in RTMP streams. --- .../calls/group/calls_group_call.cpp | 11 +++++++++- .../calls/group/calls_group_call.h | 2 ++ .../calls/group/calls_group_panel.cpp | 20 +++++++++++++------ Telegram/SourceFiles/data/data_group_call.cpp | 8 +++++++- Telegram/SourceFiles/data/data_group_call.h | 2 ++ 5 files changed, 35 insertions(+), 8 deletions(-) diff --git a/Telegram/SourceFiles/calls/group/calls_group_call.cpp b/Telegram/SourceFiles/calls/group/calls_group_call.cpp index 64dc46a1b..4381935a3 100644 --- a/Telegram/SourceFiles/calls/group/calls_group_call.cpp +++ b/Telegram/SourceFiles/calls/group/calls_group_call.cpp @@ -582,6 +582,7 @@ GroupCall::GroupCall( , _checkJoinedTimer([=] { checkJoined(); }) , _pushToTalkCancelTimer([=] { pushToTalkCancel(); }) , _connectingSoundTimer([=] { playConnectingSoundOnce(); }) +, _listenersHidden(info.rtmp) , _rtmp(info.rtmp) , _mediaDevices(CreateMediaDevices()) { _muted.value( @@ -693,7 +694,9 @@ bool GroupCall::screenSharingWithAudio() const { bool GroupCall::mutedByAdmin() const { const auto mute = muted(); - return mute == MuteState::ForceMuted || mute == MuteState::RaisedHand; + return _rtmp + || (mute == MuteState::ForceMuted) + || (mute == MuteState::RaisedHand); } bool GroupCall::canManage() const { @@ -756,6 +759,8 @@ void GroupCall::setScheduledDate(TimeId date) { } void GroupCall::subscribeToReal(not_null real) { + _listenersHidden = real->listenersHidden(); + real->scheduleDateValue( ) | rpl::start_with_next([=](TimeId date) { setScheduledDate(date); @@ -1001,6 +1006,10 @@ bool GroupCall::rtmp() const { return _rtmp; } +bool GroupCall::listenersHidden() const { + return _listenersHidden; +} + Data::GroupCall *GroupCall::lookupReal() const { const auto real = _peer->groupCall(); return (real && real->id() == _id) ? real : nullptr; diff --git a/Telegram/SourceFiles/calls/group/calls_group_call.h b/Telegram/SourceFiles/calls/group/calls_group_call.h index be11ac4ba..e7cd9fd7c 100644 --- a/Telegram/SourceFiles/calls/group/calls_group_call.h +++ b/Telegram/SourceFiles/calls/group/calls_group_call.h @@ -232,6 +232,7 @@ public: } [[nodiscard]] bool scheduleStartSubscribed() const; [[nodiscard]] bool rtmp() const; + [[nodiscard]] bool listenersHidden() const; [[nodiscard]] Data::GroupCall *lookupReal() const; [[nodiscard]] rpl::producer> real() const; @@ -659,6 +660,7 @@ private: base::Timer _pushToTalkCancelTimer; base::Timer _connectingSoundTimer; bool _hadJoinedState = false; + bool _listenersHidden = false; bool _rtmp = false; std::unique_ptr _mediaDevices; diff --git a/Telegram/SourceFiles/calls/group/calls_group_panel.cpp b/Telegram/SourceFiles/calls/group/calls_group_panel.cpp index 18aba7e97..d9d7d467b 100644 --- a/Telegram/SourceFiles/calls/group/calls_group_panel.cpp +++ b/Telegram/SourceFiles/calls/group/calls_group_panel.cpp @@ -1433,8 +1433,9 @@ bool Panel::updateMode() { if (!_viewport) { return false; } - const auto wide = _call->hasVideoWithFrames() - && (widget()->width() >= st::groupCallWideModeWidthMin); + const auto wide = _call->rtmp() + || (_call->hasVideoWithFrames() + && (widget()->width() >= st::groupCallWideModeWidthMin)); const auto mode = wide ? PanelMode::Wide : PanelMode::Default; if (_mode.current() == mode) { return false; @@ -1457,6 +1458,8 @@ bool Panel::updateMode() { _subtitle.destroy(); } else if (!wide && !_subtitle) { refreshTitle(); + } else if (!_members) { + setupMembers(); } _wideControlsShown = _showWideControls = true; _wideControlsAnimation.stop(); @@ -1934,7 +1937,7 @@ void Panel::updateButtonsGeometry() { const auto hidden = (shown == 0.); if (_viewport) { - _viewport->setControlsShown(shown); + _viewport->setControlsShown(_call->rtmp() ? 0. : shown); } const auto buttonsTop = widget()->height() - anim::interpolate( @@ -1950,8 +1953,9 @@ void Panel::updateButtonsGeometry() { + (_settings ->width() + skip) + _hangup->width(); const auto membersSkip = st::groupCallNarrowSkip; - const auto membersWidth = st::groupCallNarrowMembersWidth - + 2 * membersSkip; + const auto membersWidth = _call->rtmp() + ? membersSkip + : (st::groupCallNarrowMembersWidth + 2 * membersSkip); auto left = membersSkip + (widget()->width() - membersWidth - membersSkip @@ -2046,6 +2050,7 @@ void Panel::updateMembersGeometry() { if (!_members) { return; } + _members->setVisible(!_call->rtmp()); const auto desiredHeight = _members->desiredHeight(); if (mode() == PanelMode::Wide) { const auto skip = st::groupCallNarrowSkip; @@ -2056,10 +2061,13 @@ void Panel::updateMembersGeometry() { top, membersWidth, std::min(desiredHeight, widget()->height() - top - skip)); + const auto viewportSkip = _call->rtmp() + ? 0 + : (skip + membersWidth); _viewport->setGeometry({ skip, top, - widget()->width() - membersWidth - 3 * skip, + widget()->width() - viewportSkip - 2 * skip, widget()->height() - top - skip, }); } else { diff --git a/Telegram/SourceFiles/data/data_group_call.cpp b/Telegram/SourceFiles/data/data_group_call.cpp index 941c73b55..4a84e138e 100644 --- a/Telegram/SourceFiles/data/data_group_call.cpp +++ b/Telegram/SourceFiles/data/data_group_call.cpp @@ -68,7 +68,8 @@ GroupCall::GroupCall( , _reloadByQueuedUpdatesTimer([=] { reload(); }) , _speakingByActiveFinishTimer([=] { checkFinishSpeakingByActive(); }) , _scheduleDate(scheduleDate) -, _rtmp(rtmp) { +, _rtmp(rtmp) +, _listenersHidden(rtmp) { } GroupCall::~GroupCall() { @@ -89,6 +90,10 @@ bool GroupCall::rtmp() const { return _rtmp; } +bool GroupCall::listenersHidden() const { + return _listenersHidden; +} + not_null GroupCall::peer() const { return _peer; } @@ -395,6 +400,7 @@ void GroupCall::applyCallFields(const MTPDgroupCall &data) { _version = 1; } _rtmp = data.is_rtmp_stream(); + _listenersHidden = data.is_listeners_hidden(); _joinMuted = data.is_join_muted(); _canChangeJoinMuted = data.is_can_change_join_muted(); _joinedToTop = !data.is_join_date_asc(); diff --git a/Telegram/SourceFiles/data/data_group_call.h b/Telegram/SourceFiles/data/data_group_call.h index 392ef5f18..542b3dc3e 100644 --- a/Telegram/SourceFiles/data/data_group_call.h +++ b/Telegram/SourceFiles/data/data_group_call.h @@ -64,6 +64,7 @@ public: [[nodiscard]] CallId id() const; [[nodiscard]] bool loaded() const; [[nodiscard]] bool rtmp() const; + [[nodiscard]] bool listenersHidden() const; [[nodiscard]] not_null peer() const; [[nodiscard]] MTPInputGroupCall input() const; [[nodiscard]] QString title() const { @@ -244,6 +245,7 @@ private: bool _joinedToTop = false; bool _applyingQueuedUpdates = false; bool _rtmp = false; + bool _listenersHidden = false; };