As we have seen, the Wowza Media Server is an extensible Streaming Server that can allow you to create time shifted streams or scheduled streams. If you are using the live-record stream type or the LiveStreamRecord module, you can create a good time shifting module to schedule streams along a given set of streams. The problem is that the playlist must be dynamic, so I’ve solved that issue rescheduling the playlist.
non cycled media files
If you have non-cycled media files you can’t the timestamp on files to cycle them. You need create a dynamic playlist, reading the media file metadata each time that the playlist finishes to transmit its contents. Fortunately, the Wowza Media Server API provides an event handling method called onPlaylistItemStop on the IStreamActionNotify interface. To reconstruct the playlist on that method, you just need to call a playlist refreshing method.
try { log.error("---> Scheduled: onPlaylistItemStop() -> Enter"); if (item.getIndex() == (stream.getPlaylist().size() - 1)) { stream.getPlaylist().clear(); setupStream(stream, pl); } log.error("---> Scheduled: onPlaylistItemStop() -> Exit"); } catch (Exception ex) { log.error(ex.getMessage()); }
Once we clear the playlist, we call the setupStream method — which must be implemented by you — and it will reconstruct the playlist.
The arguments that I bring to the application through the WowzaScheduler module — which is a private development, so I can’t release the module, and even the code — are as follows:
<Property> <Name>StreamsToAdd</Name> <Value>CH2_TV,CH3_TV,CH4_TV</Value><!-- dmw: stream names to add --> </Property> <Property> <Name>MinutesToShift</Name> <Value>30</Value><!-- dmw: 30 minutes --> </Property>
This will allow you to add only the streams CH2_TV, CH3_TV and CH4_TV, with a timeshift of 30 minutes.
major problems found
Major problems found while I was developing the extension are a little bit hard to handle. The main one is the fact that the API do not provides publicly any class or method that allows you to read metadata information about the media files. We used some external tools to handle that issue.
Another problem is that Stream.getPlaylist method provides an instance to the playlist in the form of a standard List<PlaylistItem>. So, we have some problems with that, since we don’t have any media type related methods and the PlaylistItem interface do not provides media file metadata information methods too. We are using a kind of catalog to handle media processing tasks. Probably we need to create a daemon to handle media processing, something done in a low level language, like C, and third party FOSS libraries.
You can find problematic some issues related to the streams storing on the media server. For example if the server is very busy, and you do a server restart or server stop, and the operating system requires to kill the process instead of doing a normal shutdown, some media files will be truncated, and certain data blocks for those media files will not be flushed to the hard drive, with the risk of lost recording seconds.
For now, the stream scheduler and stream time shifter is working fine. It passed many tests, but still we are testing the module. I hope that we will finish this project very well, as it is working now…