Skip to main content
December 12, 2011
Question

Can I re-stream a stream from wowza to fms 4.5?

  • December 12, 2011
  • 1 reply
  • 3759 views

Can I re-stream a stream from wowza to fms 4.5?

I have a wowza stream with the url similiar to rtmp://wowzaip/edge/app.stream. Is it possible to restream this to fms 4.5?

    This topic has been closed for replies.

    1 reply

    Nikhil_Kalyan
    Participating Frequently
    December 12, 2011

    Hi,

    Never tried , but there should not be any problem in republishing. FMS accepts any source of RTMP as an input. Thanks for trying it out.

    December 12, 2011

    Yes. You can.

    If you want FMS to pull from Wowza, you can use the netconnection and stream classes on the FMS side. If you want to push from Wowza to FMS, use the Wowza PushPublisher class (you can find examples on Wowza's forum)

    December 14, 2011

    Does anyone have a working example of how to pull the stream. Where and how in the main.asc do I add the url to pull from Wowza. I am a newbie to FMS 4.5.  A little nudge in the right direction will help me a whole lot. Thanks.

    /////////////////////////////////////////////////////////////////////////////////////////////////

    // ADOBE SYSTEMS INCORPORATED

    // Copyright 2009 Adobe Systems Incorporated

    // All Rights Reserved.

    //

    // NOTICE:  Adobe permits you to use, modify, and distribute this file in accordance with the

    // terms of the Adobe license agreement accompanying it.  If you have received this file from a

    // source other than Adobe, then your use, modification, or distribution of it requires the prior

    // written permission of Adobe.

    /////////////////////////////////////////////////////////////////////////////////////////////////

    load("ExLiveStream.asc");

    //This function is called when the application starts and can be

    //used for initialization.

    application.onAppStart = function()

    {

              trace( "onAppStart - " + application.name + "\n" );

              application.streams = new Object();

              application.childServers = new Object();

              application.clientID = 0;

    }

    //This function is called when a client connects to the application.

    //Api calls are setup to receive commands from the clients

    application.onConnect = function( newClient )

    {

              application.clientID++;

              newClient.clientID = application.clientID;

              //clients send FCPublish to ask for the premission to publish a stream

              newClient.FCPublish = function( name )

              {

                        if (application.streams[name])

                        {

                                  if (!application.streams[name].publisher)

                                  {

                                            //the stream exists, but there is no publisher

                                            application.acceptPublish( name, newClient );

                                  }

                                  else if (newClient != application.streams[name].publisher)

                                  {

                                            //the stream is already published by another client

                                            this.call("onFCPublish", null, {code:"NetStream.Publish.BadName", description:name});

                                  }

                                  else

                                  {

                                            //allow publish from the same client

                                            this.call("onFCPublish", null, {code:"NetStream.Publish.Start", description:name});

                                  }

                        }

                        else

                        {

                                  //stream doesn't exist, create a new one

                                  application.streams[name] = new ExLiveStream(name, "rtmp://localhost/dummy", 1000, 1);

                                  application.acceptPublish( name, newClient );

                        }

              }

              //clients send FCUnpublish to release the usage of a stream, so other clients can publish to the stream

              newClient.FCUnpublish = function( name )

              {

                        if (application.streams[name] && newClient == application.streams[name].publisher)

                        {

                                  application.acceptUnpublish( name, newClient );

                        }

                        this.call("onFCUnpublish", null, {code:"NetStream.Unpublish.Success", description:name});

              }

              //add alternate unpublish function used by several encoders

              newClient.releaseStream = function( name )

              {

                        //force to unpublish

                        if (application.streams[name])

                        {

                                  // first be nice, and issue an unpublish notification

                                  application.acceptUnpublish( name, newClient );

                        }

                        // worst case if the the unpublish failed, force a removal of the stream

                        s = Stream.get(name);

                        s.play(false);

              }

              //when a client wants to subscribe to a live stream in this app.

              newClient.FCSubscribe = function( name )

              {

                        if (application.streams[name] == null)

                        {

                                  application.streams[name] = new ExLiveStream( name, "rtmp://localhost/dummy", 1000, 1, null );

                        }

                        application.streams[name].addSubscriber(this);

                        this.call("onFCSubscribe", null, {code:"NetStream.Play.Start", description:name});

              }

              //when a client stops subcribing.

              newClient.FCUnsubscribe = function( name )

              {

                        if (application.streams[name] != null)

                        {

                                  application.streams[name].removeSubscriber(this);

                        }

                        this.call("onFCUnsubscribe", null, {code:"NetStream.Play.Stop", description:name});

              }

              //when another server wants to register as a child server

              newClient.FCAddChild = function()

              {

                        //go through the all the streams and return the stream name to the client

                        for (i in application.streams)

                        {

                                  if (application.streams.publisher)

                                  {

                                            this.call("addStream", null, i);

                                  }

                        }

                        //add the client to the subscriber list

                        application.childServers[this.clientID] = newClient;

              }

              return true;

    }

    //When a client disconnects

    application.onDisconnect = function( client )

    {

              //walk through all the streams and remove the disconnecting client form the subscriber list.

              for (p in application.streams)

              {

                        application.streams

    .removeSubscriber( client );

                        client.FCUnpublish( p );

              }

              //if the client is a child server, remove it from the property of childServers.

              application.childServers[client.clientID] = null;

              delete application.childServers[client.clientID];

    }

    //Accept a publisher and notify everyone the stream is add

    application.acceptPublish = function( name, client )

    {

              application.streams[name].setPublisher(client);

              client.call("onFCPublish", null, {code:"NetStream.Publish.Start", description:name});

              //notify all subscribers

              application.streams[name].notifyClient("onFCSubscribe", {code:"NetStream.Play.PublishNotify", description: name});

              //notify all the childServers a new stream is published

              for (i in application.childServers)

              {

                        application.childServers.call("addStream", null, name);

              }

    }

    //Accept an unpublisher and notify everyone the stream is removed

    application.acceptUnpublish = function( name, client )

    {

              application.streams[name].setPublisher(null);

              //notify all subscribers

              application.streams[name].notifyClient("onFCSubscribe", {code:"NetStream.Play.UnpublishNotify", description: name});

              //notify all the childServers a stream is unpublished

              for (i in application.childServers)

              {

                        application.childServers.call("removeStream", null, name);

              }

    }