// Creates the ByteBuffer for the ogg tag public void create(Tag tag, ByteBuffer buf, List fields, int tagSize, int padding) throws UnsupportedEncodingException { String vendorString = ((OggTag) tag).getVendor(); int vendorLength = Utils.getUTF8Bytes(vendorString).length; buf.put( new byte[] { (byte) (vendorLength & 0xFF), (byte) ((vendorLength & 0xFF00) >> 8), (byte) ((vendorLength & 0xFF0000) >> 16), (byte) ((vendorLength & 0xFF000000) >> 24) }); buf.put(Utils.getUTF8Bytes(vendorString)); // [user comment list length] int listLength = fields.size(); byte[] b = new byte[4]; b[3] = (byte) ((listLength & 0xFF000000) >> 24); b[2] = (byte) ((listLength & 0x00FF0000) >> 16); b[1] = (byte) ((listLength & 0x0000FF00) >> 8); b[0] = (byte) (listLength & 0x000000FF); buf.put(b); Iterator it = fields.iterator(); while (it.hasNext()) { buf.put((byte[]) it.next()); } }
protected int getFixedTagLength(Tag tag) throws UnsupportedEncodingException { return 8 + Utils.getUTF8Bytes(((OggTag) tag).getVendor()).length; }