private int packExtendedHeader(byte[] bytes, int offset) { BufferTools.packSynchsafeInteger(extendedHeaderLength, bytes, offset); BufferTools.copyIntoByteBuffer(extendedHeaderData, 0, extendedHeaderData.length, bytes, offset + 4); return offset + 4 + extendedHeaderData.length; }
public void packFrame(byte[] bytes, int offset) throws NotSupportedException { packHeader(bytes, offset); BufferTools.copyIntoByteBuffer(data, 0, data.length, bytes, offset + HEADER_LENGTH); }
private void packHeader(byte[] bytes, int i) { try { BufferTools.stringIntoByteBuffer(id, 0, id.length(), bytes, 0); } catch (UnsupportedEncodingException e) { } BufferTools.copyIntoByteBuffer(packDataLength(), 0, 4, bytes, 4); BufferTools.copyIntoByteBuffer(packFlags(), 0, 2, bytes, 8); }
private int packSpecifiedFrames(byte[] bytes, int offset, String onlyId, String notId) throws NotSupportedException { Iterator<ID3v2FrameSet> setIterator = frameSets.values().iterator(); while (setIterator.hasNext()) { ID3v2FrameSet frameSet = setIterator.next(); if ((onlyId == null || onlyId.equals(frameSet.getId())) && (notId == null || !notId.equals(frameSet.getId()))) { Iterator<ID3v2Frame> frameIterator = frameSet.getFrames().iterator(); while (frameIterator.hasNext()) { ID3v2Frame frame = (ID3v2Frame) frameIterator.next(); if (frame.getDataLength() > 0) { byte[] frameData = frame.toBytes(); BufferTools.copyIntoByteBuffer(frameData, 0, frameData.length, bytes, offset); offset += frameData.length; } } } } return offset; }
@Override protected byte[] packFrameData() { byte[] bytes = new byte[getLength()]; if (text != null) { bytes[0] = text.getTextEncoding(); byte[] textBytes = text.toBytes(true, false); if (textBytes.length > 0) { BufferTools.copyIntoByteBuffer(textBytes, 0, textBytes.length, bytes, 1); } } return bytes; }
@Override protected byte[] packFrameData() { byte[] bytes = new byte[getLength()]; if (description != null) bytes[0] = description.getTextEncoding(); else bytes[0] = 0; int mimeTypeLength = 0; if (mimeType != null && mimeType.length() > 0) { mimeTypeLength = mimeType.length(); try { BufferTools.stringIntoByteBuffer(mimeType, 0, mimeTypeLength, bytes, 1); } catch (UnsupportedEncodingException e) { } } int marker = mimeTypeLength + 1; bytes[marker++] = 0; bytes[marker++] = pictureType; if (description != null && description.toBytes().length > 0) { byte[] descriptionBytes = description.toBytes(true, true); BufferTools.copyIntoByteBuffer(descriptionBytes, 0, descriptionBytes.length, bytes, marker); marker += descriptionBytes.length; } else { bytes[marker++] = 0; } if (imageData != null && imageData.length > 0) { BufferTools.copyIntoByteBuffer(imageData, 0, imageData.length, bytes, marker); } return bytes; }
if (description != null) { byte[] descriptionBytes = description.toBytes(true, true); BufferTools.copyIntoByteBuffer(descriptionBytes, 0, descriptionBytes.length, bytes, marker); marker += descriptionBytes.length; } else { byte[] terminatorBytes = comment != null ? comment.getTerminator() : new byte[]{0}; BufferTools.copyIntoByteBuffer(terminatorBytes, 0, terminatorBytes.length, bytes, marker); marker += terminatorBytes.length; BufferTools.copyIntoByteBuffer(commentBytes, 0, commentBytes.length, bytes, marker);
@Override protected byte[] packFrameData() { byte[] bytes = new byte[getLength()]; if (description != null) bytes[0] = description.getTextEncoding(); else bytes[0] = 0; int marker = 1; if (description != null) { byte[] descriptionBytes = description.toBytes(true, true); BufferTools.copyIntoByteBuffer(descriptionBytes, 0, descriptionBytes.length, bytes, marker); marker += descriptionBytes.length; } else { bytes[marker++] = 0; } if (url != null && url.length() > 0) { try { BufferTools.stringIntoByteBuffer(url, 0, url.length(), bytes, marker); } catch (UnsupportedEncodingException e) { } } return bytes; }
private int packExtendedHeader(byte[] bytes, int offset) { BufferTools.packSynchsafeInteger(extendedHeaderLength, bytes, offset); BufferTools.copyIntoByteBuffer(extendedHeaderData, 0, extendedHeaderData.length, bytes, offset + 4); return offset + 4 + extendedHeaderData.length; }
public void packFrame(byte[] bytes, int offset) throws NotSupportedException { packHeader(bytes, offset); BufferTools.copyIntoByteBuffer(data, 0, data.length, bytes, offset + HEADER_LENGTH); }
private void packHeader(byte[] bytes, int i) { try { BufferTools.stringIntoByteBuffer(id, 0, id.length(), bytes, 0); } catch (UnsupportedEncodingException e) { } BufferTools.copyIntoByteBuffer(packDataLength(), 0, 4, bytes, 4); BufferTools.copyIntoByteBuffer(packFlags(), 0, 2, bytes, 8); }
private int packSpecifiedFrames(byte[] bytes, int offset, String onlyId, String notId) throws NotSupportedException { Iterator<ID3v2FrameSet> setIterator = frameSets.values().iterator(); while (setIterator.hasNext()) { ID3v2FrameSet frameSet = setIterator.next(); if ((onlyId == null || onlyId.equals(frameSet.getId())) && (notId == null || !notId.equals(frameSet.getId()))) { Iterator<ID3v2Frame> frameIterator = frameSet.getFrames().iterator(); while (frameIterator.hasNext()) { ID3v2Frame frame = (ID3v2Frame) frameIterator.next(); if (frame.getDataLength() > 0) { byte[] frameData = frame.toBytes(); BufferTools.copyIntoByteBuffer(frameData, 0, frameData.length, bytes, offset); offset += frameData.length; } } } } return offset; }
@Override protected byte[] packFrameData() { byte[] bytes = new byte[getLength()]; if (text != null) { bytes[0] = text.getTextEncoding(); byte[] textBytes = text.toBytes(true, false); if (textBytes.length > 0) { BufferTools.copyIntoByteBuffer(textBytes, 0, textBytes.length, bytes, 1); } } return bytes; }
@Override protected byte[] packFrameData() { byte[] bytes = new byte[getLength()]; if (description != null) bytes[0] = description.getTextEncoding(); else bytes[0] = 0; int mimeTypeLength = 0; if (mimeType != null && mimeType.length() > 0) { mimeTypeLength = mimeType.length(); try { BufferTools.stringIntoByteBuffer(mimeType, 0, mimeTypeLength, bytes, 1); } catch (UnsupportedEncodingException e) { } } int marker = mimeTypeLength + 1; bytes[marker++] = 0; bytes[marker++] = pictureType; if (description != null && description.toBytes().length > 0) { byte[] descriptionBytes = description.toBytes(true, true); BufferTools.copyIntoByteBuffer(descriptionBytes, 0, descriptionBytes.length, bytes, marker); marker += descriptionBytes.length; } else { bytes[marker++] = 0; } if (imageData != null && imageData.length > 0) { BufferTools.copyIntoByteBuffer(imageData, 0, imageData.length, bytes, marker); } return bytes; }
private void updateCustomTag() { byte[] existingCustomTag = mp3file.getCustomTag(); byte[] newCustomTag = null; if (keepCustomTag && existingCustomTag != null && existingCustomTag.length > 0) { if (customTag != null && customTag.length() > 0) { EncodedText customTagEncodedText = new EncodedText(customTag); byte bytes[] = customTagEncodedText.toBytes(true); int newLength = existingCustomTag.length + bytes.length; newCustomTag = new byte[newLength]; BufferTools.copyIntoByteBuffer(existingCustomTag, 0, existingCustomTag.length, newCustomTag, 0); BufferTools.copyIntoByteBuffer(bytes, 0, bytes.length, newCustomTag, existingCustomTag.length); } else { newCustomTag = mp3file.getCustomTag(); } } else if (customTag != null && customTag.length() > 0) { EncodedText customTagEncodedText = new EncodedText(customTag); newCustomTag = customTagEncodedText.toBytes(true); } mp3file.setCustomTag(newCustomTag); }
if (description != null) { byte[] descriptionBytes = description.toBytes(true, true); BufferTools.copyIntoByteBuffer(descriptionBytes, 0, descriptionBytes.length, bytes, marker); marker += descriptionBytes.length; } else { byte[] terminatorBytes = comment != null ? comment.getTerminator() : new byte[]{0}; BufferTools.copyIntoByteBuffer(terminatorBytes, 0, terminatorBytes.length, bytes, marker); marker += terminatorBytes.length; BufferTools.copyIntoByteBuffer(commentBytes, 0, commentBytes.length, bytes, marker);
@Override protected byte[] packFrameData() { byte[] bytes = new byte[getLength()]; if (description != null) bytes[0] = description.getTextEncoding(); else bytes[0] = 0; int marker = 1; if (description != null) { byte[] descriptionBytes = description.toBytes(true, true); BufferTools.copyIntoByteBuffer(descriptionBytes, 0, descriptionBytes.length, bytes, marker); marker += descriptionBytes.length; } else { bytes[marker++] = 0; } if (url != null && url.length() > 0) { try { BufferTools.stringIntoByteBuffer(url, 0, url.length(), bytes, marker); } catch (UnsupportedEncodingException e) { } } return bytes; }