Hi John,
The Ban Streams server listener currently only shuts down player streams that are running at the time they are banned. It doesn’t check to see if they are banned when a player reconnects because it also shuts down the published stream from the encoder. Unfortunately, this doesn’t work for mediaCaster streams that are started dynamically.
The following class will check to see if the stream name is banned when the player connects and will prevent it from starting a mediaCaster if it is.
class StreamAliasProvider implements IMediaStreamNameAliasProvider
{
@Override
public String resolvePlayAlias(IApplicationInstance appInstance, String name)
{
if (BlackListUtils.isStreamBlackListed(appInstance.getApplication().getName(), appInstance.getName(), name))
return null;
return name;
}
@Override
public String resolveStreamAlias(IApplicationInstance appInstance, String name)
{
return MediaCasterUtils.handleStreamAliasFile(appInstance, name);
}
}
Add it as a sub class to the ServerListenerBanStreams class and invoke it from the ApplicationInstanceNotify.onApplicationInstanceCreate method.
public void onApplicationInstanceCreate(IApplicationInstance appInstance)
{
if (ServerListenerBanStreams.debug)
{
logger.info(MODULE_NAME + ".onApplicationInstanceCreate[" + appInstance.getName() + "] Stream Listener is initiated");
}
[B]appInstance.setStreamNameAliasProvider(new StreamAliasProvider());[/B]
appInstance.addMediaStreamListener(listener);
}
It works by returning null from the resolvePlayAlias method if the stream is banned. When null is returned from this method, a 404 response is sent back to the player. The resolveStreamAlias method calls the internal stream files handler so these will still work.
Note: You can only have one StreamNameAliasProvider for an appInstance. If there are multiple ones in different modules then the last one loaded will override the rest.
The onApplicationInstanceCreate method gets called after any onAppStart module methods so will override those. If you already have a alias provider in a module then it would be best to do the ban check there. It is a static method so can be called from anywhere.
Roger.