[Red5devs] Error App
Victor Brunetti
victor_brunetti at yahoo.com.br
Mon Mar 31 06:00:53 PST 2008
Hello,
Excuse my English but I am using google translator. I am in Brazil
My problems with this app someone could help me?
Application.java
///////////////////////////////////////////////////////////////////////////////////////////////////////////
package org.red5.demos.fitc;
import org.red5.server.adapter.ApplicationAdapter;
import org.red5.server.api.IBandwidthConfigure;
import org.red5.server.api.IConnection;
import org.red5.server.api.IScope;
import org.red5.server.api.Red5;
import org.red5.server.api.IClient;
import org.red5.server.api.stream.IBroadcastStream;
import org.red5.server.api.stream.IServerStream;
import org.red5.server.api.stream.IStreamCapableConnection;
import org.red5.server.api.stream.support.SimpleConnectionBWConfig;
import java.util.Iterator;
import java.util.List;
import org.jdom.Document;
import org.jdom.Element;
import org.jdom.input.SAXBuilder;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
public class Application extends ApplicationAdapter {
protected static Logger log = LoggerFactory.getLogger(Application.class);
private IScope appScope;
private IServerStream serverStream;
public boolean appStart(IScope app) {
log.info("0 - Iniciando App {}", app);
appScope = app;
return true;
}
public boolean appConnect(IConnection conn, Object[] params) {
log.info("1 - Conexão ID: {} Conexão IP: {}", new Object[]{conn.getClient().getId(), conn.getRemoteAddress()});
log.info("2- Stream id: {}", getClients().size()); // just a unique number
/////////////////////////////////////
measureBandwidth(conn);
if (conn instanceof IStreamCapableConnection) {
IStreamCapableConnection streamConn = (IStreamCapableConnection) conn;
SimpleConnectionBWConfig bwConfig = new SimpleConnectionBWConfig();
bwConfig.getChannelBandwidth()[IBandwidthConfigure.OVERALL_CHANNEL] =
1024 * 1024;
bwConfig.getChannelInitialBurst()[IBandwidthConfigure.OVERALL_CHANNEL] =
128 * 1024;
streamConn.setBandwidthConfigure(bwConfig);
}
///////////////////////////////////////
return super.appConnect(conn, params);
}
public boolean appJoin(IClient client, IScope scope) {
log.info("3 - Cliente ID {}", client.getId());
log.info("4 - IScope {}", scope.getScopeNames());
//
return true;
}
public boolean roomStart(IScope room){
log.info("ATENÇÃO - Tentativa de Criar ChildScoop: {}", room);
Red5.getConnectionLocal().close();
return false;
}
public void streamPublishStart(IBroadcastStream stream) {
log.info("5 - Iniciando Stream em: {}", stream.getPublishedName());
}
public void streamBroadcastStart(IBroadcastStream stream) {
Document doc = null;
SAXBuilder builder = new SAXBuilder();
try {
doc = builder.build("../xml/teste.xml");
} catch (Exception e) {
e.printStackTrace();
}
Element streamxml = doc.getRootElement();
List elements = streamxml.getChildren();
Iterator i = elements.iterator();
String[] Array=new String[10];
String aux = null;
int x=0;
while (i.hasNext()) {
Element element = (Element) i.next();
Array[x] = element.getChildText("app").toUpperCase();
log.info("xml: {}", element.getChildText("app").toUpperCase());
x++;
}
for (int xx = 0; xx < Array.length; xx++){
if (Array[xx].equals(stream.getPublishedName().toUpperCase())){
aux = "sim";
}
}
if (!"sim".equals(aux)){
log.info("ERRO - Canal invalido: {}", stream.getPublishedName());
stream.stop();
// Red5.getConnectionLocal().close();
}else{
log.info("6 - Publicando no Canal: {}", stream.getPublishedName());
}
}
public void streamBroadcastClose(IBroadcastStream stream) {
log.info("7 - Parou o Canal: {}", stream.getPublishedName());
}
public void appDisconnect(IConnection conn) {
if (appScope == conn.getScope() && serverStream != null) {
serverStream.close();
log.info("8 - Parou a App: {}", conn.getRemoteAddress());
}
super.appDisconnect(conn);
}
}
//////////////////////////////////////////////////////////////////////////////////////////////////////
And teste.xml
//////////////////////////////////////////////////////////////
<?xml version="1.0" encoding="iso-8859-1"?>
<stream>
<canal>
<app>test</app>
<app>live</app>
</canal>
</stream>
////////////////////////////////////////////////////////////
Abra sua conta no Yahoo! Mail, o único sem limite de espaço para armazenamento!
http://br.mail.yahoo.com/
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://osflash.org/pipermail/red5devs_osflash.org/attachments/20080331/16678df0/attachment-0001.html
More information about the Red5devs
mailing list