Hi
I am creating an P2P Netgroup audio/Video chat application. I am using FMS 4.5 and made connection through RTMFP. In this Application I made sever as part of the Group.
No error occur at both server side and client side. Both side we got NetStream success status. but data in the playing stream is zero. So Not able to receive stream via P2P netgroup. GroupSpecifier name is same at both server side as well as client side.
"a1" is stream name.
Here Is the server side code:
load("framework.asc");
var disTimer;
var clToDis;
var nc = null;
var intervalID;
var gs = null;
var arrusers = new Array();
var streamsArr = new Array();
var ingest= null;
var netGroup = null;
application.onConnect = function(client) {
application.acceptConnection(client);
};
application.onConnectAccept = function(client) {
};
application.onAppStart = function (){
createConnection();
}
function createConnection(){
if(nc == null){
nc = new NetConnection();
}
nc.connect("rtmfp:");
nc.onStatus = function(info){
if(info.code == "NetConnection.Connect.Success"){
createGroupSpecifier();
}
else if(info.code == "NetConnection.Connect.Closed"){
//application.broadcastMsg("streamingServerDisconnect");
}
}
}
function createGroupSpecifier(){
gs = new GroupSpecifier("abc123");
gs.multicastEnabled = true;
gs.postingEnabled = true;
gs.serverChannelEnabled = true;
gs.routingEnabled = true;
netGroup = new NetGroup(nc, gs.groupspecWithoutAuthorizations());
netGroup.onStatus = ngStatusHandler;
/*var ns = new NetStream(nc,gs.groupspecWithoutAuthorizations());
var myStream = Stream.get("a1");
ns.onStatus = function(info){
trace("Net Stream Status on new connection: "+ info.code);
}
ns.attach(myStream);
ns.publish(myStream.name);
trace("GroupName>>>>>>>>>>>: "+gs.groupspecWithoutAuthorizations() ); */
}
function ngStatusHandler(info) {
trace("ngStatusHandler: " + info.code);
if (info.code == "NetGroup.Connect.Success") {
ingest = netGroup.getMulticastStreamIngest("a1");
}
}
function callDisconn(){
application.disconnect(clToDis);
}
application.onPublish = function(client,myStream){
intervalID = setInterval(publishStream,5000,myStream);
}
function publishStream(myStream){
clearInterval(intervalID);
var streamName = myStream.name;
streamsArr[streamName] = streamName;
if(nc.isConnected){
var ns = new NetStream(nc,gs.groupspecWithoutAuthorizations());
ns.attach(myStream);
ns.publish(streamName);
ns.onStatus = function(info){
if(info.code == "NetStream.Publish.Start"){
//application.broadcastMsg("receiveSingleStream",streamName);
}
}
myStream.playFromGroup(ingest);
}
}
application.onUnpublish = function(client,myStream){
delete streamsArr[myStream.name];
}
application.onDisconnect = function(oldClient) {
trace("On disconnect Handler: "+ oldClient);
};
Client side code for Plying stream:
private function playStream():void{
videoLocalRec = new Video(vidWidth, vidHeight);
netstrm = new NetStream(fmsCon,fmsCon._groupSpecifier.groupspecWithoutAuthorization s());
netstrm.addEventListener(AsyncErrorEvent.ASYNC_ERROR, asyncErrorEventHandler);
intervalId = setInterval(getStreamInfo,2000);
netstrm.addEventListener(NetStatusEvent.NET_STATUS, streamNetStatHandler);
videoLocalRec.attachNetStream(netstrm);
netstrm.play(instanceName);
videoDisplay1.video = videoLocalRec;
}
North America
Europe, Middle East and Africa
Asia Pacific