Skip to main content
Participant
October 2, 2009
Question

Multi-point Publishing, Changing the Stream Name

  • October 2, 2009
  • 1 reply
  • 726 views

I have justed started using Flash Media server so this could be a really easy one to answer or not even possible.

I have Adobe Flash Media Live Encoder 3 publishing to Adobe Flash Media Server 3.5 which then publishes this live stream to two CDN providers.  I want to publish the stream with a different name to each CDN. Anyone know howI can do this without having FMLE3 publishing a backup stream and then FMS having to process two differently named streams?

I.E.

FMLE publishes a stream called bob
This is then published to CDN1 as bob and I then want to publish it to CDN2 as bob2

Below the main.asc for the application but it ignores the second stream name and publishes to CDN2 with bob

// main.asc file
// server-side actionscript
 
var nc;
var ns;
var nc2;
var ns2;
 
// Called when a client connects
application.onConnect = function(client) {
     
     // accept the new client's connection
      application.acceptConnection(client);
      
      // send a message
      trace(client.id + " is connected");     
}
 
// Called when a client disconnects
application.onDisconnect = function(client) {
     trace(client.id + "disconnecting at " + new Date());
}
 
 
// Called when the client publishes
application.onPublish = function(client, myStream) {
trace(myStream.name + " is publishing into application " + application.name);
// This is an example of using the multi-point publish feature to republish
// streams to another application instance on the local server.
if (application.name == "live/_definst_"){
trace("Republishing the stream into livestreams/anotherinstance");
 
nc = new NetConnection();
nc2 = new NetConnection();
 
nc.connect( "rtmp://cdn1/app" );
nc2.connect( "rtmp://cdn2/app" );
 
ns = new NetStream(nc);
ns2 = new NetStream(nc2);
 
//Publishing Streams
 
ns.setBufferTime(2);
ns.attach(myStream);
ns.publish( myStream.name, "bob" );
 
ns2.setBufferTime(2);
ns2.attach(myStream);
ns2.publish( myStream.name, "bob2" );
}
}
 
application.onUnpublish = function( client, myStream ) {
    trace(myStream.name + " is unpublishing"  );
     }
    This topic has been closed for replies.

    1 reply

    October 2, 2009

    I think your syntax is wrong. Try this:


    ns.attach(myStream);
    ns.publish("bob", "live" );


    ns2.attach(myStream);
    ns2.publish("bob2","live" );