TOPIC EDITED:
Hello this is my first post, and my first module.
included banned ips, limit viewers channel and server, auto play on slot free, channels vips
sorry for my bad english
[PHP]
package capos;
import com.wowza.wms.client.*;
import com.wowza.wms.request.*;
import java.util.*;
import com.wowza.wms.application.*;
import com.wowza.wms.amf.*;
import com.wowza.wms.module.*;
import com.wowza.wms.stream.*;
public class Capos extends ModuleBase
{
private int MaxViewersPerChannel = 200;
private int MaxViewersTotal = 2000;
String vips[] = {“live1”,“live2”};
String ipsbanned[] = {“127.0.0.1”,“ipbaned2”,“etc…”};
public void play(IClient client, RequestFunction function, AMFDataList params)
{
IMediaStream stream = getStream(client, function);
if (stream == null)
{
sendStreamOnStatusError(stream, “NetStream.Play.Failed”, “Null stream”);
return;
}
for (int i=0;i<ipsbanned.length; i++)
{
if (client.getIp().equals(ipsbanned*))*
{
sendStreamOnStatusError(stream, “NetStream.Play.Failed”, “IP banned”);
return;
}
}
if(getParamType(params, PARAM1) == AMFData.DATA_TYPE_STRING)
{
String streamName = getParamString(params, PARAM1);
if(isvip(streamName))
{
this.invokePrevious(client, function, params);
return;
}
IApplicationInstance appInstance = client.getAppInstance();
List streamList = appInstance.getPlayStreamsByName(streamName);
boolean waiting = false;
int viewers= 0;
if(streamList!=null)
{
viewers = streamList.size();
if (viewers > MaxViewersPerChannel)
{
sendResult(client, params, “Max Channel viewers, waiting for slot…”);
waiting = true;
}
}
viewers = 0;
if(waiting)
{
while(true)
{
try {
Thread.sleep(5000);
} catch (InterruptedException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
streamList = appInstance.getPlayStreamsByName(streamName);
if (streamList != null)
{
viewers = streamList.size();
if (viewers > MaxViewersPerChannel)
{
sendResult(client, params, “Max Channel viewers, waiting for slot…”);
}
else
{
waiting = false;
break;
}
}
}
}
MediaStreamMap streams = appInstance.getStreams();
List streamNames = streams.getPublishStreamNames();
Iterator iter = streamNames.iterator();
viewers = 0;
while(iter.hasNext())
{
String Name = iter.next();
streamList = appInstance.getPlayStreamsByName(Name);
if (streamList == null)
continue;
viewers += streamList.size();
if(viewers > MaxViewersTotal)
{
sendResult(client, params, “Max Total viewers, waiting for slot…”);
waiting = true;
break;
}
}
if(waiting)
{
while(true)
{
try {
Thread.sleep(5000);
} catch (InterruptedException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
viewers = 0;
waiting = false;
streams = appInstance.getStreams();
streamNames = streams.getPublishStreamNames();
iter = streamNames.iterator();
while(iter.hasNext())
{
String Name = iter.next();
streamList = appInstance.getPlayStreamsByName(Name);
if (streamList == null)
continue;
viewers += streamList.size();
if(viewers > MaxViewersTotal)
{
break;
}
}
if(viewers > MaxViewersTotal)
{
sendResult(client, params, “Max Total viewers, waiting for slot…”);
}
else
{
break;
}
}
}
this.invokePrevious(client, function, params);
}
}
public boolean isvip(String Name)
{
for (int i=0;i<vips.length; i++)
{
if (Name.equals(vips*))*
{
return true;
}
}
return false;
}
}
[/PHP]