Class BufferUtils


  • public class BufferUtils
    extends Object
    Buffer Utility class which reads/writes integers to the input/output buffer
    Author:
    The Red5 Project, Luke Hubbard, Codegent Ltd (luke@codegent.com), Andy Shaules (bowljoman@hotmail.com)
    • Constructor Summary

      Constructors 
      Constructor Description
      BufferUtils()  
    • Method Summary

      All Methods Static Methods Concrete Methods 
      Modifier and Type Method Description
      static byte[] consumeBytes​(byte[] in, int numBytesMax)
      Consumes bytes from an input buffer and returns them in an output buffer.
      static int put​(org.apache.mina.core.buffer.IoBuffer out, org.apache.mina.core.buffer.IoBuffer in, int numBytesMax)
      Puts an input buffer in an output buffer and returns number of bytes written.
      static int readMediumInt​(org.apache.mina.core.buffer.IoBuffer in)
      Reads a Medium Int to the in buffer
      static int readUnsignedMediumInt​(org.apache.mina.core.buffer.IoBuffer in)
      Reads an unsigned Medium Int from the in buffer
      static void writeMediumInt​(org.apache.mina.core.buffer.IoBuffer out, int value)
      Writes a Medium Int to the output buffer
    • Constructor Detail

      • BufferUtils

        public BufferUtils()
    • Method Detail

      • writeMediumInt

        public static void writeMediumInt​(org.apache.mina.core.buffer.IoBuffer out,
                                          int value)
        Writes a Medium Int to the output buffer
        Parameters:
        out - Container to write to
        value - Integer to write
      • readUnsignedMediumInt

        public static int readUnsignedMediumInt​(org.apache.mina.core.buffer.IoBuffer in)
        Reads an unsigned Medium Int from the in buffer
        Parameters:
        in - Source
        Returns:
        int Integer value
      • readMediumInt

        public static int readMediumInt​(org.apache.mina.core.buffer.IoBuffer in)
        Reads a Medium Int to the in buffer
        Parameters:
        in - Source
        Returns:
        int Medium int
      • put

        public static final int put​(org.apache.mina.core.buffer.IoBuffer out,
                                    org.apache.mina.core.buffer.IoBuffer in,
                                    int numBytesMax)
        Puts an input buffer in an output buffer and returns number of bytes written.
        Parameters:
        out - Output buffer
        in - Input buffer
        numBytesMax - Number of bytes max
        Returns:
        int Number of bytes written
      • consumeBytes

        public static final byte[] consumeBytes​(byte[] in,
                                                int numBytesMax)
        Consumes bytes from an input buffer and returns them in an output buffer.
        Parameters:
        in - Input byte array
        numBytesMax - Number of bytes max
        Returns:
        out Output byte array