Wowza Streaming Engine 4.9.4 is available! Go to the Downloads page to download. See the 4.9.4 Release Notes.

Control access to HTTP streams with the Wowza Streaming Engine Java API

The following example shows how to use the Wowza Streamign Engine™ Java API for controlling access to HLS (cupertinostreaming) and MPEG-DASH (mpegdashstreaming) streams in one module.

package com.wowza.wms.example.module;

import com.wowza.wms.httpstreamer.model.IHTTPStreamerSession;
import com.wowza.wms.module.*;
import com.wowza.wms.application.*;

public class ModuleAccessControlHTTPStreaming extends ModuleBase
{
	public void onHTTPSessionCreate(IHTTPStreamerSession httpSession)
	{
		boolean isGood = true;

		String ipAddressClient = httpSession.getIpAddress();
		String ipAddressServer = httpSession.getServerIp();
		String queryStr = httpSession.getQueryStr();
		String referrer = httpSession.getReferrer();
		String cookieStr = httpSession.getCookieStr();
		String userAgent = httpSession.getUserAgent();

		IApplicationInstance appInstance = httpSession.getAppInstance();
		String streamName = httpSession.getStreamName();

		// Here you can use the request and session information above to determine 
		// if you want to reject the connection
		// isGood = true/false;

		getLogger().info("ModuleAccessControlHTTPStreaming.onHTTPSessionCreate["+appInstance.getContextStr()+":"+streamName+"]: accept:"+isGood);

		if (!isGood)
			httpSession.rejectSession();
	}
}

Build this module using the Wowza IDE and add it last in the <Modules> section in /conf/[app-name]/Application.xml:

<Module>
	<Name>ModuleAccessControlHTTPStreaming</Name>
	<Description>Access control for HTTP streams</Description>
	<Class>com.wowza.wms.example.module.ModuleAccessControlHTTPStreaming</Class>
</Module>