Daren - I’ve been able to start and stop a stream using the following code. Can you please let me know if you see any red flags?
package wowzaAPI;
import java.io.*;
import com.wowza.wms.http.*;
import com.wowza.wms.logging.*;
import com.wowza.wms.vhost.*;
import com.wowza.wms.application.*;
public class API extends HTTProvider2Base {
public void onHTTPRequest(IVHost vhost, IHTTPRequest req, IHTTPResponse resp) {
if (!doHTTPAuthentication(vhost, req, resp))
return;
String action = req.getParameter("action");
String streamName = req.getParameter("streamName");
String applicationName = req.getParameter("applicationName");
String retStr = "";
if( streamName == null)
{
retStr = "<html><head><title>streamName is Required</title></head><body>streamName is Required</body></html>";
}
else
{
if( action == null)
{
retStr = "<html><head><title>action parameter is required</title></head><body>action parameter is required</body></html>";
}
else if( action.equals( "start" ) )
{
startMediaCasterStream(vhost, "_definst", streamName, "rtp", applicationName);
retStr = "<html><head><title>" + streamName
+ "</title></head><body>" + streamName + " has been started</body></html>";
}
else if( action.equals( "stop" ) )
{
stopMediaCasterStream(vhost, "_definst", streamName, "rtp", applicationName);
retStr = "<html><head><title>" + streamName
+ "</title></head><body>" + streamName + " has been stopped</body></html>";
}
}
try {
OutputStream out = resp.getOutputStream();
byte[] outBytes = retStr.getBytes();
out.write(outBytes);
} catch (Exception e) {
WMSLoggerFactory.getLogger(null).error("API: " + e.toString());
}
}
public void startMediaCasterStream(IVHost vhost, String appInstanceStr, String streamName, String mediaCasterType, String applicationName)
{
WMSLoggerFactory.getLogger(null).info("WowzaServerWebService.startMediaCasterStream: appInstance:"+appInstanceStr+" streamName:"+streamName+" mediaCasterType:"+mediaCasterType);
try
{
while(true)
{
vhost = VHostSingleton.getInstance("_defaultVHost_");
if (vhost == null)
{
WMSLoggerFactory.getLogger(null).warn("WowzaServerWebService.startMediaCasterStream: vhost missing: _defaultVHost_");
break;
}
vhost.startApplicationInstance(applicationName, "_definst_");
IApplication application = null;
IApplicationInstance appInstance = null;
try
{
application = vhost.getApplication(applicationName);
if (application == null)
WMSLoggerFactory.getLogger(null).warn("WowzaServerWebService.startMediaCasterStream: application missing:" + applicationName);
else
appInstance = application.getAppInstance("_definst_");
if (appInstance == null)
WMSLoggerFactory.getLogger(null).warn("WowzaServerWebService.startMediaCasterStream: appInstance missing: _definst_");
}
catch(Exception e)
{
}
if (appInstance == null)
break;
appInstance.startMediaCasterStream(streamName, mediaCasterType);
break;
}
}
catch(Exception e)
{
WMSLoggerFactory.getLogger(null).error("WowzaServerWebService.startMediaCasterStream: "+e.toString());
}
}
public void stopMediaCasterStream(IVHost vhost, String appInstanceStr, String streamName, String mediaCasterType, String applicationName)
{
WMSLoggerFactory.getLogger(null).info("WowzaServerWebService.startMediaCasterStream: appInstance:"+appInstanceStr+" streamName:"+streamName+" mediaCasterType:"+mediaCasterType);
try
{
while(true)
{
vhost = VHostSingleton.getInstance("_defaultVHost_");
if (vhost == null)
{
WMSLoggerFactory.getLogger(null).warn("WowzaServerWebService.startMediaCasterStream: vhost missing: _defaultVHost_");
break;
}
IApplication application = null;
IApplicationInstance appInstance = null;
try
{
application = vhost.getApplication(applicationName);
if (application == null)
WMSLoggerFactory.getLogger(null).warn("WowzaServerWebService.startMediaCasterStream: application missing:" + applicationName);
else
appInstance = application.getAppInstance("_definst_");
if (appInstance == null)
WMSLoggerFactory.getLogger(null).warn("WowzaServerWebService.startMediaCasterStream: appInstance missing: _definst_");
}
catch(Exception e)
{
}
if (appInstance == null)
break;
appInstance.stopMediaCasterStream(streamName);
break;
}
}
catch(Exception e)
{
WMSLoggerFactory.getLogger(null).error("WowzaServerWebService.startMediaCasterStream: "+e.toString());
}
}
}
For reference here is a photo of what I see in the GUI that does start the stream.