Search in sources :

Example 1 with TagHeader

use of de.danoeh.antennapod.parser.media.id3.model.TagHeader in project AntennaPod by AntennaPod.

the class ID3Reader method readInputStream.

public void readInputStream() throws IOException, ID3ReaderException {
    tagHeader = readTagHeader();
    int tagContentStartPosition = getPosition();
    while (getPosition() < tagContentStartPosition + tagHeader.getSize()) {
        FrameHeader frameHeader = readFrameHeader();
        if (frameHeader.getId().charAt(0) < '0' || frameHeader.getId().charAt(0) > 'z') {
            Log.d(TAG, "Stopping because of invalid frame: " + frameHeader.toString());
            return;
        }
        readFrame(frameHeader);
    }
}
Also used : FrameHeader(de.danoeh.antennapod.parser.media.id3.model.FrameHeader)

Example 2 with TagHeader

use of de.danoeh.antennapod.parser.media.id3.model.TagHeader in project AntennaPod by AntennaPod.

the class Id3ReaderTest method testReadTagHeader.

@Test
public void testReadTagHeader() throws IOException, ID3ReaderException {
    byte[] data = generateId3Header(23);
    CountingInputStream inputStream = new CountingInputStream(new ByteArrayInputStream(data));
    TagHeader header = new ID3Reader(inputStream).readTagHeader();
    assertEquals("ID3", header.getId());
    assertEquals(42, header.getVersion());
    assertEquals(23, header.getSize());
}
Also used : ByteArrayInputStream(java.io.ByteArrayInputStream) TagHeader(de.danoeh.antennapod.parser.media.id3.model.TagHeader) CountingInputStream(org.apache.commons.io.input.CountingInputStream) Test(org.junit.Test)

Aggregations

FrameHeader (de.danoeh.antennapod.parser.media.id3.model.FrameHeader)1 TagHeader (de.danoeh.antennapod.parser.media.id3.model.TagHeader)1 ByteArrayInputStream (java.io.ByteArrayInputStream)1 CountingInputStream (org.apache.commons.io.input.CountingInputStream)1 Test (org.junit.Test)1