Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Limit video senders #827

Merged
merged 6 commits into from
Nov 9, 2021
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions src/main/java/org/jitsi/impl/protocol/xmpp/ChatRoomImpl.java
Original file line number Diff line number Diff line change
Expand Up @@ -589,12 +589,22 @@ public void addVideoSender()
{
++numVideoSenders;
logger.debug(() -> "The number of video senders has increased to " + numVideoSenders + ".");

eventEmitter.fireEvent(handler -> {
handler.numVideoSendersChanged(numVideoSenders);
return Unit.INSTANCE;
});
}

public void removeVideoSender()
{
--numVideoSenders;
logger.debug(() -> "The number of video senders has decreased to " + numVideoSenders + ".");

eventEmitter.fireEvent(handler -> {
handler.numVideoSendersChanged(numVideoSenders);
return Unit.INSTANCE;
});
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ public class JitsiMeetConferenceImpl
@NotNull
private final JitsiMeetConfig config;

private final ChatRoomListener chatRoomListener = new ChatRoomListenerImpl();
private final ChatRoomListener chatRoomListener = new ChatRoomListenerImpl(this);

/**
* Conference room chat instance.
Expand Down Expand Up @@ -228,6 +228,11 @@ public class JitsiMeetConferenceImpl
*/
private final ValidatingConferenceSourceMap conferenceSources = new ValidatingConferenceSourceMap();

/**
* Whether the limit on the number of video senders is currently hit.
*/
private boolean videoLimitReached = false;

/**
* Creates new instance of {@link JitsiMeetConferenceImpl}.
*
Expand Down Expand Up @@ -526,6 +531,19 @@ private void setConferenceProperty(String key, String value, boolean updatePrese
}
}

/**
* Process the new number of video senders reported by the chat room.
*/
private void numVideoSendersChanged(int numVideoSenders)
{
boolean newValue = numVideoSenders >= ConferenceConfig.config.getMaxVideoSenders();
if (videoLimitReached != newValue)
{
videoLimitReached = newValue;
setConferenceProperty("video-limit-reached", String.valueOf(videoLimitReached));
}
}

/**
* Leaves the conference room.
*/
Expand Down Expand Up @@ -2425,6 +2443,12 @@ public void bridgeAdded(Bridge bridge)

private class ChatRoomListenerImpl implements ChatRoomListener
{
private final JitsiMeetConferenceImpl conference;
private ChatRoomListenerImpl(JitsiMeetConferenceImpl conference)
jqdrqgnq marked this conversation as resolved.
Show resolved Hide resolved
{
this.conference = conference;
}

@Override
public void roomDestroyed(@NotNull String reason)
{
Expand Down Expand Up @@ -2471,5 +2495,11 @@ public void localRoleChanged(@NotNull MemberRole newRole, @Nullable MemberRole o
public void memberPresenceChanged(@NotNull ChatRoomMember member)
{
}

@Override
public void numVideoSendersChanged(int numVideoSenders)
{
conference.numVideoSendersChanged(numVideoSenders);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ interface ChatRoomListener {
fun roomDestroyed(reason: String) {}
fun startMutedChanged(startAudioMuted: Boolean, startVideoMuted: Boolean) {}
fun localRoleChanged(newRole: MemberRole, oldRole: MemberRole? = null) {}
fun numVideoSendersChanged(numVideoSenders: Int) {}
}

/** A class with the default kotlin method implementations (to avoid using @JvmDefault) **/
Expand Down