private boolean isXingFrame(byte[] bytes, int offset) { if (bytes.length >= offset + XING_MARKER_OFFSET_1 + 3) { if ("Xing".equals(BufferTools.byteBufferToStringIgnoringEncodingIssues(bytes, offset + XING_MARKER_OFFSET_1, 4))) return true; if ("Info".equals(BufferTools.byteBufferToStringIgnoringEncodingIssues(bytes, offset + XING_MARKER_OFFSET_1, 4))) return true; if (bytes.length >= offset + XING_MARKER_OFFSET_2 + 3) { if ("Xing".equals(BufferTools.byteBufferToStringIgnoringEncodingIssues(bytes, offset + XING_MARKER_OFFSET_2, 4))) return true; if ("Info".equals(BufferTools.byteBufferToStringIgnoringEncodingIssues(bytes, offset + XING_MARKER_OFFSET_2, 4))) return true; if (bytes.length >= offset + XING_MARKER_OFFSET_3 + 3) { if ("Xing".equals(BufferTools.byteBufferToStringIgnoringEncodingIssues(bytes, offset + XING_MARKER_OFFSET_3, 4))) return true; if ("Info".equals(BufferTools.byteBufferToStringIgnoringEncodingIssues(bytes, offset + XING_MARKER_OFFSET_3, 4))) return true; } } } return false; }
@Override protected int unpackHeader(byte[] buffer, int offset) { id = BufferTools.byteBufferToStringIgnoringEncodingIssues(buffer, offset + ID_OFFSET, ID_LENGTH); unpackDataLength(buffer, offset); return offset + HEADER_LENGTH; }
private int unpackFooter(byte[] bytes, int offset) throws InvalidDataException { if (!FOOTER_TAG.equals(BufferTools.byteBufferToStringIgnoringEncodingIssues(bytes, offset, FOOTER_TAG.length()))) { throw new InvalidDataException("Invalid footer"); } return FOOTER_LENGTH; }
private void sanityCheckTag(byte[] bytes) throws NoSuchTagException { if (bytes.length != TAG_LENGTH) { throw new NoSuchTagException("Buffer length wrong"); } if (!TAG.equals(BufferTools.byteBufferToStringIgnoringEncodingIssues(bytes, 0, TAG.length()))) { throw new NoSuchTagException(); } }
private void unpackTag(byte[] bytes) throws NoSuchTagException { sanityCheckTag(bytes); title = BufferTools.trimStringRight(BufferTools.byteBufferToStringIgnoringEncodingIssues(bytes, TITLE_OFFSET, TITLE_LENGTH)); artist = BufferTools.trimStringRight(BufferTools.byteBufferToStringIgnoringEncodingIssues(bytes, ARTIST_OFFSET, ARTIST_LENGTH)); album = BufferTools.trimStringRight(BufferTools.byteBufferToStringIgnoringEncodingIssues(bytes, ALBUM_OFFSET, ALBUM_LENGTH)); year = BufferTools.trimStringRight(BufferTools.byteBufferToStringIgnoringEncodingIssues(bytes, YEAR_OFFSET, YEAR_LENGTH)); genre = bytes[GENRE_OFFSET] & 0xFF; if (genre == 0xFF) { genre = -1; } if (bytes[TRACK_MARKER_OFFSET] != 0) { comment = BufferTools.trimStringRight(BufferTools.byteBufferToStringIgnoringEncodingIssues(bytes, COMMENT_OFFSET, COMMENT_LENGTH_V1_0)); track = null; } else { comment = BufferTools.trimStringRight(BufferTools.byteBufferToStringIgnoringEncodingIssues(bytes, COMMENT_OFFSET, COMMENT_LENGTH_V1_1)); int trackInt = bytes[TRACK_OFFSET]; if (trackInt == 0) { track = ""; } else { track = Integer.toString(trackInt); } } }
protected int unpackHeader(byte[] buffer, int offset) { id = BufferTools.byteBufferToStringIgnoringEncodingIssues(buffer, offset + ID_OFFSET, ID_LENGTH); unpackDataLength(buffer, offset); unpackFlags(buffer, offset); return offset + HEADER_LENGTH; }
public static void sanityCheckTag(byte[] bytes) throws NoSuchTagException, UnsupportedTagException { if (bytes.length < AbstractID3v2Tag.HEADER_LENGTH) { throw new NoSuchTagException("Buffer too short"); } if (!AbstractID3v2Tag.TAG.equals(BufferTools.byteBufferToStringIgnoringEncodingIssues(bytes, 0, AbstractID3v2Tag.TAG.length()))) { throw new NoSuchTagException(); } int majorVersion = bytes[AbstractID3v2Tag.MAJOR_VERSION_OFFSET]; if (majorVersion != 2 && majorVersion != 3 && majorVersion != 4) { int minorVersion = bytes[AbstractID3v2Tag.MINOR_VERSION_OFFSET]; throw new UnsupportedTagException("Unsupported version 2." + majorVersion + "." + minorVersion); } } }
private boolean isXingFrame(byte[] bytes, int offset) { if (bytes.length >= offset + XING_MARKER_OFFSET_1 + 3) { if ("Xing".equals(BufferTools.byteBufferToStringIgnoringEncodingIssues(bytes, offset + XING_MARKER_OFFSET_1, 4))) return true; if ("Info".equals(BufferTools.byteBufferToStringIgnoringEncodingIssues(bytes, offset + XING_MARKER_OFFSET_1, 4))) return true; if (bytes.length >= offset + XING_MARKER_OFFSET_2 + 3) { if ("Xing".equals(BufferTools.byteBufferToStringIgnoringEncodingIssues(bytes, offset + XING_MARKER_OFFSET_2, 4))) return true; if ("Info".equals(BufferTools.byteBufferToStringIgnoringEncodingIssues(bytes, offset + XING_MARKER_OFFSET_2, 4))) return true; if (bytes.length >= offset + XING_MARKER_OFFSET_3 + 3) { if ("Xing".equals(BufferTools.byteBufferToStringIgnoringEncodingIssues(bytes, offset + XING_MARKER_OFFSET_3, 4))) return true; if ("Info".equals(BufferTools.byteBufferToStringIgnoringEncodingIssues(bytes, offset + XING_MARKER_OFFSET_3, 4))) return true; } } } return false; }
private int unpackFooter(byte[] bytes, int offset) throws InvalidDataException { if (!FOOTER_TAG.equals(BufferTools.byteBufferToStringIgnoringEncodingIssues(bytes, offset, FOOTER_TAG.length()))) { throw new InvalidDataException("Invalid footer"); } return FOOTER_LENGTH; }
@Override protected int unpackHeader(byte[] buffer, int offset) { id = BufferTools.byteBufferToStringIgnoringEncodingIssues(buffer, offset + ID_OFFSET, ID_LENGTH); unpackDataLength(buffer, offset); return offset + HEADER_LENGTH; }
private void sanityCheckTag(byte[] bytes) throws NoSuchTagException { if (bytes.length != TAG_LENGTH) { throw new NoSuchTagException("Buffer length wrong"); } if (!TAG.equals(BufferTools.byteBufferToStringIgnoringEncodingIssues(bytes, 0, TAG.length()))) { throw new NoSuchTagException(); } }
private void unpackTag(byte[] bytes) throws NoSuchTagException { sanityCheckTag(bytes); title = BufferTools.trimStringRight(BufferTools.byteBufferToStringIgnoringEncodingIssues(bytes, TITLE_OFFSET, TITLE_LENGTH)); artist = BufferTools.trimStringRight(BufferTools.byteBufferToStringIgnoringEncodingIssues(bytes, ARTIST_OFFSET, ARTIST_LENGTH)); album = BufferTools.trimStringRight(BufferTools.byteBufferToStringIgnoringEncodingIssues(bytes, ALBUM_OFFSET, ALBUM_LENGTH)); year = BufferTools.trimStringRight(BufferTools.byteBufferToStringIgnoringEncodingIssues(bytes, YEAR_OFFSET, YEAR_LENGTH)); genre = bytes[GENRE_OFFSET] & 0xFF; if (genre == 0xFF) { genre = -1; } if (bytes[TRACK_MARKER_OFFSET] != 0) { comment = BufferTools.trimStringRight(BufferTools.byteBufferToStringIgnoringEncodingIssues(bytes, COMMENT_OFFSET, COMMENT_LENGTH_V1_0)); track = null; } else { comment = BufferTools.trimStringRight(BufferTools.byteBufferToStringIgnoringEncodingIssues(bytes, COMMENT_OFFSET, COMMENT_LENGTH_V1_1)); int trackInt = bytes[TRACK_OFFSET]; if (trackInt == 0) { track = ""; } else { track = Integer.toString(trackInt); } } }
protected int unpackHeader(byte[] buffer, int offset) { id = BufferTools.byteBufferToStringIgnoringEncodingIssues(buffer, offset + ID_OFFSET, ID_LENGTH); unpackDataLength(buffer, offset); unpackFlags(buffer, offset); return offset + HEADER_LENGTH; }
public static void sanityCheckTag(byte[] bytes) throws NoSuchTagException, UnsupportedTagException { if (bytes.length < AbstractID3v2Tag.HEADER_LENGTH) { throw new NoSuchTagException("Buffer too short"); } if (!AbstractID3v2Tag.TAG.equals(BufferTools.byteBufferToStringIgnoringEncodingIssues(bytes, 0, AbstractID3v2Tag.TAG.length()))) { throw new NoSuchTagException(); } int majorVersion = bytes[AbstractID3v2Tag.MAJOR_VERSION_OFFSET]; if (majorVersion != 2 && majorVersion != 3 && majorVersion != 4) { int minorVersion = bytes[AbstractID3v2Tag.MINOR_VERSION_OFFSET]; throw new UnsupportedTagException("Unsupported version 2." + majorVersion + "." + minorVersion); } } }