Avec l’avènement de Flash player 9.115, Adobe utilise le codec H264 MPEG4 pour remplacer le codec historique de Flash.
La version 0.7 de red5 n’intègre pas encore cette compression. Voici un lien d’un projet openSource sous RUBY qui intègre la compression H264: http://code.google.com/p/rubyizumi/
Peut être pour la version 0.8 de RED5 ?
Mots clés Technorati :
LinkedHashMap,
hashmap
hashmap ne garantit pas l’ordre des insertions des données.
public HashMap<String,Player> users = new LinkedHashMap<String,Player>();
// ne garatit pas l’ordre des insertions des données
public LinkedHashMap<String,Player> users = new LinkedHashMap<String,Player>();
// garatit l’ordre des insertions des données
var nc:NetConnection = new NetConnection();
nc.connect(”rtmp://localhost/whiteBoard”,”zaza”,”zaza”);
var so:SharedObject = SharedObject.getRemote(”whiteBoard”, nc.uri, false);
so.connect(nc);
so.onSync = function(list) {
trace(”SYNCRO”);
}
nc.onStatus= function(infoObject:Object) {
trace(infoObject.code);
}
test_btn.onPress=function() {
trace(”click”);
_root.so.data.mousePosition = {x: 100, y: 200};
}
Shared Whiteboard application in Red5
Pour cela il faut utiliser les SharedObject (SO): recuperer les coordonnées de la souris et les transmettre vers le SO.
Sur la partie client:
var whiteboard_SO:SharedObject = SharedObject।getRemote(”whiteboard”,nc.uri,”false”);
Quand nous pressons la souris sur un MovieClip, nous capturons les positions x et y de la souris et nous les envoyons vers le serveur:
clip_MC.onPress = function(){
//envoyer x et y au serveur
NetConnectionObj.call(”draw”, null,param1, param2,param3);
};
clip_MC.onMouseMove = function(){
//envoyer x et y au serveur
NetConnectionObj.call(”draw”, null,param1, param2,param3);
}
Sur le serveur,
public void draw(Object[] params){
whiteboard_SO.setAttribute(”point”,params[0].toString()+”:”+params[1].toString()+”:”+params[2].toString());
// va etre declanché sur l’evenement onSync sur tous les clients connectés
}
Enfin sur la partie client
Whiteboard_SO.onSync = function(infolist){
// Inside the change event we will get the xmouse and ymouse and press string
//If event string is press, jump to new line(i.e. lineto(x,y))
//If event string is move, move with drawing(i.e. moveto(x,y))
}
TRADUIT de http://sunil-gupta.blogspot.com/2007/04/shared-whiteboard-application-in-red5.html
1) Allez dans c:\program files\red5\webapps
copier test en demo2
2) garder le dossier source et classes mais effacer leur contenu
3) Ouvrir eclipse:Chosir le workspace:C:\Program Files\Red5\webapps\
4) dans Eclipse: Nouveau projet - demo2
5) Right click source: Build path->use as source folder
6) Bouton droit sur le projet (TOP) demo2->Propritétés
7) Java Build Path->Browse->classes
Effacer le dossier inutile Bin
9) Click droit sur demo2 projet et propriété: Java Build Path->Libraries->Add external JAR->
Red5.jar
commons-logging-1.1.jar
10) demo2->New->Package->demo2
11) demo2 package->New Class->Application
12) ecrire
package demo2;import org.red5.server.adapter.ApplicationAdapter;
public class Application extends ApplicationAdapter {
public double add(double a, double b){return a + b; }
}13) editer les fichiers: red5-web.xml effacer
Editer
class=”demo2.Application”
singleton=”true” />14) Editer red5-web.properties
webapp.contextPath=/demo214) Editer red5-web.properties15) Editer web.xml
Changer
webAppRootKey /demo2
SOUS FLASH taper:
var nc:NetConnection = new NetConnection();
// connect to the local Red5 server
nc.connect(”rtmp://localhost/demo2″);
nc.onResult = function(obj) {
trace(”the result is”+obj);
};
nc.onStatus = function(info:Object) {
trace(info.code);
trace(info.level);
trace(info);
if (info.code == “NetConnection.Connect.Success”) {
//trace(”susccess”);
}
};
nc.call(”add”, nc, 2,3);
resultat:5
Comment creer un client avec paramètres (role, id, username) sous red5 ?
Creer un objet client
public class Client{
String clientId = null;
String clienName = null;
String clientRole = null;
public String getRole(){
return clientRole;
}
public String getName(){
return clientName;
}
public String getId(){
return clientId;
}
public void setRole(String role){
clientRole = role;
}
public void setName(String name){
clientName = name;
}
public void setId(String id){
clientId = id;
}
}
(…)
public boolean roomConnect(IConnection iconnection, Object params[]){
if(!super.roomConnect(iconnection, params)){
log.info((new StringBuilder()).append(”Application failed to connect room: “).append(iconnection.getScope().getName()).toString());
return false;
}
else{
log.info((new StringBuilder()).append(”Application room connect initiated for room “).append(iconnection.getScope().getName()).append(”: “).toString());
//AJouter les infos du client ici
Client client = new Client();
client.setId(params[0].toString());
client.setName(params[1].toString());
client.setRole(params[2].toString());
iconnection.getClient().setAttribute(”client”, client);
return true
}
}
public boolean roomJoin(IClient iclient, IScope iscope){
/*ICI on accede aux infos de notre client !*/
Client client = ((Client)iclient.getAttribute(”client”));
String clientName = client.getName();
String clientId = client.getId();
String clientRole = client.getRole();
return true;
}
commentaires récenets