DefaultOggSeeker implements OggSeeker { @VisibleForTesting long readGranuleOfLastPage(ExtractorInput input) throws IOException, InterruptedException { skipToNextPage(input); pageHeader.reset(); while ((pageHeader.type & 0x04) != 0x04 && input.getPosition() < payloadEndPosition) { pageHeader.populate(input, false); input.skipFully(pageHeader.headerSize + pageHeader.bodySize); } return pageHeader.granulePosition; } DefaultOggSeeker(
      StreamReader streamReader,
      long payloadStartPosition,
      long payloadEndPosition,
      long firstPayloadPageSize,
      long firstPayloadPageGranulePosition,
      boolean firstPayloadPageIsLastPage); @Override long read(ExtractorInput input); @Override OggSeekMap createSeekMap(); @Override void startSeek(long targetGranule);  }
@Test public void testReadGranuleOfLastPage() throws IOException, InterruptedException { FakeExtractorInput input = OggTestData.createInput( TestUtil.joinByteArrays( TestUtil.buildTestData(100, random), OggTestData.buildOggHeader(0x00, 20000, 66, 3), TestUtil.createByteArray(254, 254, 254), TestUtil.buildTestData(3 * 254, random), OggTestData.buildOggHeader(0x00, 40000, 67, 3), TestUtil.createByteArray(254, 254, 254), TestUtil.buildTestData(3 * 254, random), OggTestData.buildOggHeader(0x05, 60000, 68, 3), TestUtil.createByteArray(254, 254, 254), TestUtil.buildTestData(3 * 254, random)), false); assertReadGranuleOfLastPage(input, 60000); }