I have devices that Announce RTSP streams to Wowza “live” application.
I want to track the I/O throughput, kick the devices out when they reach it and disallow reconnection for set period of time, like 24 hours.
The issue i’m having is that I can “shutdown” the RTPSession object in my module but it does not send a TEARDOWN command to the device, hence the device just keeps streaming RTP/UDP packets to Wowza.
I see that there is a com.wowza.wms.rtsp library, but I can’t find any documentation for it, nor there is any Interfaces to it, becides the IRTSPActionNotify.
I’ve also noticed that “rtspTunnelingSessionId” in my RTPSession object is always NULL. So how can I access the stream related RTSP Session?
In the future I also want to send SET_PARAMETERS RTSP messages.
Any info would be greatly appreciated.
Here is my module so far:
package com.my.wms.testing;
import java.util.*;
import com.wowza.wms.module.*;
import com.wowza.wms.stream.*;
import com.wowza.wms.util.*;
import com.wowza.util.*;
import com.wowza.wms.application.*;
import com.wowza.wms.rtp.*;
import com.wowza.wms.rtp.model.*;
import com.wowza.wms.authentication.*;
import com.wowza.wms.*;
import com.wowza.wms.rtsp.*;
public class MyTesting extends ModuleBase implements IModuleOnApp, IModuleOnStream, IModuleOnRTPSession
{
List<IMediaStream> hwstreams = new ArrayList<IMediaStream>(0);
IApplicationInstance appInstance = null;
class MyActionListener implements IMediaStreamActionNotify {
void addStream(IMediaStream stream) {
hwstreams.add(stream);
}
void removeStream(IMediaStream stream) {
hwstreams.remove(stream);
}
public void onPause(IMediaStream stream, boolean isPause, double location) {}
public void onPlay(IMediaStream stream, String streamName, double playStart, double playLen, int playReset) {}
public void onPublish(IMediaStream stream, String streamName, boolean isRecord, boolean isAppend) {
addStream(stream);
}
public void onSeek(IMediaStream stream, double location) {}
public void onStop(IMediaStream stream) {}
public void onUnPublish(IMediaStream stream, String streamName, boolean isRecord, boolean isAppend) {
removeStream(stream);
}
}
MyActionListener eal = new MyActionListener();
class MyWorker extends Thread {
public void run() {
try {
while( true ) {
sleep(3000);
getLogger().info("My MyWorker - checking active streams");
List<IMediaStream> hwstreamsClone = new ArrayList<IMediaStream>(hwstreams);
Iterator<IMediaStream> i = hwstreamsClone.iterator();
while(i.hasNext()) {
IMediaStream stream = i.next();
RTPStream eStream = stream.getRTPStream();
getLogger().info(" "+stream+" "+stream.getName());
getLogger().info(" In/Out Bytes: "+p.getMessagesInBytes()+" "+p.getMessagesOutBytes());
if( p.getMessagesInBytes() > 0.5*1024*1024 ) {
bannedStreams.add(new BannedStream(stream.getName(), System.currentTimeMillis()+60*60*1000));
eStream.shutdown(null);
getLogger().info("My MyWorker - RTPStream shutdown ");
}
}
}
} catch (Exception e) {e.printStackTrace();}
}
}
MyWorker worker = new MyWorker();
public void onAppStart(IApplicationInstance appInstance)
{
getLogger().info("My onAppStart");
this.appInstance = appInstance;
worker.start();
}
public void onAppStop(IApplicationInstance appInstance) {
getLogger().info("My onAppStop");
worker.interrupt();
}
public void onStreamCreate(IMediaStream stream)
{
getLogger().info("My IMediaStream onStreamCreate");
stream.addClientListener(eal);
}
}