One way to check if an origin stream is running is to ask the origin using a Module or HTTPProvider. For example, with a module like this on the origin, a Flash RTMP client could connect to the origin and find out if the stream is live.
package test;
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;
import com.wowza.wms.stream.MediaStreamMap;
public class ModuleCheckStream extends ModuleBase {
public void isStreamLive(IClient client, RequestFunction function,
AMFDataList params) {
Boolean streamExists = false;
String streamName = getParamString(params, PARAM1);
client.getAppInstance().getPublishStreamNames().contains(streamName);
MediaStreamMap streams = client.getAppInstance().getStreams();
IMediaStream stream = streams.getStream(streamName);
if (stream != null)
streamExists = true;
sendResult(client, params, streamExists);
}
}
Or use an HTTPProvider
package test;
import java.io.*;
import java.util.List;
import java.util.Map;
import com.wowza.wms.application.IApplicationInstance;
import com.wowza.wms.http.*;
import com.wowza.wms.logging.*;
import com.wowza.wms.vhost.*;
public class HTTPOriginStreamCheck extends HTTProvider2Base {
public void onHTTPRequest(IVHost vhost, IHTTPRequest req, IHTTPResponse resp) {
if (!doHTTPAuthentication(vhost, req, resp))
return;
String retStr = "false";
String streamName = "myStream";
String app = "live";
req.parseBodyForParams(true);
Map<String, List<String>> params = req.getParameterMap();
if (params.containsKey("app"))
app = params.get("app").get(0);
if (params.containsKey("streamname"))
streamName = params.get("streamname").get(0);
IApplicationInstance appInstance = vhost.getApplication(app).getAppInstance("_definst_");
if (appInstance.getPublishStreamNames().contains(streamName))
{
retStr = "true";
}
try {
OutputStream out = resp.getOutputStream();
byte[] outBytes = retStr.getBytes();
out.write(outBytes);
} catch (Exception e) {
WMSLoggerFactory.getLogger(null).error(
"HTTPOriginStreamCheck: " + e.toString());
}
}
}
Richard