Class RTMPProtocolDecoder

java.lang.Object
org.red5.server.net.rtmp.codec.RTMPProtocolDecoder
All Implemented Interfaces:
IEventDecoder, Constants

public class RTMPProtocolDecoder extends Object implements Constants, IEventDecoder
RTMP protocol decoder.
  • Field Details

    • log

      protected static final org.slf4j.Logger log
    • closeOnHeaderError

      protected boolean closeOnHeaderError
    • MAX_PACKET_SIZE

      protected static int MAX_PACKET_SIZE
  • Constructor Details

    • RTMPProtocolDecoder

      public RTMPProtocolDecoder()
      Constructs a new RTMPProtocolDecoder.
  • Method Details

    • decodeBuffer

      public List<Object> decodeBuffer(RTMPConnection conn, org.apache.mina.core.buffer.IoBuffer buffer)
      Decode all available objects in buffer.
      Parameters:
      conn - RTMP connection
      buffer - IoBuffer of data to be decoded
      Returns:
      a list of decoded objects, may be empty if nothing could be decoded
    • decode

      public Object decode(RTMPConnection conn, RTMPDecodeState state, org.apache.mina.core.buffer.IoBuffer in) throws ProtocolException
      Decodes the buffer data.
      Parameters:
      conn - RTMP connection
      state - Stores state for the protocol, ProtocolState is just a marker interface
      in - IoBuffer of data to be decoded
      Returns:
      one of three possible values:
       1. null : the object could not be decoded, or some data was skipped, just continue 
       2. ProtocolState : the decoder was unable to decode the whole object, refer to the protocol state 
       3. Object : something was decoded, continue
       
      Throws:
      ProtocolException - on error
    • decodePacket

      public Packet decodePacket(RTMPConnection conn, RTMPDecodeState state, org.apache.mina.core.buffer.IoBuffer in)
      Decodes an IoBuffer into a Packet.
      Parameters:
      conn - Connection
      state - RTMP protocol state
      in - IoBuffer
      Returns:
      Packet
    • decodeHeader

      public Header decodeHeader(ChunkHeader chh, RTMPDecodeState state, org.apache.mina.core.buffer.IoBuffer in, RTMP rtmp)
      Decodes packet header.
      Parameters:
      chh - chunk header
      state - RTMP decode state
      in - Input IoBuffer
      rtmp - RTMP object to get last header
      Returns:
      Decoded header
    • decodeMessage

      public IRTMPEvent decodeMessage(RTMPConnection conn, Header header, org.apache.mina.core.buffer.IoBuffer in)
      Decodes RTMP message event.
      Parameters:
      conn - RTMP connection
      header - RTMP header
      in - Input IoBuffer
      Returns:
      RTMP event
    • decodeAbort

      public IRTMPEvent decodeAbort(org.apache.mina.core.buffer.IoBuffer in)
    • decodeServerBW

      private IRTMPEvent decodeServerBW(org.apache.mina.core.buffer.IoBuffer in)
      Decodes server bandwidth.
      Parameters:
      in - IoBuffer
      Returns:
      RTMP event
    • decodeClientBW

      private IRTMPEvent decodeClientBW(org.apache.mina.core.buffer.IoBuffer in)
      Decodes client bandwidth.
      Parameters:
      in - Byte buffer
      Returns:
      RTMP event
    • decodeUnknown

      public Unknown decodeUnknown(byte dataType, org.apache.mina.core.buffer.IoBuffer in)
      Decodes event of Unknown type.
      Specified by:
      decodeUnknown in interface IEventDecoder
      Parameters:
      dataType - Data type
      in - Byte buffer to decode
      Returns:
      Unknown event
    • decodeAggregate

      public Aggregate decodeAggregate(org.apache.mina.core.buffer.IoBuffer in)
      Decodes the aggregated data.
      Specified by:
      decodeAggregate in interface IEventDecoder
      Parameters:
      in - Byte buffer to decode
      Returns:
      Aggregate event
    • decodeChunkSize

      public ChunkSize decodeChunkSize(org.apache.mina.core.buffer.IoBuffer in)
      Decodes chunk size event.
      Specified by:
      decodeChunkSize in interface IEventDecoder
      Parameters:
      in - Byte buffer to decode
      Returns:
      ChunkSize event
    • decodeAction

      private Invoke decodeAction(IConnection.Encoding encoding, org.apache.mina.core.buffer.IoBuffer in, Header header)
      Decode the 'action' for a supplied an Invoke.
      Parameters:
      encoding - AMF encoding
      in - buffer
      header - data header
      Returns:
      notify
    • decodePing

      public Ping decodePing(org.apache.mina.core.buffer.IoBuffer in)
      Decodes ping event.
      Specified by:
      decodePing in interface IEventDecoder
      Parameters:
      in - IoBuffer
      Returns:
      Ping event
    • decodeBytesRead

      public BytesRead decodeBytesRead(org.apache.mina.core.buffer.IoBuffer in)
      Decodes BytesRead event.
      Specified by:
      decodeBytesRead in interface IEventDecoder
      Parameters:
      in - Byte buffer to decode
      Returns:
      BytesRead event
    • decodeAudioData

      public AudioData decodeAudioData(org.apache.mina.core.buffer.IoBuffer in)
      Decodes audio data event.
      Specified by:
      decodeAudioData in interface IEventDecoder
      Parameters:
      in - Byte buffer to decode
      Returns:
      AudioData event
    • decodeVideoData

      public VideoData decodeVideoData(org.apache.mina.core.buffer.IoBuffer in)
      Decodes video data event.
      Specified by:
      decodeVideoData in interface IEventDecoder
      Parameters:
      in - Byte buffer to decode
      Returns:
      VideoData event
    • decodeStreamData

      public Notify decodeStreamData(org.apache.mina.core.buffer.IoBuffer in)
      Decodes stream data, to include onMetaData, onCuePoint, and onFI.
      Parameters:
      in - input buffer
      Returns:
      Notify
    • decodeFlexMessage

      public FlexMessage decodeFlexMessage(org.apache.mina.core.buffer.IoBuffer in)
      Decodes FlexMessage event.
      Specified by:
      decodeFlexMessage in interface IEventDecoder
      Parameters:
      in - IoBuffer
      Returns:
      FlexMessage event
    • setCloseOnHeaderError

      public void setCloseOnHeaderError(boolean closeOnHeaderError)
      Sets whether or not a header error on any channel should result in a closed connection.
      Parameters:
      closeOnHeaderError - true to close on header decode errors
    • isStreamCommand

      private boolean isStreamCommand(String action)
      Checks if the passed action is a reserved stream method.
      Parameters:
      action - Action to check
      Returns:
      true if passed action is a reserved stream method, false otherwise
    • handleParameters

      private Object[] handleParameters(org.apache.mina.core.buffer.IoBuffer in, Notify notify, Input input)
      Sets incoming connection parameters and / or returns encoded parameters for use in a call.
      Parameters:
      in -
      notify -
      input -
      Returns:
      parameters array
    • setMaxPacketSize

      public static void setMaxPacketSize(int maxPacketSize)
      Set the maximum allowed packet size. Default is 3 Mb.
      Parameters:
      maxPacketSize -