org.red5.server.net.rtmp.codec
Class RTMPProtocolDecoder

java.lang.Object
  extended by 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
protected  Deserializer deserializer
          Deserializer
protected static Logger log
           
 
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
RTMPProtocolDecoder()
          Constructs a new RTMPProtocolDecoder.
 
Method Summary
 Object decode(ProtocolState state, IoBuffer in)
          Decodes the buffer data
 IRTMPEvent decodeAbort(IoBuffer in)
           
 Aggregate decodeAggregate(IoBuffer in)
          Decodes the aggregated data.
 AudioData decodeAudioData(IoBuffer in)
          Decodes audio data event.
 List<Object> decodeBuffer(ProtocolState state, IoBuffer buffer)
          Decode all available objects in buffer.
 BytesRead decodeBytesRead(IoBuffer in)
          Decodes BytesRead event.
 ChunkSize decodeChunkSize(IoBuffer in)
          Decodes chunk size event.
 FlexMessage decodeFlexMessage(IoBuffer in, RTMP rtmp)
          Decodes FlexMessage event.
 ISharedObjectMessage decodeFlexSharedObject(IoBuffer in, RTMP rtmp)
          Decodes shared object message event from AMF3 encoding.
 FlexStreamSend decodeFlexStreamSend(IoBuffer in)
           
 IoBuffer decodeHandshake(RTMP rtmp, IoBuffer in)
          Decodes handshake message.
 Header decodeHeader(IoBuffer in, Header lastHeader)
          Decodes packet header.
 Invoke decodeInvoke(IoBuffer in, RTMP rtmp)
          Decodes invocation event.
 IRTMPEvent decodeMessage(RTMP rtmp, Header header, IoBuffer in)
          Decodes RTMP message event.
 Notify decodeNotify(IoBuffer in, Header header, RTMP rtmp)
           
 Notify decodeNotify(IoBuffer in, RTMP rtmp)
          Decodes notification event.
protected  Notify decodeNotifyOrInvoke(Notify notify, IoBuffer in, Header header, RTMP rtmp)
          Decodes notification event.
 Packet decodePacket(RTMP rtmp, IoBuffer in)
          Decodes packet.
 Ping decodePing(IoBuffer in)
          Decodes ping event.
 ISharedObjectMessage decodeSharedObject(IoBuffer in, RTMP rtmp)
          Decodes shared object message event.
 Notify decodeStreamMetadata(IoBuffer in, RTMP rtmp)
          Decodes stream meta data, to include onMetaData, onCuePoint, and onFI.
 Unknown decodeUnknown(byte dataType, IoBuffer in)
          Decodes event of Unknown type.
 VideoData decodeVideoData(IoBuffer in)
          Decodes video data event.
protected  void doDecodeSharedObject(SharedObjectMessage so, 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 Logger log

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,
                                 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,
                     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 IoBuffer decodeHandshake(RTMP rtmp,
                                IoBuffer in)
Decodes handshake message.

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

decodePacket

public Packet decodePacket(RTMP rtmp,
                           IoBuffer in)
Decodes packet.

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

decodeHeader

public Header decodeHeader(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,
                                IoBuffer in)
Decodes RTMP message event.

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

decodeAbort

public IRTMPEvent decodeAbort(IoBuffer in)

decodeUnknown

public Unknown decodeUnknown(byte dataType,
                             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(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(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(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(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,
                                    IoBuffer in,
                                    Input input)
Perform the actual decoding of the shared object contents.

Parameters:
so -
in -
input -

decodeNotify

public Notify decodeNotify(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(IoBuffer in,
                           Header header,
                           RTMP rtmp)

decodeInvoke

public Invoke decodeInvoke(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,
                                      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(IoBuffer in)
Decodes ping event.

Specified by:
decodePing in interface IEventDecoder
Parameters:
in - IoBuffer
Returns:
Ping event

decodeBytesRead

public BytesRead decodeBytesRead(IoBuffer in)
Decodes BytesRead event.

Specified by:
decodeBytesRead in interface IEventDecoder
Parameters:
in - Byte buffer to decode
Returns:
BytesRead event

decodeAudioData

public AudioData decodeAudioData(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(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(IoBuffer in,
                                   RTMP rtmp)
Decodes stream meta data, to include onMetaData, onCuePoint, and onFI.

Parameters:
in -
rtmp -
Returns:
Notify

decodeFlexMessage

public FlexMessage decodeFlexMessage(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(IoBuffer in)


Copyright © 2006-2012 The Red5 Project