public IsoBufferWrapper nextNALUnit() throws IOException { if (src.remaining() < 5) { return null; } long nalLength; if (src.remaining() >= nalLengthSize) { // nalLength = src.read(nalLengthSize); nalLength = src.readUInt32(); if (nalLength == 0) return null; IsoBufferWrapper segment = src.getSegment(src.position(), nalLength); src.position(src.position() + nalLength); return segment; } else { throw new RuntimeException( "remaining bytes less than nalLengthSize found in sample. should not be here."); } }