Skip to content

Commit

Permalink
Update settings on the fly
Browse files Browse the repository at this point in the history
  • Loading branch information
mustafaboleken committed Jan 2, 2025
1 parent cd83507 commit c806eb4
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 30 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -34,25 +34,7 @@ public void setApplicationContext(@NotNull ApplicationContext applicationContext

IAntMediaStreamHandler app = getApplication();
appSettings = app.getAppSettings();

Object circleSettingsString = appSettings.getCustomSetting("circle");
if (circleSettingsString == null) {
logger.error("Using default settings for Conference Room Settings because no Circle settings in the AppSettings");

conferenceRoomSettings = new ConferenceRoomSettings();
}
else {
try {
conferenceRoomSettings = gson.fromJson(circleSettingsString.toString(), ConferenceRoomSettings.class);
}
catch (Exception e)
{
logger.error("Invalid Conference room settings, using default conference room settings");
conferenceRoomSettings = new ConferenceRoomSettings();
}
}
conferenceRoomSettings.init();

fetchConferenceRoomSettings();
}

public AntMediaApplicationAdapter getApplication() {
Expand Down Expand Up @@ -103,6 +85,36 @@ public boolean updateBroadcastRole(String streamId, String role) {
return result;
}

public void fetchConferenceRoomSettings() {
Object circleSettingsString = appSettings.getCustomSetting("circle");
if (circleSettingsString == null) {
logger.error("Using default settings for Conference Room Settings because no Circle settings in the AppSettings");

conferenceRoomSettings = new ConferenceRoomSettings();
}
else {
try {
conferenceRoomSettings = gson.fromJson(circleSettingsString.toString(), ConferenceRoomSettings.class);
}
catch (Exception e)
{
logger.error("Invalid Conference room settings, using default conference room settings");
conferenceRoomSettings = new ConferenceRoomSettings();
}
}
conferenceRoomSettings.init();

String participantVisibilityMatrix = appSettings.getParticipantVisibilityMatrix().toString();

if (participantVisibilityMatrix != null && conferenceRoomSettings.getParticipantVisibilityMatrix() == null) {
conferenceRoomSettings.setParticipantVisibilityMatrix(participantVisibilityMatrix);
}

int maxVideoTrackCount = appSettings.getMaxVideoTrackCount();

conferenceRoomSettings.setMaxVideoTrackCount(maxVideoTrackCount);
}

public ConferenceRoomSettings getConferenceRoomSettings() {
return conferenceRoomSettings;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,7 @@ private AMSBroadcastManager getAMSBroadcastManager() {
}

private void setConferenceRoomSettings(){
getAMSBroadcastManager().fetchConferenceRoomSettings();
conferenceRoomSettings = getAMSBroadcastManager().getConferenceRoomSettings();
}

Expand Down Expand Up @@ -321,17 +322,6 @@ private Object getMediaPushPlugin() {
}

private void responseRoomSettings(Session session) {

String participantVisibilityMatrix = appSettings.getParticipantVisibilityMatrix().toString();

if (participantVisibilityMatrix != null && conferenceRoomSettings.getParticipantVisibilityMatrix() == null) {
conferenceRoomSettings.setParticipantVisibilityMatrix(participantVisibilityMatrix);
}

int maxVideoTrackCount = appSettings.getMaxVideoTrackCount();

conferenceRoomSettings.setMaxVideoTrackCount(maxVideoTrackCount);

JSONObject jsonResponse = new JSONObject();
jsonResponse.put(WebSocketConstants.COMMAND, WebSocketApplicationConstants.SET_SETTINGS_COMMAND);
jsonResponse.put(WebSocketApplicationConstants.SETTINGS, gsonOnlyExposedFields.toJson(conferenceRoomSettings));
Expand Down

0 comments on commit c806eb4

Please sign in to comment.