org.red5.server.net.rtmp.codec

## Class RTMPProtocolDecoder

- java.lang.Object
- - org.red5.server.net.rtmp.codec.RTMPProtocolDecoder

All Implemented Interfaces:
  IEventDecoder, Constants

Direct Known Subclasses:
  RTMPTProtocolDecoder

    public class RTMPProtocolDecoder
    extends Object
    implements Constants, IEventDecoder

RTMP protocol decoder.

### Field Summary

Fields
`protected Deserializer` `deserializer` Deserializer
`protected static org.slf4j.Logger` `log` Logger

### Fields inherited from interface org.red5.server.net.rtmp.message.Constants

`HANDSHAKE_SIZE, HEADER_CONTINUE, HEADER_NEW, HEADER_SAME_SOURCE, HEADER_TIMER_CHANGE, MEDIUM_INT_MAX, SO_CLIENT_CLEAR_DATA, SO_CLIENT_DELETE_DATA, SO_CLIENT_INITIAL_DATA, SO_CLIENT_SEND_MESSAGE, SO_CLIENT_STATUS, SO_CLIENT_UPDATE_ATTRIBUTE, SO_CLIENT_UPDATE_DATA, SO_CONNECT, SO_DELETE_ATTRIBUTE, SO_DISCONNECT, SO_SEND_MESSAGE, SO_SET_ATTRIBUTE, SOURCE_TYPE_LIVE, SOURCE_TYPE_VOD, TYPE_ABORT, TYPE_AGGREGATE, TYPE_AUDIO_DATA, TYPE_BYTES_READ, TYPE_CHUNK_SIZE, TYPE_CLIENT_BANDWIDTH, TYPE_EDGE_ORIGIN, TYPE_FLEX_MESSAGE, TYPE_FLEX_SHARED_OBJECT, TYPE_FLEX_STREAM_SEND, TYPE_INVOKE, TYPE_NOTIFY, TYPE_PING, TYPE_SERVER_BANDWIDTH, TYPE_SHARED_OBJECT, TYPE_STREAM_METADATA, TYPE_VIDEO_DATA`

### Constructor Summary

Constructors
Constructor and Description
`RTMPProtocolDecoder()` Constructs a new RTMPProtocolDecoder.

### Method Summary

Methods
`Object` `decode(ProtocolState state, org.apache.mina.core.buffer.IoBuffer in)` Decodes the buffer data
`IRTMPEvent` `decodeAbort(org.apache.mina.core.buffer.IoBuffer in)`
`Aggregate` `decodeAggregate(org.apache.mina.core.buffer.IoBuffer in)` Decodes the aggregated data.
`AudioData` `decodeAudioData(org.apache.mina.core.buffer.IoBuffer in)` Decodes audio data event.
`List<Object>` `decodeBuffer(ProtocolState state, org.apache.mina.core.buffer.IoBuffer buffer)` Decode all available objects in buffer.
`BytesRead` `decodeBytesRead(org.apache.mina.core.buffer.IoBuffer in)` Decodes BytesRead event.
`ChunkSize` `decodeChunkSize(org.apache.mina.core.buffer.IoBuffer in)` Decodes chunk size event.
`FlexMessage` `decodeFlexMessage(org.apache.mina.core.buffer.IoBuffer in, RTMP rtmp)` Decodes FlexMessage event.
`ISharedObjectMessage` `decodeFlexSharedObject(org.apache.mina.core.buffer.IoBuffer in, RTMP rtmp)` Decodes shared object message event from AMF3 encoding.
`FlexStreamSend` `decodeFlexStreamSend(org.apache.mina.core.buffer.IoBuffer in)`
`org.apache.mina.core.buffer.IoBuffer` `decodeHandshake(RTMP rtmp, org.apache.mina.core.buffer.IoBuffer in)` Decodes handshake message.
`Header` `decodeHeader(org.apache.mina.core.buffer.IoBuffer in, Header lastHeader)` Decodes packet header.
`Invoke` `decodeInvoke(org.apache.mina.core.buffer.IoBuffer in, RTMP rtmp)` Decodes invocation event.
`IRTMPEvent` `decodeMessage(RTMP rtmp, Header header, org.apache.mina.core.buffer.IoBuffer in)` Decodes RTMP message event.
`Notify` `decodeNotify(org.apache.mina.core.buffer.IoBuffer in, Header header, RTMP rtmp)`
`Notify` `decodeNotify(org.apache.mina.core.buffer.IoBuffer in, RTMP rtmp)` Decodes notification event.
`protected Notify` `decodeNotifyOrInvoke(Notify notify, org.apache.mina.core.buffer.IoBuffer in, Header header, RTMP rtmp)` Decodes notification event.
`Packet` `decodePacket(RTMP rtmp, org.apache.mina.core.buffer.IoBuffer in)` Decodes packet.
`Ping` `decodePing(org.apache.mina.core.buffer.IoBuffer in)` Decodes ping event.
`ISharedObjectMessage` `decodeSharedObject(org.apache.mina.core.buffer.IoBuffer in, RTMP rtmp)` Decodes shared object message event.
`Notify` `decodeStreamMetadata(org.apache.mina.core.buffer.IoBuffer in, RTMP rtmp)` Decodes stream meta data, to include onMetaData, onCuePoint, and onFI.
`Unknown` `decodeUnknown(byte dataType, org.apache.mina.core.buffer.IoBuffer in)` Decodes event of Unknown type.
`VideoData` `decodeVideoData(org.apache.mina.core.buffer.IoBuffer in)` Decodes video data event.
`protected void` `doDecodeSharedObject(SharedObjectMessage so, org.apache.mina.core.buffer.IoBuffer in, Input input)` Perform the actual decoding of the shared object contents.
`void` `setDeserializer(Deserializer deserializer)` Setter for deserializer.

