forked from bigbluebutton/bigbluebutton
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
47 changed files
with
3,025 additions
and
95 deletions.
There are no files selected for viewing
29 changes: 29 additions & 0 deletions
29
...n-apps/src/main/java/org/bigbluebutton/conference/service/layout/ILayoutRoomListener.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
/** | ||
* BigBlueButton open source conferencing system - http://www.bigbluebutton.org/ | ||
* | ||
* Copyright (c) 2012 BigBlueButton Inc. and by respective authors (see below). | ||
* | ||
* This program is free software; you can redistribute it and/or modify it under the | ||
* terms of the GNU Lesser General Public License as published by the Free Software | ||
* Foundation; either version 2.1 of the License, or (at your option) any later | ||
* version. | ||
* | ||
* BigBlueButton is distributed in the hope that it will be useful, but WITHOUT ANY | ||
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A | ||
* PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU Lesser General Public License along | ||
* with BigBlueButton; if not, see <http://www.gnu.org/licenses/>. | ||
* | ||
* Author: Felipe Cecagno <[email protected]> | ||
*/ | ||
package org.bigbluebutton.conference.service.layout; | ||
|
||
import java.util.List; | ||
|
||
public interface ILayoutRoomListener { | ||
public String getName(); | ||
public void updateLayout(List<Object> args); | ||
// public void lockLayout(); | ||
// public void unlockLayout(); | ||
} |
75 changes: 75 additions & 0 deletions
75
...ton-apps/src/main/java/org/bigbluebutton/conference/service/layout/LayoutApplication.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,75 @@ | ||
/** | ||
* BigBlueButton open source conferencing system - http://www.bigbluebutton.org/ | ||
* | ||
* Copyright (c) 2012 BigBlueButton Inc. and by respective authors (see below). | ||
* | ||
* This program is free software; you can redistribute it and/or modify it under the | ||
* terms of the GNU Lesser General Public License as published by the Free Software | ||
* Foundation; either version 2.1 of the License, or (at your option) any later | ||
* version. | ||
* | ||
* BigBlueButton is distributed in the hope that it will be useful, but WITHOUT ANY | ||
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A | ||
* PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU Lesser General Public License along | ||
* with BigBlueButton; if not, see <http://www.gnu.org/licenses/>. | ||
* | ||
* Author: Felipe Cecagno <[email protected]> | ||
*/ | ||
package org.bigbluebutton.conference.service.layout; | ||
|
||
import java.util.List; | ||
|
||
import org.red5.logging.Red5LoggerFactory; | ||
import org.slf4j.Logger; | ||
|
||
public class LayoutApplication { | ||
|
||
private static Logger log = Red5LoggerFactory.getLogger( LayoutApplication.class, "bigbluebutton" ); | ||
|
||
private LayoutRoomsManager roomsManager; | ||
public LayoutHandler handler; | ||
|
||
public boolean createRoom(String name) { | ||
roomsManager.addRoom(new LayoutRoom(name)); | ||
return true; | ||
} | ||
|
||
public boolean destroyRoom(String name) { | ||
if (roomsManager.hasRoom(name)) { | ||
roomsManager.removeRoom(name); | ||
} | ||
return true; | ||
} | ||
|
||
public boolean hasRoom(String name) { | ||
return roomsManager.hasRoom(name); | ||
} | ||
|
||
public boolean addRoomListener(String room, ILayoutRoomListener listener) { | ||
if (roomsManager.hasRoom(room)){ | ||
roomsManager.addRoomListener(room, listener); | ||
return true; | ||
} | ||
log.warn("Adding listener to a non-existant room " + room); | ||
return false; | ||
} | ||
|
||
public void setRoomsManager(LayoutRoomsManager r) { | ||
log.debug("Setting room manager"); | ||
roomsManager = r; | ||
} | ||
|
||
public void lockLayout(String room, int userId, String layout) { | ||
roomsManager.lockLayout(room, userId, layout); | ||
} | ||
|
||
public void unlockLayout(String room) { | ||
roomsManager.unlockLayout(room); | ||
} | ||
|
||
public List<Object> currentLayout(String roomName) { | ||
return roomsManager.currentLayout(roomName); | ||
} | ||
} |
130 changes: 130 additions & 0 deletions
130
...ebutton-apps/src/main/java/org/bigbluebutton/conference/service/layout/LayoutHandler.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,130 @@ | ||
/** | ||
* BigBlueButton open source conferencing system - http://www.bigbluebutton.org/ | ||
* | ||
* Copyright (c) 2012 BigBlueButton Inc. and by respective authors (see below). | ||
* | ||
* This program is free software; you can redistribute it and/or modify it under the | ||
* terms of the GNU Lesser General Public License as published by the Free Software | ||
* Foundation; either version 2.1 of the License, or (at your option) any later | ||
* version. | ||
* | ||
* BigBlueButton is distributed in the hope that it will be useful, but WITHOUT ANY | ||
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A | ||
* PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU Lesser General Public License along | ||
* with BigBlueButton; if not, see <http://www.gnu.org/licenses/>. | ||
* | ||
* Author: Felipe Cecagno <[email protected]> | ||
*/ | ||
package org.bigbluebutton.conference.service.layout; | ||
|
||
import org.red5.logging.Red5LoggerFactory; | ||
import org.red5.server.adapter.ApplicationAdapter; | ||
import org.red5.server.adapter.IApplication; | ||
import org.red5.server.api.IClient; | ||
import org.red5.server.api.IConnection; | ||
import org.red5.server.api.IScope; | ||
import org.red5.server.api.so.ISharedObject; | ||
import org.slf4j.Logger; | ||
|
||
public class LayoutHandler extends ApplicationAdapter implements IApplication { | ||
private static Logger log = Red5LoggerFactory.getLogger( LayoutHandler.class, "bigbluebutton" ); | ||
|
||
private static final String APP = "LAYOUT"; | ||
private static final String LAYOUT_SO = "layoutSO"; | ||
|
||
private LayoutApplication layoutApplication; | ||
|
||
@Override | ||
public boolean appConnect(IConnection conn, Object[] params) { | ||
log.debug(APP + ":appConnect"); | ||
return true; | ||
} | ||
|
||
@Override | ||
public void appDisconnect(IConnection conn) { | ||
log.debug( APP + ":appDisconnect"); | ||
} | ||
|
||
@Override | ||
public boolean appJoin(IClient client, IScope scope) { | ||
log.debug( APP + ":appJoin " + scope.getName()); | ||
return true; | ||
} | ||
|
||
@Override | ||
public void appLeave(IClient client, IScope scope) { | ||
log.debug(APP + ":appLeave " + scope.getName()); | ||
} | ||
|
||
@Override | ||
public boolean appStart(IScope scope) { | ||
log.debug(APP + ":appStart " + scope.getName()); | ||
return true; | ||
} | ||
|
||
@Override | ||
public void appStop(IScope scope) { | ||
log.debug(APP + ":appStop " + scope.getName()); | ||
} | ||
|
||
@Override | ||
public boolean roomConnect(IConnection connection, Object[] params) { | ||
log.debug(APP + ":roomConnect"); | ||
ISharedObject so = getSharedObject(connection.getScope(), LAYOUT_SO); | ||
log.debug("Setting up Listener"); | ||
LayoutSender sender = new LayoutSender(so); | ||
String room = connection.getScope().getName(); | ||
log.debug("Adding event listener to " + room); | ||
log.debug("Adding room listener"); | ||
layoutApplication.addRoomListener(room, sender); | ||
log.debug("Done setting up listener"); | ||
return true; | ||
} | ||
|
||
@Override | ||
public void roomDisconnect(IConnection connection) { | ||
log.debug(APP + ":roomDisconnect"); | ||
} | ||
|
||
@Override | ||
public boolean roomJoin(IClient client, IScope scope) { | ||
log.debug(APP + ":roomJoin " + scope.getName() + " - " + scope.getParent().getName()); | ||
return true; | ||
} | ||
|
||
@Override | ||
public void roomLeave(IClient client, IScope scope) { | ||
log.debug(APP + ":roomLeave " + scope.getName()); | ||
} | ||
|
||
@Override | ||
public boolean roomStart(IScope scope) { | ||
log.debug(APP + ":roomStart " + scope.getName()); | ||
layoutApplication.createRoom(scope.getName()); | ||
if (!hasSharedObject(scope, LAYOUT_SO)) { | ||
if (createSharedObject(scope, LAYOUT_SO, false)) { | ||
return true; | ||
} | ||
} | ||
log.error("Failed to start room " + scope.getName()); | ||
return false; | ||
} | ||
|
||
@Override | ||
public void roomStop(IScope scope) { | ||
log.debug(APP + ":roomStop " + scope.getName()); | ||
layoutApplication.destroyRoom(scope.getName()); | ||
if (!hasSharedObject(scope, LAYOUT_SO)) { | ||
clearSharedObjects(scope, LAYOUT_SO); | ||
} | ||
} | ||
|
||
public void setLayoutApplication(LayoutApplication a) { | ||
log.debug("Setting layout application"); | ||
layoutApplication = a; | ||
layoutApplication.handler = this; | ||
} | ||
|
||
} |
96 changes: 96 additions & 0 deletions
96
bigbluebutton-apps/src/main/java/org/bigbluebutton/conference/service/layout/LayoutRoom.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,96 @@ | ||
/** | ||
* BigBlueButton open source conferencing system - http://www.bigbluebutton.org/ | ||
* | ||
* Copyright (c) 2012 BigBlueButton Inc. and by respective authors (see below). | ||
* | ||
* This program is free software; you can redistribute it and/or modify it under the | ||
* terms of the GNU Lesser General Public License as published by the Free Software | ||
* Foundation; either version 2.1 of the License, or (at your option) any later | ||
* version. | ||
* | ||
* BigBlueButton is distributed in the hope that it will be useful, but WITHOUT ANY | ||
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A | ||
* PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU Lesser General Public License along | ||
* with BigBlueButton; if not, see <http://www.gnu.org/licenses/>. | ||
* | ||
* Author: Felipe Cecagno <[email protected]> | ||
*/ | ||
package org.bigbluebutton.conference.service.layout; | ||
|
||
import java.util.ArrayList; | ||
import java.util.Iterator; | ||
import java.util.List; | ||
import java.util.Map; | ||
import java.util.concurrent.ConcurrentHashMap; | ||
|
||
import net.jcip.annotations.ThreadSafe; | ||
|
||
import org.red5.logging.Red5LoggerFactory; | ||
import org.slf4j.Logger; | ||
/** | ||
* Contains information about a LayoutRoom. | ||
*/ | ||
@ThreadSafe | ||
public class LayoutRoom { | ||
private static Logger log = Red5LoggerFactory.getLogger( LayoutRoom.class, "bigbluebutton" ); | ||
|
||
private final String name; | ||
private final Map<String, ILayoutRoomListener> listeners; | ||
private boolean locked = false; | ||
private int modifierId = -1; | ||
private String currentLayout = ""; | ||
|
||
public LayoutRoom(String name) { | ||
this.name = name; | ||
this.listeners = new ConcurrentHashMap<String, ILayoutRoomListener>(); | ||
} | ||
|
||
public String getName() { | ||
return name; | ||
} | ||
|
||
public void addRoomListener(ILayoutRoomListener listener) { | ||
if (! listeners.containsKey(listener.getName())) { | ||
log.debug("adding room listener"); | ||
listeners.put(listener.getName(), listener); | ||
} | ||
} | ||
|
||
public void removeRoomListener(ILayoutRoomListener listener) { | ||
log.debug("removing room listener"); | ||
listeners.remove(listener); | ||
} | ||
|
||
private void updateLayout() { | ||
for (Iterator<ILayoutRoomListener> iter = listeners.values().iterator(); iter.hasNext();) { | ||
log.debug("calling on listener"); | ||
ILayoutRoomListener listener = (ILayoutRoomListener) iter.next(); | ||
log.debug("calling updateLayout on listener " + listener.getName()); | ||
listener.updateLayout(currentLayout()); | ||
} | ||
} | ||
|
||
public void lockLayout(int userId, String layout) { | ||
locked = true; | ||
modifierId = userId; | ||
currentLayout = layout; | ||
updateLayout(); | ||
} | ||
|
||
public void unlockLayout() { | ||
locked = false; | ||
modifierId = -1; | ||
currentLayout = ""; | ||
updateLayout(); | ||
} | ||
|
||
public List<Object> currentLayout() { | ||
List<Object> args = new ArrayList<Object>(); | ||
args.add(locked); | ||
args.add(modifierId); | ||
args.add(currentLayout); | ||
return args; | ||
} | ||
} |
Oops, something went wrong.