## org.red5.server.net.rtmp
Class RTMPUtils

    java.lang.Object
      org.red5.server.net.rtmp.RTMPUtils

All Implemented Interfaces:
  Constants

    public class RTMPUtils

extends Object
implements Constants

RTMP utilities class.

Author:
  The Red5 Project (red5@osflash.org), Luke Hubbard, Codegent Ltd (luke@codegent.com), Art Clarke (aclarke@xuggle.com)

Field Summary

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
`RTMPUtils()`

Method Summary
`static int` `compareTimestamps(int a, int b)` Compares two RTMP time stamps, accounting for time stamp wrapping.
`static int` `decodeChannelId(int header, int byteCount)` Decode channel id.
`static byte` `decodeHeaderSize(int header, int byteCount)` Decode header size.
`static long` `diffTimestamps(int a, int b)` Calculates the delta between two time stamps, adjusting for time stamp wrapping.
`static void` `encodeHeaderByte(IoBuffer out, byte headerSize, int channelId)` Encodes header size marker and channel id into header marker.
`static int` `getHeaderLength(byte headerSize)` Return header length from marker value.
`static int` `readMediumInt(IoBuffer in)`
`static int` `readMediumIntOld(IoBuffer in)`
`static int` `readReverseInt(IoBuffer in)` Read integer in reversed order.
`static int` `readUnsignedMediumInt(IoBuffer in)`
`static int` `readUnsignedMediumIntOld(IoBuffer in)`
`static void` `writeMediumInt(IoBuffer out, int value)`
`static void` `writeReverseInt(IoBuffer out, int value)` Writes reversed integer to buffer.
`static void` `writeReverseIntOld(IoBuffer out, int value)` Writes reversed integer to buffer.

Methods inherited from class java.lang.Object
`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

Constructor Detail

### RTMPUtils

    public RTMPUtils()

Method Detail

### writeReverseIntOld

    public static void writeReverseIntOld(IoBuffer out,
                                          int value)

  Writes reversed integer to buffer.

  Parameters:
    `out` - Buffer
    `value` - Integer to write

### writeReverseInt

    public static void writeReverseInt(IoBuffer out,
                                       int value)

  Writes reversed integer to buffer.

  Parameters:
    `out` - Buffer
    `value` - Integer to write

### writeMediumInt

    public static void writeMediumInt(IoBuffer out,
                                      int value)

  Parameters:
    `out` - output buffer
    `value` - value to write

### readUnsignedMediumInt

    public static int readUnsignedMediumInt(IoBuffer in)

  Parameters:
    `in` - input
  Returns:
    unsigned int

### readUnsignedMediumIntOld

    public static int readUnsignedMediumIntOld(IoBuffer in)

  Parameters:
    `in` - input
  Returns:
    unsigned medium (3 byte) int.

### readMediumIntOld

    public static int readMediumIntOld(IoBuffer in)

  Parameters:
    `in` - input
  Returns:
    signed 3-byte int

### readMediumInt

    public static int readMediumInt(IoBuffer in)

  Parameters:
    `in` - input
  Returns:
    signed 3 byte int

### readReverseInt

    public static int readReverseInt(IoBuffer in)

  Read integer in reversed order.

  Parameters:
    `in` - Input buffer
  Returns:
    Integer

### encodeHeaderByte

    public static void encodeHeaderByte(IoBuffer out,
                                        byte headerSize,
                                        int channelId)

  Encodes header size marker and channel id into header marker.

  Parameters:
    `out` - output buffer
    `headerSize` - Header size marker
    `channelId` - Channel used

### decodeChannelId

    public static int decodeChannelId(int header,
                                      int byteCount)

  Decode channel id.

  Parameters:
    `header` - Header
    `byteCount` - byte count
  Returns:
    Channel id

### decodeHeaderSize

    public static byte decodeHeaderSize(int header,
                                        int byteCount)

  Decode header size.

  Parameters:
    `header` - Header byte
    `byteCount` - byte count
  Returns:
    Header size byte

### getHeaderLength

    public static int getHeaderLength(byte headerSize)

  Return header length from marker value.

  Parameters:
    `headerSize` - Header size marker value
  Returns:
    Header length

### compareTimestamps

    public static int compareTimestamps(int a,
                                        int b)

  Compares two RTMP time stamps, accounting for time stamp wrapping.

  Parameters:
    `a` - First time stamp
    `b` - Second time stamp
  Returns:
    -1 if a < b, 1 if a > b, or 0 if a == b

### diffTimestamps

    public static long diffTimestamps(int a,
                                      int b)

  Calculates the delta between two time stamps, adjusting for time stamp wrapping.

  Parameters:
    `a` - First time stamp
    `b` - Second time stamp
  Returns:
    the distance between a and b, which will be negative if a is less than b.

Copyright © 2006-2010 The Red5 Project