You can always create your own API and build the mechanism for webhooks
Hi @Daniel_Taylor, following up on @Connessione’s message, if you want to create a custom Wowza module (plug-in) that can call your own webhooks on certain events then here’s some code that we wrote a while ago.
public class ModulePublishWebhook extends ModuleBase {
private IMediaStreamActionNotify2 actionNotify;
private IApplicationInstance appInstance;
private String baseURL;
private String publishPath;
private String unPublishPath;
class StreamListener implements IMediaStreamActionNotify2 {
@Override
public void onPublish(IMediaStream stream, String streamName, boolean isRecord, boolean isAppend) {
doCall(publishPath, streamName);
}
@Override
public void onUnPublish(IMediaStream stream, String streamName, boolean isRecord, boolean isAppend) {
doCall(unPublishPath, streamName);
}
public void doCall(String path, String streamName) {
try {
HttpPost post = new HttpPost(baseURL + "/" + path);
List<NameValuePair> params = new ArrayList<NameValuePair>(2);
params.add(new BasicNameValuePair("application", appInstance.getApplication().getName() ));
params.add(new BasicNameValuePair("stream", streamName));
post.setEntity(new UrlEncodedFormEntity(params, "UTF-8"));
CloseableHttpClient client = HttpClients.createDefault();
client.execute(post);
} catch (Exception e) {
getLogger().error("An error occurred while calling the webhook", e);
}
}
}
public void onAppStart(IApplicationInstance appInstance) {
this.actionNotify = new StreamListener();
this.appInstance = appInstance;
this.baseURL = appInstance.getProperties().getPropertyStr("webhook.baseurl", "");
this.publishPath = appInstance.getProperties().getPropertyStr("webhook.publish", "");
this.unPublishPath = appInstance.getProperties().getPropertyStr("webhook.unpublish", "");
}
public void onStreamCreate(IMediaStream stream) {
stream.addClientListener(this.actionNotify);
}
public void onStreamDestroy(IMediaStream stream) {
if (this.actionNotify != null) {
stream.removeClientListener(this.actionNotify);
}
}
}