mirror of
https://github.com/AyuGram/AyuGramDesktop.git
synced 2025-06-05 06:33:57 +02:00
Queue skipped self updates in voice chats.
This commit is contained in:
parent
0e47c6b415
commit
d41bd1483e
2 changed files with 90 additions and 71 deletions
|
@ -548,6 +548,7 @@ void GroupCall::rejoin(not_null<PeerData*> as) {
|
||||||
applyMeInCallLocally();
|
applyMeInCallLocally();
|
||||||
maybeSendMutedUpdate(wasMuteState);
|
maybeSendMutedUpdate(wasMuteState);
|
||||||
_peer->session().api().applyUpdates(updates);
|
_peer->session().api().applyUpdates(updates);
|
||||||
|
applyQueuedSelfUpdates();
|
||||||
checkFirstTimeJoined();
|
checkFirstTimeJoined();
|
||||||
}).fail([=](const MTP::Error &error) {
|
}).fail([=](const MTP::Error &error) {
|
||||||
const auto type = error.type();
|
const auto type = error.type();
|
||||||
|
@ -991,88 +992,102 @@ void GroupCall::handleUpdate(const MTPDupdateGroupCallParticipants &data) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
const auto state = _state.current();
|
const auto state = _state.current();
|
||||||
if (state != State::Joined && state != State::Connecting) {
|
const auto joined = (state == State::Joined)
|
||||||
return;
|
|| (state == State::Connecting);
|
||||||
}
|
|
||||||
|
|
||||||
const auto handleOtherParticipants = [=](
|
|
||||||
const MTPDgroupCallParticipant &data) {
|
|
||||||
if (data.is_min()) {
|
|
||||||
// No real information about mutedByMe or my custom volume.
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
const auto participantPeer = _peer->owner().peer(
|
|
||||||
peerFromMTP(data.vpeer()));
|
|
||||||
const auto participant = LookupParticipant(
|
|
||||||
_peer,
|
|
||||||
_id,
|
|
||||||
participantPeer);
|
|
||||||
if (!participant) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
_otherParticipantStateValue.fire(Group::ParticipantState{
|
|
||||||
.peer = participantPeer,
|
|
||||||
.volume = data.vvolume().value_or_empty(),
|
|
||||||
.mutedByMe = data.is_muted_by_you(),
|
|
||||||
});
|
|
||||||
};
|
|
||||||
|
|
||||||
for (const auto &participant : data.vparticipants().v) {
|
for (const auto &participant : data.vparticipants().v) {
|
||||||
participant.match([&](const MTPDgroupCallParticipant &data) {
|
participant.match([&](const MTPDgroupCallParticipant &data) {
|
||||||
const auto isSelf = data.is_self()
|
const auto isSelf = data.is_self()
|
||||||
|| (data.is_min()
|
|| (data.is_min()
|
||||||
&& peerFromMTP(data.vpeer()) == _joinAs->id);
|
&& peerFromMTP(data.vpeer()) == _joinAs->id);
|
||||||
if (!isSelf) {
|
if (!isSelf) {
|
||||||
handleOtherParticipants(data);
|
applyOtherParticipantUpdate(data);
|
||||||
return;
|
} else if (joined) {
|
||||||
}
|
applySelfUpdate(data);
|
||||||
if (data.is_left()) {
|
} else {
|
||||||
if (data.vsource().v == _mySsrc) {
|
_queuedSelfUpdates.push_back(participant);
|
||||||
// I was removed from the call, rejoin.
|
|
||||||
LOG(("Call Info: "
|
|
||||||
"Rejoin after got 'left' with my ssrc."));
|
|
||||||
setState(State::Joining);
|
|
||||||
rejoin();
|
|
||||||
}
|
|
||||||
return;
|
|
||||||
} else if (data.vsource().v != _mySsrc) {
|
|
||||||
if (!_mySsrcs.contains(data.vsource().v)) {
|
|
||||||
// I joined from another device, hangup.
|
|
||||||
LOG(("Call Info: "
|
|
||||||
"Hangup after '!left' with ssrc %1, my %2."
|
|
||||||
).arg(data.vsource().v
|
|
||||||
).arg(_mySsrc));
|
|
||||||
_mySsrc = 0;
|
|
||||||
hangup();
|
|
||||||
} else {
|
|
||||||
LOG(("Call Info: "
|
|
||||||
"Some old 'self' with '!left' and ssrc %1, my %2."
|
|
||||||
).arg(data.vsource().v
|
|
||||||
).arg(_mySsrc));
|
|
||||||
}
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
if (data.is_muted() && !data.is_can_self_unmute()) {
|
|
||||||
setMuted(data.vraise_hand_rating().value_or_empty()
|
|
||||||
? MuteState::RaisedHand
|
|
||||||
: MuteState::ForceMuted);
|
|
||||||
} else if (_instanceMode == InstanceMode::Stream) {
|
|
||||||
LOG(("Call Info: Rejoin after unforcemute in stream mode."));
|
|
||||||
setState(State::Joining);
|
|
||||||
rejoin();
|
|
||||||
} else if (muted() == MuteState::ForceMuted
|
|
||||||
|| muted() == MuteState::RaisedHand) {
|
|
||||||
setMuted(MuteState::Muted);
|
|
||||||
if (!_instanceTransitioning) {
|
|
||||||
notifyAboutAllowedToSpeak();
|
|
||||||
}
|
|
||||||
} else if (data.is_muted() && muted() != MuteState::Muted) {
|
|
||||||
setMuted(MuteState::Muted);
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void GroupCall::applyQueuedSelfUpdates() {
|
||||||
|
const auto weak = base::make_weak(this);
|
||||||
|
while (weak
|
||||||
|
&& !_queuedSelfUpdates.empty()
|
||||||
|
&& (_state.current() == State::Joined
|
||||||
|
|| _state.current() == State::Connecting)) {
|
||||||
|
const auto update = _queuedSelfUpdates.front();
|
||||||
|
_queuedSelfUpdates.erase(_queuedSelfUpdates.begin());
|
||||||
|
update.match([&](const MTPDgroupCallParticipant &data) {
|
||||||
|
applySelfUpdate(data);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void GroupCall::applySelfUpdate(const MTPDgroupCallParticipant &data) {
|
||||||
|
if (data.is_left()) {
|
||||||
|
if (data.vsource().v == _mySsrc) {
|
||||||
|
// I was removed from the call, rejoin.
|
||||||
|
LOG(("Call Info: "
|
||||||
|
"Rejoin after got 'left' with my ssrc."));
|
||||||
|
setState(State::Joining);
|
||||||
|
rejoin();
|
||||||
|
}
|
||||||
|
return;
|
||||||
|
} else if (data.vsource().v != _mySsrc) {
|
||||||
|
if (!_mySsrcs.contains(data.vsource().v)) {
|
||||||
|
// I joined from another device, hangup.
|
||||||
|
LOG(("Call Info: "
|
||||||
|
"Hangup after '!left' with ssrc %1, my %2."
|
||||||
|
).arg(data.vsource().v
|
||||||
|
).arg(_mySsrc));
|
||||||
|
_mySsrc = 0;
|
||||||
|
hangup();
|
||||||
|
} else {
|
||||||
|
LOG(("Call Info: "
|
||||||
|
"Some old 'self' with '!left' and ssrc %1, my %2."
|
||||||
|
).arg(data.vsource().v
|
||||||
|
).arg(_mySsrc));
|
||||||
|
}
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (data.is_muted() && !data.is_can_self_unmute()) {
|
||||||
|
setMuted(data.vraise_hand_rating().value_or_empty()
|
||||||
|
? MuteState::RaisedHand
|
||||||
|
: MuteState::ForceMuted);
|
||||||
|
} else if (_instanceMode == InstanceMode::Stream) {
|
||||||
|
LOG(("Call Info: Rejoin after unforcemute in stream mode."));
|
||||||
|
setState(State::Joining);
|
||||||
|
rejoin();
|
||||||
|
} else if (muted() == MuteState::ForceMuted
|
||||||
|
|| muted() == MuteState::RaisedHand) {
|
||||||
|
setMuted(MuteState::Muted);
|
||||||
|
if (!_instanceTransitioning) {
|
||||||
|
notifyAboutAllowedToSpeak();
|
||||||
|
}
|
||||||
|
} else if (data.is_muted() && muted() != MuteState::Muted) {
|
||||||
|
setMuted(MuteState::Muted);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void GroupCall::applyOtherParticipantUpdate(
|
||||||
|
const MTPDgroupCallParticipant &data) {
|
||||||
|
if (data.is_min()) {
|
||||||
|
// No real information about mutedByMe or my custom volume.
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
const auto participantPeer = _peer->owner().peer(
|
||||||
|
peerFromMTP(data.vpeer()));
|
||||||
|
if (!LookupParticipant(_peer, _id, participantPeer)) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
_otherParticipantStateValue.fire(Group::ParticipantState{
|
||||||
|
.peer = participantPeer,
|
||||||
|
.volume = data.vvolume().value_or_empty(),
|
||||||
|
.mutedByMe = data.is_muted_by_you(),
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
void GroupCall::changeTitle(const QString &title) {
|
void GroupCall::changeTitle(const QString &title) {
|
||||||
const auto real = lookupReal();
|
const auto real = lookupReal();
|
||||||
if (!real || real->title() == title) {
|
if (!real || real->title() == title) {
|
||||||
|
|
|
@ -290,6 +290,9 @@ private:
|
||||||
not_null<PeerData*> participantPeer,
|
not_null<PeerData*> participantPeer,
|
||||||
bool mute,
|
bool mute,
|
||||||
std::optional<int> volume);
|
std::optional<int> volume);
|
||||||
|
void applyQueuedSelfUpdates();
|
||||||
|
void applySelfUpdate(const MTPDgroupCallParticipant &data);
|
||||||
|
void applyOtherParticipantUpdate(const MTPDgroupCallParticipant &data);
|
||||||
|
|
||||||
[[nodiscard]] MTPInputGroupCall inputCall() const;
|
[[nodiscard]] MTPInputGroupCall inputCall() const;
|
||||||
|
|
||||||
|
@ -321,6 +324,7 @@ private:
|
||||||
bool _acceptFields = false;
|
bool _acceptFields = false;
|
||||||
|
|
||||||
rpl::event_stream<Group::ParticipantState> _otherParticipantStateValue;
|
rpl::event_stream<Group::ParticipantState> _otherParticipantStateValue;
|
||||||
|
std::vector<MTPGroupCallParticipant> _queuedSelfUpdates;
|
||||||
|
|
||||||
uint64 _id = 0;
|
uint64 _id = 0;
|
||||||
uint64 _accessHash = 0;
|
uint64 _accessHash = 0;
|
||||||
|
|
Loading…
Add table
Reference in a new issue