Control Stream class streams dynamically with a Wowza Streaming Engine Java module

You can use the HTTPStreamControl module for Wowza Streaming Engine™ media server software to control Stream class streams and playlists through HTTP requests. Use it to dynamically create, set up, and start new live Stream class streams from static and live sources, and to add sources to existing Stream class streams. For extra control, use this HTTP provider with the StreamPublisher module.

Notes:
  • Be careful when using HTTPStreamControl with the StreamPublisher module. Changes made to one module may not be picked up in the other module.
  • HTTPStreamControl uses internal ApplicationInstance properties to store references to streams and playlists. Do not use the same name for a stream and a playlist. Using the same name for both will have unexpected results because the last object defined (either the stream or the playlist) will be stored in the properties and will overwrite what's already there.

Prerequisites


Wowza Streaming Engine 4.0.0 or later is required.

Installation


  1. Download wse-plugin-httpstreamcontrol.zip.
  2. Extract the contents from the downloaded (zipped) package, and then copy the lib/wse-plugin-httpstreamcontrol.jar file from the package to the lib folder in your Wowza Streaming Engine installation ([install-dir]/lib).
  3. Restart Wowza Streaming Engine.

Configuration


  1. Navigate to [install-dir]/conf and open VHost.xml in a text editor.
  2. Locate the section <HostPortList>/<HostPort>/<Name>Default Streaming</Name>.
  3. Add the following HTTP provider definition to the <HTTPProviders> section:
<HTTPProvider>
	<BaseClass>com.wowza.wms.plugin.HTTPStreamControl</BaseClass>
	<RequestFilters>streamcontrol*</RequestFilters>
	<AuthenticationMethod>none</AuthenticationMethod>
</HTTPProvider>
 

Important: The new HTTP provider must be above the last HTTP provider that's used to resolve all requests that aren't handled by other providers. RequestFilters identifies the last part of the URL that's checked to see if the HTTP provider can handle the request. It isn't the name of a custom image.

To make it harder for someone to detect that this is a referer check, change the request filter to your own value, but note that stream extensions that aren't currently used elsewhere in the server won't work.

  1. Save and close VHost.xml, and then restart Wowza Streaming Engine.

Usage


Control the playlist through an HTTP request, passing the required variables as query string parameters.

Add a new stream:


curl "http://localhost:8086/streamcontrol?appName=myApplication&action=addNewStream&streamName=testStream"

Add a new playlist:


curl "http://localhost:8086/streamcontrol?appName=myApplication&action=addNewPlaylist&playlistName=p1"

Add a playlist item:


curl "http://localhost:8086/streamcontrol?appName=myApplication&action=addItemToPlaylist&playlistName=p1&streamName=testStream&playlistItemName=sample.mp4"

Open the playlist on a stream. By default, start is 0 and length is -1. For live streams, use -2 for start. Any positive integer for length plays the source for that number of seconds:


curl "http://localhost:8086/streamcontrol?appName=myApplication&action=openPlaylistOnStream&playlistName=p1&streamName=testStream"

Play the next item on the playlist:


curl "http://localhost:8086/streamcontrol?appName=myApplication&action=playNextPlaylistItem&streamName=testStream"

Remove an item from a playlist:


curl "http://localhost:8086/streamcontrol?appName=myApplication&action=removeItemFromPlaylist&playlistItemName=sample.mp4&streamName=testStream"

Stop a stream:


curl "http://localhost:8086/streamcontrol?appName=myApplication&action=stopStream&streamName=testStream"

For developers


  • Get the source code on GitHub