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, Luke Hubbard, Codegent Ltd (luke@codegent.com), Art Clarke (aclarke@xuggle.com)
  • Constructor Details

    • RTMPUtils

      public RTMPUtils()
  • Method Details

    • writeReverseIntOld

      public static void writeReverseIntOld(org.apache.mina.core.buffer.IoBuffer out, int value)
      Writes reversed integer to buffer.
      Parameters:
      out - Buffer
      value - Integer to write
    • writeReverseInt

      public static void writeReverseInt(org.apache.mina.core.buffer.IoBuffer out, int value)
      Writes reversed integer to buffer.
      Parameters:
      out - Buffer
      value - Integer to write
    • writeMediumInt

      public static void writeMediumInt(org.apache.mina.core.buffer.IoBuffer out, int value)
      Parameters:
      out - output buffer
      value - value to write
    • readUnsignedMediumInt

      public static int readUnsignedMediumInt(org.apache.mina.core.buffer.IoBuffer in)
      Parameters:
      in - input
      Returns:
      unsigned int
    • readUnsignedMediumIntOld

      public static int readUnsignedMediumIntOld(org.apache.mina.core.buffer.IoBuffer in)
      Parameters:
      in - input
      Returns:
      unsigned medium (3 byte) int.
    • readMediumIntOld

      public static int readMediumIntOld(org.apache.mina.core.buffer.IoBuffer in)
      Parameters:
      in - input
      Returns:
      signed 3-byte int
    • readMediumInt

      public static int readMediumInt(org.apache.mina.core.buffer.IoBuffer in)
      Parameters:
      in - input
      Returns:
      signed 3 byte int
    • readReverseInt

      public static int readReverseInt(org.apache.mina.core.buffer.IoBuffer in)
      Read integer in reversed order.
      Parameters:
      in - Input buffer
      Returns:
      Integer
    • encodeHeaderByte

      public static void encodeHeaderByte(org.apache.mina.core.buffer.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.