diff --git a/Telegram/SourceFiles/calls/calls_call.cpp b/Telegram/SourceFiles/calls/calls_call.cpp index 91b46b0665..4edd70beda 100644 --- a/Telegram/SourceFiles/calls/calls_call.cpp +++ b/Telegram/SourceFiles/calls/calls_call.cpp @@ -1196,6 +1196,10 @@ void Call::createAndStartController(const MTPDphoneCall &call) { raw->setIncomingVideoOutput(_videoIncoming->sink()); raw->setAudioOutputDuckingEnabled(settings.callAudioDuckingEnabled()); + _muted.value() | rpl::on_next([=](bool muted) { + Core::App().mediaDevices().setCaptureMuted(muted); + }, _instanceLifetime); + _state.value() | rpl::on_next([=](State state) { const auto track = (state != State::FailedHangingUp) && (state != State::Failed) @@ -1207,10 +1211,6 @@ void Call::createAndStartController(const MTPDphoneCall &call) { Core::App().mediaDevices().setCaptureMuteTracker(this, track); }, _instanceLifetime); - _muted.value() | rpl::on_next([=](bool muted) { - Core::App().mediaDevices().setCaptureMuted(muted); - }, _instanceLifetime); - #if 0 Core::App().batterySaving().value( ) | rpl::on_next([=](bool isSaving) { diff --git a/Telegram/SourceFiles/calls/group/calls_group_call.cpp b/Telegram/SourceFiles/calls/group/calls_group_call.cpp index f002f3cd22..70be0e306a 100644 --- a/Telegram/SourceFiles/calls/group/calls_group_call.cpp +++ b/Telegram/SourceFiles/calls/group/calls_group_call.cpp @@ -1606,6 +1606,7 @@ void GroupCall::rejoin(not_null as) { _joinState.action = JoinAction::Joining; _joinState.ssrc = 0; _initialMuteStateSent = false; + _systemMuteReconciled = false; setState(State::Joining); if (!tryCreateController()) { setInstanceMode(InstanceMode::None); @@ -1794,6 +1795,13 @@ void GroupCall::joinDone( : State::Joined); applyMeInCallLocally(); maybeSendMutedUpdate(wasMuteState); + _systemMuteReconciled = true; + if (!_rtmp) { + const auto state = muted(); + const auto nowMuted = (state != MuteState::Active) + && (state != MuteState::PushToTalk); + Core::App().mediaDevices().setCaptureMuted(nowMuted); + } for (auto &state : _subchains) { // Accept initial join blocks. @@ -2699,8 +2707,8 @@ void GroupCall::setupMediaDevices() { const auto muted = (state != MuteState::Active) && (state != MuteState::PushToTalk); const auto track = !muted || (state == MuteState::Muted); - devices->setCaptureMuteTracker(this, track); devices->setCaptureMuted(muted); + devices->setCaptureMuteTracker(this, track); }, _lifetime); } } @@ -2712,8 +2720,20 @@ void GroupCall::captureMuteChanged(bool mute) { || oldState == MuteState::RaisedHand || oldState == MuteState::Muted)) { return; + } else if (!mute + && (oldState == MuteState::ForceMuted + || oldState == MuteState::RaisedHand)) { + crl::on_main(this, [] { + Core::App().mediaDevices().setCaptureMuted(true); + }); + return; } else if (!mute && oldState != MuteState::Muted) { return; + } else if (!mute && !_systemMuteReconciled) { + crl::on_main(this, [] { + Core::App().mediaDevices().setCaptureMuted(true); + }); + return; } setMutedAndUpdate(mute ? MuteState::Muted : MuteState::Active); } diff --git a/Telegram/SourceFiles/calls/group/calls_group_call.h b/Telegram/SourceFiles/calls/group/calls_group_call.h index c2820cd8b7..4e63e93482 100644 --- a/Telegram/SourceFiles/calls/group/calls_group_call.h +++ b/Telegram/SourceFiles/calls/group/calls_group_call.h @@ -727,6 +727,7 @@ private: rpl::variable _emptyRtmp = false; rpl::variable _messagesEnabled = false; bool _initialMuteStateSent = false; + bool _systemMuteReconciled = false; bool _acceptFields = false; rpl::event_stream _otherParticipantStateValue; diff --git a/Telegram/lib_webrtc b/Telegram/lib_webrtc index b0c28ed410..52636e86ea 160000 --- a/Telegram/lib_webrtc +++ b/Telegram/lib_webrtc @@ -1 +1 @@ -Subproject commit b0c28ed41034860c671ad4f7533dd476cc356072 +Subproject commit 52636e86eaa493de670daf71959d000b281bd153