I have an HTTPProvider that needs to load a file from the conf directory. When I debug from Eclipse the current working directory is not the Wowza install directory. Is there a call I can make to determine the location of the Wowza install?
Also I will be using the mediacaster routines to start and stop a stream as shown in the example HTTPProvider. However, I have streams that start up on demand using mediacaster’s “rtp-live” and would like to be able to dynamically make them inaccessible just like stopping the mediacaster “rtp” streams. Any advice on the best way to do this? The purpose of my HTTPProvider is to make a custom web page of all streams and control their access.
JohnA
Hello JohnA
To obtain the filepath to your conf directory, you might try the following:
Bootstrap.getServerHome(Bootstrap.CONFIGHOME) + "/conf/"
As per your second question, it sounds like you might want to take a look at our ban stream server listener from within our Module Collection. This should allow you to make these streams inaccessible. Just setup the listener as follows in your Server.xml:
<ServerListener>
<BaseClass>com.wowza.wms.plugin.collection.serverlistener.ServerListenerBanStreams</BaseClass>
</ServerListener>
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.
Hey JohnA,
You are welcome. That server listener resides in the actual collection (you’ll see when you download it) but hasn’t made it onto the list shown on the module collection page as of yet.
Matt
Hello
Please restart Wowza and reproduce this issue and then zip up your conf/ and logs/ directories and send them to support@wowza.com.
Thanks,
Matt
Thanks for the info Matt. I’ll check out the module collection.
JohnA
Found it in the Java source.
Tried using the ban to prevent access to a mediacaster “rtp” stream and it didn’t work. The stream does appear in the blacklist.txt file as…
live:definst:entrance.stream
The application name is “live”. Not sure what the meaning of application instance is, but definst seems to be used in the examples I’ve seen. And the stream name is entrance.stream.
Does “ban” not work on a stream that is running in the mediacaster? I know you suggested ban for mediacaster “rtp-live”, but it seemed simple if I could use it for both. I haven’t tried it on “rtp-live” yet.
Even restarting the server didn’t have an effect. And I need to do this dynamically anyway.
JohnA
I have the WowzaServerAddOnCollection_4.0 imported into Eclipse to make the mods. I put the WowzaServerAddOnCollection_4.0 directory in my “workspace” folder where my custom HTTPProvider is located. If I load it as an existing project it has a bunch of errors because it doesn’t know the location of any of the Wowza jars. So I add them as external jars and everything is fine except it can’t find either of these two imports…
import com.wowza.wms.plugin.loadbalancer.LoadBalancerSender;
import com.wowza.wms.plugin.loadbalancer.ServerListenerLoadBalancerSender;
Any idea where this is?
EDIT: I found the LoadBalancer_2.0.zip file and put the jar in my Wowza lib folder.