Package org.red5.server.net.rtmp.codec
Class RTMPProtocolDecoder
java.lang.Object
org.red5.server.net.rtmp.codec.RTMPProtocolDecoder
- All Implemented Interfaces:
IEventDecoder
,Constants
RTMP protocol decoder.
-
Field Summary
Modifier and TypeFieldDescriptionprotected boolean
protected static final org.slf4j.Logger
protected static int
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
-
Method Summary
Modifier and TypeMethodDescriptiondecode
(RTMPConnection conn, RTMPDecodeState state, org.apache.mina.core.buffer.IoBuffer in) Decodes the buffer data.decodeAbort
(org.apache.mina.core.buffer.IoBuffer in) private Invoke
decodeAction
(IConnection.Encoding encoding, org.apache.mina.core.buffer.IoBuffer in, Header header) Decode the 'action' for a supplied an Invoke.decodeAggregate
(org.apache.mina.core.buffer.IoBuffer in) Decodes the aggregated data.decodeAudioData
(org.apache.mina.core.buffer.IoBuffer in) Decodes audio data event.decodeBuffer
(RTMPConnection conn, org.apache.mina.core.buffer.IoBuffer buffer) Decode all available objects in buffer.decodeBytesRead
(org.apache.mina.core.buffer.IoBuffer in) Decodes BytesRead event.decodeChunkSize
(org.apache.mina.core.buffer.IoBuffer in) Decodes chunk size event.private IRTMPEvent
decodeClientBW
(org.apache.mina.core.buffer.IoBuffer in) Decodes client bandwidth.decodeFlexMessage
(org.apache.mina.core.buffer.IoBuffer in) Decodes FlexMessage event.decodeHeader
(ChunkHeader chh, RTMPDecodeState state, org.apache.mina.core.buffer.IoBuffer in, RTMP rtmp) Decodes packet header.decodeMessage
(RTMPConnection conn, Header header, org.apache.mina.core.buffer.IoBuffer in) Decodes RTMP message event.decodePacket
(RTMPConnection conn, RTMPDecodeState state, org.apache.mina.core.buffer.IoBuffer in) Decodes an IoBuffer into a Packet.decodePing
(org.apache.mina.core.buffer.IoBuffer in) Decodes ping event.private IRTMPEvent
decodeServerBW
(org.apache.mina.core.buffer.IoBuffer in) Decodes server bandwidth.decodeStreamData
(org.apache.mina.core.buffer.IoBuffer in) Decodes stream data, to include onMetaData, onCuePoint, and onFI.decodeUnknown
(byte dataType, org.apache.mina.core.buffer.IoBuffer in) Decodes event of Unknown type.decodeVideoData
(org.apache.mina.core.buffer.IoBuffer in) Decodes video data event.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.private boolean
isStreamCommand
(String action) Checks if the passed action is a reserved stream method.void
setCloseOnHeaderError
(boolean closeOnHeaderError) Sets whether or not a header error on any channel should result in a closed connection.static void
setMaxPacketSize
(int maxPacketSize) Set the maximum allowed packet size.
-
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
Decode all available objects in buffer.- Parameters:
conn
- RTMP connectionbuffer
- 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 connectionstate
- Stores state for the protocol, ProtocolState is just a marker interfacein
- 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
- Connectionstate
- RTMP protocol statein
- 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 headerstate
- RTMP decode statein
- Input IoBufferrtmp
- 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 connectionheader
- RTMP headerin
- Input IoBuffer- Returns:
- RTMP event
-
decodeAbort
-
decodeServerBW
Decodes server bandwidth.- Parameters:
in
- IoBuffer- Returns:
- RTMP event
-
decodeClientBW
Decodes client bandwidth.- Parameters:
in
- Byte buffer- Returns:
- RTMP event
-
decodeUnknown
Decodes event of Unknown type.- Specified by:
decodeUnknown
in interfaceIEventDecoder
- Parameters:
dataType
- Data typein
- Byte buffer to decode- Returns:
- Unknown event
-
decodeAggregate
Decodes the aggregated data.- Specified by:
decodeAggregate
in interfaceIEventDecoder
- Parameters:
in
- Byte buffer to decode- Returns:
- Aggregate event
-
decodeChunkSize
Decodes chunk size event.- Specified by:
decodeChunkSize
in interfaceIEventDecoder
- 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 encodingin
- bufferheader
- data header- Returns:
- notify
-
decodePing
Decodes ping event.- Specified by:
decodePing
in interfaceIEventDecoder
- Parameters:
in
- IoBuffer- Returns:
- Ping event
-
decodeBytesRead
Decodes BytesRead event.- Specified by:
decodeBytesRead
in interfaceIEventDecoder
- Parameters:
in
- Byte buffer to decode- Returns:
- BytesRead event
-
decodeAudioData
Decodes audio data event.- Specified by:
decodeAudioData
in interfaceIEventDecoder
- Parameters:
in
- Byte buffer to decode- Returns:
- AudioData event
-
decodeVideoData
Decodes video data event.- Specified by:
decodeVideoData
in interfaceIEventDecoder
- Parameters:
in
- Byte buffer to decode- Returns:
- VideoData event
-
decodeStreamData
Decodes stream data, to include onMetaData, onCuePoint, and onFI.- Parameters:
in
- input buffer- Returns:
- Notify
-
decodeFlexMessage
Decodes FlexMessage event.- Specified by:
decodeFlexMessage
in interfaceIEventDecoder
- 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
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
-
-