### Methods inherited from class java.lang.Object

`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

### Field Detail

#### log

    protected static org.slf4j.Logger log

Logger

#### deserializer

    protected Deserializer deserializer

Deserializer

### Constructor Detail

#### RTMPProtocolDecoder

    public RTMPProtocolDecoder()

Constructs a new RTMPProtocolDecoder.

### Method Detail

#### setDeserializer

    public void setDeserializer(Deserializer deserializer)

Setter for deserializer.

Parameters:
  `deserializer` - Deserializer

#### decodeBuffer

    public List<Object> decodeBuffer(ProtocolState state,
                            org.apache.mina.core.buffer.IoBuffer buffer)

Decode all available objects in buffer.

Parameters:
  `state` - Stores state for the protocol
  `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(ProtocolState state,
                org.apache.mina.core.buffer.IoBuffer in)
                  throws ProtocolException

Decodes the buffer data

Parameters:
  `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. null : the object could not be decoded, or some data was skipped, just continue. ProtocolState : the decoder was unable to decode the whole object, refer to the protocol state Object : something was decoded, continue
Throws:
  `Exception` - on error
  `ProtocolException`

#### decodeHandshake

    public org.apache.mina.core.buffer.IoBuffer decodeHandshake(RTMP rtmp,
                                                       org.apache.mina.core.buffer.IoBuffer in)

Decodes handshake message.

Parameters:
  `rtmp` - RTMP protocol state
  `in` - IoBuffer
Returns:
  IoBuffer

#### decodePacket

    public Packet decodePacket(RTMP rtmp,
                      org.apache.mina.core.buffer.IoBuffer in)

Decodes packet.

Parameters:
  `rtmp` - RTMP protocol state
  `in` - IoBuffer
Returns:
  IoBuffer

#### decodeHeader

    public Header decodeHeader(org.apache.mina.core.buffer.IoBuffer in,
                      Header lastHeader)

Decodes packet header.

Parameters:
  `in` - Input IoBuffer
  `lastHeader` - Previous header
Returns:
  Decoded header

#### decodeMessage

    public IRTMPEvent decodeMessage(RTMP rtmp,
                           Header header,
                           org.apache.mina.core.buffer.IoBuffer in)

Decodes RTMP message event.

Parameters:
  `rtmp` - RTMP protocol state
  `header` - RTMP header
  `in` - Input IoBuffer
Returns:
  RTMP event

#### decodeAbort

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

#### 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

#### decodeFlexSharedObject

    public ISharedObjectMessage decodeFlexSharedObject(org.apache.mina.core.buffer.IoBuffer in,
                                              RTMP rtmp)

Decodes shared object message event from AMF3 encoding.

Specified by:
  `decodeFlexSharedObject` in interface `IEventDecoder`
Parameters:
  `in` - Byte buffer to decode
  `rtmp` - RTMP protocol state
Returns:
  ISharedObjectMessage event

#### decodeSharedObject

    public ISharedObjectMessage decodeSharedObject(org.apache.mina.core.buffer.IoBuffer in,
                                          RTMP rtmp)

Decodes shared object message event.

Specified by:
  `decodeSharedObject` in interface `IEventDecoder`
Parameters:
  `in` - Byte buffer to decode
  `rtmp` - RTMP protocol state
Returns:
  ISharedObjectMessage event

#### doDecodeSharedObject

    protected void doDecodeSharedObject(SharedObjectMessage so,
                            org.apache.mina.core.buffer.IoBuffer in,
                            Input input)

Perform the actual decoding of the shared object contents.

Parameters:
  `so` -
  `in` -
  `input` -

#### decodeNotify

    public Notify decodeNotify(org.apache.mina.core.buffer.IoBuffer in,
                      RTMP rtmp)

Decodes notification event.

Specified by:
  `decodeNotify` in interface `IEventDecoder`
Parameters:
  `in` - Byte buffer to decode
  `rtmp` - RTMP protocol state
Returns:
  Notify event

#### decodeNotify

    public Notify decodeNotify(org.apache.mina.core.buffer.IoBuffer in,
                      Header header,
                      RTMP rtmp)

#### decodeInvoke

    public Invoke decodeInvoke(org.apache.mina.core.buffer.IoBuffer in,
                      RTMP rtmp)

Decodes invocation event.

Specified by:
  `decodeInvoke` in interface `IEventDecoder`
Parameters:
  `in` - Byte buffer to decode
  `rtmp` - RTMP protocol state
Returns:
  Invoke event

#### decodeNotifyOrInvoke

    protected Notify decodeNotifyOrInvoke(Notify notify,
                              org.apache.mina.core.buffer.IoBuffer in,
                              Header header,
                              RTMP rtmp)

Decodes notification event.

Parameters:
  `notify` - Notify event
  `in` - Byte buffer
  `header` - Header
  `rtmp` - RTMP protocol state
Returns:
  Notification event

#### 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

#### decodeStreamMetadata

    public Notify decodeStreamMetadata(org.apache.mina.core.buffer.IoBuffer in,
                              RTMP rtmp)

Decodes stream meta data, to include onMetaData, onCuePoint, and onFI.

Parameters:
  `in` -
  `rtmp` -
Returns:
  Notify

#### decodeFlexMessage

    public FlexMessage decodeFlexMessage(org.apache.mina.core.buffer.IoBuffer in,
                                RTMP rtmp)

Decodes FlexMessage event.

Specified by:
  `decodeFlexMessage` in interface `IEventDecoder`
Parameters:
  `in` - IoBuffer
  `rtmp` - RTMP protocol state
Returns:
  FlexMessage event

#### decodeFlexStreamSend

    public FlexStreamSend decodeFlexStreamSend(org.apache.mina.core.buffer.IoBuffer in)