Overview | Package | Class | Use | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## org.red5.server.net.rtmp.codec
Class RTMPProtocolEncoder

    java.lang.Object
      org.red5.server.net.rtmp.codec.RTMPProtocolEncoder

All Implemented Interfaces:
  IEventEncoder, Constants

Direct Known Subclasses:
  RTMPTProtocolEncoder

    public class RTMPProtocolEncoder

extends Object
implements Constants, IEventEncoder

RTMP protocol encoder encodes RTMP messages and packets to byte buffers.

Field Summary
`protected static 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_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
`RTMPProtocolEncoder()`

Method Summary
`void` | `doEncodeSharedObject(ISharedObjectMessage so, RTMP rtmp, IoBuffer out)` Perform the actual encoding of the shared object contents.
`protected boolean` | `dropMessage(RTMP rtmp, int channelId, IRTMPEvent message)` Determine if this message should be dropped for lateness.
`IoBuffer` | `encode(ProtocolState state, Object message)` Encodes object with given protocol state to byte buffer
`IoBuffer` | `encodeAudioData(AudioData audioData)` Encodes AudioData event to byte buffer.
`IoBuffer` | `encodeBytesRead(BytesRead bytesRead)` Encodes BytesRead event to byte buffer.
`IoBuffer` | `encodeChunkSize(ChunkSize chunkSize)` Encodes ChunkSize event to byte buffer.
`IoBuffer` | `encodeFlexMessage(FlexMessage msg, RTMP rtmp)` Encodes Flex message event.
`IoBuffer` | `encodeFlexSharedObject(ISharedObjectMessage so, RTMP rtmp)` Encodes SharedObjectMessage event to byte buffer using AMF3 encoding.
`IoBuffer` | `encodeFlexStreamSend(FlexStreamSend msg)`
`IoBuffer` | `encodeHeader(RTMP rtmp, Header header, Header lastHeader)` Encode RTMP header.
`void` | `encodeHeader(RTMP rtmp, Header header, Header lastHeader, IoBuffer buf)` Encode RTMP header into given IoBuffer.
`IoBuffer` | `encodeInvoke(Invoke invoke, RTMP rtmp)` Encodes Invoke event to byte buffer.
`IoBuffer` | `encodeMessage(RTMP rtmp, Header header, IRTMPEvent message)` Encode message.
`IoBuffer` | `encodeNotify(Notify notify, RTMP rtmp)` Encodes Notify event to byte buffer.
`protected void` | `encodeNotifyOrInvoke(IoBuffer out, Notify invoke, RTMP rtmp)` Encode notification event and fill given byte buffer.
`protected IoBuffer` | `encodeNotifyOrInvoke(Notify invoke, RTMP rtmp)` Encode notification event.
`IoBuffer` | `encodePacket(RTMP rtmp, Packet packet)` Encode packet.
`IoBuffer` | `encodePing(Ping ping)` Encodes Ping event to byte buffer.
`IoBuffer` | `encodeSharedObject(ISharedObjectMessage so, RTMP rtmp)` Encodes SharedObjectMessage event to byte buffer.
`IoBuffer` | `encodeStreamMetadata(Notify metaData)`
`IoBuffer` | `encodeUnknown(Unknown unknown)` Encodes Unknown event to byte buffer.
`IoBuffer` | `encodeVideoData(VideoData videoData)` Encodes VideoData event to byte buffer.
`protected StatusObject` | `generateErrorResult(String code, Throwable error)` Generate error object to return for given exception.
`long` | `getBaseTolerance()`
`void` | `setBaseTolerance(long baseTolerance)`
`void` | `setDropLiveFuture(boolean dropLiveFuture)` Setter for dropLiveFuture
`void` | `setSerializer(Serializer serializer)` Setter for serializer.

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

  Logger.

Constructor Detail

### RTMPProtocolEncoder

    public RTMPProtocolEncoder()

Method Detail

### encode

    public IoBuffer encode(ProtocolState state,
                           Object message)
                    throws Exception

  Encodes object with given protocol state to byte buffer

  Parameters:
    `state` - Protocol state
    `message` - Object to encode
  Returns:
    IoBuffer with encoded data
  Throws:
    `Exception` - Any decoding exception

### encodePacket

    public IoBuffer encodePacket(RTMP rtmp,
                                 Packet packet)

  Encode packet.

  Parameters:
    `rtmp` - RTMP protocol state
    `packet` - RTMP packet
  Returns:
    Encoded data

### dropMessage

    protected boolean dropMessage(RTMP rtmp,
                                  int channelId,
                                  IRTMPEvent message)

  Determine if this message should be dropped for lateness. Live publish data does not come through this section, only outgoing data does. - determine latency between server and client using ping - ping timestamp is unsigned int (4 bytes) and is set from value on sender 1st drop disposable frames - lowest mark 2nd drop interframes - middle 3rd drop key frames - high mark

  Parameters:
    `rtmp` - the protocol state
    `channelId` - the channel ID
    `message` - the message
  Returns:
    true to drop; false to send

### encodeHeader

    public IoBuffer encodeHeader(RTMP rtmp,
                                 Header header,
                                 Header lastHeader)

  Encode RTMP header.

  Parameters:
    `rtmp` - The protocol state
    `header` - RTMP message header
    `lastHeader` - Previous header
  Returns:
    Encoded header data

### encodeHeader

    public void encodeHeader(RTMP rtmp,
                             Header header,
                             Header lastHeader,
                             IoBuffer buf)

  Encode RTMP header into given IoBuffer.

  Parameters:
    `rtmp` - The protocol state
    `header` - RTMP message header
    `lastHeader` - Previous header
    `buf` - Buffer to write encoded header to

### encodeMessage

    public IoBuffer encodeMessage(RTMP rtmp,
                                  Header header,
                                  IRTMPEvent message)

  Encode message.

  Parameters:
    `rtmp` - RTMP protocol state
    `header` - RTMP message header
    `message` - RTMP message (event)
  Returns:
    Encoded message data

### encodeChunkSize

    public IoBuffer encodeChunkSize(ChunkSize chunkSize)

  Encodes ChunkSize event to byte buffer.

  Specified by:
    `encodeChunkSize` in interface `IEventEncoder`
  Parameters:
    `chunkSize` - ChunkSize event
  Returns:
    Byte buffer

### encodeFlexSharedObject

    public IoBuffer encodeFlexSharedObject(ISharedObjectMessage so,
                                           RTMP rtmp)

  Encodes SharedObjectMessage event to byte buffer using AMF3 encoding.

  Specified by:
    `encodeFlexSharedObject` in interface `IEventEncoder`
  Parameters:
    `so` - ISharedObjectMessage event
    `rtmp` - RTMP protocol state
  Returns:
    Byte buffer

### encodeSharedObject

    public IoBuffer encodeSharedObject(ISharedObjectMessage so,
                                       RTMP rtmp)

  Encodes SharedObjectMessage event to byte buffer.

  Specified by:
    `encodeSharedObject` in interface `IEventEncoder`
  Parameters:
    `so` - ISharedObjectMessage event
    `rtmp` - RTMP protocol state
  Returns:
    Byte buffer

### doEncodeSharedObject

    public void doEncodeSharedObject(ISharedObjectMessage so,
                                     RTMP rtmp,
                                     IoBuffer out)

  Perform the actual encoding of the shared object contents.

  Parameters:
    `so` - shared object
    `rtmp` - rtmp
    `out` - output buffer

### encodeNotify

    public IoBuffer encodeNotify(Notify notify,
                                 RTMP rtmp)

  Encodes Notify event to byte buffer.

  Specified by:
    `encodeNotify` in interface `IEventEncoder`
  Parameters:
    `notify` - Notify event
    `rtmp` - RTMP protocol state
  Returns:
    Byte buffer

### encodeInvoke

    public IoBuffer encodeInvoke(Invoke invoke,
                                 RTMP rtmp)

  Encodes Invoke event to byte buffer.

  Specified by:
    `encodeInvoke` in interface `IEventEncoder`
  Parameters:
    `invoke` - Invoke event
    `rtmp` - RTMP protocol state
  Returns:
    Byte buffer

### encodeNotifyOrInvoke

    protected IoBuffer encodeNotifyOrInvoke(Notify invoke,
                                            RTMP rtmp)

  Encode notification event.

  Parameters:
    `invoke` - Notification event
  Returns:
    Encoded event data

### encodeNotifyOrInvoke

    protected void encodeNotifyOrInvoke(IoBuffer out,
                                        Notify invoke,
                                        RTMP rtmp)

  Encode notification event and fill given byte buffer.

  Parameters:
    `out` - Byte buffer to fill
    `invoke` - Notification event

### encodePing

    public IoBuffer encodePing(Ping ping)

  Encodes Ping event to byte buffer.

  Specified by:
    `encodePing` in interface `IEventEncoder`
  Parameters:
    `ping` - Ping event
  Returns:
    Byte buffer

### encodeBytesRead

    public IoBuffer encodeBytesRead(BytesRead bytesRead)

  Encodes BytesRead event to byte buffer.

  Specified by:
    `encodeBytesRead` in interface `IEventEncoder`
  Parameters:
    `bytesRead` - BytesRead event
  Returns:
    Byte buffer

### encodeAudioData

    public IoBuffer encodeAudioData(AudioData audioData)

  Encodes AudioData event to byte buffer.

  Specified by:
    `encodeAudioData` in interface `IEventEncoder`
  Parameters:
    `audioData` - AudioData event
  Returns:
    Byte buffer

### encodeVideoData

    public IoBuffer encodeVideoData(VideoData videoData)

  Encodes VideoData event to byte buffer.

  Specified by:
    `encodeVideoData` in interface `IEventEncoder`
  Parameters:
    `videoData` - VideoData event
  Returns:
    Byte buffer

### encodeUnknown

    public IoBuffer encodeUnknown(Unknown unknown)

  Encodes Unknown event to byte buffer.

  Specified by:
    `encodeUnknown` in interface `IEventEncoder`
  Parameters:
    `unknown` - Unknown event
  Returns:
    Byte buffer

### encodeStreamMetadata

    public IoBuffer encodeStreamMetadata(Notify metaData)

### generateErrorResult

    protected StatusObject generateErrorResult(String code,
                                               Throwable error)

  Generate error object to return for given exception.

  Parameters:
    `code` - call
    `error` - error
  Returns:
    status object

### encodeFlexMessage

    public IoBuffer encodeFlexMessage(FlexMessage msg,
                                      RTMP rtmp)

  Encodes Flex message event.

  Parameters:
    `msg` - Flex message event
    `rtmp` - RTMP
  Returns:
    Encoded data

### encodeFlexStreamSend

    public IoBuffer encodeFlexStreamSend(FlexStreamSend msg)

### setSerializer

    public void setSerializer(Serializer serializer)

  Setter for serializer.

  Parameters:
    `serializer` - Serializer

### setBaseTolerance

    public void setBaseTolerance(long baseTolerance)

### setDropLiveFuture

    public void setDropLiveFuture(boolean dropLiveFuture)

  Setter for dropLiveFuture

### getBaseTolerance

    public long getBaseTolerance()

Overview | Package | Class | Use | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

Copyright © 2006-2010 The Red5 Project