user1505698
user1505698

Reputation: 37

Wowza Media Server 2.2.3 schedule

Is possible to schedule playlists with this version of Wowza?

I am tried the article https://www.wowza.com/forums/content.php?145-How-to-schedule-streaming-with-Wowza-Streaming-Engine-(ServerListenerStreamPublisher) upload the module collection, but without success, on logs not record any data about the playlist.

/conf/live/Application.xml
<Module>
<Name>streamPublisher</Name>
<Description>Playlists</Description>
<Class>com.wowza.wms.plugin.collection.module.ModuleStreamPublisher</Class>
</Module>

<Property>
<Name>streamPublisherSmilFile</Name>
<Value>playlists.smil</Value>
<Type>String</Type>
</Property>

Upvotes: 0

Views: 671

Answers (1)

Michelle-B
Michelle-B

Reputation: 629

I tested this module on a Wowza version 2.2.3 instance, and it worked fine for me, with the access logs showing the following:

ServerListenerStreamPublisher Scheduled: Stream1 for: 2015-04-07
ServerListenerStreamPublisher stream is **NOT** set to not repeat, setUnpublishOnEnd: true Stream1
ServerListenerStreamPublisher scheduled playlist: Stream1 on stream: Stream1 for:Tue Apr 07
ServerListenerStreamPublisher Scheduled stream is now live: Stream1
ModuleStreamPublisher.onAppStart: [live/_definst_]: DONE!
Stream.switch[live/_definst_/Stream1]: index: 0 name:mp4:sample.mp4 start:5 length:5

This module can be done on a server-level or an application-level. The difference is in starting the output stream, where implementing on a server-level automatically connects the scheduled playlist, while on an application-level you would need to manually connect the SMIL file that contains the schedule.

To connect on an application-level:

  1. Make sure that you have copied the module (jar file) to your /lib folder in your Wowza installation.
  2. Add the fully qualified class name in the Modules list of your live application configuration file (which looks like you've added already).
  3. In addition to the streamPublisherSmilFile property, you may also want to add the Boolean streamPublisherSwitchLog property (set to true) so that you can view additional debug logs.
  4. Make sure that playlists.smil exists in your content/ directory and has correct permissions. An example SMIL file:

    <smil>
        <head></head>
        <body>
            <stream name="Stream1"></stream>
            <playlist name="pl1" playOnStream="Stream1" repeat="true" scheduled="2015-04-07 16:00:00">
               <video src="mp4:sample.mp4" start="5" length="5"/>
               <video src="mp4:elephantsdream_750.mp4" start="50" length="25"/>
               <video src="mp4:sample.mp4" start="0" length="150"/>
            </playlist>
         </body>
    </smil>
    
  5. Connect playlists.smil to your live application through the Stream Manager (http://wowzaIP:8086/streammanager). Your playback stream name, if you are using the above example on application 'live', would be rtmp://wowzaIP:1935/live/Stream1.

The basis of this module is the Stream class, so you can also opt to build your own module. Here is a simple one that is very similar to the above (except it starts up automatically on server restart since it is added as a Server Listener). Once you build the module, add it to conf/Server.xml to the ServerListeners container. I also tested this module on a version 2.2.3 and it was working for me.

package com.wowza.wms.example.serverlistener;

import com.wowza.wms.logging.WMSLoggerFactory;
import com.wowza.wms.server.*;
import com.wowza.wms.vhost.*;
import com.wowza.wms.stream.publish.*;
import com.wowza.wms.application.*;

public class StreamPublisherDemo implements IServerNotify2 {

    public void onServerConfigLoaded(IServer server)
    {
    }

    public void onServerCreate(IServer server)
    {
    }

    public void onServerInit(IServer server)
    {
        IVHost vhost = VHostSingleton.getInstance(VHost.VHOST_DEFAULT);
        IApplication app = vhost.getApplication("live");
        IApplicationInstance appInstance = app.getAppInstance("_definst_");

        Stream stream1 = Stream.createInstance(vhost, "live", "Stream1");

        stream1.play("mp4:sample.mp4", 5, 5, true);
        stream1.play("mp4:sample.mp4", 50, 5, false);
        stream1.play("mp4:sample.mp4", 150, 5, false);
        stream1.addListener(new StreamListener(appInstance));

        Stream stream2 = Stream.createInstance(vhost, "live", "Stream2");

        stream2.play("mp4:sample.mp4", 0, -1, true);
        stream2.addListener(new StreamListener(appInstance));

    }

    public void onServerShutdownStart(IServer server)
    {
    }

    public void onServerShutdownComplete(IServer server)
    {
    }

    class StreamListener implements IStreamActionNotify
    {
        StreamListener(IApplicationInstance appInstance)
        {
        }
        public void onPlaylistItemStop(Stream stream, PlaylistItem item)
        {
            WMSLoggerFactory.getLogger(null).info("Item Stopped: " + item.getName() + "on Stream: " + stream.getName());            
        }
        public void onPlaylistItemStart(Stream stream, PlaylistItem item) 
        {
            WMSLoggerFactory.getLogger(null).info("Item Started: " + item.getName() + "on Stream: " + stream.getName());
        }
    }   
}

Upvotes: 0

Related Questions