Work on the RTMPAdapter. Connected it to redis
This commit is contained in:
parent
5678c40416
commit
07ee9003d8
@ -0,0 +1,74 @@
|
||||
/**
|
||||
* ===License Header===
|
||||
*
|
||||
* BigBlueButton open source conferencing system - http://www.bigbluebutton.org/
|
||||
*
|
||||
* Copyright (c) 2010 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/>.
|
||||
*
|
||||
* ===License Header===
|
||||
*/
|
||||
package org.bigbluebutton.conference.service.rtmpadapter;
|
||||
|
||||
import org.red5.server.api.so.ISharedObject;
|
||||
import java.util.ArrayList;
|
||||
import redis.clients.jedis.Jedis;
|
||||
|
||||
import org.red5.server.api.IScope;
|
||||
import org.red5.logging.Red5LoggerFactory;
|
||||
import org.red5.server.adapter.IApplication;
|
||||
import org.red5.server.adapter.MultiThreadedApplicationAdapter;
|
||||
import org.red5.server.api.IClient;
|
||||
import org.red5.server.api.IConnection;
|
||||
import org.red5.server.api.IScope;
|
||||
import org.red5.server.api.Red5;
|
||||
import org.red5.server.api.so.ISharedObject;
|
||||
import org.slf4j.Logger;
|
||||
import redis.clients.jedis.Jedis;
|
||||
import redis.clients.jedis.JedisPubSub;
|
||||
|
||||
public class ChannelManager {
|
||||
|
||||
private static Logger log = Red5LoggerFactory.getLogger(RTMPAdapterApp.class, "bigbluebutton");
|
||||
|
||||
private ArrayList<ISharedObject> channels;
|
||||
private RTMPAdapterApp application;
|
||||
private PubSubListener pubSubListener;
|
||||
private Jedis jedis;
|
||||
|
||||
public ChannelManager(RTMPAdapterApp application){
|
||||
this.application = application;
|
||||
channels = new ArrayList<ISharedObject>();
|
||||
|
||||
jedis = new Jedis("localhost:6379");
|
||||
pubSubListener = new PubSubListener(this);
|
||||
jedis.psubscribe(pubSubListener, "bigbluebutton:");
|
||||
|
||||
pubSubListener = new PubSubListener(this);
|
||||
}
|
||||
|
||||
public void sendData(String appName, String clientScope, String method, String data){
|
||||
log.info("RTMPAdapter sending: bigbluebutton:" + appName + ":" + clientScope + ":" + method + ", data: " + data);
|
||||
String channel = "bigbluebutton:" + appName + ":" + clientScope + ":" + method;
|
||||
jedis.publish(channel, data);
|
||||
}
|
||||
|
||||
public void receivedMessage(String channel, String message){
|
||||
log.info("RTMPAdapter received: " + channel + ", data: " + message);
|
||||
}
|
||||
|
||||
public void addChannel(String appName, IScope scope){
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,67 @@
|
||||
/**
|
||||
* ===License Header===
|
||||
*
|
||||
* BigBlueButton open source conferencing system - http://www.bigbluebutton.org/
|
||||
*
|
||||
* Copyright (c) 2010 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/>.
|
||||
*
|
||||
* ===License Header===
|
||||
*/
|
||||
package org.bigbluebutton.conference.service.rtmpadapter;
|
||||
|
||||
import org.red5.compatibility.flex.messaging.io.ArrayCollection;
|
||||
import org.red5.logging.Red5LoggerFactory;
|
||||
import org.red5.server.adapter.IApplication;
|
||||
import org.red5.server.adapter.MultiThreadedApplicationAdapter;
|
||||
import org.red5.server.api.IClient;
|
||||
import org.red5.server.api.IConnection;
|
||||
import org.red5.server.api.IScope;
|
||||
import org.red5.server.api.Red5;
|
||||
import org.red5.server.api.so.ISharedObject;
|
||||
import org.slf4j.Logger;
|
||||
import redis.clients.jedis.Jedis;
|
||||
import redis.clients.jedis.JedisPubSub;
|
||||
|
||||
public class PubSubListener extends JedisPubSub {
|
||||
|
||||
private static Logger log = Red5LoggerFactory.getLogger(RTMPAdapterApp.class, "bigbluebutton");
|
||||
private static final String APP = "RTMPAdapter";
|
||||
private Jedis jedis;
|
||||
private ChannelManager channelManager;
|
||||
|
||||
public PubSubListener(ChannelManager channelManager){
|
||||
this.channelManager = channelManager;
|
||||
}
|
||||
|
||||
public void onMessage(String channel, String message) {
|
||||
channelManager.receivedMessage(channel, message);
|
||||
}
|
||||
|
||||
public void onSubscribe(String channel, int subscribedChannels) {
|
||||
}
|
||||
|
||||
public void onUnsubscribe(String channel, int subscribedChannels) {
|
||||
}
|
||||
|
||||
public void onPSubscribe(String pattern, int subscribedChannels) {
|
||||
}
|
||||
|
||||
public void onPUnsubscribe(String pattern, int subscribedChannels) {
|
||||
}
|
||||
|
||||
public void onPMessage(String pattern, String channel,
|
||||
String message) {
|
||||
}
|
||||
}
|
@ -40,14 +40,14 @@ public class RTMPAdapterApp extends MultiThreadedApplicationAdapter implements I
|
||||
|
||||
private static Logger log = Red5LoggerFactory.getLogger(RTMPAdapterApp.class, "bigbluebutton");
|
||||
private static final String APP = "RTMPAdapter";
|
||||
private Jedis jedis;
|
||||
|
||||
private ChannelManager channelManager;
|
||||
|
||||
@Override
|
||||
public boolean appStart(IScope app){
|
||||
log.info("Starting RTMPAdapterApp");
|
||||
this.scope = app;
|
||||
|
||||
jedis = new Jedis("localhost:6379");
|
||||
channelManager = new ChannelManager(this);
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -55,6 +55,15 @@ public class RTMPAdapterApp extends MultiThreadedApplicationAdapter implements I
|
||||
public void appStop(IScope scope){
|
||||
}
|
||||
|
||||
public void publish(String appName, String method, String data){
|
||||
String clientScope = getLocalScope().getName();
|
||||
channelManager.sendData(appName, clientScope, method, data);
|
||||
}
|
||||
|
||||
public void message(String channel, String message){
|
||||
log.info("got message from redis on channel: " + channel + " - " + message);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean appConnect(IConnection conn, Object[] params) {
|
||||
return true;
|
||||
|
@ -37,5 +37,9 @@ public class RTMPAdapterService {
|
||||
log.debug("Setting RTMPAdapter application instance");
|
||||
this.application = a;
|
||||
}
|
||||
|
||||
public void publish(String appName, String method, String data){
|
||||
application.publish(appName, method, data);
|
||||
}
|
||||
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user