Use the Wowza Streaming Engine™ Java API to intercept the UDP packets in incoming RTP or MPEG-TS streams and control which packets are passed to the depacketizer. This enables you to block stray UDP packets coming from a port sniffer or other sources, pull out specific data (such as a custom track, application track, or MPEG-TS PID) from the stream, monitor the incoming UDP stream for health, and more.
To intercept UDP packets in an incoming RTP or MPEG-TS stream, create a class that implements the IRTPDePacketizerWrapper interface. This enables decryption, filtering, or re-ordering of the individual UDP packets before they're processed by Wowza Streaming Engine:
package com.wowza.wms.plugin.test.depacketizer; import java.net.*; import com.wowza.wms.application.*; 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) { this.rtpDePacketizer = rtpDePacketizer; } public boolean canHandle(RTPTrack rtpTrack) { return rtpDePacketizer.canHandle(rtpTrack); } public void handleRTCPPacket(SocketAddress socketAddr, RTPTrack rtpTrack, byte[] bytes, int offset, int len) { // 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) { // process RTP packets rtpDePacketizer.handleRTPPacket(socketAddr, rtpTrack, bytes, offset, len); } public void init(RTPContext rtpContext, RTPDePacketizerItem rtpDePacketizerItem) { rtpDePacketizer.init(rtpContext, rtpDePacketizerItem); } public void setProperties(WMSProperties properties) { rtpDePacketizer.setProperties(properties); } public void shutdown(RTPTrack rtpTrack) { rtpDePacketizer.shutdown(rtpTrack); } public void startup(RTPTrack rtpTrack) { rtpDePacketizer.startup(rtpTrack); } }
To add the above wrapper to your Application.xml file, add the following property to the <RTP>/Properties container:
<Property> <Name>rtpDePacketizerWrapper</Name> <Value>com.wowza.wms.plugin.test.depacketizer.RTPDePacketizerWrapperFilter</Value> </Property>