流媒体技术世界——分享技术,增值服务
采用服务端API对Http流的播放请求进行访问控制
下面的例子代码展现了如何使用服务端API对基于Http协议的流媒体播放请求进行访问控制,基于Http协议的流媒体播放技术在Wowza Stream Engine 4中包括Cupertino (iOS hls)、微软Smooth (Silverlight) 以及San Jose (Flash HTTP):

注意:在这个例子中,只要是Http协议的流媒体请求,都将统一进行访问控制。

Code:
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();
	}
}
www.ttstream.com
使用如何使用Wowza IDE开发Wowza的扩展模块编译上面的代码,将这个模块添加到/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>


在下面的代码展示了如何使用服务端API对使用Http Live Streaming协议的流媒体请求进行访问控制(通常用于iOS设备)。

Code:
package com.wowza.wms.example.module;

import com.wowza.wms.httpstreamer.cupertinostreaming.httpstreamer.*;
import com.wowza.wms.module.*;
import com.wowza.wms.application.*;

public class ModuleAccessControlCupertinoStreaming extends ModuleBase
{
	public void onHTTPCupertinoStreamingSessionCreate(HTTPStreamerSessionCupertino httpCupertinoStreamingSession)
	{
		boolean isGood = true;
		
		String ipAddressClient = httpCupertinoStreamingSession.getIpAddress();
		String ipAddressServer = httpCupertinoStreamingSession.getServerIp();
		String queryStr = httpCupertinoStreamingSession.getQueryStr();
		String referrer = httpCupertinoStreamingSession.getReferrer();
		String cookieStr = httpCupertinoStreamingSession.getCookieStr();
		String userAgent = httpCupertinoStreamingSession.getUserAgent();
		
		IApplicationInstance appInstance = httpCupertinoStreamingSession.getAppInstance();
		String streamName = httpCupertinoStreamingSession.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("ModuleAccessControlCupertinoStreaming.onHTTPCupertinoStreamingSessionCreate["+appInstance.getContextStr()+":"+streamName+"]: accept:"+isGood);
		
		if (!isGood)
			httpCupertinoStreamingSession.rejectSession();
	}
}
Code:
<Module>
	<Name>ModuleAccessControlCupertinoStreaming</Name>
	<Description>ModuleAccessControlCupertinoStreaming</Description>
	<Class>com.wowza.wms.example.module.ModuleAccessControlCupertinoStreaming</Class>
</Module>


下面的代码例子展示了如何使用服务端API对使用微软Smooth Streaming协议的流媒体播放请求进行访问控制。

package com.wowza.wms.example.module;

import com.wowza.wms.application.IApplicationInstance;
import com.wowza.wms.httpstreamer.smoothstreaming.httpstreamer.*;
import com.wowza.wms.module.*;

public class ModuleAccessControlSmoothStreaming extends ModuleBase
{
	public void onHTTPSmoothStreamingSessionCreate(HTTPStreamerSessionSmoothStreamer httpSmoothStreamingSession)
	{
		boolean isGood = true;
		
		String ipAddressClient = httpCupertinoStreamingSession.getIpAddress();
		String ipAddressServer = httpCupertinoStreamingSession.getServerIp();
		String queryStr = httpSmoothStreamingSession.getQueryStr();
		String referrer = httpSmoothStreamingSession.getReferrer();
		String cookieStr = httpSmoothStreamingSession.getCookieStr();
		String userAgent = httpSmoothStreamingSession.getUserAgent();
		
		IApplicationInstance appInstance = httpSmoothStreamingSession.getAppInstance();
		String streamName = httpSmoothStreamingSession.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("ModuleAccessControlSmoothStreaming.onHTTPSmoothStreamingSessionCreate["+appInstance.getContextStr()+":"+streamName+"]: accept:"+isGood);
		
		if (!isGood)
			httpSmoothStreamingSession.rejectSession();
	}

}
Code:
<Module>
	<Name>ModuleAccessControlSmoothStreaming</Name>
	<Description>ModuleAccessControlSmoothStreaming</Description>
	<Class>com.wowza.wms.example.module.ModuleAccessControlSmoothStreaming</Class>
</Module>


下面的代码例子展示了如何使用服务端API对使用Adobe HTTP Dynamic Streaming(sanjosestreaming)协议的流媒体播放请求进行访问控制。

package com.wowza.wms.example.module;

import com.wowza.wms.httpstreamer.sanjosestreaming.httpstreamer.HTTPStreamerSessionSanJose;
import com.wowza.wms.module.*;
import com.wowza.wms.application.*;

public class ModuleAccessControlSanJoseStreaming extends ModuleBase
{	
public void onHTTPSanJoseStreamingSessionCreate(HTTPStreamerSessionSanJose httpSanJoseStreamingSession)
{
boolean isGood = true;
		
	String ipAddressClient = httpSanJoseStreamingSession.getIpAddress();
	String ipAddressServer = httpSanJoseStreamingSession.getServerIp();
	String queryStr = httpSanJoseStreamingSession.getQueryStr();
	String referrer = httpSanJoseStreamingSession.getReferrer();
	String cookieStr = httpSanJoseStreamingSession.getCookieStr();
	String userAgent = httpSanJoseStreamingSession.getUserAgent();
		
	IApplicationInstance appInstance = httpSanJoseStreamingSession.getAppInstance();
	String streamName = httpSanJoseStreamingSession.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("ModuleAccessControlCupertinoStreaming.onHTTPCupertinoStreamingSessionCreate["+appInstance.getContextStr()+":"+streamName+"]: accept:"+isGood);
		
	if (!isGood)
		httpSanJoseStreamingSession.rejectSession();
	}
}
<Module>
	<Name>ModuleAccessControlSanJoseStreaming</Name>
	<Description>ModuleAccessControlSanJoseStreaming</Description>
	<Class>com.wowza.wms.example.module.ModuleAccessControlSanJoseStreaming</Class>
</Module>
匿名用户
评论

我们的地址


北京市朝阳区管庄西里建基商务楼423室


邮编:100024

关于我们


北京联方信科信息技术有限责任公司


官网:www.ttstream.com

联系我们


王经理:phone


柳经理:phone

京ICP备14033868号-2