Good afternoon,
I am attempting to custom code a module that will stop a stream. I got the code working that supposedly stops ip streams but I need it to stop rtmp streams so I was trying to merge them together and somehow got some code messed up. If an advanced coder could look at it I would be much obliged.
package com.marestare.wms.module;
import java.io.*;
import java.util.List;
import java.util.Map;
import java.util.Iterator;
import java.util.List;
import com.wowza.wms.application.IApplicationInstance;
import com.wowza.wms.http.*;
import com.wowza.wms.logging.*;
import com.wowza.wms.vhost.*;
import com.wowza.wms.amf.*;
import com.wowza.wms.client.*;
import com.wowza.wms.module.*;
import com.wowza.wms.request.*;
import com.wowza.wms.stream.IMediaStream;
public class CamManager extends HTTProvider2Base {
public void onHTTPRequest(IVHost vhost, IHTTPRequest req, IHTTPResponse resp) {
if (!doHTTPAuthentication(vhost, req, resp))
return;
Map<String, List<String>> params = req.getParameterMap();
String action = "";
String app = "";
String streamName = "";
String mediacasterType = "";
if (req.getMethod().equalsIgnoreCase("post")) {
req.parseBodyForParams(true);
}
if (params.containsKey("action"))
action = params.get("action").get(0);
if (params.containsKey("app"))
app = params.get("app").get(0);
if (params.containsKey("streamName"))
streamName = params.get("streamName").get(0);
if (params.containsKey("mediacasterType"))
mediacasterType = params.get("mediacasterType").get(0);
IApplicationInstance appInstance = vhost.getApplication(app).getAppInstance("_definst_");
String report = action + " " + streamName;
try
{
if (action.equalsIgnoreCase("start"))
{
appInstance.startMediaCasterStream(streamName, mediacasterType);
}
else if (action.equalsIgnoreCase("stop"))
{
appInstance.stopMediaCasterStream(streamName);
stopStream();
}
}
catch(Exception e)
{
report = e.getMessage();
}
String retStr = "<html><head><title>MediaCaster HTTProvider</title></head><body>" + report + "</body></html>";
try {
OutputStream out = resp.getOutputStream();
byte[] outBytes = retStr.getBytes();
out.write(outBytes);
} catch (Exception e) {
WMSLoggerFactory.getLogger(null).error(
"MediaCasterHTTP: " + e.toString());
}
}
public stopStream(IClient client, RequestFunction function,
AMFDataList params) {
String streamName = getParamString(params, PARAM1);
List<String> published = client.getAppInstance().getPublishStreamNames();
Iterator iter = published.iterator();
while (iter.hasNext())
{
IMediaStream publishstream = (IMediaStream )iter.next();
if (publishstream.getName().equalsIgnoreCase(streamName))
{
publishstream.getClient().setShutdownClient(true);
}
}
}
}