Skip to content

Commit

Permalink
Improve group call cells
Browse files Browse the repository at this point in the history
  • Loading branch information
FrayxRulez committed Oct 5, 2024
1 parent 644e34f commit 096ad91
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 24 deletions.
31 changes: 14 additions & 17 deletions Telegram/Controls/Cells/GroupCallParticipantGridCell.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,6 @@ public GroupCallParticipantGridCell(IClientService clientService, GroupCallParti
InitializeComponent();
UpdateGroupCallParticipant(clientService, participant, videoInfo);

_sink = VoipVideoOutput.CreateSink(CanvasRoot, false);
_screenSharing = screenSharing;

if (screenSharing)
Expand All @@ -59,7 +58,19 @@ public bool Matches(GroupCallParticipant participant, GroupCallParticipantVideoI
return participant != null && participant.ParticipantId.AreTheSame(ParticipantId) && _videoInfo.EndpointId == _videoInfo.EndpointId;
}

public VoipVideoOutputSink Sink => _sink;
public VoipVideoOutputSink Connect(bool mirrored)
{
_sink?.Stop();
_sink = VoipVideoOutput.CreateSink(CanvasRoot, mirrored);

return _sink;
}

public void Disconnect()
{
_sink?.Stop();
_sink = null;
}

public VoipVideoChannelQuality Quality => ActualHeight switch
{
Expand Down Expand Up @@ -87,21 +98,7 @@ public Stretch GetStretch(ParticipantsGridMode mode, bool list)

public bool IsScreenSharing => _screenSharing;

private bool _isConnected;
public bool IsConnected
{
get => _isConnected;
set
{
_isConnected = value;

if (value is false)
{
_sink.Stop();
_sink = VoipVideoOutput.CreateSink(CanvasRoot, false);
}
}
}
public bool IsConnected => _sink != null;

public bool IsSelected { get; set; }

Expand Down
12 changes: 5 additions & 7 deletions Telegram/Views/Calls/GroupCallPage.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -260,7 +260,7 @@ private void RemoveChildren(bool list)
{
if (collection[i] is GroupCallParticipantGridCell cell)
{
cell.IsConnected = false;
cell.Disconnect();
}
}
}
Expand Down Expand Up @@ -1803,7 +1803,7 @@ private void RemoveItem(GroupCallParticipantGridCell cell, bool list)
prev.Remove(cell.EndpointId);
cells.Remove(cell.EndpointId);

cell.IsConnected = false;
cell.Disconnect();
viewport.Remove(cell);

if (_mode == ParticipantsGridMode.Compact)
Expand Down Expand Up @@ -2094,16 +2094,14 @@ private void UpdateVisibleParticipants(int first, int last, bool list)

if (participant.ScreenSharingVideoInfo?.EndpointId == child.EndpointId && participant.IsCurrentUser && _call.IsScreenSharing)
{
_call.AddScreenSharingVideoOutput(child.EndpointId, child.Sink);
_call.AddScreenSharingVideoOutput(child.EndpointId, child.Connect(false));
}
else
{
_call.AddIncomingVideoOutput(child.VideoInfo.EndpointId, child.Sink);
_call.AddIncomingVideoOutput(child.VideoInfo.EndpointId, child.Connect(participant.IsCurrentUser));
}

//child.Sink.Stretch = child.GetStretch(_mode, list);
child.IsConnected = true;
child.Sink.IsMirrored = participant.IsCurrentUser && participant.ScreenSharingVideoInfo?.EndpointId != child.EndpointId;
//tokens[child.EndpointId] = future;
}
}
Expand All @@ -2122,7 +2120,7 @@ private void UpdateVisibleParticipants(int first, int last, bool list)
// token.Stop();
//}

prev[item].IsConnected = false;
prev[item].Disconnect();
prev.Remove(item);
}

Expand Down

0 comments on commit 096ad91

Please sign in to comment.