Added handler of state changes of other participants in group calls.
This commit is contained in:
parent
e1f5e10764
commit
e12689c8c1
|
@ -589,10 +589,25 @@ void GroupCall::handleUpdate(const MTPDupdateGroupCallParticipants &data) {
|
|||
return;
|
||||
}
|
||||
|
||||
const auto handleOtherParticipants = [=](
|
||||
const MTPDgroupCallParticipant &data) {
|
||||
const auto user = _peer->owner().user(data.vuser_id().v);
|
||||
const auto participant = LookupParticipant(_peer, _id, user);
|
||||
if (!participant) {
|
||||
return;
|
||||
}
|
||||
_otherParticipantStateValue.fire(Group::ParticipantState{
|
||||
.user = user,
|
||||
.mutedByMe = data.is_muted_by_you(),
|
||||
.volume = data.vvolume().value_or_empty(),
|
||||
});
|
||||
};
|
||||
|
||||
const auto self = _peer->session().userId();
|
||||
for (const auto &participant : data.vparticipants().v) {
|
||||
participant.match([&](const MTPDgroupCallParticipant &data) {
|
||||
if (data.vuser_id().v != self) {
|
||||
handleOtherParticipants(data);
|
||||
return;
|
||||
}
|
||||
if (data.is_left() && data.vsource().v == _mySsrc) {
|
||||
|
@ -1030,6 +1045,11 @@ void GroupCall::pushToTalkCancel() {
|
|||
}
|
||||
}
|
||||
|
||||
auto GroupCall::otherParticipantStateValue() const
|
||||
-> rpl::producer<Group::ParticipantState> {
|
||||
return _otherParticipantStateValue.events();
|
||||
}
|
||||
|
||||
//void GroupCall::setAudioVolume(bool input, float level) {
|
||||
// if (_instance) {
|
||||
// if (input) {
|
||||
|
|
|
@ -38,6 +38,7 @@ namespace Calls {
|
|||
namespace Group {
|
||||
struct MuteRequest;
|
||||
struct VolumeRequest;
|
||||
struct ParticipantState;
|
||||
} // namespace Group
|
||||
|
||||
enum class MuteState {
|
||||
|
@ -109,6 +110,9 @@ public:
|
|||
return _muted.value();
|
||||
}
|
||||
|
||||
[[nodiscard]] auto otherParticipantStateValue() const
|
||||
-> rpl::producer<Group::ParticipantState>;
|
||||
|
||||
enum State {
|
||||
Creating,
|
||||
Joining,
|
||||
|
@ -206,6 +210,8 @@ private:
|
|||
rpl::variable<MuteState> _muted = MuteState::Muted;
|
||||
bool _acceptFields = false;
|
||||
|
||||
rpl::event_stream<Group::ParticipantState> _otherParticipantStateValue;
|
||||
|
||||
uint64 _id = 0;
|
||||
uint64 _accessHash = 0;
|
||||
uint32 _mySsrc = 0;
|
||||
|
|
|
@ -26,4 +26,11 @@ struct VolumeRequest {
|
|||
bool locallyOnly = false;
|
||||
};
|
||||
|
||||
struct ParticipantState {
|
||||
not_null<UserData*> user;
|
||||
std::optional<int> volume;
|
||||
bool mutedByMe = false;
|
||||
bool locallyOnly = false;
|
||||
};
|
||||
|
||||
} // namespace Calls::Group
|
||||
|
|
Loading…
Reference in New Issue