src/main/java/org/jcodec/containers/mkv/MKVParser.java
static public byte[] readEbmlId(SeekableByteChannel source) throws IOException {
        if (source.position() == source.size())
            return null;
    
        ByteBuffer buffer = ByteBuffer.allocate(8);
        buffer.limit(1);
        source.read(buffer);
        buffer.flip();
    
        byte firstByte = buffer.get();
        int numBytes = EbmlUtil.computeLength(firstByte);
    
        if (numBytes == 0)
            return null;
    
        if (numBytes > 1) {
            buffer.limit(numBytes);
            source.read(buffer);
        }
        
        buffer.flip();
        ByteBuffer val = ByteBuffer.allocate(buffer.remaining());
        val.put(buffer);
        return val.array();
    }
static public byte[] readEbmlId(SeekableByteChannel source) throws IOException {
        if (source.position() == source.size())
            return null;
    
        ByteBuffer buffer = ByteBuffer.allocate(8);
        buffer.limit(1);
        source.read(buffer);
        buffer.flip();
    
        byte firstByte = buffer.get();
        int numBytes = EbmlUtil.computeLength(firstByte);
    
        if (numBytes == 0)
            return null;
    
        if (numBytes > 1) {
            buffer.limit(numBytes);
            source.read(buffer);
        }
        
        buffer.flip();
        ByteBuffer val = ByteBuffer.allocate(buffer.remaining());
        val.put(buffer);
        return val.array();
    }
static public byte [ ] readEbmlId ( SeekableByteChannel source ) throws IOException { if ( source . position ( ) == source . size ( ) ) return null ; ByteBuffer buffer = ByteBuffer . allocate ( 8 ) ; buffer . limit ( 1 ) ; source . read ( buffer ) ; buffer . flip ( ) ; byte firstByte = buffer . get ( ) ; int numBytes = EbmlUtil . computeLength ( firstByte ) ; if ( numBytes == 0 ) return null ; if ( numBytes > 1 ) { buffer . limit ( numBytes ) ; source . read ( buffer ) ; } buffer . flip ( ) ; ByteBuffer val = ByteBuffer . allocate ( buffer . remaining ( ) ) ; val . put ( buffer ) ; return val . array ( ) ; }
Reads an EBML id from the channel. EBML ids have length encoded inside of them For instance, all one-byte ids have first byte set to '1', like 0xA3 or 0xE7, whereas the two-byte ids have first
byte set to '0' and second byte set to '1', thus: 0x42 0x86  or 0x42 0xF7

@return byte array filled with the ebml id
@throws IOException
Reads an EBML id from the channel . EBML ids have length encoded inside of them For instance all one - byte ids have first byte set to 1 like 0xA3 or 0xE7 whereas the two - byte ids have first byte set to 0 and second byte set to 1 thus : 0x42 0x86 or 0x42 0xF7