Skip to content
Snippets Groups Projects
Commit 42ef51a2 authored by Lyubomir Marinov's avatar Lyubomir Marinov
Browse files

- Fixes the horizontal gap between multiple videos in a call. It used to...

- Fixes the horizontal gap between multiple videos in a call. It used to appear different between the different columns and caused videos with equal aspect ratios to appear with unequal heights.
- Tries to prevent a deadlock in UI-related code upon hanging up a call. It appeared as if the camera wouldn't get closed.
- Fixes a NullPointerException.
parent 7a1593f8
No related branches found
No related tags found
No related merge requests found
...@@ -42,6 +42,12 @@ public class VideoLayout ...@@ -42,6 +42,12 @@ public class VideoLayout
*/ */
public static final String EAST_REMOTE = "EAST_REMOTE"; public static final String EAST_REMOTE = "EAST_REMOTE";
/**
* The horizontal gap between the <tt>Component</tt> being laid out by
* <tt>VideoLayout</tt>.
*/
private static final int HGAP = 10;
/** /**
* The local video constraint. * The local video constraint.
*/ */
...@@ -229,13 +235,9 @@ public void layoutContainer(Container parent) ...@@ -229,13 +235,9 @@ public void layoutContainer(Container parent)
remotes = this.remotes; remotes = this.remotes;
int remoteCount = remotes.size(); int remoteCount = remotes.size();
// We need to reduce parent size in order to fit also the space we've
// left between videos.
Dimension parentSize = parent.getSize(); Dimension parentSize = parent.getSize();
parentSize.width -= remoteCount*10;
if (remoteCount == 1 && !isConference) if ((remoteCount == 1) && !isConference)
{ {
super.layoutContainer(parent, super.layoutContainer(parent,
(local == null) (local == null)
...@@ -245,14 +247,21 @@ public void layoutContainer(Container parent) ...@@ -245,14 +247,21 @@ public void layoutContainer(Container parent)
else if (remoteCount > 0) else if (remoteCount > 0)
{ {
int columns = calculateColumnCount(remotes); int columns = calculateColumnCount(remotes);
int rows = (remoteCount + columns - 1) / columns; int columnsMinus1 = columns - 1;
int rows = (remoteCount + columnsMinus1) / columns;
Rectangle bounds Rectangle bounds
= new Rectangle( = new Rectangle(
0, 0,
0, 0,
parentSize.width / columns, /*
* HGAP is the horizontal gap between the Components
* being laid out by this VideoLayout so the number of
* HGAPs will be with one less than the number of
* columns and that horizontal space cannot be allocated
* to the bounds of the Components.
*/
(parentSize.width - (columnsMinus1 * HGAP)) / columns,
parentSize.height / rows); parentSize.height / rows);
int columnsMinus1 = columns - 1;
int i = 0; int i = 0;
for (Component remote : remotes) for (Component remote : remotes)
...@@ -261,12 +270,14 @@ else if (remoteCount > 0) ...@@ -261,12 +270,14 @@ else if (remoteCount > 0)
* We want the remote videos ordered from right to left so that * We want the remote videos ordered from right to left so that
* the local video does not cover a remote video when possible. * the local video does not cover a remote video when possible.
*/ */
bounds.x = (columnsMinus1 - (i % columns)) * bounds.width; /*
* We account for the HGAP between the Components being laid out
* by this VideoLayout.
*/
bounds.x
= (columnsMinus1 - (i % columns)) * (bounds.width + HGAP);
bounds.y = (i / columns) * bounds.height; bounds.y = (i / columns) * bounds.height;
if (bounds.x > 0)
bounds.x += ((columns - (i%columns))*10);
super.layoutComponent( super.layoutComponent(
remote, remote,
bounds, bounds,
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment