To use multipoint publishing, you need to write both client and server-side code.
private function publishLiveStream():void {
var ns:NetStream = new NetStream(nc);
ns.addEventListener(NetStatusEvent.NET_STATUS, netStatusHandler);
camera = Camera.getCamera();
mic = Microphone.getMicrophone();
if (camera != null && mic != null) {
camera.addEventListener(ActivityEvent.ACTIVITY, activityHandler);
mic.addEventListener(ActivityEvent.ACTIVITY, activityHandler);
ns.attachCamera( camera );
ns.attachAudio( mic );
// start publishing
// triggers NetStream.Publish.Start
ns.publish( "localNews", "record" );
} else {
trace("Please check your camera and microphone");
}
}
// called when the client publishes
application.onPublish = function( client, myStream ) {
trace(myStream.name + " is publishing" );
nc = new NetConnection();
nc.onStatus = function (info) {
if (info.code == "NetConnection.Connect.Success") {
ns = new NetStream(nc);
ns.setBufferTime(2);
ns.attach(myStream);
ns.publish( myStream.name, "live" );
}
nc.connect( "rtmp://xyz.com/myApp" );
}
}
Calling NetStream.publish() publishes the stream from your server to the remote server.
ns.onStatus = function(info) {
if (info.code) == "NetStream.Publish.Start") {
trace("The stream is now publishing");
trace("Buffer time is : " + this.bufferTime);
}
}
Just as with publishing live streams from a user's computer, the NetStream.publish() method triggers a netStatus event with a NetStream.Publish.Start code.
application.onUnpublish = function( client, myStream ) {
trace(myStream.name + " is unpublishing" );
}