org.jcodec.containers.mkv
Class Reader

java.lang.Object
  extended by org.jcodec.containers.mkv.Reader

public class Reader
extends Object

JEBML Intro


The following are the basic steps of how reading in JEBML works.


Reads EBML elements from a DataSource and looks them up in the provided DocType.

Author:
(c) 2002 John Cannon, (c) 2004 Jory Stone

Field Summary
protected  FileChannel ds
           
static long[] signedComplement
           
 
Constructor Summary
Reader(FileChannel source)
          Creates a new EBMLReader reading from the DataSource source.
 
Method Summary
static String asHex(int i)
           
static String bytesToHex(byte[] bts)
           
static long bytesToLong(byte[] data)
           
static long bytesToLong(ByteBuffer data)
           
 long getAvailable()
           
static byte[] getEbmlBytes(FileChannel source)
           
static int getEbmlSizeByFirstByte(byte b)
           
static long getEbmlVInt(ByteBuffer bb)
          Reads an (Unsigned) EBML code from the DataSource and encodes it into a long.
static long getEbmlVInt(ByteBuffer source, int offset)
          Reads an (Unsigned) EBML code from the DataSource and encodes it into a long.
static long getEbmlVInt(FileChannel source)
          Reads an (Unsigned) EBML code from the DataSource and encodes it into a long.
 long getPos()
           
static byte[] getRawEbmlBytes(FileChannel source)
          Reads an EBML id from the DataSource.
static long getSignedEbmlVInt(ByteBuffer source)
          Reads an Signed EBML code from the DataSource and encodes it into a long.
static long getSignedEbmlVInt(FileChannel is)
          Reads an Signed EBML code from the DataSource and encodes it into a long.
static byte[] getVIntEbmlBytes(ByteBuffer source)
           
static String printAsHex(byte[] a)
           
 Element readNextElement()
           
 Element readNextFirstLevelElement()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

ds

protected FileChannel ds

signedComplement

public static final long[] signedComplement
Constructor Detail

Reader

public Reader(FileChannel source)
Creates a new EBMLReader reading from the DataSource source. The DocType doc is used to validate the document.

Parameters:
source - DataSource to read from
doc - DocType to use to validate the docment
Method Detail

getPos

public long getPos()
            throws IOException
Throws:
IOException

getAvailable

public long getAvailable()
                  throws IOException
Throws:
IOException

bytesToHex

public static String bytesToHex(byte[] bts)

printAsHex

public static String printAsHex(byte[] a)

readNextElement

public Element readNextElement()
                        throws IOException
Throws:
IOException

getEbmlVInt

public static long getEbmlVInt(FileChannel source)
                        throws IOException
Reads an (Unsigned) EBML code from the DataSource and encodes it into a long. This size should be cast into an int for actual use as Java only allows upto 32-bit file I/O operations.

Returns:
ebml size
Throws:
IOException

getSignedEbmlVInt

public static long getSignedEbmlVInt(FileChannel is)
                              throws IOException
Reads an Signed EBML code from the DataSource and encodes it into a long. This size should be cast into an int for actual use as Java only allows upto 32-bit file I/O operations.

Returns:
ebml size
Throws:
IOException

bytesToLong

public static long bytesToLong(ByteBuffer data)

bytesToLong

public static long bytesToLong(byte[] data)

getEbmlSizeByFirstByte

public static int getEbmlSizeByFirstByte(byte b)

getEbmlVInt

public static long getEbmlVInt(ByteBuffer bb)
Reads an (Unsigned) EBML code from the DataSource and encodes it into a long. This size should be cast into an int for actual use as Java only allows upto 32-bit file I/O operations.

Returns:
ebml size

getEbmlVInt

public static long getEbmlVInt(ByteBuffer source,
                               int offset)
Reads an (Unsigned) EBML code from the DataSource and encodes it into a long. This size should be cast into an int for actual use as Java only allows upto 32-bit file I/O operations.

Returns:
ebml size

asHex

public static String asHex(int i)

getSignedEbmlVInt

public static long getSignedEbmlVInt(ByteBuffer source)
Reads an Signed EBML code from the DataSource and encodes it into a long. This size should be cast into an int for actual use as Java only allows upto 32-bit file I/O operations.

Returns:
ebml size

getVIntEbmlBytes

public static byte[] getVIntEbmlBytes(ByteBuffer source)

getEbmlBytes

public static byte[] getEbmlBytes(FileChannel source)
                           throws IOException
Throws:
IOException

getRawEbmlBytes

public static byte[] getRawEbmlBytes(FileChannel source)
                              throws IOException
Reads an EBML id from the DataSource. EBML ids have length encoded inside of them For instance, all one-byte ids have first byte set to '1', like 0xA3, 0xE7, whereas the two-byte ids have first byte set to '0' and second byte set to '1', thus: 0x4286 (ebml version) or 0x42F7 (ebml read version)

Returns:
byte array filled with the ebml size, (size bits included)
Throws:
IOException

readNextFirstLevelElement

public Element readNextFirstLevelElement()
                                  throws IOException
Throws:
IOException


Copyright © 2013. All Rights Reserved.