I am trying to intercept UDP packets from an RTSP encoder following this article. I am trying to implement a decryption mechanism for the RTP stream received but it looks like my code is never called.
Following the article, I have built my .jar file, confirmed it is loaded into [Wowza install dir]/lib/ and modified [Wowza install dir]/conf/live/Application.xml with the correct property. It looks like Wowza is successfully loading my package because I see a ClassNotFoundException in the logs when I misspell my entry in Application.xml and I do not see any error when I remove the misspelling.
I don’t think my code is being called for a couple reasons. I have added log statements that never appear in the Wowza logs and I have also tried to garble the stream with no success. I am not testing with an encrypted stream and I have used both RTSP encoders and a simple RTP stream from ffmpeg.
Can anyone help me get this working? I have barely found any information on intercepting packets. I’m working on Windows 10 64-bit and I’ve copied my code below. Let me know if there is anything else that would be helpful to provide.
package depacketizer;
import java.net.*;
import com.wowza.wms.application.*;
import com.wowza.wms.logging.WMSLoggerFactory;
import com.wowza.wms.rtp.depacketizer.*;
import com.wowza.wms.rtp.model.*;
public class RTPDePacketizerWrapperFilter implements IRTPDePacketizerWrapper
{
private IRTPDePacketizer rtpDePacketizer = null;
public void setDePacketizer(IRTPDePacketizer rtpDePacketizer)
{
WMSLoggerFactory.getLogger(null).info("RTPDEPACKETIZERWRAPPERFILTER setDePacketizer");
this.rtpDePacketizer = rtpDePacketizer;
}
public boolean canHandle(RTPTrack rtpTrack)
{
WMSLoggerFactory.getLogger(null).info("RTPDEPACKETIZERWRAPPERFILTER canHandle");
return rtpDePacketizer.canHandle(rtpTrack);
}
public void handleRTCPPacket(SocketAddress socketAddr, RTPTrack rtpTrack, byte[] bytes, int offset, int len)
{
WMSLoggerFactory.getLogger(null).info("RTPDEPACKETIZERWRAPPERFILTER handleRTCPPacket");
// filter here based on socketAddr
rtpDePacketizer.handleRTCPPacket(socketAddr, rtpTrack, bytes, offset, len);
}
public void handleRTPPacket(SocketAddress socketAddr, RTPTrack rtpTrack, byte[] bytes, int offset, int len)
{
WMSLoggerFactory.getLogger(null).info("RTPDEPACKETIZERWRAPPERFILTER handleRTPPacket");
for(int i = offset; i < len; i++)
{
bytes[i] = (byte) 0; // try to destroy stream
}
// process RTP packets
rtpDePacketizer.handleRTPPacket(socketAddr, rtpTrack, bytes, offset, len);
}
public void init(RTPContext rtpContext, RTPDePacketizerItem rtpDePacketizerItem)
{
WMSLoggerFactory.getLogger(null).info("RTPDEPACKETIZERWRAPPERFILTER init");
rtpDePacketizer.init(rtpContext, rtpDePacketizerItem);
}
public void setProperties(WMSProperties properties)
{
WMSLoggerFactory.getLogger(null).info("RTPDEPACKETIZERWRAPPERFILTER set properties");
rtpDePacketizer.setProperties(properties);
}
public void shutdown(RTPTrack rtpTrack)
{
WMSLoggerFactory.getLogger(null).info("RTPDEPACKETIZERWRAPPERFILTER shutdown");
rtpDePacketizer.shutdown(rtpTrack);
}
public void startup(RTPTrack rtpTrack)
{
WMSLoggerFactory.getLogger(null).info("RTPDEPACKETIZERWRAPPERFILTER startup");
rtpDePacketizer.startup(rtpTrack);
}
}