How To Add a MediaCache Source Dynamically

One of things we have been asked to do many times is add a media cache source WITHOUT the need to restart Wowza Streaming Engine. If you use the Wowza Streaming Engine Manager then this is not possible as it will prompt for a server restart.

It is possible to add a MediaCache source and below is a snippet of code which demonstrates this


MediaCacheConfigSourceItem sourceItem = new MediaCacheConfigSourceItem();
sourceItem.setName("Test");
sourceItem.setBasePath("http://192.168.1.200/");
sourceItem.setPrefix("http/");
sourceItem.setBaseClass("com.wowza.wms.mediacache.impl.MediaCacheItemHTTPImpl");
//sourceItem.setReaderClass("");
sourceItem.setDefaultBlockSize(1024);
sourceItem.setMaxTimeToLive(300000);
sourceItem.setMinTimeToLive(100000);
sourceItem.setReadAhead(true);
sourceItem.setReadAheadThreshold(30);
sourceItem.setPassThru(false);
MediaCacheSourceBasic source = new MediaCacheSourceBasic();
sourceItem.configureMediaCacheSource(source);
MediaCache mediaCache = MediaCacheImpl.getMediaCache();
mediaCache.addSource("Test", source);

This has been tested with onAppStart but of course can be added anywhere.


Comments are closed.