Skip to content

Commit

Permalink
- add more logging about the connection to red5
Browse files Browse the repository at this point in the history
  • Loading branch information
ritzalam committed Nov 7, 2014
1 parent 56dad02 commit 000ddbd
Show file tree
Hide file tree
Showing 13 changed files with 318 additions and 119 deletions.
19 changes: 10 additions & 9 deletions bbb-video/build.gradle
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -64,18 +64,18 @@ dependencies {
providedCompile 'javax.servlet:servlet-api:2.5@jar'

// Mina
providedCompile 'org.apache.mina:mina-core:2.0.7@jar'
providedCompile 'org.apache.mina:mina-integration-beans:2.0.7@jar'
providedCompile 'org.apache.mina:mina-integration-jmx:2.0.7@jar'
providedCompile 'org.apache.mina:mina-core:2.0.8@jar'
providedCompile 'org.apache.mina:mina-integration-beans:2.0.8@jar'
providedCompile 'org.apache.mina:mina-integration-jmx:2.0.8@jar'

// Spring
providedCompile 'org.springframework:spring-web:4.0.6.RELEASE@jar'
providedCompile 'org.springframework:spring-beans:4.0.6.RELEASE@jar'
providedCompile 'org.springframework:spring-context:4.0.6.RELEASE@jar'
providedCompile 'org.springframework:spring-core:4.0.6.RELEASE@jar'
providedCompile 'org.springframework:spring-web:4.0.7.RELEASE@jar'
providedCompile 'org.springframework:spring-beans:4.0.7.RELEASE@jar'
providedCompile 'org.springframework:spring-context:4.0.7.RELEASE@jar'
providedCompile 'org.springframework:spring-core:4.0.7.RELEASE@jar'

// Red5
providedCompile 'org/red5:red5-server:1.0.3-RELEASE@jar'
providedCompile 'org/red5:red5-server:1.0.4-SNAPSHOT@jar'
providedCompile 'org.red5:red5-io:1.0.4-SNAPSHOT@jar'

// Logging
Expand All @@ -88,7 +88,7 @@ dependencies {

// Needed for the JVM shutdown hook but needs to be put into red5/lib dir.
// Otherwise we get exception on aop utils class not found.
providedCompile 'org.springframework:spring-aop:4.0.6.RELEASE@jar'
providedCompile 'org.springframework:spring-aop:4.0.7.RELEASE@jar'
compile 'aopalliance:aopalliance:1.0@jar'

// Java Concurrency In Practice
Expand All @@ -101,6 +101,7 @@ dependencies {
//redis
compile 'redis.clients:jedis:2.0.0'
providedCompile 'commons-pool:commons-pool:1.5.6'
compile 'com.google.code.gson:gson:1.7.1'
}

test {
Expand Down
104 changes: 97 additions & 7 deletions bbb-video/src/main/java/org/bigbluebutton/app/video/VideoApplication.java
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@
import java.util.HashMap;
import java.util.Map;
import java.util.concurrent.TimeUnit;

import org.red5.logging.Red5LoggerFactory;
import org.red5.server.adapter.MultiThreadedApplicationAdapter;
import org.red5.server.api.IConnection;
Expand All @@ -32,6 +31,7 @@
import org.red5.server.api.stream.IStreamListener;
import org.red5.server.stream.ClientBroadcastStream;
import org.slf4j.Logger;
import com.google.gson.Gson;

public class VideoApplication extends MultiThreadedApplicationAdapter {
private static Logger log = Red5LoggerFactory.getLogger(VideoApplication.class, "video");
Expand All @@ -46,27 +46,117 @@ public class VideoApplication extends MultiThreadedApplicationAdapter {
@Override
public boolean appStart(IScope app) {
super.appStart(app);
log.info("oflaDemo appStart");
System.out.println("oflaDemo appStart");
log.info("BBB Video appStart");
System.out.println("BBB Video appStart");
appScope = app;
return true;
}

@Override
public boolean appConnect(IConnection conn, Object[] params) {
log.info("oflaDemo appConnect");
log.info("BBB Video appConnect");
return super.appConnect(conn, params);
}

@Override
@Override
public boolean roomConnect(IConnection conn, Object[] params) {
log.info("BBB Video roomConnect");
String meetingId = ((String) params[0]).toString();
String userId = ((String) params[1]).toString();

Red5.getConnectionLocal().setAttribute("MEETING_ID", meetingId);
Red5.getConnectionLocal().setAttribute("USERID", userId);

String connType = getConnectionType(Red5.getConnectionLocal().getType());
String connId = Red5.getConnectionLocal().getSessionId();

Map<String, Object> logData = new HashMap<String, Object>();
logData.put("meetingId", meetingId);
logData.put("userId", userId);
logData.put("connType", connType);
logData.put("connId", connId);
logData.put("event", "user_joining_bbb_video");
logData.put("description", "User joining BBB Video.");

Gson gson = new Gson();
String logStr = gson.toJson(logData);

log.info("User joining bbb-video: data={}", logStr);

return super.roomConnect(conn, params);
}

private String getConnectionType(String connType) {
if ("persistent".equals(connType.toLowerCase())) {
return "RTMP";
} else if("polling".equals(connType.toLowerCase())) {
return "RTMPT";
} else {
return connType.toUpperCase();
}
}

private String getUserId() {
String userid = (String) Red5.getConnectionLocal().getAttribute("USERID");
if ((userid == null) || ("".equals(userid))) userid = "unknown-userid";
return userid;
}

private String getMeetingId() {
String meetingId = (String) Red5.getConnectionLocal().getAttribute("MEETING_ID");
if ((meetingId == null) || ("".equals(meetingId))) meetingId = "unknown-meetingid";
return meetingId;
}

@Override
public void appDisconnect(IConnection conn) {
log.info("oflaDemo appDisconnect");
log.info("BBB Video appDisconnect");
if (appScope == conn.getScope() && serverStream != null) {
serverStream.close();
}

String connType = getConnectionType(Red5.getConnectionLocal().getType());
String connId = Red5.getConnectionLocal().getSessionId();

Map<String, Object> logData = new HashMap<String, Object>();
logData.put("meetingId", getMeetingId());
logData.put("userId", getUserId());
logData.put("connType", connType);
logData.put("connId", connId);
logData.put("event", "user_leaving_bbb_video");
logData.put("description", "User leaving BBB Video.");

Gson gson = new Gson();
String logStr = gson.toJson(logData);

log.info("User leaving bbb-video: data={}", logStr);

super.appDisconnect(conn);
}


@Override
public void roomDisconnect(IConnection conn) {
log.info("BBB Video roomDisconnect");

String connType = getConnectionType(Red5.getConnectionLocal().getType());
String connId = Red5.getConnectionLocal().getSessionId();

Map<String, Object> logData = new HashMap<String, Object>();
logData.put("meetingId", getMeetingId());
logData.put("userId", getUserId());
logData.put("connType", connType);
logData.put("connId", connId);
logData.put("event", "user_leaving_bbb_video");
logData.put("description", "User leaving BBB Video.");

Gson gson = new Gson();
String logStr = gson.toJson(logData);

log.info("User leaving bbb-video: data={}", logStr);

super.roomDisconnect(conn);
}

@Override
public void streamPublishStart(IBroadcastStream stream) {
super.streamPublishStart(stream);
Expand Down
18 changes: 9 additions & 9 deletions bbb-voice/build.gradle
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -64,18 +64,18 @@ dependencies {
providedCompile 'javax.servlet:servlet-api:2.5@jar'

// Mina
providedCompile 'org.apache.mina:mina-core:2.0.7@jar'
providedCompile 'org.apache.mina:mina-integration-beans:2.0.7@jar'
providedCompile 'org.apache.mina:mina-integration-jmx:2.0.7@jar'
providedCompile 'org.apache.mina:mina-core:2.0.8@jar'
providedCompile 'org.apache.mina:mina-integration-beans:2.0.8@jar'
providedCompile 'org.apache.mina:mina-integration-jmx:2.0.8@jar'

// Spring
providedCompile 'org.springframework:spring-web:4.0.6.RELEASE@jar'
providedCompile 'org.springframework:spring-beans:4.0.6.RELEASE@jar'
providedCompile 'org.springframework:spring-context:4.0.6.RELEASE@jar'
providedCompile 'org.springframework:spring-core:4.0.6.RELEASE@jar'
providedCompile 'org.springframework:spring-web:4.0.7.RELEASE@jar'
providedCompile 'org.springframework:spring-beans:4.0.7.RELEASE@jar'
providedCompile 'org.springframework:spring-context:4.0.7.RELEASE@jar'
providedCompile 'org.springframework:spring-core:4.0.7.RELEASE@jar'

// Red5
providedCompile 'org/red5:red5-server:1.0.3-RELEASE@jar'
providedCompile 'org/red5:red5-server:1.0.4-SNAPSHOT@jar'
providedCompile 'org.red5:red5-io:1.0.4-SNAPSHOT@jar'

// Logging
Expand All @@ -88,7 +88,7 @@ dependencies {

// Needed for the JVM shutdown hook but needs to be put into red5/lib dir.
// Otherwise we get exception on aop utils class not found.
providedCompile 'org.springframework:spring-aop:4.0.6.RELEASE@jar'
providedCompile 'org.springframework:spring-aop:4.0.7.RELEASE@jar'
compile 'aopalliance:aopalliance:1.0@jar'

// Java Concurrency In Practice
Expand Down
Loading

0 comments on commit 000ddbd

Please sign in to comment.