• How to intercept and block incoming UDP packets for an RTP or MPEG-TS stream

    Sample code that shows how to intercept the incoming UDP packets of an RTP or MPEG-TS stream and control which packets are passed to the depacketizer. 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>